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.accessibilityservice.AccessibilityService; 22 import android.annotation.AnyRes; 23 import android.annotation.BroadcastBehavior; 24 import android.annotation.IntDef; 25 import android.annotation.NonNull; 26 import android.annotation.Nullable; 27 import android.annotation.RequiresPermission; 28 import android.annotation.SdkConstant; 29 import android.annotation.SdkConstant.SdkConstantType; 30 import android.annotation.SuppressLint; 31 import android.annotation.SystemApi; 32 import android.annotation.TestApi; 33 import android.app.AppGlobals; 34 import android.bluetooth.BluetoothDevice; 35 import android.compat.annotation.UnsupportedAppUsage; 36 import android.content.pm.ActivityInfo; 37 import android.content.pm.ApplicationInfo; 38 import android.content.pm.ComponentInfo; 39 import android.content.pm.PackageManager; 40 import android.content.pm.ResolveInfo; 41 import android.content.pm.ShortcutInfo; 42 import android.content.pm.SuspendDialogInfo; 43 import android.content.pm.verify.domain.DomainVerificationManager; 44 import android.content.res.Resources; 45 import android.content.res.TypedArray; 46 import android.graphics.Rect; 47 import android.net.Uri; 48 import android.os.Build; 49 import android.os.Bundle; 50 import android.os.IBinder; 51 import android.os.IncidentManager; 52 import android.os.Parcel; 53 import android.os.Parcelable; 54 import android.os.PersistableBundle; 55 import android.os.Process; 56 import android.os.ResultReceiver; 57 import android.os.ShellCommand; 58 import android.os.StrictMode; 59 import android.os.UserHandle; 60 import android.os.storage.StorageManager; 61 import android.provider.ContactsContract.QuickContact; 62 import android.provider.DocumentsContract; 63 import android.provider.DocumentsProvider; 64 import android.provider.MediaStore; 65 import android.provider.OpenableColumns; 66 import android.telecom.PhoneAccount; 67 import android.telecom.TelecomManager; 68 import android.text.TextUtils; 69 import android.util.ArraySet; 70 import android.util.AttributeSet; 71 import android.util.Log; 72 import android.util.proto.ProtoOutputStream; 73 74 import com.android.internal.util.XmlUtils; 75 76 import org.xmlpull.v1.XmlPullParser; 77 import org.xmlpull.v1.XmlPullParserException; 78 import org.xmlpull.v1.XmlSerializer; 79 80 import java.io.File; 81 import java.io.IOException; 82 import java.io.PrintWriter; 83 import java.io.Serializable; 84 import java.lang.annotation.Retention; 85 import java.lang.annotation.RetentionPolicy; 86 import java.net.URISyntaxException; 87 import java.util.ArrayList; 88 import java.util.HashSet; 89 import java.util.List; 90 import java.util.Locale; 91 import java.util.Objects; 92 import java.util.Set; 93 import java.util.TimeZone; 94 95 /** 96 * An intent is an abstract description of an operation to be performed. It 97 * can be used with {@link Context#startActivity(Intent) startActivity} to 98 * launch an {@link android.app.Activity}, 99 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to 100 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, 101 * and {@link android.content.Context#startService} or 102 * {@link android.content.Context#bindService} to communicate with a 103 * background {@link android.app.Service}. 104 * 105 * <p>An Intent provides a facility for performing late runtime binding between the code in 106 * different applications. Its most significant use is in the launching of activities, where it 107 * can be thought of as the glue between activities. It is basically a passive data structure 108 * holding an abstract description of an action to be performed.</p> 109 * 110 * <div class="special reference"> 111 * <h3>Developer Guides</h3> 112 * <p>For information about how to create and resolve intents, read the 113 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> 114 * developer guide.</p> 115 * </div> 116 * 117 * <a name="IntentStructure"></a> 118 * <h3>Intent Structure</h3> 119 * <p>The primary pieces of information in an intent are:</p> 120 * 121 * <ul> 122 * <li> <p><b>action</b> -- The general action to be performed, such as 123 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, 124 * etc.</p> 125 * </li> 126 * <li> <p><b>data</b> -- The data to operate on, such as a person record 127 * in the contacts database, expressed as a {@link android.net.Uri}.</p> 128 * </li> 129 * </ul> 130 * 131 * 132 * <p>Some examples of action/data pairs are:</p> 133 * 134 * <ul> 135 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display 136 * information about the person whose identifier is "1".</p> 137 * </li> 138 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display 139 * the phone dialer with the person filled in.</p> 140 * </li> 141 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display 142 * the phone dialer with the given number filled in. Note how the 143 * VIEW action does what is considered the most reasonable thing for 144 * a particular URI.</p> 145 * </li> 146 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display 147 * the phone dialer with the given number filled in.</p> 148 * </li> 149 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit 150 * information about the person whose identifier is "1".</p> 151 * </li> 152 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display 153 * a list of people, which the user can browse through. This example is a 154 * typical top-level entry into the Contacts application, showing you the 155 * list of people. Selecting a particular person to view would result in a 156 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> } 157 * being used to start an activity to display that person.</p> 158 * </li> 159 * </ul> 160 * 161 * <p>In addition to these primary attributes, there are a number of secondary 162 * attributes that you can also include with an intent:</p> 163 * 164 * <ul> 165 * <li> <p><b>category</b> -- Gives additional information about the action 166 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should 167 * appear in the Launcher as a top-level application, while 168 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list 169 * of alternative actions the user can perform on a piece of data.</p> 170 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the 171 * intent data. Normally the type is inferred from the data itself. 172 * By setting this attribute, you disable that evaluation and force 173 * an explicit type.</p> 174 * <li> <p><b>component</b> -- Specifies an explicit name of a component 175 * class to use for the intent. Normally this is determined by looking 176 * at the other information in the intent (the action, data/type, and 177 * categories) and matching that with a component that can handle it. 178 * If this attribute is set then none of the evaluation is performed, 179 * and this component is used exactly as is. By specifying this attribute, 180 * all of the other Intent attributes become optional.</p> 181 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. 182 * This can be used to provide extended information to the component. 183 * For example, if we have a action to send an e-mail message, we could 184 * also include extra pieces of data here to supply a subject, body, 185 * etc.</p> 186 * </ul> 187 * 188 * <p>Here are some examples of other operations you can specify as intents 189 * using these additional parameters:</p> 190 * 191 * <ul> 192 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- 193 * Launch the home screen.</p> 194 * </li> 195 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 196 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI 197 * vnd.android.cursor.item/phone}</i></b> 198 * -- Display the list of people's phone numbers, allowing the user to 199 * browse through them and pick one and return it to the parent activity.</p> 200 * </li> 201 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 202 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> 203 * -- Display all pickers for data that can be opened with 204 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, 205 * allowing the user to pick one of them and then some data inside of it 206 * and returning the resulting URI to the caller. This can be used, 207 * for example, in an e-mail application to allow the user to pick some 208 * data to include as an attachment.</p> 209 * </li> 210 * </ul> 211 * 212 * <p>There are a variety of standard Intent action and category constants 213 * defined in the Intent class, but applications can also define their own. 214 * These strings use Java-style scoping, to ensure they are unique -- for 215 * example, the standard {@link #ACTION_VIEW} is called 216 * "android.intent.action.VIEW".</p> 217 * 218 * <p>Put together, the set of actions, data types, categories, and extra data 219 * defines a language for the system allowing for the expression of phrases 220 * such as "call john smith's cell". As applications are added to the system, 221 * they can extend this language by adding new actions, types, and categories, or 222 * they can modify the behavior of existing phrases by supplying their own 223 * activities that handle them.</p> 224 * 225 * <a name="IntentResolution"></a> 226 * <h3>Intent Resolution</h3> 227 * 228 * <p>There are two primary forms of intents you will use. 229 * 230 * <ul> 231 * <li> <p><b>Explicit Intents</b> have specified a component (via 232 * {@link #setComponent} or {@link #setClass}), which provides the exact 233 * class to be run. Often these will not include any other information, 234 * simply being a way for an application to launch various internal 235 * activities it has as the user interacts with the application. 236 * 237 * <li> <p><b>Implicit Intents</b> have not specified a component; 238 * instead, they must include enough information for the system to 239 * determine which of the available components is best to run for that 240 * intent. 241 * </ul> 242 * 243 * <p>When using implicit intents, given such an arbitrary intent we need to 244 * know what to do with it. This is handled by the process of <em>Intent 245 * resolution</em>, which maps an Intent to an {@link android.app.Activity}, 246 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or 247 * more activities/receivers) that can handle it.</p> 248 * 249 * <p>The intent resolution mechanism basically revolves around matching an 250 * Intent against all of the <intent-filter> descriptions in the 251 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} 252 * objects explicitly registered with {@link Context#registerReceiver}.) More 253 * details on this can be found in the documentation on the {@link 254 * IntentFilter} class.</p> 255 * 256 * <p>There are three pieces of information in the Intent that are used for 257 * resolution: the action, type, and category. Using this information, a query 258 * is done on the {@link PackageManager} for a component that can handle the 259 * intent. The appropriate component is determined based on the intent 260 * information supplied in the <code>AndroidManifest.xml</code> file as 261 * follows:</p> 262 * 263 * <ul> 264 * <li> <p>The <b>action</b>, if given, must be listed by the component as 265 * one it handles.</p> 266 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not 267 * already supplied in the Intent. Like the action, if a type is 268 * included in the intent (either explicitly or implicitly in its 269 * data), then this must be listed by the component as one it handles.</p> 270 * <li> For data that is not a <code>content:</code> URI and where no explicit 271 * type is included in the Intent, instead the <b>scheme</b> of the 272 * intent data (such as <code>http:</code> or <code>mailto:</code>) is 273 * considered. Again like the action, if we are matching a scheme it 274 * must be listed by the component as one it can handle. 275 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed 276 * by the activity as categories it handles. That is, if you include 277 * the categories {@link #CATEGORY_LAUNCHER} and 278 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components 279 * with an intent that lists <em>both</em> of those categories. 280 * Activities will very often need to support the 281 * {@link #CATEGORY_DEFAULT} so that they can be found by 282 * {@link Context#startActivity Context.startActivity()}.</p> 283 * </ul> 284 * 285 * <p>For example, consider the Note Pad sample application that 286 * allows a user to browse through a list of notes data and view details about 287 * individual items. Text in italics indicates places where you would replace a 288 * name with one specific to your own package.</p> 289 * 290 * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 291 * package="<i>com.android.notepad</i>"> 292 * <application android:icon="@drawable/app_notes" 293 * android:label="@string/app_name"> 294 * 295 * <provider class=".NotePadProvider" 296 * android:authorities="<i>com.google.provider.NotePad</i>" /> 297 * 298 * <activity class=".NotesList" android:label="@string/title_notes_list"> 299 * <intent-filter> 300 * <action android:name="android.intent.action.MAIN" /> 301 * <category android:name="android.intent.category.LAUNCHER" /> 302 * </intent-filter> 303 * <intent-filter> 304 * <action android:name="android.intent.action.VIEW" /> 305 * <action android:name="android.intent.action.EDIT" /> 306 * <action android:name="android.intent.action.PICK" /> 307 * <category android:name="android.intent.category.DEFAULT" /> 308 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 309 * </intent-filter> 310 * <intent-filter> 311 * <action android:name="android.intent.action.GET_CONTENT" /> 312 * <category android:name="android.intent.category.DEFAULT" /> 313 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 314 * </intent-filter> 315 * </activity> 316 * 317 * <activity class=".NoteEditor" android:label="@string/title_note"> 318 * <intent-filter android:label="@string/resolve_edit"> 319 * <action android:name="android.intent.action.VIEW" /> 320 * <action android:name="android.intent.action.EDIT" /> 321 * <category android:name="android.intent.category.DEFAULT" /> 322 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 323 * </intent-filter> 324 * 325 * <intent-filter> 326 * <action android:name="android.intent.action.INSERT" /> 327 * <category android:name="android.intent.category.DEFAULT" /> 328 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 329 * </intent-filter> 330 * 331 * </activity> 332 * 333 * <activity class=".TitleEditor" android:label="@string/title_edit_title" 334 * android:theme="@android:style/Theme.Dialog"> 335 * <intent-filter android:label="@string/resolve_title"> 336 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 337 * <category android:name="android.intent.category.DEFAULT" /> 338 * <category android:name="android.intent.category.ALTERNATIVE" /> 339 * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> 340 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 341 * </intent-filter> 342 * </activity> 343 * 344 * </application> 345 * </manifest></pre> 346 * 347 * <p>The first activity, 348 * <code>com.android.notepad.NotesList</code>, serves as our main 349 * entry into the app. It can do three things as described by its three intent 350 * templates: 351 * <ol> 352 * <li><pre> 353 * <intent-filter> 354 * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> 355 * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> 356 * </intent-filter></pre> 357 * <p>This provides a top-level entry into the NotePad application: the standard 358 * MAIN action is a main entry point (not requiring any other information in 359 * the Intent), and the LAUNCHER category says that this entry point should be 360 * listed in the application launcher.</p> 361 * <li><pre> 362 * <intent-filter> 363 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 364 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 365 * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> 366 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 367 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 368 * </intent-filter></pre> 369 * <p>This declares the things that the activity can do on a directory of 370 * notes. The type being supported is given with the <type> tag, where 371 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which 372 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can 373 * be retrieved which holds our note pad data (<code>vnd.google.note</code>). 374 * The activity allows the user to view or edit the directory of data (via 375 * the VIEW and EDIT actions), or to pick a particular note and return it 376 * to the caller (via the PICK action). Note also the DEFAULT category 377 * supplied here: this is <em>required</em> for the 378 * {@link Context#startActivity Context.startActivity} method to resolve your 379 * activity when its component name is not explicitly specified.</p> 380 * <li><pre> 381 * <intent-filter> 382 * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> 383 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 384 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 385 * </intent-filter></pre> 386 * <p>This filter describes the ability to return to the caller a note selected by 387 * the user without needing to know where it came from. The data type 388 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which 389 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can 390 * be retrieved which contains our note pad data (<code>vnd.google.note</code>). 391 * The GET_CONTENT action is similar to the PICK action, where the activity 392 * will return to its caller a piece of data selected by the user. Here, 393 * however, the caller specifies the type of data they desire instead of 394 * the type of data the user will be picking from.</p> 395 * </ol> 396 * 397 * <p>Given these capabilities, the following intents will resolve to the 398 * NotesList activity:</p> 399 * 400 * <ul> 401 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the 402 * activities that can be used as top-level entry points into an 403 * application.</p> 404 * <li> <p><b>{ action=android.app.action.MAIN, 405 * category=android.app.category.LAUNCHER }</b> is the actual intent 406 * used by the Launcher to populate its top-level list.</p> 407 * <li> <p><b>{ action=android.intent.action.VIEW 408 * data=content://com.google.provider.NotePad/notes }</b> 409 * displays a list of all the notes under 410 * "content://com.google.provider.NotePad/notes", which 411 * the user can browse through and see the details on.</p> 412 * <li> <p><b>{ action=android.app.action.PICK 413 * data=content://com.google.provider.NotePad/notes }</b> 414 * provides a list of the notes under 415 * "content://com.google.provider.NotePad/notes", from which 416 * the user can pick a note whose data URL is returned back to the caller.</p> 417 * <li> <p><b>{ action=android.app.action.GET_CONTENT 418 * type=vnd.android.cursor.item/vnd.google.note }</b> 419 * is similar to the pick action, but allows the caller to specify the 420 * kind of data they want back so that the system can find the appropriate 421 * activity to pick something of that data type.</p> 422 * </ul> 423 * 424 * <p>The second activity, 425 * <code>com.android.notepad.NoteEditor</code>, shows the user a single 426 * note entry and allows them to edit it. It can do two things as described 427 * by its two intent templates: 428 * <ol> 429 * <li><pre> 430 * <intent-filter android:label="@string/resolve_edit"> 431 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 432 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 433 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 434 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 435 * </intent-filter></pre> 436 * <p>The first, primary, purpose of this activity is to let the user interact 437 * with a single note, as decribed by the MIME type 438 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can 439 * either VIEW a note or allow the user to EDIT it. Again we support the 440 * DEFAULT category to allow the activity to be launched without explicitly 441 * specifying its component.</p> 442 * <li><pre> 443 * <intent-filter> 444 * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> 445 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 446 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 447 * </intent-filter></pre> 448 * <p>The secondary use of this activity is to insert a new note entry into 449 * an existing directory of notes. This is used when the user creates a new 450 * note: the INSERT action is executed on the directory of notes, causing 451 * this activity to run and have the user create the new note data which 452 * it then adds to the content provider.</p> 453 * </ol> 454 * 455 * <p>Given these capabilities, the following intents will resolve to the 456 * NoteEditor activity:</p> 457 * 458 * <ul> 459 * <li> <p><b>{ action=android.intent.action.VIEW 460 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 461 * shows the user the content of note <var>{ID}</var>.</p> 462 * <li> <p><b>{ action=android.app.action.EDIT 463 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 464 * allows the user to edit the content of note <var>{ID}</var>.</p> 465 * <li> <p><b>{ action=android.app.action.INSERT 466 * data=content://com.google.provider.NotePad/notes }</b> 467 * creates a new, empty note in the notes list at 468 * "content://com.google.provider.NotePad/notes" 469 * and allows the user to edit it. If they keep their changes, the URI 470 * of the newly created note is returned to the caller.</p> 471 * </ul> 472 * 473 * <p>The last activity, 474 * <code>com.android.notepad.TitleEditor</code>, allows the user to 475 * edit the title of a note. This could be implemented as a class that the 476 * application directly invokes (by explicitly setting its component in 477 * the Intent), but here we show a way you can publish alternative 478 * operations on existing data:</p> 479 * 480 * <pre> 481 * <intent-filter android:label="@string/resolve_title"> 482 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 483 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 484 * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> 485 * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> 486 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 487 * </intent-filter></pre> 488 * 489 * <p>In the single intent template here, we 490 * have created our own private action called 491 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to 492 * edit the title of a note. It must be invoked on a specific note 493 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous 494 * view and edit actions, but here displays and edits the title contained 495 * in the note data. 496 * 497 * <p>In addition to supporting the default category as usual, our title editor 498 * also supports two other standard categories: ALTERNATIVE and 499 * SELECTED_ALTERNATIVE. Implementing 500 * these categories allows others to find the special action it provides 501 * without directly knowing about it, through the 502 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or 503 * more often to build dynamic menu items with 504 * {@link android.view.Menu#addIntentOptions}. Note that in the intent 505 * template here was also supply an explicit name for the template 506 * (via <code>android:label="@string/resolve_title"</code>) to better control 507 * what the user sees when presented with this activity as an alternative 508 * action to the data they are viewing. 509 * 510 * <p>Given these capabilities, the following intent will resolve to the 511 * TitleEditor activity:</p> 512 * 513 * <ul> 514 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE 515 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 516 * displays and allows the user to edit the title associated 517 * with note <var>{ID}</var>.</p> 518 * </ul> 519 * 520 * <h3>Standard Activity Actions</h3> 521 * 522 * <p>These are the current standard actions that Intent defines for launching 523 * activities (usually through {@link Context#startActivity}. The most 524 * important, and by far most frequently used, are {@link #ACTION_MAIN} and 525 * {@link #ACTION_EDIT}. 526 * 527 * <ul> 528 * <li> {@link #ACTION_MAIN} 529 * <li> {@link #ACTION_VIEW} 530 * <li> {@link #ACTION_ATTACH_DATA} 531 * <li> {@link #ACTION_EDIT} 532 * <li> {@link #ACTION_PICK} 533 * <li> {@link #ACTION_CHOOSER} 534 * <li> {@link #ACTION_GET_CONTENT} 535 * <li> {@link #ACTION_DIAL} 536 * <li> {@link #ACTION_CALL} 537 * <li> {@link #ACTION_SEND} 538 * <li> {@link #ACTION_SENDTO} 539 * <li> {@link #ACTION_ANSWER} 540 * <li> {@link #ACTION_INSERT} 541 * <li> {@link #ACTION_DELETE} 542 * <li> {@link #ACTION_RUN} 543 * <li> {@link #ACTION_SYNC} 544 * <li> {@link #ACTION_PICK_ACTIVITY} 545 * <li> {@link #ACTION_SEARCH} 546 * <li> {@link #ACTION_WEB_SEARCH} 547 * <li> {@link #ACTION_FACTORY_TEST} 548 * </ul> 549 * 550 * <h3>Standard Broadcast Actions</h3> 551 * 552 * <p>These are the current standard actions that Intent defines for receiving 553 * broadcasts (usually through {@link Context#registerReceiver} or a 554 * <receiver> tag in a manifest). 555 * 556 * <ul> 557 * <li> {@link #ACTION_TIME_TICK} 558 * <li> {@link #ACTION_TIME_CHANGED} 559 * <li> {@link #ACTION_TIMEZONE_CHANGED} 560 * <li> {@link #ACTION_BOOT_COMPLETED} 561 * <li> {@link #ACTION_PACKAGE_ADDED} 562 * <li> {@link #ACTION_PACKAGE_CHANGED} 563 * <li> {@link #ACTION_PACKAGE_REMOVED} 564 * <li> {@link #ACTION_PACKAGE_RESTARTED} 565 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} 566 * <li> {@link #ACTION_PACKAGES_SUSPENDED} 567 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} 568 * <li> {@link #ACTION_UID_REMOVED} 569 * <li> {@link #ACTION_BATTERY_CHANGED} 570 * <li> {@link #ACTION_POWER_CONNECTED} 571 * <li> {@link #ACTION_POWER_DISCONNECTED} 572 * <li> {@link #ACTION_SHUTDOWN} 573 * </ul> 574 * 575 * <h3>Standard Categories</h3> 576 * 577 * <p>These are the current standard categories that can be used to further 578 * clarify an Intent via {@link #addCategory}. 579 * 580 * <ul> 581 * <li> {@link #CATEGORY_DEFAULT} 582 * <li> {@link #CATEGORY_BROWSABLE} 583 * <li> {@link #CATEGORY_TAB} 584 * <li> {@link #CATEGORY_ALTERNATIVE} 585 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} 586 * <li> {@link #CATEGORY_LAUNCHER} 587 * <li> {@link #CATEGORY_INFO} 588 * <li> {@link #CATEGORY_HOME} 589 * <li> {@link #CATEGORY_PREFERENCE} 590 * <li> {@link #CATEGORY_TEST} 591 * <li> {@link #CATEGORY_CAR_DOCK} 592 * <li> {@link #CATEGORY_DESK_DOCK} 593 * <li> {@link #CATEGORY_LE_DESK_DOCK} 594 * <li> {@link #CATEGORY_HE_DESK_DOCK} 595 * <li> {@link #CATEGORY_CAR_MODE} 596 * <li> {@link #CATEGORY_APP_MARKET} 597 * <li> {@link #CATEGORY_VR_HOME} 598 * </ul> 599 * 600 * <h3>Standard Extra Data</h3> 601 * 602 * <p>These are the current standard fields that can be used as extra data via 603 * {@link #putExtra}. 604 * 605 * <ul> 606 * <li> {@link #EXTRA_ALARM_COUNT} 607 * <li> {@link #EXTRA_BCC} 608 * <li> {@link #EXTRA_CC} 609 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} 610 * <li> {@link #EXTRA_DATA_REMOVED} 611 * <li> {@link #EXTRA_DOCK_STATE} 612 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} 613 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} 614 * <li> {@link #EXTRA_DOCK_STATE_CAR} 615 * <li> {@link #EXTRA_DOCK_STATE_DESK} 616 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} 617 * <li> {@link #EXTRA_DONT_KILL_APP} 618 * <li> {@link #EXTRA_EMAIL} 619 * <li> {@link #EXTRA_INITIAL_INTENTS} 620 * <li> {@link #EXTRA_INTENT} 621 * <li> {@link #EXTRA_KEY_EVENT} 622 * <li> {@link #EXTRA_ORIGINATING_URI} 623 * <li> {@link #EXTRA_PHONE_NUMBER} 624 * <li> {@link #EXTRA_REFERRER} 625 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} 626 * <li> {@link #EXTRA_REPLACING} 627 * <li> {@link #EXTRA_SHORTCUT_ICON} 628 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} 629 * <li> {@link #EXTRA_SHORTCUT_INTENT} 630 * <li> {@link #EXTRA_STREAM} 631 * <li> {@link #EXTRA_SHORTCUT_NAME} 632 * <li> {@link #EXTRA_SUBJECT} 633 * <li> {@link #EXTRA_TEMPLATE} 634 * <li> {@link #EXTRA_TEXT} 635 * <li> {@link #EXTRA_TITLE} 636 * <li> {@link #EXTRA_UID} 637 * <li> {@link #EXTRA_USER_INITIATED} 638 * </ul> 639 * 640 * <h3>Flags</h3> 641 * 642 * <p>These are the possible flags that can be used in the Intent via 643 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list 644 * of all possible flags. 645 */ 646 public class Intent implements Parcelable, Cloneable { 647 private static final String TAG = "Intent"; 648 649 private static final String ATTR_ACTION = "action"; 650 private static final String TAG_CATEGORIES = "categories"; 651 private static final String ATTR_CATEGORY = "category"; 652 private static final String TAG_EXTRA = "extra"; 653 private static final String ATTR_TYPE = "type"; 654 private static final String ATTR_IDENTIFIER = "ident"; 655 private static final String ATTR_COMPONENT = "component"; 656 private static final String ATTR_DATA = "data"; 657 private static final String ATTR_FLAGS = "flags"; 658 659 // --------------------------------------------------------------------- 660 // --------------------------------------------------------------------- 661 // Standard intent activity actions (see action variable). 662 663 /** 664 * Activity Action: Start as a main entry point, does not expect to 665 * receive data. 666 * <p>Input: nothing 667 * <p>Output: nothing 668 */ 669 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 670 public static final String ACTION_MAIN = "android.intent.action.MAIN"; 671 672 /** 673 * Activity Action: Display the data to the user. This is the most common 674 * action performed on data -- it is the generic action you can use on 675 * a piece of data to get the most reasonable thing to occur. For example, 676 * when used on a contacts entry it will view the entry; when used on a 677 * mailto: URI it will bring up a compose window filled with the information 678 * supplied by the URI; when used with a tel: URI it will invoke the 679 * dialer. 680 * <p>Input: {@link #getData} is URI from which to retrieve data. 681 * <p>Output: nothing. 682 */ 683 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 684 public static final String ACTION_VIEW = "android.intent.action.VIEW"; 685 686 /** 687 * Extra that can be included on activity intents coming from the storage UI 688 * when it launches sub-activities to manage various types of storage. For example, 689 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show 690 * the images on the device, and in that case also include this extra to tell the 691 * app it is coming from the storage UI so should help the user manage storage of 692 * this type. 693 */ 694 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE"; 695 696 /** 697 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is 698 * performed on a piece of data. 699 */ 700 public static final String ACTION_DEFAULT = ACTION_VIEW; 701 702 /** 703 * Activity Action: Quick view the data. Launches a quick viewer for 704 * a URI or a list of URIs. 705 * <p>Activities handling this intent action should handle the vast majority of 706 * MIME types rather than only specific ones. 707 * <p>Quick viewers must render the quick view image locally, and must not send 708 * file content outside current device. 709 * <p>Input: {@link #getData} is a mandatory content URI of the item to 710 * preview. {@link #getClipData} contains an optional list of content URIs 711 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an 712 * optional index of the URI in the clip data to show first. 713 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features 714 * that can be shown in the quick view UI. 715 * <p>Output: nothing. 716 * @see #EXTRA_INDEX 717 * @see #EXTRA_QUICK_VIEW_FEATURES 718 */ 719 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 720 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; 721 722 /** 723 * Used to indicate that some piece of data should be attached to some other 724 * place. For example, image data could be attached to a contact. It is up 725 * to the recipient to decide where the data should be attached; the intent 726 * does not specify the ultimate destination. 727 * <p>Input: {@link #getData} is URI of data to be attached. 728 * <p>Output: nothing. 729 */ 730 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 731 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; 732 733 /** 734 * Activity Action: Provide explicit editable access to the given data. 735 * <p>Input: {@link #getData} is URI of data to be edited. 736 * <p>Output: nothing. 737 */ 738 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 739 public static final String ACTION_EDIT = "android.intent.action.EDIT"; 740 741 /** 742 * Activity Action: Pick an existing item, or insert a new item, and then edit it. 743 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. 744 * The extras can contain type specific data to pass through to the editing/creating 745 * activity. 746 * <p>Output: The URI of the item that was picked. This must be a content: 747 * URI so that any receiver can access it. 748 */ 749 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 750 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; 751 752 /** 753 * Activity Action: Pick an item from the data, returning what was selected. 754 * <p>Input: {@link #getData} is URI containing a directory of data 755 * (vnd.android.cursor.dir/*) from which to pick an item. 756 * <p>Output: The URI of the item that was picked. 757 */ 758 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 759 public static final String ACTION_PICK = "android.intent.action.PICK"; 760 761 /** 762 * Activity Action: Creates a reminder. 763 * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user. 764 * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at 765 * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will 766 * be shown to the user. The time is specified in milliseconds since the Epoch (optional). 767 * </p> 768 * <p>Output: Nothing.</p> 769 * 770 * @see #EXTRA_TITLE 771 * @see #EXTRA_TEXT 772 * @see #EXTRA_TIME 773 */ 774 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 775 public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER"; 776 777 /** 778 * Activity Action: Creates a shortcut. 779 * <p>Input: Nothing.</p> 780 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> 781 * <p>For compatibility with older versions of android the intent may also contain three 782 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), 783 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE 784 * (value: ShortcutIconResource).</p> 785 * 786 * @see android.content.pm.ShortcutManager#createShortcutResultIntent 787 * @see #EXTRA_SHORTCUT_INTENT 788 * @see #EXTRA_SHORTCUT_NAME 789 * @see #EXTRA_SHORTCUT_ICON 790 * @see #EXTRA_SHORTCUT_ICON_RESOURCE 791 * @see android.content.Intent.ShortcutIconResource 792 */ 793 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 794 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; 795 796 /** 797 * The name of the extra used to define the Intent of a shortcut. 798 * 799 * @see #ACTION_CREATE_SHORTCUT 800 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 801 */ 802 @Deprecated 803 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; 804 /** 805 * The name of the extra used to define the name of a shortcut. 806 * 807 * @see #ACTION_CREATE_SHORTCUT 808 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 809 */ 810 @Deprecated 811 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; 812 /** 813 * The name of the extra used to define the icon, as a Bitmap, of a shortcut. 814 * 815 * @see #ACTION_CREATE_SHORTCUT 816 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 817 */ 818 @Deprecated 819 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; 820 /** 821 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. 822 * 823 * @see #ACTION_CREATE_SHORTCUT 824 * @see android.content.Intent.ShortcutIconResource 825 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 826 */ 827 @Deprecated 828 public static final String EXTRA_SHORTCUT_ICON_RESOURCE = 829 "android.intent.extra.shortcut.ICON_RESOURCE"; 830 831 /** 832 * An activity that provides a user interface for adjusting application preferences. 833 * Optional but recommended settings for all applications which have settings. 834 */ 835 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 836 public static final String ACTION_APPLICATION_PREFERENCES 837 = "android.intent.action.APPLICATION_PREFERENCES"; 838 839 /** 840 * Activity Action: Launch an activity showing the app information. 841 * For applications which install other applications (such as app stores), it is recommended 842 * to handle this action for providing the app information to the user. 843 * 844 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs 845 * to be displayed. 846 * <p>Output: Nothing. 847 */ 848 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 849 public static final String ACTION_SHOW_APP_INFO 850 = "android.intent.action.SHOW_APP_INFO"; 851 852 /** 853 * Activity Action: Placeholder that the component handling it can do activity 854 * recognition. Can be placed on a service. Only one service per package is 855 * supported. 856 * 857 * <p>Input: Nothing.</p> 858 * <p>Output: Nothing </p> 859 * 860 * @hide 861 */ 862 @SystemApi 863 @SdkConstant(SdkConstantType.SERVICE_ACTION) 864 public static final String ACTION_ACTIVITY_RECOGNIZER = 865 "android.intent.action.ACTIVITY_RECOGNIZER"; 866 867 /** 868 * Represents a shortcut/live folder icon resource. 869 * 870 * @see Intent#ACTION_CREATE_SHORTCUT 871 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE 872 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER 873 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON 874 */ 875 public static class ShortcutIconResource implements Parcelable { 876 /** 877 * The package name of the application containing the icon. 878 */ 879 public String packageName; 880 881 /** 882 * The resource name of the icon, including package, name and type. 883 */ 884 public String resourceName; 885 886 /** 887 * Creates a new ShortcutIconResource for the specified context and resource 888 * identifier. 889 * 890 * @param context The context of the application. 891 * @param resourceId The resource identifier for the icon. 892 * @return A new ShortcutIconResource with the specified's context package name 893 * and icon resource identifier.`` 894 */ fromContext(Context context, @AnyRes int resourceId)895 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { 896 ShortcutIconResource icon = new ShortcutIconResource(); 897 icon.packageName = context.getPackageName(); 898 icon.resourceName = context.getResources().getResourceName(resourceId); 899 return icon; 900 } 901 902 /** 903 * Used to read a ShortcutIconResource from a Parcel. 904 */ 905 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR = 906 new Parcelable.Creator<ShortcutIconResource>() { 907 908 public ShortcutIconResource createFromParcel(Parcel source) { 909 ShortcutIconResource icon = new ShortcutIconResource(); 910 icon.packageName = source.readString8(); 911 icon.resourceName = source.readString8(); 912 return icon; 913 } 914 915 public ShortcutIconResource[] newArray(int size) { 916 return new ShortcutIconResource[size]; 917 } 918 }; 919 920 /** 921 * No special parcel contents. 922 */ describeContents()923 public int describeContents() { 924 return 0; 925 } 926 writeToParcel(Parcel dest, int flags)927 public void writeToParcel(Parcel dest, int flags) { 928 dest.writeString8(packageName); 929 dest.writeString8(resourceName); 930 } 931 932 @Override toString()933 public String toString() { 934 return resourceName; 935 } 936 } 937 938 /** 939 * Activity Action: Display an activity chooser, allowing the user to pick 940 * what they want to before proceeding. This can be used as an alternative 941 * to the standard activity picker that is displayed by the system when 942 * you try to start an activity with multiple possible matches, with these 943 * differences in behavior: 944 * <ul> 945 * <li>You can specify the title that will appear in the activity chooser. 946 * <li>The user does not have the option to make one of the matching 947 * activities a preferred activity, and all possible activities will 948 * always be shown even if one of them is currently marked as the 949 * preferred activity. 950 * </ul> 951 * <p> 952 * This action should be used when the user will naturally expect to 953 * select an activity in order to proceed. An example if when not to use 954 * it is when the user clicks on a "mailto:" link. They would naturally 955 * expect to go directly to their mail app, so startActivity() should be 956 * called directly: it will 957 * either launch the current preferred app, or put up a dialog allowing the 958 * user to pick an app to use and optionally marking that as preferred. 959 * <p> 960 * In contrast, if the user is selecting a menu item to send a picture 961 * they are viewing to someone else, there are many different things they 962 * may want to do at this point: send it through e-mail, upload it to a 963 * web service, etc. In this case the CHOOSER action should be used, to 964 * always present to the user a list of the things they can do, with a 965 * nice title given by the caller such as "Send this photo with:". 966 * <p> 967 * If you need to grant URI permissions through a chooser, you must specify 968 * the permissions to be granted on the ACTION_CHOOSER Intent 969 * <em>in addition</em> to the EXTRA_INTENT inside. This means using 970 * {@link #setClipData} to specify the URIs to be granted as well as 971 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 972 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. 973 * <p> 974 * As a convenience, an Intent of this form can be created with the 975 * {@link #createChooser} function. 976 * <p> 977 * Input: No data should be specified. get*Extra must have 978 * a {@link #EXTRA_INTENT} field containing the Intent being executed, 979 * and can optionally have a {@link #EXTRA_TITLE} field containing the 980 * title text to display in the chooser. 981 * <p> 982 * Output: Depends on the protocol of {@link #EXTRA_INTENT}. 983 */ 984 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 985 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; 986 987 /** 988 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 989 * 990 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 991 * target intent, also optionally supplying a title. If the target 992 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 993 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 994 * set in the returned chooser intent, with its ClipData set appropriately: 995 * either a direct reflection of {@link #getClipData()} if that is non-null, 996 * or a new ClipData built from {@link #getData()}. 997 * 998 * @param target The Intent that the user will be selecting an activity 999 * to perform. 1000 * @param title Optional title that will be displayed in the chooser, 1001 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1002 * @return Return a new Intent object that you can hand to 1003 * {@link Context#startActivity(Intent) Context.startActivity()} and 1004 * related methods. 1005 */ createChooser(Intent target, CharSequence title)1006 public static Intent createChooser(Intent target, CharSequence title) { 1007 return createChooser(target, title, null); 1008 } 1009 1010 /** 1011 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 1012 * 1013 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 1014 * target intent, also optionally supplying a title. If the target 1015 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 1016 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 1017 * set in the returned chooser intent, with its ClipData set appropriately: 1018 * either a direct reflection of {@link #getClipData()} if that is non-null, 1019 * or a new ClipData built from {@link #getData()}.</p> 1020 * 1021 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback 1022 * when the user makes a choice. This can be useful if the calling application wants 1023 * to remember the last chosen target and surface it as a more prominent or one-touch 1024 * affordance elsewhere in the UI for next time.</p> 1025 * 1026 * @param target The Intent that the user will be selecting an activity 1027 * to perform. 1028 * @param title Optional title that will be displayed in the chooser, 1029 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1030 * @param sender Optional IntentSender to be called when a choice is made. 1031 * @return Return a new Intent object that you can hand to 1032 * {@link Context#startActivity(Intent) Context.startActivity()} and 1033 * related methods. 1034 */ createChooser(Intent target, CharSequence title, IntentSender sender)1035 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) { 1036 Intent intent = new Intent(ACTION_CHOOSER); 1037 intent.putExtra(EXTRA_INTENT, target); 1038 if (title != null) { 1039 intent.putExtra(EXTRA_TITLE, title); 1040 } 1041 1042 if (sender != null) { 1043 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); 1044 } 1045 1046 // Migrate any clip data and flags from target. 1047 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION 1048 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 1049 | FLAG_GRANT_PREFIX_URI_PERMISSION); 1050 if (permFlags != 0) { 1051 ClipData targetClipData = target.getClipData(); 1052 if (targetClipData == null && target.getData() != null) { 1053 ClipData.Item item = new ClipData.Item(target.getData()); 1054 String[] mimeTypes; 1055 if (target.getType() != null) { 1056 mimeTypes = new String[] { target.getType() }; 1057 } else { 1058 mimeTypes = new String[] { }; 1059 } 1060 targetClipData = new ClipData(null, mimeTypes, item); 1061 } 1062 if (targetClipData != null) { 1063 intent.setClipData(targetClipData); 1064 intent.addFlags(permFlags); 1065 } 1066 } 1067 1068 return intent; 1069 } 1070 1071 /** 1072 * Activity Action: Allow the user to select a particular kind of data and 1073 * return it. This is different than {@link #ACTION_PICK} in that here we 1074 * just say what kind of data is desired, not a URI of existing data from 1075 * which the user can pick. An ACTION_GET_CONTENT could allow the user to 1076 * create the data as it runs (for example taking a picture or recording a 1077 * sound), let them browse over the web and download the desired data, 1078 * etc. 1079 * <p> 1080 * There are two main ways to use this action: if you want a specific kind 1081 * of data, such as a person contact, you set the MIME type to the kind of 1082 * data you want and launch it with {@link Context#startActivity(Intent)}. 1083 * The system will then launch the best application to select that kind 1084 * of data for you. 1085 * <p> 1086 * You may also be interested in any of a set of types of content the user 1087 * can pick. For example, an e-mail application that wants to allow the 1088 * user to add an attachment to an e-mail message can use this action to 1089 * bring up a list of all of the types of content the user can attach. 1090 * <p> 1091 * In this case, you should wrap the GET_CONTENT intent with a chooser 1092 * (through {@link #createChooser}), which will give the proper interface 1093 * for the user to pick how to send your data and allow you to specify 1094 * a prompt indicating what they are doing. You will usually specify a 1095 * broad MIME type (such as image/* or {@literal *}/*), resulting in a 1096 * broad range of content types the user can select from. 1097 * <p> 1098 * When using such a broad GET_CONTENT action, it is often desirable to 1099 * only pick from data that can be represented as a stream. This is 1100 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. 1101 * <p> 1102 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that 1103 * the launched content chooser only returns results representing data that 1104 * is locally available on the device. For example, if this extra is set 1105 * to true then an image picker should not show any pictures that are available 1106 * from a remote server but not already on the local device (thus requiring 1107 * they be downloaded when opened). 1108 * <p> 1109 * If the caller can handle multiple returned items (the user performing 1110 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} 1111 * to indicate this. 1112 * <p> 1113 * Input: {@link #getType} is the desired MIME type to retrieve. Note 1114 * that no URI is supplied in the intent, as there are no constraints on 1115 * where the returned data originally comes from. You may also include the 1116 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be 1117 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content 1118 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to 1119 * allow the user to select multiple items. 1120 * <p> 1121 * Output: The URI of the item that was picked. This must be a content: 1122 * URI so that any receiver can access it. 1123 */ 1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1125 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; 1126 /** 1127 * Activity Action: Dial a number as specified by the data. This shows a 1128 * UI with the number being dialed, allowing the user to explicitly 1129 * initiate the call. 1130 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1131 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1132 * number. 1133 * <p>Output: nothing. 1134 */ 1135 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1136 public static final String ACTION_DIAL = "android.intent.action.DIAL"; 1137 /** 1138 * Activity Action: Perform a call to someone specified by the data. 1139 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1140 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1141 * number. 1142 * <p>Output: nothing. 1143 * 1144 * <p>Note: there will be restrictions on which applications can initiate a 1145 * call; most applications should use the {@link #ACTION_DIAL}. 1146 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency 1147 * numbers. Applications can <strong>dial</strong> emergency numbers using 1148 * {@link #ACTION_DIAL}, however. 1149 * 1150 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M} 1151 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE} 1152 * permission which is not granted, then attempting to use this action will 1153 * result in a {@link java.lang.SecurityException}. 1154 */ 1155 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1156 public static final String ACTION_CALL = "android.intent.action.CALL"; 1157 /** 1158 * Activity Action: Perform a call to an emergency number specified by the 1159 * data. 1160 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1161 * tel: URI of an explicit phone number. 1162 * <p>Output: nothing. 1163 * 1164 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on 1165 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} 1166 * extra (if specified) and may be placed on another {@link PhoneAccount} with the 1167 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external 1168 * factors, such as network conditions and Modem/SIM status. 1169 * @hide 1170 */ 1171 @SystemApi 1172 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1173 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; 1174 /** 1175 * Activity Action: Dial a emergency number specified by the data. This shows a 1176 * UI with the number being dialed, allowing the user to explicitly 1177 * initiate the call. 1178 * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData} 1179 * is a tel: URI of an explicit emergency phone number. 1180 * <p>Output: nothing. 1181 * @hide 1182 */ 1183 @SystemApi 1184 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1185 public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY"; 1186 /** 1187 * Activity action: Perform a call to any number (emergency or not) 1188 * specified by the data. 1189 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1190 * tel: URI of an explicit phone number. 1191 * <p>Output: nothing. 1192 * @hide 1193 */ 1194 @SystemApi 1195 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1196 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; 1197 1198 /** 1199 * Activity Action: Main entry point for carrier setup apps. 1200 * <p>Carrier apps that provide an implementation for this action may be invoked to configure 1201 * carrier service and typically require 1202 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to 1203 * fulfill their duties. 1204 */ 1205 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1206 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP"; 1207 /** 1208 * Activity Action: Send a message to someone specified by the data. 1209 * <p>Input: {@link #getData} is URI describing the target. 1210 * <p>Output: nothing. 1211 */ 1212 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1213 public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; 1214 /** 1215 * Activity Action: Deliver some data to someone else. Who the data is 1216 * being delivered to is not specified; it is up to the receiver of this 1217 * action to ask the user where the data should be sent. 1218 * <p> 1219 * When launching a SEND intent, you should usually wrap it in a chooser 1220 * (through {@link #createChooser}), which will give the proper interface 1221 * for the user to pick how to send your data and allow you to specify 1222 * a prompt indicating what they are doing. 1223 * <p> 1224 * Input: {@link #getType} is the MIME type of the data being sent. 1225 * get*Extra can have either a {@link #EXTRA_TEXT} 1226 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If 1227 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it 1228 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* 1229 * if the MIME type is unknown (this will only allow senders that can 1230 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can 1231 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve 1232 * your text with HTML formatting. 1233 * <p> 1234 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1235 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1236 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1237 * content: URIs and other advanced features of {@link ClipData}. If 1238 * using this approach, you still must supply the same data through the 1239 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1240 * for compatibility with old applications. If you don't set a ClipData, 1241 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1242 * <p> 1243 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1244 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1245 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1246 * be openable only as asset typed files using 1247 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1248 * <p> 1249 * Optional standard extras, which may be interpreted by some recipients as 1250 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1251 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1252 * <p> 1253 * Output: nothing. 1254 */ 1255 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1256 public static final String ACTION_SEND = "android.intent.action.SEND"; 1257 /** 1258 * Activity Action: Deliver multiple data to someone else. 1259 * <p> 1260 * Like {@link #ACTION_SEND}, except the data is multiple. 1261 * <p> 1262 * Input: {@link #getType} is the MIME type of the data being sent. 1263 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link 1264 * #EXTRA_STREAM} field, containing the data to be sent. If using 1265 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} 1266 * for clients to retrieve your text with HTML formatting. 1267 * <p> 1268 * Multiple types are supported, and receivers should handle mixed types 1269 * whenever possible. The right way for the receiver to check them is to 1270 * use the content resolver on each URI. The intent sender should try to 1271 * put the most concrete mime type in the intent type, but it can fall 1272 * back to {@literal <type>/*} or {@literal *}/* as needed. 1273 * <p> 1274 * e.g. if you are sending image/jpg and image/jpg, the intent's type can 1275 * be image/jpg, but if you are sending image/jpg and image/png, then the 1276 * intent's type should be image/*. 1277 * <p> 1278 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1279 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1280 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1281 * content: URIs and other advanced features of {@link ClipData}. If 1282 * using this approach, you still must supply the same data through the 1283 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1284 * for compatibility with old applications. If you don't set a ClipData, 1285 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1286 * <p> 1287 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1288 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1289 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1290 * be openable only as asset typed files using 1291 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1292 * <p> 1293 * Optional standard extras, which may be interpreted by some recipients as 1294 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1295 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1296 * <p> 1297 * Output: nothing. 1298 */ 1299 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1300 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; 1301 /** 1302 * Activity Action: Handle an incoming phone call. 1303 * <p>Input: nothing. 1304 * <p>Output: nothing. 1305 */ 1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1307 public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; 1308 /** 1309 * Activity Action: Insert an empty item into the given container. 1310 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1311 * in which to place the data. 1312 * <p>Output: URI of the new data that was created. 1313 */ 1314 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1315 public static final String ACTION_INSERT = "android.intent.action.INSERT"; 1316 /** 1317 * Activity Action: Create a new item in the given container, initializing it 1318 * from the current contents of the clipboard. 1319 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1320 * in which to place the data. 1321 * <p>Output: URI of the new data that was created. 1322 */ 1323 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1324 public static final String ACTION_PASTE = "android.intent.action.PASTE"; 1325 /** 1326 * Activity Action: Delete the given data from its container. 1327 * <p>Input: {@link #getData} is URI of data to be deleted. 1328 * <p>Output: nothing. 1329 */ 1330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1331 public static final String ACTION_DELETE = "android.intent.action.DELETE"; 1332 /** 1333 * Activity Action: Run the data, whatever that means. 1334 * <p>Input: ? (Note: this is currently specific to the test harness.) 1335 * <p>Output: nothing. 1336 */ 1337 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1338 public static final String ACTION_RUN = "android.intent.action.RUN"; 1339 /** 1340 * Activity Action: Perform a data synchronization. 1341 * <p>Input: ? 1342 * <p>Output: ? 1343 */ 1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1345 public static final String ACTION_SYNC = "android.intent.action.SYNC"; 1346 /** 1347 * Activity Action: Pick an activity given an intent, returning the class 1348 * selected. 1349 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent 1350 * used with {@link PackageManager#queryIntentActivities} to determine the 1351 * set of activities from which to pick. 1352 * <p>Output: Class name of the activity that was selected. 1353 */ 1354 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1355 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; 1356 /** 1357 * Activity Action: Perform a search. 1358 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1359 * is the text to search for. If empty, simply 1360 * enter your search results Activity with the search UI activated. 1361 * <p>Output: nothing. 1362 */ 1363 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1364 public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; 1365 /** 1366 * Activity Action: Start the platform-defined tutorial 1367 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1368 * is the text to search for. If empty, simply 1369 * enter your search results Activity with the search UI activated. 1370 * <p>Output: nothing. 1371 */ 1372 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1373 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; 1374 /** 1375 * Activity Action: Perform a web search. 1376 * <p> 1377 * Input: {@link android.app.SearchManager#QUERY 1378 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is 1379 * a url starts with http or https, the site will be opened. If it is plain 1380 * text, Google search will be applied. 1381 * <p> 1382 * Output: nothing. 1383 */ 1384 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1385 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; 1386 1387 /** 1388 * Activity Action: Perform assist action. 1389 * <p> 1390 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1391 * additional optional contextual information about where the user was when they 1392 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer 1393 * information. 1394 * Output: nothing. 1395 */ 1396 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1397 public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; 1398 1399 /** 1400 * Activity Action: Perform voice assist action. 1401 * <p> 1402 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1403 * additional optional contextual information about where the user was when they 1404 * requested the voice assist. 1405 * Output: nothing. 1406 * @hide 1407 */ 1408 @SystemApi 1409 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1410 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; 1411 1412 /** 1413 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground 1414 * application package at the time the assist was invoked. 1415 */ 1416 public static final String EXTRA_ASSIST_PACKAGE 1417 = "android.intent.extra.ASSIST_PACKAGE"; 1418 1419 /** 1420 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground 1421 * application package at the time the assist was invoked. 1422 */ 1423 public static final String EXTRA_ASSIST_UID 1424 = "android.intent.extra.ASSIST_UID"; 1425 1426 /** 1427 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual 1428 * information supplied by the current foreground app at the time of the assist request. 1429 * This is a {@link Bundle} of additional data. 1430 */ 1431 public static final String EXTRA_ASSIST_CONTEXT 1432 = "android.intent.extra.ASSIST_CONTEXT"; 1433 1434 /** 1435 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a 1436 * keyboard as the primary input device for assistance. 1437 */ 1438 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = 1439 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; 1440 1441 /** 1442 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id 1443 * that was used to invoke the assist. 1444 */ 1445 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = 1446 "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; 1447 1448 /** 1449 * Activity Action: List all available applications. 1450 * <p>Input: Nothing. 1451 * <p>Output: nothing. 1452 */ 1453 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1454 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; 1455 /** 1456 * Activity Action: Show settings for choosing wallpaper. 1457 * <p>Input: Nothing. 1458 * <p>Output: Nothing. 1459 */ 1460 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1461 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; 1462 1463 /** 1464 * Activity Action: Show activity for reporting a bug. 1465 * <p>Input: Nothing. 1466 * <p>Output: Nothing. 1467 */ 1468 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1469 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; 1470 1471 /** 1472 * Activity Action: Main entry point for factory tests. Only used when 1473 * the device is booting in factory test node. The implementing package 1474 * must be installed in the system image. 1475 * <p>Input: nothing 1476 * <p>Output: nothing 1477 */ 1478 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1479 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; 1480 1481 /** 1482 * Activity Action: The user pressed the "call" button to go to the dialer 1483 * or other appropriate UI for placing a call. 1484 * <p>Input: Nothing. 1485 * <p>Output: Nothing. 1486 */ 1487 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1488 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; 1489 1490 /** 1491 * Activity Action: Start Voice Command. 1492 * <p>Input: Nothing. 1493 * <p>Output: Nothing. 1494 * <p class="note"> 1495 * In some cases, a matching Activity may not exist, so ensure you 1496 * safeguard against this. 1497 */ 1498 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1499 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; 1500 1501 /** 1502 * Activity Action: Start action associated with long pressing on the 1503 * search key. 1504 * <p>Input: Nothing. 1505 * <p>Output: Nothing. 1506 */ 1507 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1508 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; 1509 1510 /** 1511 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. 1512 * This intent is delivered to the package which installed the application, usually 1513 * Google Play. 1514 * <p>Input: No data is specified. The bug report is passed in using 1515 * an {@link #EXTRA_BUG_REPORT} field. 1516 * <p>Output: Nothing. 1517 * 1518 * @see #EXTRA_BUG_REPORT 1519 */ 1520 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1521 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; 1522 1523 /** 1524 * An incident or bug report has been taken, and a system app has requested it to be shared, 1525 * so trigger the confirmation screen. 1526 * 1527 * This will be sent directly to the registered receiver with the 1528 * android.permission.APPROVE_INCIDENT_REPORTS permission. 1529 * @hide 1530 */ 1531 @SystemApi 1532 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED = 1533 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED"; 1534 1535 /** 1536 * An incident report has been taken, and the user has approved it for sharing. 1537 * <p> 1538 * This will be sent directly to the registered receiver, which must have 1539 * both the DUMP and USAGE_STATS permissions. 1540 * <p> 1541 * After receiving this, the application should wait until a suitable time 1542 * (e.g. network available), get the list of available reports with 1543 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)} 1544 * and then when the reports have been successfully uploaded, call 1545 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}. 1546 * 1547 * @hide 1548 */ 1549 @SystemApi 1550 public static final String ACTION_INCIDENT_REPORT_READY = 1551 "android.intent.action.INCIDENT_REPORT_READY"; 1552 1553 /** 1554 * Activity Action: Show power usage information to the user. 1555 * <p>Input: Nothing. 1556 * <p>Output: Nothing. 1557 */ 1558 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1559 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; 1560 1561 /** 1562 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs 1563 * to run. 1564 * <p>Input: Nothing. 1565 * <p>Output: Nothing. 1566 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified 1567 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD} 1568 * @hide 1569 * @removed 1570 */ 1571 @Deprecated 1572 @SystemApi 1573 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = 1574 "android.intent.action.DEVICE_INITIALIZATION_WIZARD"; 1575 1576 /** 1577 * Activity Action: Setup wizard to launch after a platform update. This 1578 * activity should have a string meta-data field associated with it, 1579 * {@link #METADATA_SETUP_VERSION}, which defines the current version of 1580 * the platform for setup. The activity will be launched only if 1581 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the 1582 * same value. 1583 * <p>Input: Nothing. 1584 * <p>Output: Nothing. 1585 * @hide 1586 */ 1587 @SystemApi 1588 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1589 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; 1590 1591 /** 1592 * Activity Action: Start the Keyboard Shortcuts Helper screen. 1593 * <p>Input: Nothing. 1594 * <p>Output: Nothing. 1595 * @hide 1596 */ 1597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1598 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = 1599 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; 1600 1601 /** 1602 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. 1603 * <p>Input: Nothing. 1604 * <p>Output: Nothing. 1605 * @hide 1606 */ 1607 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1608 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = 1609 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; 1610 1611 /** 1612 * Activity Action: Show settings for managing network data usage of a 1613 * specific application. Applications should define an activity that offers 1614 * options to control data usage. 1615 */ 1616 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1617 public static final String ACTION_MANAGE_NETWORK_USAGE = 1618 "android.intent.action.MANAGE_NETWORK_USAGE"; 1619 1620 /** 1621 * Activity Action: Launch application installer. 1622 * <p> 1623 * Input: The data must be a content: URI at which the application 1624 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, 1625 * you can also use "package:<package-name>" to install an application for the 1626 * current user that is already installed for another user. You can optionally supply 1627 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, 1628 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. 1629 * <p> 1630 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1631 * succeeded. 1632 * <p> 1633 * <strong>Note:</strong>If your app is targeting API level higher than 25 you 1634 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} 1635 * in order to launch the application installer. 1636 * </p> 1637 * 1638 * @see #EXTRA_INSTALLER_PACKAGE_NAME 1639 * @see #EXTRA_NOT_UNKNOWN_SOURCE 1640 * @see #EXTRA_RETURN_RESULT 1641 * 1642 * @deprecated use {@link android.content.pm.PackageInstaller} instead 1643 */ 1644 @Deprecated 1645 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1646 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; 1647 1648 /** 1649 * Activity Action: Activity to handle split installation failures. 1650 * <p>Splits may be installed dynamically. This happens when an Activity is launched, 1651 * but the split that contains the application isn't installed. When a split is 1652 * installed in this manner, the containing package usually doesn't know this is 1653 * happening. However, if an error occurs during installation, the containing 1654 * package can define a single activity handling this action to deal with such 1655 * failures. 1656 * <p>The activity handling this action must be in the base package. 1657 * <p> 1658 * Input: {@link #EXTRA_INTENT} the original intent that started split installation. 1659 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed. 1660 */ 1661 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1662 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE"; 1663 1664 /** 1665 * Activity Action: Launch instant application installer. 1666 * <p class="note"> 1667 * This is a protected intent that can only be sent by the system. 1668 * </p> 1669 * 1670 * @hide 1671 */ 1672 @SystemApi 1673 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1674 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE 1675 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE"; 1676 1677 /** 1678 * Service Action: Resolve instant application. 1679 * <p> 1680 * The system will have a persistent connection to this service. 1681 * This is a protected intent that can only be sent by the system. 1682 * </p> 1683 * 1684 * @hide 1685 */ 1686 @SystemApi 1687 @SdkConstant(SdkConstantType.SERVICE_ACTION) 1688 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE 1689 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; 1690 1691 /** 1692 * Activity Action: Launch instant app settings. 1693 * 1694 * <p class="note"> 1695 * This is a protected intent that can only be sent by the system. 1696 * </p> 1697 * 1698 * @hide 1699 */ 1700 @SystemApi 1701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1702 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS 1703 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS"; 1704 1705 /** 1706 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1707 * package. Specifies the installer package name; this package will receive the 1708 * {@link #ACTION_APP_ERROR} intent. 1709 */ 1710 public static final String EXTRA_INSTALLER_PACKAGE_NAME 1711 = "android.intent.extra.INSTALLER_PACKAGE_NAME"; 1712 1713 /** 1714 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1715 * package. Specifies that the application being installed should not be 1716 * treated as coming from an unknown source, but as coming from the app 1717 * invoking the Intent. For this to work you must start the installer with 1718 * startActivityForResult(). 1719 */ 1720 public static final String EXTRA_NOT_UNKNOWN_SOURCE 1721 = "android.intent.extra.NOT_UNKNOWN_SOURCE"; 1722 1723 /** 1724 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and 1725 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent 1726 * data field originated from. 1727 */ 1728 public static final String EXTRA_ORIGINATING_URI 1729 = "android.intent.extra.ORIGINATING_URI"; 1730 1731 /** 1732 * This extra can be used with any Intent used to launch an activity, supplying information 1733 * about who is launching that activity. This field contains a {@link android.net.Uri} 1734 * object, typically an http: or https: URI of the web site that the referral came from; 1735 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify 1736 * a native application that it came from. 1737 * 1738 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} 1739 * instead of directly retrieving the extra. It is also valid for applications to 1740 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create 1741 * a string, not a Uri; the field here, if supplied, will always take precedence, 1742 * however.</p> 1743 * 1744 * @see #EXTRA_REFERRER_NAME 1745 */ 1746 public static final String EXTRA_REFERRER 1747 = "android.intent.extra.REFERRER"; 1748 1749 /** 1750 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather 1751 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can 1752 * not be created, in particular when Intent extras are supplied through the 1753 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} 1754 * schemes. 1755 * 1756 * @see #EXTRA_REFERRER 1757 */ 1758 public static final String EXTRA_REFERRER_NAME 1759 = "android.intent.extra.REFERRER_NAME"; 1760 1761 /** 1762 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and 1763 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install 1764 * Currently only a system app that hosts the provider authority "downloads" or holds the 1765 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this. 1766 * @hide 1767 */ 1768 @SystemApi 1769 public static final String EXTRA_ORIGINATING_UID 1770 = "android.intent.extra.ORIGINATING_UID"; 1771 1772 /** 1773 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1774 * package. Tells the installer UI to skip the confirmation with the user 1775 * if the .apk is replacing an existing one. 1776 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android 1777 * will no longer show an interstitial message about updating existing 1778 * applications so this is no longer needed. 1779 */ 1780 @Deprecated 1781 public static final String EXTRA_ALLOW_REPLACE 1782 = "android.intent.extra.ALLOW_REPLACE"; 1783 1784 /** 1785 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or 1786 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should 1787 * return to the application the result code of the install/uninstall. The returned result 1788 * code will be {@link android.app.Activity#RESULT_OK} on success or 1789 * {@link android.app.Activity#RESULT_FIRST_USER} on failure. 1790 */ 1791 public static final String EXTRA_RETURN_RESULT 1792 = "android.intent.extra.RETURN_RESULT"; 1793 1794 /** 1795 * Package manager install result code. @hide because result codes are not 1796 * yet ready to be exposed. 1797 */ 1798 public static final String EXTRA_INSTALL_RESULT 1799 = "android.intent.extra.INSTALL_RESULT"; 1800 1801 /** 1802 * Activity Action: Launch application uninstaller. 1803 * <p> 1804 * Input: The data must be a package: URI whose scheme specific part is 1805 * the package name of the current installed package to be uninstalled. 1806 * You can optionally supply {@link #EXTRA_RETURN_RESULT}. 1807 * <p> 1808 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1809 * succeeded. 1810 * <p> 1811 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} 1812 * since {@link Build.VERSION_CODES#P}. 1813 * 1814 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)} 1815 * instead 1816 */ 1817 @Deprecated 1818 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1819 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; 1820 1821 /** 1822 * Specify whether the package should be uninstalled for all users. 1823 * @hide because these should not be part of normal application flow. 1824 */ 1825 public static final String EXTRA_UNINSTALL_ALL_USERS 1826 = "android.intent.extra.UNINSTALL_ALL_USERS"; 1827 1828 /** 1829 * A string that associates with a metadata entry, indicating the last run version of the 1830 * platform that was setup. 1831 * 1832 * @see #ACTION_UPGRADE_SETUP 1833 * 1834 * @hide 1835 */ 1836 @SystemApi 1837 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; 1838 1839 /** 1840 * Activity action: Launch UI to manage the permissions of an app. 1841 * <p> 1842 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions 1843 * will be managed by the launched UI. 1844 * </p> 1845 * <p> 1846 * Output: Nothing. 1847 * </p> 1848 * 1849 * @see #EXTRA_PACKAGE_NAME 1850 * 1851 * @hide 1852 */ 1853 @SystemApi 1854 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1855 public static final String ACTION_MANAGE_APP_PERMISSIONS = 1856 "android.intent.action.MANAGE_APP_PERMISSIONS"; 1857 1858 /** 1859 * Activity action: Launch UI to manage a specific permissions of an app. 1860 * <p> 1861 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission 1862 * will be managed by the launched UI. 1863 * </p> 1864 * <p> 1865 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission 1866 * that should be managed by the launched UI. 1867 * </p> 1868 * <p> 1869 * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app. 1870 * </p> 1871 * <p> 1872 * Output: Nothing. 1873 * </p> 1874 * 1875 * @see #EXTRA_PACKAGE_NAME 1876 * @see #EXTRA_PERMISSION_NAME 1877 * @see #EXTRA_USER 1878 * 1879 * @hide 1880 */ 1881 @SystemApi 1882 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 1883 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1884 public static final String ACTION_MANAGE_APP_PERMISSION = 1885 "android.intent.action.MANAGE_APP_PERMISSION"; 1886 1887 /** 1888 * Activity action: Launch UI to manage permissions. 1889 * <p> 1890 * Input: Nothing. 1891 * </p> 1892 * <p> 1893 * Output: Nothing. 1894 * </p> 1895 * 1896 * @hide 1897 */ 1898 @SystemApi 1899 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1900 public static final String ACTION_MANAGE_PERMISSIONS = 1901 "android.intent.action.MANAGE_PERMISSIONS"; 1902 1903 /** 1904 * Activity action: Launch UI to manage auto-revoke state. 1905 * 1906 * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS 1907 * 1908 * <p> 1909 * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with 1910 * a package name, whose auto-revoke state will be reviewed (mandatory). 1911 * E.g. {@code Uri.fromParts("package", packageName, null) } 1912 * </p> 1913 * <p> 1914 * Output: Nothing. 1915 * </p> 1916 */ 1917 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1918 public static final String ACTION_AUTO_REVOKE_PERMISSIONS = 1919 "android.intent.action.AUTO_REVOKE_PERMISSIONS"; 1920 1921 /** 1922 * Activity action: Launch UI to manage unused apps (hibernated apps). 1923 * 1924 * <p> 1925 * Input: Nothing. 1926 * </p> 1927 * <p> 1928 * Output: Nothing. 1929 * </p> 1930 */ 1931 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1932 public static final String ACTION_MANAGE_UNUSED_APPS = 1933 "android.intent.action.MANAGE_UNUSED_APPS"; 1934 1935 /** 1936 * Activity action: Launch UI to review permissions for an app. 1937 * The system uses this intent if permission review for apps not 1938 * supporting the new runtime permissions model is enabled. In 1939 * this mode a permission review is required before any of the 1940 * app components can run. 1941 * <p> 1942 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose 1943 * permissions will be reviewed (mandatory). 1944 * </p> 1945 * <p> 1946 * Input: {@link #EXTRA_INTENT} specifies a pending intent to 1947 * be fired after the permission review (optional). 1948 * </p> 1949 * <p> 1950 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to 1951 * be invoked after the permission review (optional). 1952 * </p> 1953 * <p> 1954 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent 1955 * passed via {@link #EXTRA_INTENT} needs a result (optional). 1956 * </p> 1957 * <p> 1958 * Output: Nothing. 1959 * </p> 1960 * 1961 * @see #EXTRA_PACKAGE_NAME 1962 * @see #EXTRA_INTENT 1963 * @see #EXTRA_REMOTE_CALLBACK 1964 * @see #EXTRA_RESULT_NEEDED 1965 * 1966 * @hide 1967 */ 1968 @SystemApi 1969 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1970 public static final String ACTION_REVIEW_PERMISSIONS = 1971 "android.intent.action.REVIEW_PERMISSIONS"; 1972 1973 /** 1974 * Activity action: Launch UI to show information about the usage 1975 * of a given permission group. This action would be handled by apps that 1976 * want to show details about how and why given permission group is being 1977 * used. 1978 * <p> 1979 * <strong>Important:</strong>You must protect the activity that handles 1980 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE 1981 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the 1982 * system can launch this activity. The system will not launch 1983 * activities that are not properly protected. 1984 * 1985 * <p> 1986 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group 1987 * for which the launched UI would be targeted. 1988 * </p> 1989 * <p> 1990 * Output: Nothing. 1991 * </p> 1992 */ 1993 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1994 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 1995 public static final String ACTION_VIEW_PERMISSION_USAGE = 1996 "android.intent.action.VIEW_PERMISSION_USAGE"; 1997 1998 /** 1999 * Activity action: Launch UI to show information about the usage of a given permission group in 2000 * a given period. This action would be handled by apps that want to show details about how and 2001 * why given permission group is being used. 2002 * <p> 2003 * <strong>Important:</strong>You must protect the activity that handles this action with the 2004 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that 2005 * only the system can launch this activity. The system will not launch activities that are not 2006 * properly protected. 2007 * 2008 * <p> 2009 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for which the 2010 * launched UI would be targeted. 2011 * </p> 2012 * <p> 2013 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry. 2014 * </p> 2015 * <p> 2016 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in 2017 * millis). Both start time and end time are needed and start time must be <= end time. 2018 * </p> 2019 * <p> 2020 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in 2021 * millis). Both start time and end time are needed and start time must be <= end time. 2022 * </p> 2023 * <p> 2024 * Output: Nothing. 2025 * </p> 2026 */ 2027 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2028 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2029 public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD = 2030 "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD"; 2031 2032 /** 2033 * Activity action: Launch UI to manage a default app. 2034 * <p> 2035 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed 2036 * by the launched UI. 2037 * </p> 2038 * <p> 2039 * Output: Nothing. 2040 * </p> 2041 * 2042 * @hide 2043 */ 2044 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2045 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2046 @SystemApi 2047 public static final String ACTION_MANAGE_DEFAULT_APP = 2048 "android.intent.action.MANAGE_DEFAULT_APP"; 2049 2050 /** 2051 * Intent extra: A role name. 2052 * <p> 2053 * Type: String 2054 * </p> 2055 * 2056 * @see android.app.role.RoleManager 2057 * 2058 * @hide 2059 */ 2060 @SystemApi 2061 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME"; 2062 2063 /** 2064 * Activity action: Launch UI to manage special app accesses. 2065 * <p> 2066 * Input: Nothing. 2067 * </p> 2068 * <p> 2069 * Output: Nothing. 2070 * </p> 2071 * 2072 * @hide 2073 */ 2074 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2075 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2076 @SystemApi 2077 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES = 2078 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES"; 2079 2080 /** 2081 * Intent extra: A callback for reporting remote result as a bundle. 2082 * <p> 2083 * Type: IRemoteCallback 2084 * </p> 2085 * 2086 * @hide 2087 */ 2088 @SystemApi 2089 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; 2090 2091 /** 2092 * Intent extra: An app package name. 2093 * <p> 2094 * Type: String 2095 * </p> 2096 * 2097 */ 2098 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; 2099 2100 /** 2101 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an 2102 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}. 2103 * 2104 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the 2105 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}. 2106 * This is meant to enable the suspended app to better handle the state of being suspended. 2107 * 2108 * @see #ACTION_MY_PACKAGE_SUSPENDED 2109 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2110 * @see PackageManager#isPackageSuspended() 2111 * @see PackageManager#getSuspendedPackageAppExtras() 2112 */ 2113 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS"; 2114 2115 /** 2116 * Intent extra: An app split name. 2117 * <p> 2118 * Type: String 2119 * </p> 2120 */ 2121 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; 2122 2123 /** 2124 * Intent extra: A {@link ComponentName} value. 2125 * <p> 2126 * Type: String 2127 * </p> 2128 */ 2129 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME"; 2130 2131 /** 2132 * Intent extra: An extra for specifying whether a result is needed. 2133 * <p> 2134 * Type: boolean 2135 * </p> 2136 * 2137 * @hide 2138 */ 2139 @SystemApi 2140 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; 2141 2142 /** 2143 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with 2144 * {@link #ACTION_SEND}. 2145 * 2146 * @see ShortcutInfo#getId() 2147 * 2148 * <p> 2149 * Type: String 2150 * </p> 2151 */ 2152 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID"; 2153 2154 /** 2155 * Activity action: Launch UI to manage which apps have a given permission. 2156 * <p> 2157 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group 2158 * which will be managed by the launched UI. 2159 * </p> 2160 * <p> 2161 * Output: Nothing. 2162 * </p> 2163 * 2164 * @see #EXTRA_PERMISSION_NAME 2165 * 2166 * @hide 2167 */ 2168 @SystemApi 2169 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2170 public static final String ACTION_MANAGE_PERMISSION_APPS = 2171 "android.intent.action.MANAGE_PERMISSION_APPS"; 2172 2173 /** 2174 * Intent extra: The name of a permission. 2175 * <p> 2176 * Type: String 2177 * </p> 2178 * 2179 * @hide 2180 */ 2181 @SystemApi 2182 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; 2183 2184 /** 2185 * Intent extra: The name of a permission group. 2186 * <p> 2187 * Type: String 2188 * </p> 2189 */ 2190 public static final String EXTRA_PERMISSION_GROUP_NAME = 2191 "android.intent.extra.PERMISSION_GROUP_NAME"; 2192 2193 /** 2194 * Intent extra: The number of milliseconds. 2195 * <p> 2196 * Type: long 2197 * </p> 2198 */ 2199 public static final String EXTRA_DURATION_MILLIS = 2200 "android.intent.extra.DURATION_MILLIS"; 2201 2202 /** 2203 * Activity action: Launch UI to review app uses of permissions. 2204 * <p> 2205 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name 2206 * that will be displayed by the launched UI. Do not pass both this and 2207 * {@link #EXTRA_PERMISSION_GROUP_NAME} . 2208 * </p> 2209 * <p> 2210 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2211 * that will be displayed by the launched UI. Do not pass both this and 2212 * {@link #EXTRA_PERMISSION_NAME}. 2213 * </p> 2214 * <p> 2215 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2216 * activity to show (optional). Must be non-negative. 2217 * </p> 2218 * <p> 2219 * Output: Nothing. 2220 * </p> 2221 * <p class="note"> 2222 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2223 * </p> 2224 * 2225 * @see #EXTRA_PERMISSION_NAME 2226 * @see #EXTRA_PERMISSION_GROUP_NAME 2227 * @see #EXTRA_DURATION_MILLIS 2228 * 2229 * @hide 2230 */ 2231 @SystemApi 2232 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2234 public static final String ACTION_REVIEW_PERMISSION_USAGE = 2235 "android.intent.action.REVIEW_PERMISSION_USAGE"; 2236 2237 /** 2238 * Activity action: Launch UI to review the timeline history of permissions. 2239 * <p> 2240 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2241 * that will be displayed by the launched UI. 2242 * </p> 2243 * <p> 2244 * Output: Nothing. 2245 * </p> 2246 * <p class="note"> 2247 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2248 * </p> 2249 * 2250 * @see #EXTRA_PERMISSION_GROUP_NAME 2251 * 2252 * @hide 2253 */ 2254 @SystemApi 2255 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2257 public static final String ACTION_REVIEW_PERMISSION_HISTORY = 2258 "android.intent.action.REVIEW_PERMISSION_HISTORY"; 2259 2260 /** 2261 * Activity action: Launch UI to review ongoing app uses of permissions. 2262 * <p> 2263 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2264 * activity to show (optional). Must be non-negative. 2265 * </p> 2266 * <p> 2267 * Output: Nothing. 2268 * </p> 2269 * <p class="note"> 2270 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2271 * </p> 2272 * 2273 * @see #EXTRA_DURATION_MILLIS 2274 * 2275 * @hide 2276 */ 2277 @SystemApi 2278 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2279 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2280 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE = 2281 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE"; 2282 2283 /** 2284 * Activity action: Launch UI to review running accessibility services. 2285 * <p> 2286 * Input: Nothing. 2287 * </p> 2288 * <p> 2289 * Output: Nothing. 2290 * </p> 2291 * 2292 * @hide 2293 */ 2294 @SystemApi 2295 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES) 2296 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2297 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES = 2298 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"; 2299 2300 // --------------------------------------------------------------------- 2301 // --------------------------------------------------------------------- 2302 // Standard intent broadcast actions (see action variable). 2303 2304 /** 2305 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. 2306 * <p> 2307 * For historical reasons, the name of this broadcast action refers to the power 2308 * state of the screen but it is actually sent in response to changes in the 2309 * overall interactive state of the device. 2310 * </p><p> 2311 * This broadcast is sent when the device becomes non-interactive which may have 2312 * nothing to do with the screen turning off. To determine the 2313 * actual state of the screen, use {@link android.view.Display#getState}. 2314 * </p><p> 2315 * See {@link android.os.PowerManager#isInteractive} for details. 2316 * </p> 2317 * You <em>cannot</em> receive this through components declared in 2318 * manifests, only by explicitly registering for it with 2319 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2320 * Context.registerReceiver()}. 2321 * 2322 * <p class="note">This is a protected intent that can only be sent 2323 * by the system. 2324 */ 2325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2326 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; 2327 2328 /** 2329 * Broadcast Action: Sent when the device wakes up and becomes interactive. 2330 * <p> 2331 * For historical reasons, the name of this broadcast action refers to the power 2332 * state of the screen but it is actually sent in response to changes in the 2333 * overall interactive state of the device. 2334 * </p><p> 2335 * This broadcast is sent when the device becomes interactive which may have 2336 * nothing to do with the screen turning on. To determine the 2337 * actual state of the screen, use {@link android.view.Display#getState}. 2338 * </p><p> 2339 * See {@link android.os.PowerManager#isInteractive} for details. 2340 * </p> 2341 * You <em>cannot</em> receive this through components declared in 2342 * manifests, only by explicitly registering for it with 2343 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2344 * Context.registerReceiver()}. 2345 * 2346 * <p class="note">This is a protected intent that can only be sent 2347 * by the system. 2348 */ 2349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2350 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; 2351 2352 /** 2353 * Broadcast Action: Sent after the system stops dreaming. 2354 * 2355 * <p class="note">This is a protected intent that can only be sent by the system. 2356 * It is only sent to registered receivers.</p> 2357 */ 2358 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2359 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; 2360 2361 /** 2362 * Broadcast Action: Sent after the system starts dreaming. 2363 * 2364 * <p class="note">This is a protected intent that can only be sent by the system. 2365 * It is only sent to registered receivers.</p> 2366 */ 2367 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2368 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; 2369 2370 /** 2371 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the 2372 * keyguard is gone). 2373 * 2374 * <p class="note">This is a protected intent that can only be sent 2375 * by the system. 2376 */ 2377 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2378 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; 2379 2380 /** 2381 * Broadcast Action: The current time has changed. Sent every 2382 * minute. You <em>cannot</em> receive this through components declared 2383 * in manifests, only by explicitly registering for it with 2384 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2385 * Context.registerReceiver()}. 2386 * 2387 * <p class="note">This is a protected intent that can only be sent 2388 * by the system. 2389 */ 2390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2391 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; 2392 /** 2393 * Broadcast Action: The time was set. 2394 */ 2395 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2396 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; 2397 /** 2398 * Broadcast Action: The date has changed. 2399 */ 2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2401 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; 2402 /** 2403 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> 2404 * <ul> 2405 * <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new 2406 * time zone.</li> 2407 * </ul> 2408 * 2409 * <p class="note">This is a protected intent that can only be sent 2410 * by the system. 2411 */ 2412 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2413 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; 2414 /** 2415 * Alarm Changed Action: This is broadcast when the AlarmClock 2416 * application's alarm is set or unset. It is used by the 2417 * AlarmClock application and the StatusBar service. 2418 * @hide 2419 */ 2420 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2421 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2422 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; 2423 2424 /** 2425 * Broadcast Action: This is broadcast once, after the user has finished 2426 * booting, but while still in the "locked" state. It can be used to perform 2427 * application-specific initialization, such as installing alarms. You must 2428 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} 2429 * permission in order to receive this broadcast. 2430 * <p> 2431 * This broadcast is sent immediately at boot by all devices (regardless of 2432 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or 2433 * higher. Upon receipt of this broadcast, the user is still locked and only 2434 * device-protected storage can be accessed safely. If you want to access 2435 * credential-protected storage, you need to wait for the user to be 2436 * unlocked (typically by entering their lock pattern or PIN for the first 2437 * time), after which the {@link #ACTION_USER_UNLOCKED} and 2438 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. 2439 * <p> 2440 * To receive this broadcast, your receiver component must be marked as 2441 * being {@link ComponentInfo#directBootAware}. 2442 * <p class="note"> 2443 * This is a protected intent that can only be sent by the system. 2444 * 2445 * @see Context#createDeviceProtectedStorageContext() 2446 */ 2447 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2448 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; 2449 2450 /** 2451 * Broadcast Action: This is broadcast once, after the user has finished 2452 * booting. It can be used to perform application-specific initialization, 2453 * such as installing alarms. You must hold the 2454 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in 2455 * order to receive this broadcast. 2456 * <p> 2457 * This broadcast is sent at boot by all devices (both with and without 2458 * direct boot support). Upon receipt of this broadcast, the user is 2459 * unlocked and both device-protected and credential-protected storage can 2460 * accessed safely. 2461 * <p> 2462 * If you need to run while the user is still locked (before they've entered 2463 * their lock pattern or PIN for the first time), you can listen for the 2464 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. 2465 * <p class="note"> 2466 * This is a protected intent that can only be sent by the system. 2467 */ 2468 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2469 @BroadcastBehavior(includeBackground = true) 2470 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; 2471 2472 /** 2473 * Broadcast Action: This is broadcast when a user action should request a 2474 * temporary system dialog to dismiss. Some examples of temporary system 2475 * dialogs are the notification window-shade and the recent tasks dialog. 2476 * 2477 * @deprecated This intent is deprecated for third-party applications starting from Android 2478 * {@link Build.VERSION_CODES#S} for security reasons. Unauthorized usage by applications 2479 * will result in the broadcast intent being dropped for apps targeting API level less than 2480 * {@link Build.VERSION_CODES#S} and in a {@link SecurityException} for apps targeting SDK 2481 * level {@link Build.VERSION_CODES#S} or higher. Instrumentation initiated from the shell 2482 * (eg. tests) is still able to use the intent. The platform will automatically collapse 2483 * the proper system dialogs in the proper use-cases. For all others, the user is the one in 2484 * control of closing dialogs. 2485 * 2486 * @see AccessibilityService#GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE 2487 */ 2488 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2489 @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS) 2490 @Deprecated 2491 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; 2492 /** 2493 * Broadcast Action: Trigger the download and eventual installation 2494 * of a package. 2495 * <p>Input: {@link #getData} is the URI of the package file to download. 2496 * 2497 * <p class="note">This is a protected intent that can only be sent 2498 * by the system. 2499 * 2500 * @deprecated This constant has never been used. 2501 */ 2502 @Deprecated 2503 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2504 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; 2505 /** 2506 * Broadcast Action: A new application package has been installed on the 2507 * device. The data contains the name of the package. Note that the 2508 * newly installed package does <em>not</em> receive this broadcast. 2509 * <p>May include the following extras: 2510 * <ul> 2511 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2512 * <li> {@link #EXTRA_REPLACING} is set to true if this is following 2513 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. 2514 * </ul> 2515 * 2516 * <p class="note">This is a protected intent that can only be sent 2517 * by the system. 2518 */ 2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2520 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; 2521 /** 2522 * Broadcast Action: A new version of an application package has been 2523 * installed, replacing an existing version that was previously installed. 2524 * The data contains the name of the package. 2525 * <p>May include the following extras: 2526 * <ul> 2527 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2528 * </ul> 2529 * 2530 * <p class="note">This is a protected intent that can only be sent 2531 * by the system. 2532 */ 2533 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2534 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; 2535 /** 2536 * Broadcast Action: A new version of your application has been installed 2537 * over an existing one. This is only sent to the application that was 2538 * replaced. It does not contain any additional data; to receive it, just 2539 * use an intent filter for this action. 2540 * 2541 * <p class="note">This is a protected intent that can only be sent 2542 * by the system. 2543 */ 2544 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2545 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; 2546 /** 2547 * Broadcast Action: An existing application package has been removed from 2548 * the device. The data contains the name of the package. The package 2549 * that is being removed does <em>not</em> receive this Intent. 2550 * <ul> 2551 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2552 * to the package. 2553 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2554 * application -- data and code -- is being removed. 2555 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2556 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2557 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal that the application 2558 * was removed with the user-initiated action. 2559 * </ul> 2560 * 2561 * <p class="note">This is a protected intent that can only be sent 2562 * by the system. 2563 */ 2564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2565 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; 2566 /** 2567 * Broadcast Action: An existing application package has been removed from 2568 * the device. The data contains the name of the package and the visibility 2569 * allow list. The package that is being removed does <em>not</em> receive 2570 * this Intent. 2571 * <ul> 2572 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2573 * to the package. 2574 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2575 * application -- data and code -- is being removed. 2576 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2577 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2578 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal 2579 * that the application was removed with the user-initiated action. 2580 * <li> {@link #EXTRA_VISIBILITY_ALLOW_LIST} containing an int array to 2581 * indicate the visibility allow list. 2582 * </ul> 2583 * 2584 * <p class="note">This is a protected intent that can only be sent 2585 * by the system. 2586 * 2587 * @hide This broadcast is used internally by the system. 2588 */ 2589 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2590 public static final String ACTION_PACKAGE_REMOVED_INTERNAL = 2591 "android.intent.action.PACKAGE_REMOVED_INTERNAL"; 2592 /** 2593 * Broadcast Action: An existing application package has been completely 2594 * removed from the device. The data contains the name of the package. 2595 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when 2596 * {@link #EXTRA_DATA_REMOVED} is true and 2597 * {@link #EXTRA_REPLACING} is false of that broadcast. 2598 * 2599 * <ul> 2600 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2601 * to the package. 2602 * </ul> 2603 * 2604 * <p class="note">This is a protected intent that can only be sent 2605 * by the system. 2606 */ 2607 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2608 public static final String ACTION_PACKAGE_FULLY_REMOVED 2609 = "android.intent.action.PACKAGE_FULLY_REMOVED"; 2610 /** 2611 * Broadcast Action: An existing application package has been changed (for 2612 * example, a component has been enabled or disabled). The data contains 2613 * the name of the package. 2614 * <ul> 2615 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2616 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name 2617 * of the changed components (or the package name itself). 2618 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the 2619 * default action of restarting the application. 2620 * </ul> 2621 * 2622 * <p class="note">This is a protected intent that can only be sent 2623 * by the system. 2624 */ 2625 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2626 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; 2627 /** 2628 * Broadcast Action: Sent to the system rollback manager when a package 2629 * needs to have rollback enabled. 2630 * <p class="note"> 2631 * This is a protected intent that can only be sent by the system. 2632 * </p> 2633 * 2634 * @hide This broadcast is used internally by the system. 2635 */ 2636 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2637 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK = 2638 "android.intent.action.PACKAGE_ENABLE_ROLLBACK"; 2639 /** 2640 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain 2641 * package needs to be cancelled. 2642 * 2643 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager 2644 * that enabling a specific rollback has timed out. 2645 * 2646 * @hide 2647 */ 2648 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2649 public static final String ACTION_CANCEL_ENABLE_ROLLBACK = 2650 "android.intent.action.CANCEL_ENABLE_ROLLBACK"; 2651 /** 2652 * Broadcast Action: A rollback has been committed. 2653 * 2654 * <p class="note">This is a protected intent that can only be sent 2655 * by the system. The receiver must hold MANAGE_ROLLBACK permission. 2656 * 2657 * @hide 2658 */ 2659 @SystemApi 2660 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2661 public static final String ACTION_ROLLBACK_COMMITTED = 2662 "android.intent.action.ROLLBACK_COMMITTED"; 2663 /** 2664 * @hide 2665 * Broadcast Action: Ask system services if there is any reason to 2666 * restart the given package. The data contains the name of the 2667 * package. 2668 * <ul> 2669 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2670 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. 2671 * </ul> 2672 * 2673 * <p class="note">This is a protected intent that can only be sent 2674 * by the system. 2675 */ 2676 @SystemApi 2677 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2678 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; 2679 /** 2680 * Broadcast Action: The user has restarted a package, and all of its 2681 * processes have been killed. All runtime state 2682 * associated with it (processes, alarms, notifications, etc) should 2683 * be removed. Note that the restarted package does <em>not</em> 2684 * receive this broadcast. 2685 * The data contains the name of the package. 2686 * <ul> 2687 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2688 * </ul> 2689 * 2690 * <p class="note">This is a protected intent that can only be sent 2691 * by the system. 2692 */ 2693 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2694 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; 2695 /** 2696 * Broadcast Action: The user has cleared the data of a package. This should 2697 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of 2698 * its persistent data is erased and this broadcast sent. 2699 * Note that the cleared package does <em>not</em> 2700 * receive this broadcast. The data contains the name of the package. 2701 * <ul> 2702 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the 2703 * package whose data was cleared is an uninstalled instant app, then the UID 2704 * will be -1. The platform keeps some meta-data associated with instant apps 2705 * after they are uninstalled. 2706 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared 2707 * data was for an instant app. 2708 * </ul> 2709 * 2710 * <p class="note">This is a protected intent that can only be sent 2711 * by the system. 2712 */ 2713 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2714 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; 2715 /** 2716 * Broadcast Action: Packages have been suspended. 2717 * <p>Includes the following extras: 2718 * <ul> 2719 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended 2720 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended 2721 * </ul> 2722 * 2723 * <p class="note">This is a protected intent that can only be sent 2724 * by the system. It is only sent to registered receivers. 2725 */ 2726 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2727 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; 2728 /** 2729 * Broadcast Action: Packages have been unsuspended. 2730 * <p>Includes the following extras: 2731 * <ul> 2732 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended 2733 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended 2734 * </ul> 2735 * 2736 * <p class="note">This is a protected intent that can only be sent 2737 * by the system. It is only sent to registered receivers. 2738 */ 2739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2740 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; 2741 /** 2742 * Broadcast Action: One of the suspend conditions have been modified for the packages. 2743 * <p>Includes the following extras: 2744 * <ul> 2745 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been modified 2746 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been modified 2747 * </ul> 2748 * 2749 * <p class="note">This is a protected intent that can only be sent 2750 * by the system. It is only sent to registered receivers. 2751 * 2752 * @hide 2753 */ 2754 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2755 public static final String ACTION_PACKAGES_SUSPENSION_CHANGED = 2756 "android.intent.action.PACKAGES_SUSPENSION_CHANGED"; 2757 2758 /** 2759 * Broadcast Action: Distracting packages have been changed. 2760 * <p>Includes the following extras: 2761 * <ul> 2762 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed. 2763 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed. 2764 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages. 2765 * </ul> 2766 * 2767 * <p class="note">This is a protected intent that can only be sent 2768 * by the system. It is only sent to registered receivers. 2769 * 2770 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 2771 * @hide 2772 */ 2773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2774 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED = 2775 "android.intent.action.DISTRACTING_PACKAGES_CHANGED"; 2776 2777 /** 2778 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent 2779 * whenever a package is put into a suspended state or any of its app extras change while in the 2780 * suspended state. 2781 * <p> Optionally includes the following extras: 2782 * <ul> 2783 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain 2784 * useful information for the app being suspended. 2785 * </ul> 2786 * <p class="note">This is a protected intent that can only be sent 2787 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2788 * the manifest.</em> 2789 * 2790 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2791 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2792 * @see PackageManager#isPackageSuspended() 2793 * @see PackageManager#getSuspendedPackageAppExtras() 2794 */ 2795 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2796 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED"; 2797 2798 /** 2799 * Activity Action: Started to show more details about why an application was suspended. 2800 * 2801 * <p>Whenever the system detects an activity launch for a suspended app, this action can 2802 * be used to show more details about the reason for suspension. 2803 * 2804 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity 2805 * handling this intent and protect it with 2806 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}. 2807 * 2808 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package. 2809 * 2810 * <p class="note">This is a protected intent that can only be sent 2811 * by the system. 2812 * 2813 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2814 * PersistableBundle, String) 2815 * @see PackageManager#isPackageSuspended() 2816 * @see #ACTION_PACKAGES_SUSPENDED 2817 * 2818 * @hide 2819 */ 2820 @SystemApi 2821 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2822 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS = 2823 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS"; 2824 2825 /** 2826 * Broadcast Action: Sent to indicate that the user unsuspended a package. 2827 * 2828 * <p>This can happen when the user taps on the neutral button of the 2829 * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using 2830 * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the 2831 * suspending app that originally specified this dialog while calling 2832 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2833 * PersistableBundle, SuspendDialogInfo)}. 2834 * 2835 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just 2836 * got unsuspended. 2837 * 2838 * <p class="note">This is a protected intent that can only be sent 2839 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2840 * the manifest.</em> 2841 * 2842 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2843 * PersistableBundle, SuspendDialogInfo) 2844 * @see PackageManager#isPackageSuspended() 2845 * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS 2846 * @hide 2847 */ 2848 @SystemApi 2849 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2850 public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY = 2851 "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY"; 2852 2853 /** 2854 * Broadcast Action: Sent to a package that has been unsuspended. 2855 * 2856 * <p class="note">This is a protected intent that can only be sent 2857 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2858 * the manifest.</em> 2859 * 2860 * @see #ACTION_MY_PACKAGE_SUSPENDED 2861 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2862 * @see PackageManager#isPackageSuspended() 2863 * @see PackageManager#getSuspendedPackageAppExtras() 2864 */ 2865 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2866 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED"; 2867 2868 /** 2869 * Broadcast Action: A user ID has been removed from the system. The user 2870 * ID number is stored in the extra data under {@link #EXTRA_UID}. 2871 * 2872 * <p class="note">This is a protected intent that can only be sent 2873 * by the system. 2874 */ 2875 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2876 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; 2877 2878 /** 2879 * Broadcast Action: Sent to the installer package of an application when 2880 * that application is first launched (that is the first time it is moved 2881 * out of the stopped state). The data contains the name of the package. 2882 * 2883 * <p>When the application is first launched, the application itself doesn't receive this 2884 * broadcast.</p> 2885 * 2886 * <p class="note">This is a protected intent that can only be sent 2887 * by the system. 2888 */ 2889 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2890 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; 2891 2892 /** 2893 * Broadcast Action: Sent to the system package verifier when a package 2894 * needs to be verified. The data contains the package URI. 2895 * <p class="note"> 2896 * This is a protected intent that can only be sent by the system. 2897 * </p> 2898 */ 2899 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2900 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; 2901 2902 /** 2903 * Broadcast Action: Sent to the system package verifier when a package is 2904 * verified. The data contains the package URI. 2905 * <p class="note"> 2906 * This is a protected intent that can only be sent by the system. 2907 */ 2908 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2909 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; 2910 2911 /** 2912 * Broadcast Action: Sent to the system intent filter verifier when an 2913 * intent filter needs to be verified. The data contains the filter data 2914 * hosts to be verified against. 2915 * <p class="note"> 2916 * This is a protected intent that can only be sent by the system. 2917 * </p> 2918 * 2919 * @hide 2920 * @deprecated Superseded by domain verification APIs. See {@link DomainVerificationManager}. 2921 */ 2922 @Deprecated 2923 @SystemApi 2924 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2925 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = 2926 "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; 2927 2928 2929 /** 2930 * Broadcast Action: Sent to the system domain verification agent when an app's domains need 2931 * to be verified. The data contains the domains hosts to be verified against. 2932 * <p class="note"> 2933 * This is a protected intent that can only be sent by the system. 2934 * </p> 2935 * 2936 * @hide 2937 */ 2938 @SystemApi 2939 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2940 public static final String ACTION_DOMAINS_NEED_VERIFICATION = 2941 "android.intent.action.DOMAINS_NEED_VERIFICATION"; 2942 2943 /** 2944 * Broadcast Action: Resources for a set of packages (which were 2945 * previously unavailable) are currently 2946 * available since the media on which they exist is available. 2947 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 2948 * list of packages whose availability changed. 2949 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 2950 * list of uids of packages whose availability changed. 2951 * Note that the 2952 * packages in this list do <em>not</em> receive this broadcast. 2953 * The specified set of packages are now available on the system. 2954 * <p>Includes the following extras: 2955 * <ul> 2956 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 2957 * whose resources(were previously unavailable) are currently available. 2958 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the 2959 * packages whose resources(were previously unavailable) 2960 * are currently available. 2961 * </ul> 2962 * 2963 * <p class="note">This is a protected intent that can only be sent 2964 * by the system. 2965 */ 2966 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2967 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = 2968 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; 2969 2970 /** 2971 * Broadcast Action: Resources for a set of packages are currently 2972 * unavailable since the media on which they exist is unavailable. 2973 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 2974 * list of packages whose availability changed. 2975 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 2976 * list of uids of packages whose availability changed. 2977 * The specified set of packages can no longer be 2978 * launched and are practically unavailable on the system. 2979 * <p>Inclues the following extras: 2980 * <ul> 2981 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 2982 * whose resources are no longer available. 2983 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages 2984 * whose resources are no longer available. 2985 * </ul> 2986 * 2987 * <p class="note">This is a protected intent that can only be sent 2988 * by the system. 2989 */ 2990 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2991 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = 2992 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; 2993 2994 /** 2995 * Broadcast Action: preferred activities have changed *explicitly*. 2996 * 2997 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. 2998 * when an app is installed or uninstalled, but in such cases this broadcast will *not* 2999 * be sent. 3000 * 3001 * {@link #EXTRA_USER_HANDLE} contains the user ID in question. 3002 * 3003 * @hide 3004 */ 3005 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3006 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = 3007 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; 3008 3009 3010 /** 3011 * Broadcast Action: The current system wallpaper has changed. See 3012 * {@link android.app.WallpaperManager} for retrieving the new wallpaper. 3013 * This should <em>only</em> be used to determine when the wallpaper 3014 * has changed to show the new wallpaper to the user. You should certainly 3015 * never, in response to this, change the wallpaper or other attributes of 3016 * it such as the suggested size. That would be unexpected, right? You'd cause 3017 * all kinds of loops, especially if other apps are doing similar things, 3018 * right? Of course. So please don't do this. 3019 * 3020 * @deprecated Modern applications should use 3021 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER 3022 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper 3023 * shown behind their UI, rather than watching for this broadcast and 3024 * rendering the wallpaper on their own. 3025 */ 3026 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3027 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; 3028 /** 3029 * Broadcast Action: The current device {@link android.content.res.Configuration} 3030 * (orientation, locale, etc) has changed. When such a change happens, the 3031 * UIs (view hierarchy) will need to be rebuilt based on this new 3032 * information; for the most part, applications don't need to worry about 3033 * this, because the system will take care of stopping and restarting the 3034 * application to make sure it sees the new changes. Some system code that 3035 * can not be restarted will need to watch for this action and handle it 3036 * appropriately. 3037 * 3038 * <p class="note"> 3039 * You <em>cannot</em> receive this through components declared 3040 * in manifests, only by explicitly registering for it with 3041 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3042 * Context.registerReceiver()}. 3043 * 3044 * <p class="note">This is a protected intent that can only be sent 3045 * by the system. 3046 * 3047 * @see android.content.res.Configuration 3048 */ 3049 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3050 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; 3051 3052 /** 3053 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed 3054 * such that the device may be eligible for the installation of additional configuration splits. 3055 * Configuration properties that can trigger this broadcast include locale and display density. 3056 * 3057 * <p class="note"> 3058 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through 3059 * components declared in manifests. However, the receiver <em>must</em> hold the 3060 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. 3061 * 3062 * <p class="note"> 3063 * This is a protected intent that can only be sent by the system. 3064 * 3065 * @hide 3066 */ 3067 @SystemApi 3068 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3069 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = 3070 "android.intent.action.SPLIT_CONFIGURATION_CHANGED"; 3071 /** 3072 * Broadcast Action: The current device's locale has changed. 3073 * 3074 * <p class="note">This is a protected intent that can only be sent 3075 * by the system. 3076 */ 3077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3078 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; 3079 /** 3080 * Broadcast Action: This is a <em>sticky broadcast</em> containing the 3081 * charging state, level, and other information about the battery. 3082 * See {@link android.os.BatteryManager} for documentation on the 3083 * contents of the Intent. 3084 * 3085 * <p class="note"> 3086 * You <em>cannot</em> receive this through components declared 3087 * in manifests, only by explicitly registering for it with 3088 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3089 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, 3090 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, 3091 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related 3092 * broadcasts that are sent and can be received through manifest 3093 * receivers. 3094 * 3095 * <p class="note">This is a protected intent that can only be sent 3096 * by the system. 3097 */ 3098 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3099 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; 3100 3101 3102 /** 3103 * Broadcast Action: Sent when the current battery level changes. 3104 * 3105 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle} 3106 * instances representing individual battery level changes with associated 3107 * extras from {@link #ACTION_BATTERY_CHANGED}. 3108 * 3109 * <p class="note"> 3110 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission. 3111 * 3112 * @hide 3113 */ 3114 @SystemApi 3115 public static final String ACTION_BATTERY_LEVEL_CHANGED = 3116 "android.intent.action.BATTERY_LEVEL_CHANGED"; 3117 /** 3118 * Broadcast Action: Indicates low battery condition on the device. 3119 * This broadcast corresponds to the "Low battery warning" system dialog. 3120 * 3121 * <p class="note">This is a protected intent that can only be sent 3122 * by the system. 3123 */ 3124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3125 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; 3126 /** 3127 * Broadcast Action: Indicates the battery is now okay after being low. 3128 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has 3129 * gone back up to an okay state. 3130 * 3131 * <p class="note">This is a protected intent that can only be sent 3132 * by the system. 3133 */ 3134 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3135 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; 3136 /** 3137 * Broadcast Action: External power has been connected to the device. 3138 * This is intended for applications that wish to register specifically to this notification. 3139 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3140 * stay active to receive this notification. This action can be used to implement actions 3141 * that wait until power is available to trigger. 3142 * 3143 * <p class="note">This is a protected intent that can only be sent 3144 * by the system. 3145 */ 3146 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3147 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; 3148 /** 3149 * Broadcast Action: External power has been removed from the device. 3150 * This is intended for applications that wish to register specifically to this notification. 3151 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3152 * stay active to receive this notification. This action can be used to implement actions 3153 * that wait until power is available to trigger. 3154 * 3155 * <p class="note">This is a protected intent that can only be sent 3156 * by the system. 3157 */ 3158 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3159 public static final String ACTION_POWER_DISCONNECTED = 3160 "android.intent.action.ACTION_POWER_DISCONNECTED"; 3161 /** 3162 * Broadcast Action: Device is shutting down. 3163 * This is broadcast when the device is being shut down (completely turned 3164 * off, not sleeping). Once the broadcast is complete, the final shutdown 3165 * will proceed and all unsaved data lost. Apps will not normally need 3166 * to handle this, since the foreground activity will be paused as well. 3167 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered 3168 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3169 * Context.registerReceiver}. 3170 * 3171 * <p class="note">This is a protected intent that can only be sent 3172 * by the system. 3173 * <p>May include the following extras: 3174 * <ul> 3175 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this 3176 * shutdown is only for userspace processes. If not set, assumed to be false. 3177 * </ul> 3178 */ 3179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3180 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; 3181 /** 3182 * Activity Action: Start this activity to request system shutdown. 3183 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true 3184 * to request confirmation from the user before shutting down. The optional boolean 3185 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to 3186 * indicate that the shutdown is requested by the user. 3187 * 3188 * <p class="note">This is a protected intent that can only be sent 3189 * by the system. 3190 * 3191 * {@hide} 3192 */ 3193 public static final String ACTION_REQUEST_SHUTDOWN 3194 = "com.android.internal.intent.action.REQUEST_SHUTDOWN"; 3195 /** 3196 * Broadcast Action: A sticky broadcast that indicates low storage space 3197 * condition on the device 3198 * <p class="note"> 3199 * This is a protected intent that can only be sent by the system. 3200 * 3201 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3202 * or above, this broadcast will no longer be delivered to any 3203 * {@link BroadcastReceiver} defined in your manifest. Instead, 3204 * apps are strongly encouraged to use the improved 3205 * {@link Context#getCacheDir()} behavior so the system can 3206 * automatically free up storage when needed. 3207 */ 3208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3209 @Deprecated 3210 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; 3211 /** 3212 * Broadcast Action: Indicates low storage space condition on the device no 3213 * longer exists 3214 * <p class="note"> 3215 * This is a protected intent that can only be sent by the system. 3216 * 3217 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3218 * or above, this broadcast will no longer be delivered to any 3219 * {@link BroadcastReceiver} defined in your manifest. Instead, 3220 * apps are strongly encouraged to use the improved 3221 * {@link Context#getCacheDir()} behavior so the system can 3222 * automatically free up storage when needed. 3223 */ 3224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3225 @Deprecated 3226 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; 3227 /** 3228 * Broadcast Action: A sticky broadcast that indicates a storage space full 3229 * condition on the device. This is intended for activities that want to be 3230 * able to fill the data partition completely, leaving only enough free 3231 * space to prevent system-wide SQLite failures. 3232 * <p class="note"> 3233 * This is a protected intent that can only be sent by the system. 3234 * 3235 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3236 * or above, this broadcast will no longer be delivered to any 3237 * {@link BroadcastReceiver} defined in your manifest. Instead, 3238 * apps are strongly encouraged to use the improved 3239 * {@link Context#getCacheDir()} behavior so the system can 3240 * automatically free up storage when needed. 3241 * @hide 3242 */ 3243 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3244 @Deprecated 3245 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; 3246 /** 3247 * Broadcast Action: Indicates storage space full condition on the device no 3248 * longer exists. 3249 * <p class="note"> 3250 * This is a protected intent that can only be sent by the system. 3251 * 3252 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3253 * or above, this broadcast will no longer be delivered to any 3254 * {@link BroadcastReceiver} defined in your manifest. Instead, 3255 * apps are strongly encouraged to use the improved 3256 * {@link Context#getCacheDir()} behavior so the system can 3257 * automatically free up storage when needed. 3258 * @hide 3259 */ 3260 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3261 @Deprecated 3262 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; 3263 /** 3264 * Broadcast Action: Indicates low memory condition notification acknowledged by user 3265 * and package management should be started. 3266 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW 3267 * notification. 3268 */ 3269 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3270 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; 3271 /** 3272 * Broadcast Action: The device has entered USB Mass Storage mode. 3273 * This is used mainly for the USB Settings panel. 3274 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3275 * when the SD card file system is mounted or unmounted 3276 * @deprecated replaced by android.os.storage.StorageEventListener 3277 */ 3278 @Deprecated 3279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3280 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; 3281 3282 /** 3283 * Broadcast Action: The device has exited USB Mass Storage mode. 3284 * This is used mainly for the USB Settings panel. 3285 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3286 * when the SD card file system is mounted or unmounted 3287 * @deprecated replaced by android.os.storage.StorageEventListener 3288 */ 3289 @Deprecated 3290 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3291 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; 3292 3293 /** 3294 * Broadcast Action: External media has been removed. 3295 * The path to the mount point for the removed media is contained in the Intent.mData field. 3296 */ 3297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3298 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; 3299 3300 /** 3301 * Broadcast Action: External media is present, but not mounted at its mount point. 3302 * The path to the mount point for the unmounted media is contained in the Intent.mData field. 3303 */ 3304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3305 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; 3306 3307 /** 3308 * Broadcast Action: External media is present, and being disk-checked 3309 * The path to the mount point for the checking media is contained in the Intent.mData field. 3310 */ 3311 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3312 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; 3313 3314 /** 3315 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) 3316 * The path to the mount point for the checking media is contained in the Intent.mData field. 3317 */ 3318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3319 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; 3320 3321 /** 3322 * Broadcast Action: External media is present and mounted at its mount point. 3323 * The path to the mount point for the mounted media is contained in the Intent.mData field. 3324 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the 3325 * media was mounted read only. 3326 */ 3327 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3328 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; 3329 3330 /** 3331 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. 3332 * The path to the mount point for the shared media is contained in the Intent.mData field. 3333 */ 3334 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3335 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; 3336 3337 /** 3338 * Broadcast Action: External media is no longer being shared via USB mass storage. 3339 * The path to the mount point for the previously shared media is contained in the Intent.mData field. 3340 * 3341 * @hide 3342 */ 3343 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; 3344 3345 /** 3346 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. 3347 * The path to the mount point for the removed media is contained in the Intent.mData field. 3348 */ 3349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3350 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; 3351 3352 /** 3353 * Broadcast Action: External media is present but cannot be mounted. 3354 * The path to the mount point for the unmountable media is contained in the Intent.mData field. 3355 */ 3356 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3357 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; 3358 3359 /** 3360 * Broadcast Action: User has expressed the desire to remove the external storage media. 3361 * Applications should close all files they have open within the mount point when they receive this intent. 3362 * The path to the mount point for the media to be ejected is contained in the Intent.mData field. 3363 */ 3364 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3365 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; 3366 3367 /** 3368 * Broadcast Action: The media scanner has started scanning a directory. 3369 * The path to the directory being scanned is contained in the Intent.mData field. 3370 */ 3371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3372 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; 3373 3374 /** 3375 * Broadcast Action: The media scanner has finished scanning a directory. 3376 * The path to the scanned directory is contained in the Intent.mData field. 3377 */ 3378 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3379 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; 3380 3381 /** 3382 * Broadcast Action: Request the media scanner to scan a file and add it to 3383 * the media database. 3384 * <p> 3385 * The path to the file is contained in {@link Intent#getData()}. 3386 * 3387 * @deprecated Callers should migrate to inserting items directly into 3388 * {@link MediaStore}, where they will be automatically scanned 3389 * after each mutation. 3390 */ 3391 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3392 @Deprecated 3393 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; 3394 3395 /** 3396 * Broadcast Action: The "Media Button" was pressed. Includes a single 3397 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3398 * caused the broadcast. 3399 */ 3400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3401 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; 3402 3403 /** 3404 * Broadcast Action: The "Camera Button" was pressed. Includes a single 3405 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3406 * caused the broadcast. 3407 */ 3408 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3409 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; 3410 3411 // *** NOTE: @todo(*) The following really should go into a more domain-specific 3412 // location; they are not general-purpose actions. 3413 3414 /** 3415 * Broadcast Action: A GTalk connection has been established. 3416 */ 3417 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3418 public static final String ACTION_GTALK_SERVICE_CONNECTED = 3419 "android.intent.action.GTALK_CONNECTED"; 3420 3421 /** 3422 * Broadcast Action: A GTalk connection has been disconnected. 3423 */ 3424 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3425 public static final String ACTION_GTALK_SERVICE_DISCONNECTED = 3426 "android.intent.action.GTALK_DISCONNECTED"; 3427 3428 /** 3429 * Broadcast Action: An input method has been changed. 3430 */ 3431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3432 public static final String ACTION_INPUT_METHOD_CHANGED = 3433 "android.intent.action.INPUT_METHOD_CHANGED"; 3434 3435 /** 3436 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or 3437 * more radios have been turned off or on. The intent will have the following extra value:</p> 3438 * <ul> 3439 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, 3440 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been 3441 * turned off</li> 3442 * </ul> 3443 * 3444 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3445 */ 3446 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3447 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; 3448 3449 /** 3450 * Broadcast Action: Some content providers have parts of their namespace 3451 * where they publish new events or items that the user may be especially 3452 * interested in. For these things, they may broadcast this action when the 3453 * set of interesting items change. 3454 * 3455 * For example, GmailProvider sends this notification when the set of unread 3456 * mail in the inbox changes. 3457 * 3458 * <p>The data of the intent identifies which part of which provider 3459 * changed. When queried through the content resolver, the data URI will 3460 * return the data set in question. 3461 * 3462 * <p>The intent will have the following extra values: 3463 * <ul> 3464 * <li><em>count</em> - The number of items in the data set. This is the 3465 * same as the number of items in the cursor returned by querying the 3466 * data URI. </li> 3467 * </ul> 3468 * 3469 * This intent will be sent at boot (if the count is non-zero) and when the 3470 * data set changes. It is possible for the data set to change without the 3471 * count changing (for example, if a new unread message arrives in the same 3472 * sync operation in which a message is archived). The phone should still 3473 * ring/vibrate/etc as normal in this case. 3474 */ 3475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3476 public static final String ACTION_PROVIDER_CHANGED = 3477 "android.intent.action.PROVIDER_CHANGED"; 3478 3479 /** 3480 * Broadcast Action: Wired Headset plugged in or unplugged. 3481 * 3482 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value 3483 * and documentation. 3484 * <p>If the minimum SDK version of your application is 3485 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer 3486 * to the <code>AudioManager</code> constant in your receiver registration code instead. 3487 */ 3488 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3489 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG; 3490 3491 /** 3492 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> 3493 * <ul> 3494 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> 3495 * </ul> 3496 * 3497 * <p class="note">This is a protected intent that can only be sent 3498 * by the system. 3499 * 3500 * @hide 3501 */ 3502 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3503 public static final String ACTION_ADVANCED_SETTINGS_CHANGED 3504 = "android.intent.action.ADVANCED_SETTINGS"; 3505 3506 /** 3507 * Broadcast Action: Sent after application restrictions are changed. 3508 * 3509 * <p class="note">This is a protected intent that can only be sent 3510 * by the system.</p> 3511 */ 3512 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3513 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = 3514 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; 3515 3516 /** 3517 * Broadcast Action: An outgoing call is about to be placed. 3518 * 3519 * <p>The Intent will have the following extra value:</p> 3520 * <ul> 3521 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - 3522 * the phone number originally intended to be dialed.</li> 3523 * </ul> 3524 * <p>Once the broadcast is finished, the resultData is used as the actual 3525 * number to call. If <code>null</code>, no call will be placed.</p> 3526 * <p>It is perfectly acceptable for multiple receivers to process the 3527 * outgoing call in turn: for example, a parental control application 3528 * might verify that the user is authorized to place the call at that 3529 * time, then a number-rewriting application might add an area code if 3530 * one was not specified.</p> 3531 * <p>For consistency, any receiver whose purpose is to prohibit phone 3532 * calls should have a priority of 0, to ensure it will see the final 3533 * phone number to be dialed. 3534 * Any receiver whose purpose is to rewrite phone numbers to be called 3535 * should have a positive priority. 3536 * Negative priorities are reserved for the system for this broadcast; 3537 * using them may cause problems.</p> 3538 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> 3539 * abort the broadcast.</p> 3540 * <p>Emergency calls cannot be intercepted using this mechanism, and 3541 * other calls cannot be modified to call emergency numbers using this 3542 * mechanism. 3543 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing 3544 * call to use their own service instead. Those apps should first prevent 3545 * the call from being placed by setting resultData to <code>null</code> 3546 * and then start their own app to make the call. 3547 * <p>You must hold the 3548 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} 3549 * permission to receive this Intent.</p> 3550 * 3551 * <p class="note">This is a protected intent that can only be sent 3552 * by the system. 3553 * 3554 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to 3555 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast. 3556 * This means that attempts to re-write the outgoing call by other apps using this intent will 3557 * be ignored. 3558 * </p> 3559 * 3560 * @deprecated Apps that redirect outgoing calls should use the 3561 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening 3562 * should use the {@link android.telecom.CallScreeningService} API. Apps which need to be 3563 * notified of basic call state should use 3564 * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine 3565 * when a new outgoing call is placed. 3566 */ 3567 @Deprecated 3568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3569 public static final String ACTION_NEW_OUTGOING_CALL = 3570 "android.intent.action.NEW_OUTGOING_CALL"; 3571 3572 /** 3573 * Broadcast Action: Have the device reboot. This is only for use by 3574 * system code. 3575 * 3576 * <p class="note">This is a protected intent that can only be sent 3577 * by the system. 3578 */ 3579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3580 public static final String ACTION_REBOOT = 3581 "android.intent.action.REBOOT"; 3582 3583 /** 3584 * Broadcast Action: A sticky broadcast for changes in the physical 3585 * docking state of the device. 3586 * 3587 * <p>The intent will have the following extra values: 3588 * <ul> 3589 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock 3590 * state, indicating which dock the device is physically in.</li> 3591 * </ul> 3592 * <p>This is intended for monitoring the current physical dock state. 3593 * See {@link android.app.UiModeManager} for the normal API dealing with 3594 * dock mode changes. 3595 */ 3596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3597 public static final String ACTION_DOCK_EVENT = 3598 "android.intent.action.DOCK_EVENT"; 3599 3600 /** 3601 * Broadcast Action: A broadcast when idle maintenance can be started. 3602 * This means that the user is not interacting with the device and is 3603 * not expected to do so soon. Typical use of the idle maintenance is 3604 * to perform somehow expensive tasks that can be postponed at a moment 3605 * when they will not degrade user experience. 3606 * <p> 3607 * <p class="note">In order to keep the device responsive in case of an 3608 * unexpected user interaction, implementations of a maintenance task 3609 * should be interruptible. In such a scenario a broadcast with action 3610 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you 3611 * should not do the maintenance work in 3612 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a 3613 * maintenance service by {@link Context#startService(Intent)}. Also 3614 * you should hold a wake lock while your maintenance service is running 3615 * to prevent the device going to sleep. 3616 * </p> 3617 * <p> 3618 * <p class="note">This is a protected intent that can only be sent by 3619 * the system. 3620 * </p> 3621 * 3622 * @see #ACTION_IDLE_MAINTENANCE_END 3623 * 3624 * @hide 3625 */ 3626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3627 public static final String ACTION_IDLE_MAINTENANCE_START = 3628 "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; 3629 3630 /** 3631 * Broadcast Action: A broadcast when idle maintenance should be stopped. 3632 * This means that the user was not interacting with the device as a result 3633 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} 3634 * was sent and now the user started interacting with the device. Typical 3635 * use of the idle maintenance is to perform somehow expensive tasks that 3636 * can be postponed at a moment when they will not degrade user experience. 3637 * <p> 3638 * <p class="note">In order to keep the device responsive in case of an 3639 * unexpected user interaction, implementations of a maintenance task 3640 * should be interruptible. Hence, on receiving a broadcast with this 3641 * action, the maintenance task should be interrupted as soon as possible. 3642 * In other words, you should not do the maintenance work in 3643 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the 3644 * maintenance service that was started on receiving of 3645 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake 3646 * lock you acquired when your maintenance service started. 3647 * </p> 3648 * <p class="note">This is a protected intent that can only be sent 3649 * by the system. 3650 * 3651 * @see #ACTION_IDLE_MAINTENANCE_START 3652 * 3653 * @hide 3654 */ 3655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3656 public static final String ACTION_IDLE_MAINTENANCE_END = 3657 "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; 3658 3659 /** 3660 * Broadcast Action: a remote intent is to be broadcasted. 3661 * 3662 * A remote intent is used for remote RPC between devices. The remote intent 3663 * is serialized and sent from one device to another device. The receiving 3664 * device parses the remote intent and broadcasts it. Note that anyone can 3665 * broadcast a remote intent. However, if the intent receiver of the remote intent 3666 * does not trust intent broadcasts from arbitrary intent senders, it should require 3667 * the sender to hold certain permissions so only trusted sender's broadcast will be 3668 * let through. 3669 * @hide 3670 */ 3671 public static final String ACTION_REMOTE_INTENT = 3672 "com.google.android.c2dm.intent.RECEIVE"; 3673 3674 /** 3675 * Broadcast Action: This is broadcast once when the user is booting after a 3676 * system update. It can be used to perform cleanup or upgrades after a 3677 * system update. 3678 * <p> 3679 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} 3680 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's 3681 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only 3682 * sent to receivers in the system image. 3683 * 3684 * @hide 3685 */ 3686 @SystemApi 3687 public static final String ACTION_PRE_BOOT_COMPLETED = 3688 "android.intent.action.PRE_BOOT_COMPLETED"; 3689 3690 /** 3691 * Broadcast to a specific application to query any supported restrictions to impose 3692 * on restricted users. The broadcast intent contains an extra 3693 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted 3694 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or 3695 * String[] depending on the restriction type.<p/> 3696 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, 3697 * which is of type <code>ArrayList<RestrictionEntry></code>. It can also 3698 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. 3699 * The activity specified by that intent will be launched for a result which must contain 3700 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. 3701 * The keys and values of the returned restrictions will be persisted. 3702 * @see RestrictionEntry 3703 */ 3704 public static final String ACTION_GET_RESTRICTION_ENTRIES = 3705 "android.intent.action.GET_RESTRICTION_ENTRIES"; 3706 3707 /** 3708 * Sent the first time a user is starting, to allow system apps to 3709 * perform one time initialization. (This will not be seen by third 3710 * party applications because a newly initialized user does not have any 3711 * third party applications installed for it.) This is sent early in 3712 * starting the user, around the time the home app is started, before 3713 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground 3714 * broadcast, since it is part of a visible user interaction; be as quick 3715 * as possible when handling it. 3716 */ 3717 public static final String ACTION_USER_INITIALIZE = 3718 "android.intent.action.USER_INITIALIZE"; 3719 3720 /** 3721 * Sent when a user switch is happening, causing the process's user to be 3722 * brought to the foreground. This is only sent to receivers registered 3723 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3724 * Context.registerReceiver}. It is sent to the user that is going to the 3725 * foreground. This is sent as a foreground 3726 * broadcast, since it is part of a visible user interaction; be as quick 3727 * as possible when handling it. 3728 */ 3729 public static final String ACTION_USER_FOREGROUND = 3730 "android.intent.action.USER_FOREGROUND"; 3731 3732 /** 3733 * Sent when a user switch is happening, causing the process's user to be 3734 * sent to the background. This is only sent to receivers registered 3735 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3736 * Context.registerReceiver}. It is sent to the user that is going to the 3737 * background. This is sent as a foreground 3738 * broadcast, since it is part of a visible user interaction; be as quick 3739 * as possible when handling it. 3740 */ 3741 public static final String ACTION_USER_BACKGROUND = 3742 "android.intent.action.USER_BACKGROUND"; 3743 3744 /** 3745 * Broadcast sent to the system when a user is added. Carries an extra 3746 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to 3747 * all running users. You must hold 3748 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3749 * @hide 3750 */ 3751 @SystemApi 3752 public static final String ACTION_USER_ADDED = 3753 "android.intent.action.USER_ADDED"; 3754 3755 /** 3756 * Broadcast sent by the system when a user is started. Carries an extra 3757 * {@link EXTRA_USER_HANDLE} that has the userHandle of the user. This is only sent to 3758 * registered receivers, not manifest receivers. It is sent to the user 3759 * that has been started. This is sent as a foreground 3760 * broadcast, since it is part of a visible user interaction; be as quick 3761 * as possible when handling it. 3762 * @hide 3763 */ 3764 public static final String ACTION_USER_STARTED = 3765 "android.intent.action.USER_STARTED"; 3766 3767 /** 3768 * Broadcast sent when a user is in the process of starting. Carries an extra 3769 * {@link EXTRA_USER_HANDLE} that has the userHandle of the user. This is only 3770 * sent to registered receivers, not manifest receivers. It is sent to all 3771 * users (including the one that is being started). You must hold 3772 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3773 * this broadcast. This is sent as a background broadcast, since 3774 * its result is not part of the primary UX flow; to safely keep track of 3775 * started/stopped state of a user you can use this in conjunction with 3776 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with 3777 * other user state broadcasts since those are foreground broadcasts so can 3778 * execute in a different order. 3779 * @hide 3780 */ 3781 public static final String ACTION_USER_STARTING = 3782 "android.intent.action.USER_STARTING"; 3783 3784 /** 3785 * Broadcast sent when a user is going to be stopped. Carries an extra 3786 * {@link EXTRA_USER_HANDLE} that has the userHandle of the user. This is only 3787 * sent to registered receivers, not manifest receivers. It is sent to all 3788 * users (including the one that is being stopped). You must hold 3789 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3790 * this broadcast. The user will not stop until all receivers have 3791 * handled the broadcast. This is sent as a background broadcast, since 3792 * its result is not part of the primary UX flow; to safely keep track of 3793 * started/stopped state of a user you can use this in conjunction with 3794 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with 3795 * other user state broadcasts since those are foreground broadcasts so can 3796 * execute in a different order. 3797 * @hide 3798 */ 3799 public static final String ACTION_USER_STOPPING = 3800 "android.intent.action.USER_STOPPING"; 3801 3802 /** 3803 * Broadcast sent to the system when a user is stopped. Carries an extra 3804 * {@link EXTRA_USER_HANDLE} that has the userHandle of the user. This is similar to 3805 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a 3806 * specific package. This is only sent to registered receivers, not manifest 3807 * receivers. It is sent to all running users <em>except</em> the one that 3808 * has just been stopped (which is no longer running). 3809 * @hide 3810 */ 3811 @TestApi 3812 public static final String ACTION_USER_STOPPED = 3813 "android.intent.action.USER_STOPPED"; 3814 3815 /** 3816 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has 3817 * the userHandle of the user. It is sent to all running users except the 3818 * one that has been removed. The user will not be completely removed until all receivers have 3819 * handled the broadcast. You must hold 3820 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3821 * @hide 3822 */ 3823 @SystemApi 3824 public static final String ACTION_USER_REMOVED = 3825 "android.intent.action.USER_REMOVED"; 3826 3827 /** 3828 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has 3829 * the userHandle of the user to become the current one. This is only sent to 3830 * registered receivers, not manifest receivers. It is sent to all running users. 3831 * You must hold 3832 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3833 * @hide 3834 */ 3835 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 3836 public static final String ACTION_USER_SWITCHED = 3837 "android.intent.action.USER_SWITCHED"; 3838 3839 /** 3840 * Broadcast Action: Sent when the credential-encrypted private storage has 3841 * become unlocked for the target user. This is only sent to registered 3842 * receivers, not manifest receivers. 3843 */ 3844 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3845 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; 3846 3847 /** 3848 * Broadcast sent to the system when a user's information changes. Carries an extra 3849 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. 3850 * This is only sent to registered receivers, not manifest receivers. It is sent to all users. 3851 * @hide 3852 */ 3853 public static final String ACTION_USER_INFO_CHANGED = 3854 "android.intent.action.USER_INFO_CHANGED"; 3855 3856 /** 3857 * Broadcast sent to the primary user when an associated managed profile is added (the profile 3858 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies 3859 * the UserHandle of the profile that was added. Only applications (for example Launchers) 3860 * that need to display merged content across both primary and managed profiles need to 3861 * worry about this broadcast. This is only sent to registered receivers, 3862 * not manifest receivers. 3863 */ 3864 public static final String ACTION_MANAGED_PROFILE_ADDED = 3865 "android.intent.action.MANAGED_PROFILE_ADDED"; 3866 3867 /** 3868 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an 3869 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. 3870 * Only applications (for example Launchers) that need to display merged content across both 3871 * primary and managed profiles need to worry about this broadcast. This is only sent to 3872 * registered receivers, not manifest receivers. 3873 */ 3874 public static final String ACTION_MANAGED_PROFILE_REMOVED = 3875 "android.intent.action.MANAGED_PROFILE_REMOVED"; 3876 3877 /** 3878 * Broadcast sent to the primary user when the credential-encrypted private storage for 3879 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that 3880 * specifies the UserHandle of the profile that was unlocked. Only applications (for example 3881 * Launchers) that need to display merged content across both primary and managed profiles 3882 * need to worry about this broadcast. This is only sent to registered receivers, 3883 * not manifest receivers. 3884 */ 3885 public static final String ACTION_MANAGED_PROFILE_UNLOCKED = 3886 "android.intent.action.MANAGED_PROFILE_UNLOCKED"; 3887 3888 /** 3889 * Broadcast sent to the primary user when an associated managed profile has become available. 3890 * Currently this includes when the user disables quiet mode for the profile. Carries an extra 3891 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, 3892 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state 3893 * of quiet mode. This is only sent to registered receivers, not manifest receivers. 3894 */ 3895 public static final String ACTION_MANAGED_PROFILE_AVAILABLE = 3896 "android.intent.action.MANAGED_PROFILE_AVAILABLE"; 3897 3898 /** 3899 * Broadcast sent to the primary user when an associated managed profile has become unavailable. 3900 * Currently this includes when the user enables quiet mode for the profile. Carries an extra 3901 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, 3902 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state 3903 * of quiet mode. This is only sent to registered receivers, not manifest receivers. 3904 */ 3905 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = 3906 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; 3907 3908 /** 3909 * Broadcast sent to the parent user when an associated profile has been started and unlocked. 3910 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 3911 * This is only sent to registered receivers, not manifest receivers. 3912 */ 3913 public static final String ACTION_PROFILE_ACCESSIBLE = 3914 "android.intent.action.PROFILE_ACCESSIBLE"; 3915 3916 /** 3917 * Broadcast sent to the parent user when an associated profile has stopped. 3918 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 3919 * This is only sent to registered receivers, not manifest receivers. 3920 */ 3921 public static final String ACTION_PROFILE_INACCESSIBLE = 3922 "android.intent.action.PROFILE_INACCESSIBLE"; 3923 3924 /** 3925 * Broadcast sent to the system user when the 'device locked' state changes for any user. 3926 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which 3927 * the device was locked or unlocked. 3928 * 3929 * This is only sent to registered receivers. 3930 * 3931 * @hide 3932 */ 3933 public static final String ACTION_DEVICE_LOCKED_CHANGED = 3934 "android.intent.action.DEVICE_LOCKED_CHANGED"; 3935 3936 /** 3937 * Sent when the user taps on the clock widget in the system's "quick settings" area. 3938 */ 3939 public static final String ACTION_QUICK_CLOCK = 3940 "android.intent.action.QUICK_CLOCK"; 3941 3942 /** 3943 * Activity Action: Shows the brightness setting dialog. 3944 * @hide 3945 */ 3946 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = 3947 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; 3948 3949 /** 3950 * Broadcast Action: A global button was pressed. Includes a single 3951 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3952 * caused the broadcast. 3953 * @hide 3954 */ 3955 @SystemApi 3956 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; 3957 3958 /** 3959 * Broadcast Action: Sent when media resource is granted. 3960 * <p> 3961 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource 3962 * granted. 3963 * </p> 3964 * <p class="note"> 3965 * This is a protected intent that can only be sent by the system. 3966 * </p> 3967 * <p class="note"> 3968 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. 3969 * </p> 3970 * 3971 * @hide 3972 */ 3973 public static final String ACTION_MEDIA_RESOURCE_GRANTED = 3974 "android.intent.action.MEDIA_RESOURCE_GRANTED"; 3975 3976 /** 3977 * Broadcast Action: An overlay package has changed. The data contains the 3978 * name of the overlay package which has changed. This is broadcast on all 3979 * changes to the OverlayInfo returned by {@link 3980 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The 3981 * most common change is a state change that will change whether the 3982 * overlay is enabled or not. 3983 * @hide 3984 */ 3985 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; 3986 3987 /** 3988 * Activity Action: Allow the user to select and return one or more existing 3989 * documents. When invoked, the system will display the various 3990 * {@link DocumentsProvider} instances installed on the device, letting the 3991 * user interactively navigate through them. These documents include local 3992 * media, such as photos and video, and documents provided by installed 3993 * cloud storage providers. 3994 * <p> 3995 * Each document is represented as a {@code content://} URI backed by a 3996 * {@link DocumentsProvider}, which can be opened as a stream with 3997 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 3998 * {@link android.provider.DocumentsContract.Document} metadata. 3999 * <p> 4000 * All selected documents are returned to the calling application with 4001 * persistable read and write permission grants. If you want to maintain 4002 * access to the documents across device reboots, you need to explicitly 4003 * take the persistable permissions using 4004 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. 4005 * <p> 4006 * Callers must indicate the acceptable document MIME types through 4007 * {@link #setType(String)}. For example, to select photos, use 4008 * {@code image/*}. If multiple disjoint MIME types are acceptable, define 4009 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to 4010 * {@literal *}/*. 4011 * <p> 4012 * If the caller can handle multiple returned items (the user performing 4013 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} 4014 * to indicate this. 4015 * <p> 4016 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4017 * URIs that can be opened with 4018 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4019 * <p> 4020 * Callers can set a document URI through 4021 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4022 * location of documents navigator. System will do its best to launch the 4023 * navigator in the specified document if it's a folder, or the folder that 4024 * contains the specified document if not. 4025 * <p> 4026 * Output: The URI of the item that was picked, returned in 4027 * {@link #getData()}. This must be a {@code content://} URI so that any 4028 * receiver can access it. If multiple documents were selected, they are 4029 * returned in {@link #getClipData()}. 4030 * 4031 * @see DocumentsContract 4032 * @see #ACTION_OPEN_DOCUMENT_TREE 4033 * @see #ACTION_CREATE_DOCUMENT 4034 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4035 */ 4036 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4037 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; 4038 4039 /** 4040 * Activity Action: Allow the user to create a new document. When invoked, 4041 * the system will display the various {@link DocumentsProvider} instances 4042 * installed on the device, letting the user navigate through them. The 4043 * returned document may be a newly created document with no content, or it 4044 * may be an existing document with the requested MIME type. 4045 * <p> 4046 * Each document is represented as a {@code content://} URI backed by a 4047 * {@link DocumentsProvider}, which can be opened as a stream with 4048 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 4049 * {@link android.provider.DocumentsContract.Document} metadata. 4050 * <p> 4051 * Callers must indicate the concrete MIME type of the document being 4052 * created by setting {@link #setType(String)}. This MIME type cannot be 4053 * changed after the document is created. 4054 * <p> 4055 * Callers can provide an initial display name through {@link #EXTRA_TITLE}, 4056 * but the user may change this value before creating the file. 4057 * <p> 4058 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4059 * URIs that can be opened with 4060 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4061 * <p> 4062 * Callers can set a document URI through 4063 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4064 * location of documents navigator. System will do its best to launch the 4065 * navigator in the specified document if it's a folder, or the folder that 4066 * contains the specified document if not. 4067 * <p> 4068 * Output: The URI of the item that was created. This must be a 4069 * {@code content://} URI so that any receiver can access it. 4070 * 4071 * @see DocumentsContract 4072 * @see #ACTION_OPEN_DOCUMENT 4073 * @see #ACTION_OPEN_DOCUMENT_TREE 4074 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4075 */ 4076 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4077 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; 4078 4079 /** 4080 * Activity Action: Allow the user to pick a directory subtree. When 4081 * invoked, the system will display the various {@link DocumentsProvider} 4082 * instances installed on the device, letting the user navigate through 4083 * them. Apps can fully manage documents within the returned directory. 4084 * <p> 4085 * To gain access to descendant (child, grandchild, etc) documents, use 4086 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and 4087 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} 4088 * with the returned URI. 4089 * <p> 4090 * Callers can set a document URI through 4091 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4092 * location of documents navigator. System will do its best to launch the 4093 * navigator in the specified document if it's a folder, or the folder that 4094 * contains the specified document if not. 4095 * <p> 4096 * Output: The URI representing the selected directory tree. 4097 * 4098 * @see DocumentsContract 4099 */ 4100 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4101 public static final String 4102 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; 4103 4104 4105 /** 4106 * Activity Action: Perform text translation. 4107 * <p> 4108 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate. 4109 * <p> 4110 * Output: nothing. 4111 */ 4112 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4113 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE"; 4114 4115 /** 4116 * Activity Action: Define the meaning of the selected word(s). 4117 * <p> 4118 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define. 4119 * <p> 4120 * Output: nothing. 4121 */ 4122 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4123 public static final String ACTION_DEFINE = "android.intent.action.DEFINE"; 4124 4125 /** 4126 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or 4127 * exisiting sensor being disconnected. 4128 * 4129 * <p class="note">This is a protected intent that can only be sent by the system.</p> 4130 * 4131 * {@hide} 4132 */ 4133 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4134 public static final String 4135 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; 4136 4137 /** 4138 * Deprecated - use ACTION_FACTORY_RESET instead. 4139 * @hide 4140 * @removed 4141 */ 4142 @Deprecated 4143 @SystemApi 4144 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; 4145 4146 /** 4147 * Broadcast intent sent by the RecoverySystem to inform listeners that a global clear (wipe) 4148 * is about to be performed. 4149 * @hide 4150 */ 4151 @SystemApi 4152 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4153 public static final String ACTION_MASTER_CLEAR_NOTIFICATION 4154 = "android.intent.action.MASTER_CLEAR_NOTIFICATION"; 4155 4156 /** 4157 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4158 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4159 * 4160 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. 4161 * 4162 * @hide 4163 */ 4164 @Deprecated 4165 public static final String EXTRA_FORCE_MASTER_CLEAR = 4166 "android.intent.extra.FORCE_MASTER_CLEAR"; 4167 4168 /** 4169 * A broadcast action to trigger a factory reset. 4170 * 4171 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The 4172 * reason for the factory reset should be specified as {@link #EXTRA_REASON}. 4173 * 4174 * <p>Not for use by third-party applications. 4175 * 4176 * @see #EXTRA_FORCE_FACTORY_RESET 4177 * 4178 * {@hide} 4179 */ 4180 @SystemApi 4181 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4182 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; 4183 4184 /** 4185 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4186 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4187 * 4188 * <p>Not for use by third-party applications. 4189 * 4190 * @hide 4191 */ 4192 @SystemApi 4193 public static final String EXTRA_FORCE_FACTORY_RESET = 4194 "android.intent.extra.FORCE_FACTORY_RESET"; 4195 4196 /** 4197 * Broadcast action: report that a settings element is being restored from backup. The intent 4198 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting, 4199 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE 4200 * is the value of that settings entry prior to the restore operation, and 4201 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been 4202 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three 4203 * values are represented as strings, the fourth one as int. 4204 * 4205 * <p>This broadcast is sent only for settings provider entries known to require special handling 4206 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within 4207 * the provider's backup agent implementation. 4208 * 4209 * @see #EXTRA_SETTING_NAME 4210 * @see #EXTRA_SETTING_PREVIOUS_VALUE 4211 * @see #EXTRA_SETTING_NEW_VALUE 4212 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT 4213 * {@hide} 4214 */ 4215 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; 4216 4217 /** {@hide} */ 4218 public static final String EXTRA_SETTING_NAME = "setting_name"; 4219 /** {@hide} */ 4220 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; 4221 /** {@hide} */ 4222 public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; 4223 /** {@hide} */ 4224 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int"; 4225 4226 /** 4227 * Activity Action: Process a piece of text. 4228 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. 4229 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> 4230 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> 4231 */ 4232 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4233 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; 4234 4235 /** 4236 * Broadcast Action: The sim card state has changed. 4237 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here 4238 * because TelephonyIntents is an internal class. 4239 * The intent will have following extras.</p> 4240 * <p> 4241 * @see #EXTRA_SIM_STATE 4242 * @see #EXTRA_SIM_LOCKED_REASON 4243 * @see #EXTRA_REBROADCAST_ON_UNLOCK 4244 * 4245 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or 4246 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4247 * 4248 * @hide 4249 */ 4250 @Deprecated 4251 @SystemApi 4252 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4253 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED"; 4254 4255 /** 4256 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4257 * This will have one of the following intent values. 4258 * @see #SIM_STATE_UNKNOWN 4259 * @see #SIM_STATE_NOT_READY 4260 * @see #SIM_STATE_ABSENT 4261 * @see #SIM_STATE_PRESENT 4262 * @see #SIM_STATE_CARD_IO_ERROR 4263 * @see #SIM_STATE_CARD_RESTRICTED 4264 * @see #SIM_STATE_LOCKED 4265 * @see #SIM_STATE_READY 4266 * @see #SIM_STATE_IMSI 4267 * @see #SIM_STATE_LOADED 4268 * @hide 4269 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4270 */ 4271 public static final String EXTRA_SIM_STATE = "ss"; 4272 4273 /** 4274 * The intent value UNKNOWN represents the SIM state unknown 4275 * @hide 4276 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4277 */ 4278 public static final String SIM_STATE_UNKNOWN = "UNKNOWN"; 4279 4280 /** 4281 * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on 4282 * @hide 4283 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4284 */ 4285 public static final String SIM_STATE_NOT_READY = "NOT_READY"; 4286 4287 /** 4288 * The intent value ABSENT means the SIM card is missing 4289 * @hide 4290 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4291 */ 4292 public static final String SIM_STATE_ABSENT = "ABSENT"; 4293 4294 /** 4295 * The intent value PRESENT means the device has a SIM card inserted 4296 * @hide 4297 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4298 */ 4299 public static final String SIM_STATE_PRESENT = "PRESENT"; 4300 4301 /** 4302 * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error 4303 * @hide 4304 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4305 */ 4306 static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR"; 4307 4308 /** 4309 * The intent value CARD_RESTRICTED means card is present but not usable due to carrier 4310 * restrictions 4311 * @hide 4312 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4313 */ 4314 static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED"; 4315 4316 /** 4317 * The intent value LOCKED means the SIM is locked by PIN or by network 4318 * @hide 4319 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4320 */ 4321 public static final String SIM_STATE_LOCKED = "LOCKED"; 4322 4323 /** 4324 * The intent value READY means the SIM is ready to be accessed 4325 * @hide 4326 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4327 */ 4328 public static final String SIM_STATE_READY = "READY"; 4329 4330 /** 4331 * The intent value IMSI means the SIM IMSI is ready in property 4332 * @hide 4333 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4334 */ 4335 public static final String SIM_STATE_IMSI = "IMSI"; 4336 4337 /** 4338 * The intent value LOADED means all SIM records, including IMSI, are loaded 4339 * @hide 4340 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4341 */ 4342 public static final String SIM_STATE_LOADED = "LOADED"; 4343 4344 /** 4345 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4346 * This extra will have one of the following intent values. 4347 * <p> 4348 * @see #SIM_LOCKED_ON_PIN 4349 * @see #SIM_LOCKED_ON_PUK 4350 * @see #SIM_LOCKED_NETWORK 4351 * @see #SIM_ABSENT_ON_PERM_DISABLED 4352 * 4353 * @hide 4354 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4355 */ 4356 public static final String EXTRA_SIM_LOCKED_REASON = "reason"; 4357 4358 /** 4359 * The intent value PIN means the SIM is locked on PIN1 4360 * @hide 4361 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4362 */ 4363 public static final String SIM_LOCKED_ON_PIN = "PIN"; 4364 4365 /** 4366 * The intent value PUK means the SIM is locked on PUK1 4367 * @hide 4368 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4369 */ 4370 /* PUK means ICC is locked on PUK1 */ 4371 public static final String SIM_LOCKED_ON_PUK = "PUK"; 4372 4373 /** 4374 * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION 4375 * @hide 4376 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4377 */ 4378 public static final String SIM_LOCKED_NETWORK = "NETWORK"; 4379 4380 /** 4381 * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails 4382 * @hide 4383 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4384 */ 4385 public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED"; 4386 4387 /** 4388 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast 4389 * is a rebroadcast on unlock. Defaults to {@code false} if not specified. 4390 * 4391 * @hide 4392 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or 4393 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4394 */ 4395 public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock"; 4396 4397 /** 4398 * Broadcast Action: indicate that the phone service state has changed. 4399 * The intent will have the following extra values:</p> 4400 * <p> 4401 * @see #EXTRA_VOICE_REG_STATE 4402 * @see #EXTRA_DATA_REG_STATE 4403 * @see #EXTRA_VOICE_ROAMING_TYPE 4404 * @see #EXTRA_DATA_ROAMING_TYPE 4405 * @see #EXTRA_OPERATOR_ALPHA_LONG 4406 * @see #EXTRA_OPERATOR_ALPHA_SHORT 4407 * @see #EXTRA_OPERATOR_NUMERIC 4408 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG 4409 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT 4410 * @see #EXTRA_DATA_OPERATOR_NUMERIC 4411 * @see #EXTRA_MANUAL 4412 * @see #EXTRA_VOICE_RADIO_TECH 4413 * @see #EXTRA_DATA_RADIO_TECH 4414 * @see #EXTRA_CSS_INDICATOR 4415 * @see #EXTRA_NETWORK_ID 4416 * @see #EXTRA_SYSTEM_ID 4417 * @see #EXTRA_CDMA_ROAMING_INDICATOR 4418 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR 4419 * @see #EXTRA_EMERGENCY_ONLY 4420 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION 4421 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION 4422 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST 4423 * 4424 * <p class="note"> 4425 * Requires the READ_PHONE_STATE permission. 4426 * 4427 * <p class="note">This is a protected intent that can only be sent by the system. 4428 * @hide 4429 * @removed 4430 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper 4431 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and 4432 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState 4433 * for a given subscription id and field with a ContentObserver or using JobScheduler. 4434 */ 4435 @Deprecated 4436 @SystemApi 4437 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 4438 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE"; 4439 4440 /** 4441 * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService} 4442 * for querying Data Loader Service providers. Data loader service providers register this 4443 * intent filter in their manifests, so that they can be looked up and bound to by 4444 * {@code DataLoaderManagerService}. 4445 * 4446 * <p class="note">This is a protected intent that can only be sent by the system. 4447 * 4448 * Data loader service providers must be privileged apps. 4449 * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such 4450 * data loader service provider. 4451 * 4452 * @hide 4453 */ 4454 @SystemApi 4455 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) 4456 public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA"; 4457 4458 /** 4459 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration 4460 * state. 4461 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4462 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4463 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4464 * @see android.telephony.ServiceState#STATE_POWER_OFF 4465 * @hide 4466 * @removed 4467 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}. 4468 */ 4469 @Deprecated 4470 @SystemApi 4471 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState"; 4472 4473 /** 4474 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state. 4475 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4476 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4477 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4478 * @see android.telephony.ServiceState#STATE_POWER_OFF 4479 * @hide 4480 * @removed 4481 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}. 4482 */ 4483 @Deprecated 4484 @SystemApi 4485 public static final String EXTRA_DATA_REG_STATE = "dataRegState"; 4486 4487 /** 4488 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming 4489 * type. 4490 * @hide 4491 * @removed 4492 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}. 4493 */ 4494 @Deprecated 4495 @SystemApi 4496 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType"; 4497 4498 /** 4499 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming 4500 * type. 4501 * @hide 4502 * @removed 4503 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}. 4504 */ 4505 @Deprecated 4506 @SystemApi 4507 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType"; 4508 4509 /** 4510 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4511 * registered voice operator name in long alphanumeric format. 4512 * {@code null} if the operator name is not known or unregistered. 4513 * @hide 4514 * @removed 4515 * @deprecated Use 4516 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}. 4517 */ 4518 @Deprecated 4519 @SystemApi 4520 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long"; 4521 4522 /** 4523 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4524 * registered voice operator name in short alphanumeric format. 4525 * {@code null} if the operator name is not known or unregistered. 4526 * @hide 4527 * @removed 4528 * @deprecated Use 4529 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}. 4530 */ 4531 @Deprecated 4532 @SystemApi 4533 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short"; 4534 4535 /** 4536 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4537 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile 4538 * network. 4539 * @hide 4540 * @removed 4541 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}. 4542 */ 4543 @Deprecated 4544 @SystemApi 4545 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric"; 4546 4547 /** 4548 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4549 * registered data operator name in long alphanumeric format. 4550 * {@code null} if the operator name is not known or unregistered. 4551 * @hide 4552 * @removed 4553 * @deprecated Use 4554 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}. 4555 */ 4556 @Deprecated 4557 @SystemApi 4558 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long"; 4559 4560 /** 4561 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4562 * registered data operator name in short alphanumeric format. 4563 * {@code null} if the operator name is not known or unregistered. 4564 * @hide 4565 * @removed 4566 * @deprecated Use 4567 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}. 4568 */ 4569 @Deprecated 4570 @SystemApi 4571 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short"; 4572 4573 /** 4574 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4575 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the 4576 * data operator. 4577 * @hide 4578 * @removed 4579 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}. 4580 */ 4581 @Deprecated 4582 @SystemApi 4583 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric"; 4584 4585 /** 4586 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current 4587 * network selection mode is manual. 4588 * Will be {@code true} if manual mode, {@code false} if automatic mode. 4589 * @hide 4590 * @removed 4591 * @deprecated Use 4592 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}. 4593 */ 4594 @Deprecated 4595 @SystemApi 4596 public static final String EXTRA_MANUAL = "manual"; 4597 4598 /** 4599 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice 4600 * radio technology. 4601 * @hide 4602 * @removed 4603 * @deprecated Use 4604 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}. 4605 */ 4606 @Deprecated 4607 @SystemApi 4608 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology"; 4609 4610 /** 4611 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data 4612 * radio technology. 4613 * @hide 4614 * @removed 4615 * @deprecated Use 4616 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}. 4617 */ 4618 @Deprecated 4619 @SystemApi 4620 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology"; 4621 4622 /** 4623 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service 4624 * support on CDMA network. 4625 * Will be {@code true} if support, {@code false} otherwise. 4626 * @hide 4627 * @removed 4628 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}. 4629 */ 4630 @Deprecated 4631 @SystemApi 4632 public static final String EXTRA_CSS_INDICATOR = "cssIndicator"; 4633 4634 /** 4635 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network 4636 * id. {@code Integer.MAX_VALUE} if unknown. 4637 * @hide 4638 * @removed 4639 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}. 4640 */ 4641 @Deprecated 4642 @SystemApi 4643 public static final String EXTRA_NETWORK_ID = "networkId"; 4644 4645 /** 4646 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id. 4647 * {@code Integer.MAX_VALUE} if unknown. 4648 * @hide 4649 * @removed 4650 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}. 4651 */ 4652 @Deprecated 4653 @SystemApi 4654 public static final String EXTRA_SYSTEM_ID = "systemId"; 4655 4656 /** 4657 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming 4658 * indicator if registered on a CDMA or EVDO system or {@code -1} if not. 4659 * @hide 4660 * @removed 4661 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}. 4662 */ 4663 @Deprecated 4664 @SystemApi 4665 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator"; 4666 4667 /** 4668 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming 4669 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not. 4670 * @hide 4671 * @removed 4672 * @deprecated Use 4673 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}. 4674 */ 4675 @Deprecated 4676 @SystemApi 4677 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator"; 4678 4679 /** 4680 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency 4681 * only mode. 4682 * {@code true} if in emergency only mode, {@code false} otherwise. 4683 * @hide 4684 * @removed 4685 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}. 4686 */ 4687 @Deprecated 4688 @SystemApi 4689 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly"; 4690 4691 /** 4692 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network 4693 * registration state is roaming. 4694 * {@code true} if registration indicates roaming, {@code false} otherwise 4695 * @hide 4696 * @removed 4697 * @deprecated Use 4698 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}. 4699 */ 4700 @Deprecated 4701 @SystemApi 4702 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION = 4703 "isDataRoamingFromRegistration"; 4704 4705 /** 4706 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier 4707 * aggregation is in use. 4708 * {@code true} if carrier aggregation is in use, {@code false} otherwise. 4709 * @hide 4710 * @removed 4711 * @deprecated Use 4712 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}. 4713 */ 4714 @Deprecated 4715 @SystemApi 4716 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation"; 4717 4718 /** 4719 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which 4720 * is reduced from the rsrp threshold while calculating signal strength level. 4721 * @hide 4722 * @removed 4723 */ 4724 @Deprecated 4725 @SystemApi 4726 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; 4727 4728 /** 4729 * The name of the extra used to define the text to be processed, as a 4730 * CharSequence. Note that this may be a styled CharSequence, so you must use 4731 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. 4732 */ 4733 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; 4734 /** 4735 * The name of the boolean extra used to define if the processed text will be used as read-only. 4736 */ 4737 public static final String EXTRA_PROCESS_TEXT_READONLY = 4738 "android.intent.extra.PROCESS_TEXT_READONLY"; 4739 4740 /** 4741 * Broadcast action: reports when a new thermal event has been reached. When the device 4742 * is reaching its maximum temperatue, the thermal level reported 4743 * {@hide} 4744 */ 4745 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4746 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; 4747 4748 /** {@hide} */ 4749 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; 4750 4751 /** 4752 * Thermal state when the device is normal. This state is sent in the 4753 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4754 * {@hide} 4755 */ 4756 public static final int EXTRA_THERMAL_STATE_NORMAL = 0; 4757 4758 /** 4759 * Thermal state where the device is approaching its maximum threshold. This state is sent in 4760 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4761 * {@hide} 4762 */ 4763 public static final int EXTRA_THERMAL_STATE_WARNING = 1; 4764 4765 /** 4766 * Thermal state where the device has reached its maximum threshold. This state is sent in the 4767 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4768 * {@hide} 4769 */ 4770 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; 4771 4772 /** 4773 * Broadcast Action: Indicates the dock in idle state while device is docked. 4774 * 4775 * <p class="note">This is a protected intent that can only be sent 4776 * by the system. 4777 * 4778 * @hide 4779 */ 4780 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE"; 4781 4782 /** 4783 * Broadcast Action: Indicates the dock in active state while device is docked. 4784 * 4785 * <p class="note">This is a protected intent that can only be sent 4786 * by the system. 4787 * 4788 * @hide 4789 */ 4790 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE"; 4791 4792 /** 4793 * Broadcast Action: Indicates that a new device customization has been 4794 * downloaded and applied (packages installed, runtime resource overlays 4795 * enabled, xml files copied, ...), and that it is time for components that 4796 * need to for example clear their caches to do so now. 4797 * 4798 * @hide 4799 */ 4800 @SystemApi 4801 public static final String ACTION_DEVICE_CUSTOMIZATION_READY = 4802 "android.intent.action.DEVICE_CUSTOMIZATION_READY"; 4803 4804 4805 /** 4806 * Activity Action: Display an activity state associated with an unique {@link LocusId}. 4807 * 4808 * <p>For example, a chat app could use the context to resume a conversation between 2 users. 4809 * 4810 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the 4811 * app domain. Should be stable across reboots and backup / restore. 4812 * <p>Output: nothing. 4813 */ 4814 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4815 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS"; 4816 4817 /** 4818 * Broadcast Action: Sent to the integrity component when a package 4819 * needs to be verified. The data contains the package URI along with other relevant 4820 * information. 4821 * 4822 * <p class="note"> 4823 * This is a protected intent that can only be sent by the system. 4824 * </p> 4825 * 4826 * @hide 4827 */ 4828 @SystemApi 4829 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4830 public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION = 4831 "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION"; 4832 4833 4834 // --------------------------------------------------------------------- 4835 // --------------------------------------------------------------------- 4836 // Standard intent categories (see addCategory()). 4837 4838 /** 4839 * Set if the activity should be an option for the default action 4840 * (center press) to perform on a piece of data. Setting this will 4841 * hide from the user any activities without it set when performing an 4842 * action on some data. Note that this is normally -not- set in the 4843 * Intent when initiating an action -- it is for use in intent filters 4844 * specified in packages. 4845 */ 4846 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4847 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; 4848 /** 4849 * Activities that can be safely invoked from a browser must support this 4850 * category. For example, if the user is viewing a web page or an e-mail 4851 * and clicks on a link in the text, the Intent generated execute that 4852 * link will require the BROWSABLE category, so that only activities 4853 * supporting this category will be considered as possible actions. By 4854 * supporting this category, you are promising that there is nothing 4855 * damaging (without user intervention) that can happen by invoking any 4856 * matching Intent. 4857 */ 4858 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4859 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; 4860 /** 4861 * Categories for activities that can participate in voice interaction. 4862 * An activity that supports this category must be prepared to run with 4863 * no UI shown at all (though in some case it may have a UI shown), and 4864 * rely on {@link android.app.VoiceInteractor} to interact with the user. 4865 */ 4866 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4867 public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; 4868 /** 4869 * Set if the activity should be considered as an alternative action to 4870 * the data the user is currently viewing. See also 4871 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that 4872 * applies to the selection in a list of items. 4873 * 4874 * <p>Supporting this category means that you would like your activity to be 4875 * displayed in the set of alternative things the user can do, usually as 4876 * part of the current activity's options menu. You will usually want to 4877 * include a specific label in the <intent-filter> of this action 4878 * describing to the user what it does. 4879 * 4880 * <p>The action of IntentFilter with this category is important in that it 4881 * describes the specific action the target will perform. This generally 4882 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather 4883 * a specific name such as "com.android.camera.action.CROP. Only one 4884 * alternative of any particular action will be shown to the user, so using 4885 * a specific action like this makes sure that your alternative will be 4886 * displayed while also allowing other applications to provide their own 4887 * overrides of that particular action. 4888 */ 4889 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4890 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; 4891 /** 4892 * Set if the activity should be considered as an alternative selection 4893 * action to the data the user has currently selected. This is like 4894 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list 4895 * of items from which the user can select, giving them alternatives to the 4896 * default action that will be performed on it. 4897 */ 4898 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4899 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; 4900 /** 4901 * Intended to be used as a tab inside of a containing TabActivity. 4902 */ 4903 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4904 public static final String CATEGORY_TAB = "android.intent.category.TAB"; 4905 /** 4906 * Should be displayed in the top-level launcher. 4907 */ 4908 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4909 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; 4910 /** 4911 * Indicates an activity optimized for Leanback mode, and that should 4912 * be displayed in the Leanback launcher. 4913 */ 4914 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4915 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; 4916 /** 4917 * Indicates the preferred entry-point activity when an application is launched from a Car 4918 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a 4919 * fallback, or exclude the application entirely. 4920 * @hide 4921 */ 4922 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4923 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER"; 4924 /** 4925 * Indicates a Leanback settings activity to be displayed in the Leanback launcher. 4926 * @hide 4927 */ 4928 @SystemApi 4929 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; 4930 /** 4931 * Provides information about the package it is in; typically used if 4932 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide 4933 * a front-door to the user without having to be shown in the all apps list. 4934 */ 4935 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4936 public static final String CATEGORY_INFO = "android.intent.category.INFO"; 4937 /** 4938 * This is the home activity, that is the first activity that is displayed 4939 * when the device boots. 4940 */ 4941 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4942 public static final String CATEGORY_HOME = "android.intent.category.HOME"; 4943 /** 4944 * This is the home activity that is displayed when the device is finished setting up and ready 4945 * for use. 4946 * @hide 4947 */ 4948 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4949 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; 4950 /** 4951 * The home activity shown on secondary displays that support showing home activities. 4952 */ 4953 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4954 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME"; 4955 /** 4956 * This is the setup wizard activity, that is the first activity that is displayed 4957 * when the user sets up the device for the first time. 4958 * @hide 4959 */ 4960 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4961 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; 4962 /** 4963 * This is the home activity, that is the activity that serves as the launcher app 4964 * from there the user can start other apps. Often components with lower/higher 4965 * priority intent filters handle the home intent, for example SetupWizard, to 4966 * setup the device and we need to be able to distinguish the home app from these 4967 * setup helpers. 4968 * @hide 4969 */ 4970 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4971 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP"; 4972 /** 4973 * This activity is a preference panel. 4974 */ 4975 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4976 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; 4977 /** 4978 * This activity is a development preference panel. 4979 */ 4980 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4981 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; 4982 /** 4983 * Capable of running inside a parent activity container. 4984 */ 4985 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4986 public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; 4987 /** 4988 * This activity allows the user to browse and download new applications. 4989 */ 4990 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4991 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; 4992 /** 4993 * This activity may be exercised by the monkey or other automated test tools. 4994 */ 4995 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4996 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; 4997 /** 4998 * To be used as a test (not part of the normal user experience). 4999 */ 5000 public static final String CATEGORY_TEST = "android.intent.category.TEST"; 5001 /** 5002 * To be used as a unit test (run through the Test Harness). 5003 */ 5004 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; 5005 /** 5006 * To be used as a sample code example (not part of the normal user 5007 * experience). 5008 */ 5009 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; 5010 5011 /** 5012 * Used to indicate that an intent only wants URIs that can be opened with 5013 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs 5014 * must support at least the columns defined in {@link OpenableColumns} when 5015 * queried. 5016 * 5017 * @see #ACTION_GET_CONTENT 5018 * @see #ACTION_OPEN_DOCUMENT 5019 * @see #ACTION_CREATE_DOCUMENT 5020 */ 5021 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5022 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; 5023 5024 /** 5025 * Used to indicate that an intent filter can accept files which are not necessarily 5026 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but 5027 * at least streamable via 5028 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} 5029 * using one of the stream types exposed via 5030 * {@link ContentResolver#getStreamTypes(Uri, String)}. 5031 * 5032 * @see #ACTION_SEND 5033 * @see #ACTION_SEND_MULTIPLE 5034 */ 5035 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5036 public static final String CATEGORY_TYPED_OPENABLE = 5037 "android.intent.category.TYPED_OPENABLE"; 5038 5039 /** 5040 * To be used as code under test for framework instrumentation tests. 5041 */ 5042 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = 5043 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; 5044 /** 5045 * An activity to run when device is inserted into a car dock. 5046 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5047 * information, see {@link android.app.UiModeManager}. 5048 */ 5049 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5050 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; 5051 /** 5052 * An activity to run when device is inserted into a car dock. 5053 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5054 * information, see {@link android.app.UiModeManager}. 5055 */ 5056 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5057 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; 5058 /** 5059 * An activity to run when device is inserted into a analog (low end) dock. 5060 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5061 * information, see {@link android.app.UiModeManager}. 5062 */ 5063 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5064 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; 5065 5066 /** 5067 * An activity to run when device is inserted into a digital (high end) dock. 5068 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5069 * information, see {@link android.app.UiModeManager}. 5070 */ 5071 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5072 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK"; 5073 5074 /** 5075 * Used to indicate that the activity can be used in a car environment. 5076 */ 5077 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5078 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; 5079 5080 /** 5081 * An activity to use for the launcher when the device is placed in a VR Headset viewer. 5082 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5083 * information, see {@link android.app.UiModeManager}. 5084 */ 5085 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5086 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; 5087 5088 /** 5089 * The accessibility shortcut is a global gesture for users with disabilities to trigger an 5090 * important for them accessibility feature to help developers determine whether they want to 5091 * make their activity a shortcut target. 5092 * <p> 5093 * An activity of interest to users with accessibility needs may request to be the target of 5094 * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category, 5095 * which will be dispatched by the system when the user activates the shortcut when it is 5096 * configured to point at this target. 5097 * </p> 5098 * <p> 5099 * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must 5100 * also do two things: 5101 * <ul> 5102 * <ol> 5103 * Specify that it handles the <code>android.intent.action.MAIN</code> 5104 * {@link android.content.Intent} 5105 * with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>. 5106 * </ol> 5107 * <ol> 5108 * Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the 5109 * manifest when declaring the activity. 5110 * </ol> 5111 * </ul> 5112 * If either of these items is missing, the system will ignore the accessibility shortcut 5113 * target. Following is an example declaration: 5114 * </p> 5115 * <pre> 5116 * <activity android:name=".MainActivity" 5117 * . . . 5118 * <intent-filter> 5119 * <action android:name="android.intent.action.MAIN" /> 5120 * <category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /> 5121 * </intent-filter> 5122 * <meta-data android:name="android.accessibilityshortcut.target" 5123 * android:resource="@xml/accessibilityshortcut" /> 5124 * </activity> 5125 * </pre> 5126 * <p> This is a sample XML file configuring a accessibility shortcut target: </p> 5127 * <pre> 5128 * <accessibility-shortcut-target 5129 * android:description="@string/shortcut_target_description" 5130 * android:summary="@string/shortcut_target_summary" 5131 * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" 5132 * android:htmlDescription="@string/shortcut_target_html_description" 5133 * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /> 5134 * </pre> 5135 * <p> 5136 * Both description and summary are necessary. The system will ignore the accessibility 5137 * shortcut target if they are missing. The animated image and html description are supported 5138 * to help users understand how to use the shortcut target. The settings activity is a 5139 * component name that allows the user to modify the settings for this accessibility shortcut 5140 * target. 5141 * </p> 5142 */ 5143 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5144 public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET = 5145 "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET"; 5146 // --------------------------------------------------------------------- 5147 // --------------------------------------------------------------------- 5148 // Application launch intent categories (see addCategory()). 5149 5150 /** 5151 * Used with {@link #ACTION_MAIN} to launch the browser application. 5152 * The activity should be able to browse the Internet. 5153 * <p>NOTE: This should not be used as the primary key of an Intent, 5154 * since it will not result in the app launching with the correct 5155 * action and category. Instead, use this with 5156 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5157 * Intent with this category in the selector.</p> 5158 */ 5159 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5160 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; 5161 5162 /** 5163 * Used with {@link #ACTION_MAIN} to launch the calculator application. 5164 * The activity should be able to perform standard arithmetic operations. 5165 * <p>NOTE: This should not be used as the primary key of an Intent, 5166 * since it will not result in the app launching with the correct 5167 * action and category. Instead, use this with 5168 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5169 * Intent with this category in the selector.</p> 5170 */ 5171 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5172 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; 5173 5174 /** 5175 * Used with {@link #ACTION_MAIN} to launch the calendar application. 5176 * The activity should be able to view and manipulate calendar entries. 5177 * <p>NOTE: This should not be used as the primary key of an Intent, 5178 * since it will not result in the app launching with the correct 5179 * action and category. Instead, use this with 5180 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5181 * Intent with this category in the selector.</p> 5182 */ 5183 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5184 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; 5185 5186 /** 5187 * Used with {@link #ACTION_MAIN} to launch the contacts application. 5188 * The activity should be able to view and manipulate address book entries. 5189 * <p>NOTE: This should not be used as the primary key of an Intent, 5190 * since it will not result in the app launching with the correct 5191 * action and category. Instead, use this with 5192 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5193 * Intent with this category in the selector.</p> 5194 */ 5195 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5196 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; 5197 5198 /** 5199 * Used with {@link #ACTION_MAIN} to launch the email application. 5200 * The activity should be able to send and receive email. 5201 * <p>NOTE: This should not be used as the primary key of an Intent, 5202 * since it will not result in the app launching with the correct 5203 * action and category. Instead, use this with 5204 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5205 * Intent with this category in the selector.</p> 5206 */ 5207 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5208 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; 5209 5210 /** 5211 * Used with {@link #ACTION_MAIN} to launch the gallery application. 5212 * The activity should be able to view and manipulate image and video files 5213 * stored on the device. 5214 * <p>NOTE: This should not be used as the primary key of an Intent, 5215 * since it will not result in the app launching with the correct 5216 * action and category. Instead, use this with 5217 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5218 * Intent with this category in the selector.</p> 5219 */ 5220 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5221 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; 5222 5223 /** 5224 * Used with {@link #ACTION_MAIN} to launch the maps application. 5225 * The activity should be able to show the user's current location and surroundings. 5226 * <p>NOTE: This should not be used as the primary key of an Intent, 5227 * since it will not result in the app launching with the correct 5228 * action and category. Instead, use this with 5229 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5230 * Intent with this category in the selector.</p> 5231 */ 5232 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5233 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; 5234 5235 /** 5236 * Used with {@link #ACTION_MAIN} to launch the messaging application. 5237 * The activity should be able to send and receive text messages. 5238 * <p>NOTE: This should not be used as the primary key of an Intent, 5239 * since it will not result in the app launching with the correct 5240 * action and category. Instead, use this with 5241 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5242 * Intent with this category in the selector.</p> 5243 */ 5244 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5245 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; 5246 5247 /** 5248 * Used with {@link #ACTION_MAIN} to launch the music application. 5249 * The activity should be able to play, browse, or manipulate music files 5250 * stored on the device. 5251 * <p>NOTE: This should not be used as the primary key of an Intent, 5252 * since it will not result in the app launching with the correct 5253 * action and category. Instead, use this with 5254 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5255 * Intent with this category in the selector.</p> 5256 */ 5257 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5258 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; 5259 5260 /** 5261 * Used with {@link #ACTION_MAIN} to launch the files application. 5262 * The activity should be able to browse and manage files stored on the device. 5263 * <p>NOTE: This should not be used as the primary key of an Intent, 5264 * since it will not result in the app launching with the correct 5265 * action and category. Instead, use this with 5266 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5267 * Intent with this category in the selector.</p> 5268 */ 5269 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5270 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES"; 5271 5272 // --------------------------------------------------------------------- 5273 // --------------------------------------------------------------------- 5274 // Standard extra data keys. 5275 5276 /** 5277 * The initial data to place in a newly created record. Use with 5278 * {@link #ACTION_INSERT}. The data here is a Map containing the same 5279 * fields as would be given to the underlying ContentProvider.insert() 5280 * call. 5281 */ 5282 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; 5283 5284 /** 5285 * A constant CharSequence that is associated with the Intent, used with 5286 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that 5287 * this may be a styled CharSequence, so you must use 5288 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to 5289 * retrieve it. 5290 */ 5291 public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; 5292 5293 /** 5294 * A constant String that is associated with the Intent, used with 5295 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} 5296 * as HTML formatted text. Note that you <em>must</em> also supply 5297 * {@link #EXTRA_TEXT}. 5298 */ 5299 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; 5300 5301 /** 5302 * A content: URI holding a stream of data associated with the Intent, 5303 * used with {@link #ACTION_SEND} to supply the data being sent. 5304 */ 5305 public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; 5306 5307 /** 5308 * A String[] holding e-mail addresses that should be delivered to. 5309 */ 5310 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; 5311 5312 /** 5313 * A String[] holding e-mail addresses that should be carbon copied. 5314 */ 5315 public static final String EXTRA_CC = "android.intent.extra.CC"; 5316 5317 /** 5318 * A String[] holding e-mail addresses that should be blind carbon copied. 5319 */ 5320 public static final String EXTRA_BCC = "android.intent.extra.BCC"; 5321 5322 /** 5323 * A constant string holding the desired subject line of a message. 5324 */ 5325 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; 5326 5327 /** 5328 * An Intent describing the choices you would like shown with 5329 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. 5330 */ 5331 public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; 5332 5333 /** 5334 * An int representing the user id to be used. 5335 * 5336 * @hide 5337 */ 5338 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; 5339 5340 /** 5341 * An int representing the task id to be retrieved. This is used when a launch from recents is 5342 * intercepted by another action such as credentials confirmation to remember which task should 5343 * be resumed when complete. 5344 * 5345 * @hide 5346 */ 5347 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; 5348 5349 /** 5350 * A String[] holding attribution tags when used with 5351 * {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5352 * 5353 * E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc. 5354 */ 5355 public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS"; 5356 5357 /** 5358 * A long representing the start timestamp (epoch time in millis) of the permission usage 5359 * when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5360 */ 5361 public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME"; 5362 5363 /** 5364 * A long representing the end timestamp (epoch time in millis) of the permission usage when 5365 * used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5366 */ 5367 public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME"; 5368 5369 /** 5370 * An Intent[] describing additional, alternate choices you would like shown with 5371 * {@link #ACTION_CHOOSER}. 5372 * 5373 * <p>An app may be capable of providing several different payload types to complete a 5374 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos 5375 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer 5376 * several different supported sending mechanisms for sharing, such as the actual "image/*" 5377 * photo data or a hosted link where the photos can be viewed.</p> 5378 * 5379 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the 5380 * first/primary/preferred intent in the set. Additional intents specified in 5381 * this extra are ordered; by default intents that appear earlier in the array will be 5382 * preferred over intents that appear later in the array as matches for the same 5383 * target component. To alter this preference, a calling app may also supply 5384 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> 5385 */ 5386 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; 5387 5388 /** 5389 * A {@link ComponentName ComponentName[]} describing components that should be filtered out 5390 * and omitted from a list of components presented to the user. 5391 * 5392 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components 5393 * in this array if it otherwise would have shown them. Useful for omitting specific targets 5394 * from your own package or other apps from your organization if the idea of sending to those 5395 * targets would be redundant with other app functionality. Filtered components will not 5396 * be able to present targets from an associated <code>ChooserTargetService</code>.</p> 5397 */ 5398 public static final String EXTRA_EXCLUDE_COMPONENTS 5399 = "android.intent.extra.EXCLUDE_COMPONENTS"; 5400 5401 /** 5402 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} 5403 * describing additional high-priority deep-link targets for the chooser to present to the user. 5404 * 5405 * <p>Targets provided in this way will be presented inline with all other targets provided 5406 * by services from other apps. They will be prioritized before other service targets, but 5407 * after those targets provided by sources that the user has manually pinned to the front.</p> 5408 * 5409 * @see #ACTION_CHOOSER 5410 */ 5411 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; 5412 5413 /** 5414 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection 5415 * from the chooser activity presented by {@link #ACTION_CHOOSER}. 5416 * 5417 * <p>An app preparing an action for another app to complete may wish to allow the user to 5418 * disambiguate between several options for completing the action based on the chosen target 5419 * or otherwise refine the action before it is invoked. 5420 * </p> 5421 * 5422 * <p>When sent, this IntentSender may be filled in with the following extras:</p> 5423 * <ul> 5424 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> 5425 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's 5426 * chosen target beyond the first</li> 5427 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity 5428 * should fill in and send once the disambiguation is complete</li> 5429 * </ul> 5430 */ 5431 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER 5432 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; 5433 5434 /** 5435 * An {@code ArrayList} of {@code String} annotations describing content for 5436 * {@link #ACTION_CHOOSER}. 5437 * 5438 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a 5439 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> 5440 * 5441 * <p>Annotations should describe the major components or topics of the content. It is up to 5442 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be 5443 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to 5444 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon 5445 * character. Performance on customized annotations can suffer, if they are rarely used for 5446 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the 5447 * following annotations when applicable.</p> 5448 * <ul> 5449 * <li>"product" represents that the topic of the content is mainly about products, e.g., 5450 * health & beauty, and office supplies.</li> 5451 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g., 5452 * happy, and sad.</li> 5453 * <li>"person" represents that the topic of the content is mainly about persons, e.g., 5454 * face, finger, standing, and walking.</li> 5455 * <li>"child" represents that the topic of the content is mainly about children, e.g., 5456 * child, and baby.</li> 5457 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li> 5458 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li> 5459 * <li>"party" represents that the topic of the content is mainly about parties.</li> 5460 * <li>"animal" represent that the topic of the content is mainly about animals.</li> 5461 * <li>"plant" represents that the topic of the content is mainly about plants, e.g., 5462 * flowers.</li> 5463 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li> 5464 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g. 5465 * sunglasses, jewelry, handbags and clothing.</li> 5466 * <li>"material" represents that the topic of the content is mainly about materials, e.g., 5467 * paper, and silk.</li> 5468 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like 5469 * cars, and boats.</li> 5470 * <li>"document" represents that the topic of the content is mainly about documents, e.g. 5471 * posters.</li> 5472 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts 5473 * and designs of houses.</li> 5474 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g., 5475 * Christmas and Thanksgiving.</li> 5476 * </ul> 5477 */ 5478 public static final String EXTRA_CONTENT_ANNOTATIONS 5479 = "android.intent.extra.CONTENT_ANNOTATIONS"; 5480 5481 /** 5482 * A {@link ResultReceiver} used to return data back to the sender. 5483 * 5484 * <p>Used to complete an app-specific 5485 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> 5486 * 5487 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent 5488 * used to start a {@link #ACTION_CHOOSER} activity this extra will be 5489 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent 5490 * when the user selects a target component from the chooser. It is up to the recipient 5491 * to send a result to this ResultReceiver to signal that disambiguation is complete 5492 * and that the chooser should invoke the user's choice.</p> 5493 * 5494 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent 5495 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser 5496 * to match and fill in the final Intent or ChooserTarget before starting it. 5497 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from 5498 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to 5499 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> 5500 * 5501 * <p>The result code passed to the ResultReceiver should be 5502 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's 5503 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if 5504 * the chooser should finish without starting a target.</p> 5505 */ 5506 public static final String EXTRA_RESULT_RECEIVER 5507 = "android.intent.extra.RESULT_RECEIVER"; 5508 5509 /** 5510 * A CharSequence dialog title to provide to the user when used with a 5511 * {@link #ACTION_CHOOSER}. 5512 */ 5513 public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; 5514 5515 /** 5516 * A Parcelable[] of {@link Intent} or 5517 * {@link android.content.pm.LabeledIntent} objects as set with 5518 * {@link #putExtra(String, Parcelable[])} of additional activities to place 5519 * a the front of the list of choices, when shown to the user with a 5520 * {@link #ACTION_CHOOSER}. 5521 */ 5522 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; 5523 5524 /** 5525 * A {@link IntentSender} to start after instant app installation success. 5526 * @hide 5527 */ 5528 @SystemApi 5529 public static final String EXTRA_INSTANT_APP_SUCCESS = 5530 "android.intent.extra.INSTANT_APP_SUCCESS"; 5531 5532 /** 5533 * A {@link IntentSender} to start after instant app installation failure. 5534 * @hide 5535 */ 5536 @SystemApi 5537 public static final String EXTRA_INSTANT_APP_FAILURE = 5538 "android.intent.extra.INSTANT_APP_FAILURE"; 5539 5540 /** 5541 * The host name that triggered an instant app resolution. 5542 * @hide 5543 */ 5544 @SystemApi 5545 public static final String EXTRA_INSTANT_APP_HOSTNAME = 5546 "android.intent.extra.INSTANT_APP_HOSTNAME"; 5547 5548 /** 5549 * An opaque token to track instant app resolution. 5550 * @hide 5551 */ 5552 @SystemApi 5553 public static final String EXTRA_INSTANT_APP_TOKEN = 5554 "android.intent.extra.INSTANT_APP_TOKEN"; 5555 5556 /** 5557 * The action that triggered an instant application resolution. 5558 * @hide 5559 */ 5560 @SystemApi 5561 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION"; 5562 5563 /** 5564 * An array of {@link Bundle}s containing details about resolved instant apps.. 5565 * @hide 5566 */ 5567 @SystemApi 5568 public static final String EXTRA_INSTANT_APP_BUNDLES = 5569 "android.intent.extra.INSTANT_APP_BUNDLES"; 5570 5571 /** 5572 * A {@link Bundle} of metadata that describes the instant application that needs to be 5573 * installed. This data is populated from the response to 5574 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered 5575 * instant application resolver. 5576 * @hide 5577 */ 5578 @SystemApi 5579 public static final String EXTRA_INSTANT_APP_EXTRAS = 5580 "android.intent.extra.INSTANT_APP_EXTRAS"; 5581 5582 /** 5583 * A boolean value indicating that the instant app resolver was unable to state with certainty 5584 * that it did or did not have an app for the sanitized {@link Intent} defined at 5585 * {@link #EXTRA_INTENT}. 5586 * @hide 5587 */ 5588 @SystemApi 5589 public static final String EXTRA_UNKNOWN_INSTANT_APP = 5590 "android.intent.extra.UNKNOWN_INSTANT_APP"; 5591 5592 /** 5593 * The version code of the app to install components from. 5594 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE). 5595 * @hide 5596 */ 5597 @Deprecated 5598 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; 5599 5600 /** 5601 * The version code of the app to install components from. 5602 * @hide 5603 */ 5604 @SystemApi 5605 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE"; 5606 5607 /** 5608 * The app that triggered the instant app installation. 5609 * @hide 5610 */ 5611 @SystemApi 5612 public static final String EXTRA_CALLING_PACKAGE 5613 = "android.intent.extra.CALLING_PACKAGE"; 5614 5615 /** 5616 * Optional calling app provided bundle containing additional launch information the 5617 * installer may use. 5618 * @hide 5619 */ 5620 @SystemApi 5621 public static final String EXTRA_VERIFICATION_BUNDLE 5622 = "android.intent.extra.VERIFICATION_BUNDLE"; 5623 5624 /** 5625 * A Bundle forming a mapping of potential target package names to different extras Bundles 5626 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with 5627 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not 5628 * be currently installed on the device. 5629 * 5630 * <p>An application may choose to provide alternate extras for the case where a user 5631 * selects an activity from a predetermined set of target packages. If the activity 5632 * the user selects from the chooser belongs to a package with its package name as 5633 * a key in this bundle, the corresponding extras for that package will be merged with 5634 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement 5635 * extra has the same key as an extra already present in the intent it will overwrite 5636 * the extra from the intent.</p> 5637 * 5638 * <p><em>Examples:</em> 5639 * <ul> 5640 * <li>An application may offer different {@link #EXTRA_TEXT} to an application 5641 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query 5642 * parameters for that target.</li> 5643 * <li>An application may offer additional metadata for known targets of a given intent 5644 * to pass along information only relevant to that target such as account or content 5645 * identifiers already known to that application.</li> 5646 * </ul></p> 5647 */ 5648 public static final String EXTRA_REPLACEMENT_EXTRAS = 5649 "android.intent.extra.REPLACEMENT_EXTRAS"; 5650 5651 /** 5652 * An {@link IntentSender} that will be notified if a user successfully chooses a target 5653 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender 5654 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the 5655 * {@link ComponentName} of the chosen component. 5656 * 5657 * <p>In some situations this callback may never come, for example if the user abandons 5658 * the chooser, switches to another task or any number of other reasons. Apps should not 5659 * be written assuming that this callback will always occur.</p> 5660 */ 5661 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = 5662 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; 5663 5664 /** 5665 * The {@link ComponentName} chosen by the user to complete an action. 5666 * 5667 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER 5668 */ 5669 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; 5670 5671 /** 5672 * A {@link android.view.KeyEvent} object containing the event that 5673 * triggered the creation of the Intent it is in. 5674 */ 5675 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; 5676 5677 /** 5678 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user 5679 * before shutting down. 5680 * 5681 * {@hide} 5682 */ 5683 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; 5684 5685 /** 5686 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is 5687 * requested by the user. 5688 * 5689 * {@hide} 5690 */ 5691 public static final String EXTRA_USER_REQUESTED_SHUTDOWN = 5692 "android.intent.extra.USER_REQUESTED_SHUTDOWN"; 5693 5694 /** 5695 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 5696 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action 5697 * of restarting the application. 5698 */ 5699 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; 5700 5701 /** 5702 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 5703 * intents to signal that the application was removed with the user-initiated action. 5704 */ 5705 public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED"; 5706 5707 /** 5708 * A String holding the phone number originally entered in 5709 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual 5710 * number to call in a {@link android.content.Intent#ACTION_CALL}. 5711 */ 5712 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; 5713 5714 /** 5715 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} 5716 * intents to supply the uid the package had been assigned. Also an optional 5717 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 5718 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same 5719 * purpose. 5720 */ 5721 public static final String EXTRA_UID = "android.intent.extra.UID"; 5722 5723 /** 5724 * @hide String array of package names. 5725 */ 5726 @SystemApi 5727 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; 5728 5729 /** 5730 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 5731 * intents to indicate whether this represents a full uninstall (removing 5732 * both the code and its data) or a partial uninstall (leaving its data, 5733 * implying that this is an update). 5734 */ 5735 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; 5736 5737 /** 5738 * @hide 5739 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 5740 * intents to indicate that at this point the package has been removed for 5741 * all users on the device. 5742 */ 5743 public static final String EXTRA_REMOVED_FOR_ALL_USERS 5744 = "android.intent.extra.REMOVED_FOR_ALL_USERS"; 5745 5746 /** 5747 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 5748 * intents to indicate that this is a replacement of the package, so this 5749 * broadcast will immediately be followed by an add broadcast for a 5750 * different version of the same package. 5751 */ 5752 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING"; 5753 5754 /** 5755 * Used as an int extra field in {@link android.app.AlarmManager} pending intents 5756 * to tell the application being invoked how many pending alarms are being 5757 * delivered with the intent. For one-shot alarms this will always be 1. 5758 * For recurring alarms, this might be greater than 1 if the device was 5759 * asleep or powered off at the time an earlier alarm would have been 5760 * delivered. 5761 * 5762 * <p>Note: You must supply a <b>mutable</b> {@link android.app.PendingIntent} to 5763 * {@code AlarmManager} while setting your alarms to be able to read this value on receiving 5764 * them. <em>Mutability of pending intents must be explicitly specified by apps targeting 5765 * {@link Build.VERSION_CODES#S} or higher</em>. 5766 * 5767 * @see android.app.PendingIntent#FLAG_MUTABLE 5768 * 5769 */ 5770 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; 5771 5772 /** 5773 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} 5774 * intents to request the dock state. Possible values are 5775 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, 5776 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or 5777 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or 5778 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or 5779 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. 5780 */ 5781 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; 5782 5783 /** 5784 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5785 * to represent that the phone is not in any dock. 5786 */ 5787 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; 5788 5789 /** 5790 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5791 * to represent that the phone is in a desk dock. 5792 */ 5793 public static final int EXTRA_DOCK_STATE_DESK = 1; 5794 5795 /** 5796 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5797 * to represent that the phone is in a car dock. 5798 */ 5799 public static final int EXTRA_DOCK_STATE_CAR = 2; 5800 5801 /** 5802 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5803 * to represent that the phone is in a analog (low end) dock. 5804 */ 5805 public static final int EXTRA_DOCK_STATE_LE_DESK = 3; 5806 5807 /** 5808 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5809 * to represent that the phone is in a digital (high end) dock. 5810 */ 5811 public static final int EXTRA_DOCK_STATE_HE_DESK = 4; 5812 5813 /** 5814 * Boolean that can be supplied as meta-data with a dock activity, to 5815 * indicate that the dock should take over the home key when it is active. 5816 */ 5817 public static final String METADATA_DOCK_HOME = "android.dock_home"; 5818 5819 /** 5820 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing 5821 * the bug report. 5822 */ 5823 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; 5824 5825 /** 5826 * Used in the extra field in the remote intent. It's a string token passed with the 5827 * remote intent. 5828 */ 5829 public static final String EXTRA_REMOTE_INTENT_TOKEN = 5830 "android.intent.extra.remote_intent_token"; 5831 5832 /** 5833 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field 5834 * will contain only the first name in the list. 5835 */ 5836 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = 5837 "android.intent.extra.changed_component_name"; 5838 5839 /** 5840 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, 5841 * and contains a string array of all of the components that have changed. If 5842 * the state of the overall package has changed, then it will contain an entry 5843 * with the package name itself. 5844 */ 5845 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = 5846 "android.intent.extra.changed_component_name_list"; 5847 5848 /** 5849 * This field is part of 5850 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 5851 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, 5852 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, 5853 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} 5854 * and contains a string array of all of the components that have changed. 5855 */ 5856 public static final String EXTRA_CHANGED_PACKAGE_LIST = 5857 "android.intent.extra.changed_package_list"; 5858 5859 /** 5860 * This field is part of 5861 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 5862 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 5863 * and contains an integer array of uids of all of the components 5864 * that have changed. 5865 */ 5866 public static final String EXTRA_CHANGED_UID_LIST = 5867 "android.intent.extra.changed_uid_list"; 5868 5869 /** 5870 * An integer denoting a bitwise combination of restrictions set on distracting packages via 5871 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)} 5872 * 5873 * @hide 5874 * @see PackageManager.DistractionRestriction 5875 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 5876 */ 5877 public static final String EXTRA_DISTRACTION_RESTRICTIONS = 5878 "android.intent.extra.distraction_restrictions"; 5879 5880 /** 5881 * @hide 5882 * Magic extra system code can use when binding, to give a label for 5883 * who it is that has bound to a service. This is an integer giving 5884 * a framework string resource that can be displayed to the user. 5885 */ 5886 public static final String EXTRA_CLIENT_LABEL = 5887 "android.intent.extra.client_label"; 5888 5889 /** 5890 * @hide 5891 * Magic extra system code can use when binding, to give a PendingIntent object 5892 * that can be launched for the user to disable the system's use of this 5893 * service. 5894 */ 5895 public static final String EXTRA_CLIENT_INTENT = 5896 "android.intent.extra.client_intent"; 5897 5898 /** 5899 * Extra used to indicate that an intent should only return data that is on 5900 * the local device. This is a boolean extra; the default is false. If true, 5901 * an implementation should only allow the user to select data that is 5902 * already on the device, not requiring it be downloaded from a remote 5903 * service when opened. 5904 * 5905 * @see #ACTION_GET_CONTENT 5906 * @see #ACTION_OPEN_DOCUMENT 5907 * @see #ACTION_OPEN_DOCUMENT_TREE 5908 * @see #ACTION_CREATE_DOCUMENT 5909 */ 5910 public static final String EXTRA_LOCAL_ONLY = 5911 "android.intent.extra.LOCAL_ONLY"; 5912 5913 /** 5914 * Extra used to indicate that an intent can allow the user to select and 5915 * return multiple items. This is a boolean extra; the default is false. If 5916 * true, an implementation is allowed to present the user with a UI where 5917 * they can pick multiple items that are all returned to the caller. When 5918 * this happens, they should be returned as the {@link #getClipData()} part 5919 * of the result Intent. 5920 * 5921 * @see #ACTION_GET_CONTENT 5922 * @see #ACTION_OPEN_DOCUMENT 5923 */ 5924 public static final String EXTRA_ALLOW_MULTIPLE = 5925 "android.intent.extra.ALLOW_MULTIPLE"; 5926 5927 /** 5928 * The integer userHandle (i.e. userId) carried with broadcast intents related to addition, 5929 * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED}, 5930 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. 5931 * 5932 * @hide 5933 */ 5934 public static final String EXTRA_USER_HANDLE = 5935 "android.intent.extra.user_handle"; 5936 5937 /** 5938 * The UserHandle carried with intents. 5939 */ 5940 public static final String EXTRA_USER = 5941 "android.intent.extra.USER"; 5942 5943 /** 5944 * Extra used in the response from a BroadcastReceiver that handles 5945 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is 5946 * <code>ArrayList<RestrictionEntry></code>. 5947 */ 5948 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; 5949 5950 /** 5951 * Extra sent in the intent to the BroadcastReceiver that handles 5952 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing 5953 * the restrictions as key/value pairs. 5954 */ 5955 public static final String EXTRA_RESTRICTIONS_BUNDLE = 5956 "android.intent.extra.restrictions_bundle"; 5957 5958 /** 5959 * Extra used in the response from a BroadcastReceiver that handles 5960 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. 5961 */ 5962 public static final String EXTRA_RESTRICTIONS_INTENT = 5963 "android.intent.extra.restrictions_intent"; 5964 5965 /** 5966 * Extra used to communicate a set of acceptable MIME types. The type of the 5967 * extra is {@code String[]}. Values may be a combination of concrete MIME 5968 * types (such as "image/png") and/or partial MIME types (such as 5969 * "audio/*"). 5970 * 5971 * @see #ACTION_GET_CONTENT 5972 * @see #ACTION_OPEN_DOCUMENT 5973 */ 5974 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; 5975 5976 /** 5977 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that 5978 * this shutdown is only for the user space of the system, not a complete shutdown. 5979 * When this is true, hardware devices can use this information to determine that 5980 * they shouldn't do a complete shutdown of their device since this is not a 5981 * complete shutdown down to the kernel, but only user space restarting. 5982 * The default if not supplied is false. 5983 */ 5984 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY 5985 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; 5986 5987 /** 5988 * Optional extra specifying a time in milliseconds since the Epoch. The value must be 5989 * non-negative. 5990 * <p> 5991 * Type: long 5992 * </p> 5993 */ 5994 public static final String EXTRA_TIME = "android.intent.extra.TIME"; 5995 5996 /** 5997 * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device. 5998 * 5999 * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones. 6000 */ 6001 @SuppressLint("ActionValue") 6002 public static final String EXTRA_TIMEZONE = "time-zone"; 6003 6004 /** 6005 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the 6006 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, 6007 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and 6008 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative. 6009 * 6010 * @hide for internal use only. 6011 */ 6012 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = 6013 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; 6014 /** @hide */ 6015 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; 6016 /** @hide */ 6017 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; 6018 /** @hide */ 6019 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; 6020 6021 /** 6022 * Intent extra: the reason that the operation associated with this intent is being performed. 6023 * 6024 * <p>Type: String 6025 * @hide 6026 */ 6027 @SystemApi 6028 public static final String EXTRA_REASON = "android.intent.extra.REASON"; 6029 6030 /** 6031 * {@hide} 6032 * This extra will be send together with {@link #ACTION_FACTORY_RESET} 6033 */ 6034 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; 6035 6036 /** 6037 * {@hide} 6038 * This extra will be set to true when the user choose to wipe the data on eSIM during factory 6039 * reset for the device with eSIM. This extra will be sent together with 6040 * {@link #ACTION_FACTORY_RESET} 6041 */ 6042 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; 6043 6044 /** 6045 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM 6046 * activation request. 6047 * TODO: Add information about the structure and response data used with the pending intent. 6048 * @hide 6049 */ 6050 public static final String EXTRA_SIM_ACTIVATION_RESPONSE = 6051 "android.intent.extra.SIM_ACTIVATION_RESPONSE"; 6052 6053 /** 6054 * Optional index with semantics depending on the intent action. 6055 * 6056 * <p>The value must be an integer greater or equal to 0. 6057 * @see #ACTION_QUICK_VIEW 6058 */ 6059 public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; 6060 6061 /** 6062 * Tells the quick viewer to show additional UI actions suitable for the passed Uris, 6063 * such as opening in other apps, sharing, opening, editing, printing, deleting, 6064 * casting, etc. 6065 * 6066 * <p>The value is boolean. By default false. 6067 * @see #ACTION_QUICK_VIEW 6068 * @removed 6069 */ 6070 @Deprecated 6071 public static final String EXTRA_QUICK_VIEW_ADVANCED = 6072 "android.intent.extra.QUICK_VIEW_ADVANCED"; 6073 6074 /** 6075 * An optional extra of {@code String[]} indicating which quick view features should be made 6076 * available to the user in the quick view UI while handing a 6077 * {@link Intent#ACTION_QUICK_VIEW} intent. 6078 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer. 6079 * Quick viewer can implement features not listed below. 6080 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW}, 6081 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE}, 6082 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND}, 6083 * {@link QuickViewConstants#FEATURE_PRINT}. 6084 * <p> 6085 * Requirements: 6086 * <li>Quick viewer shouldn't show a feature if the feature is absent in 6087 * {@link #EXTRA_QUICK_VIEW_FEATURES}. 6088 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow 6089 * internal policies. 6090 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a 6091 * requirement that the feature be shown. Quick viewer may, according to its own policies, 6092 * disable or hide features. 6093 * 6094 * @see #ACTION_QUICK_VIEW 6095 */ 6096 public static final String EXTRA_QUICK_VIEW_FEATURES = 6097 "android.intent.extra.QUICK_VIEW_FEATURES"; 6098 6099 /** 6100 * Optional boolean extra indicating whether quiet mode has been switched on or off. 6101 * When a profile goes into quiet mode, all apps in the profile are killed and the 6102 * profile user is stopped. Widgets originating from the profile are masked, and app 6103 * launcher icons are grayed out. 6104 */ 6105 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; 6106 6107 /** 6108 * Optional CharSequence extra to provide a search query. 6109 * The format of this query is dependent on the receiving application. 6110 * 6111 * <p>Applicable to {@link Intent} with actions: 6112 * <ul> 6113 * <li>{@link Intent#ACTION_GET_CONTENT}</li> 6114 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li> 6115 * </ul> 6116 */ 6117 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY"; 6118 6119 /** 6120 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} 6121 * intents to specify the resource type granted. Possible values are 6122 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or 6123 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. 6124 * 6125 * @hide 6126 */ 6127 public static final String EXTRA_MEDIA_RESOURCE_TYPE = 6128 "android.intent.extra.MEDIA_RESOURCE_TYPE"; 6129 6130 /** 6131 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify 6132 * whether to show the chooser or not when there is only one application available 6133 * to choose from. 6134 */ 6135 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = 6136 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; 6137 6138 /** 6139 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6140 * to represent that a video codec is allowed to use. 6141 * 6142 * @hide 6143 */ 6144 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; 6145 6146 /** 6147 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6148 * to represent that a audio codec is allowed to use. 6149 * 6150 * @hide 6151 */ 6152 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; 6153 6154 /** 6155 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}. 6156 * 6157 * <p> 6158 * Type: {@link LocusId} 6159 * </p> 6160 */ 6161 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID"; 6162 6163 /** 6164 * Used as an int array extra field in 6165 * {@link android.content.Intent#ACTION_PACKAGE_REMOVED_INTERNAL} 6166 * intents to indicate that visibility allow list of this removed package. 6167 * 6168 * @hide 6169 */ 6170 public static final String EXTRA_VISIBILITY_ALLOW_LIST = 6171 "android.intent.extra.VISIBILITY_ALLOW_LIST"; 6172 6173 // --------------------------------------------------------------------- 6174 // --------------------------------------------------------------------- 6175 // Intent flags (see mFlags variable). 6176 6177 /** @hide */ 6178 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6179 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, 6180 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) 6181 @Retention(RetentionPolicy.SOURCE) 6182 public @interface GrantUriMode {} 6183 6184 /** @hide */ 6185 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6186 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) 6187 @Retention(RetentionPolicy.SOURCE) 6188 public @interface AccessUriMode {} 6189 6190 /** 6191 * Test if given mode flags specify an access mode, which must be at least 6192 * read and/or write. 6193 * 6194 * @hide 6195 */ isAccessUriMode(int modeFlags)6196 public static boolean isAccessUriMode(int modeFlags) { 6197 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION 6198 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; 6199 } 6200 6201 /** @hide */ 6202 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 6203 FLAG_GRANT_READ_URI_PERMISSION, 6204 FLAG_GRANT_WRITE_URI_PERMISSION, 6205 FLAG_FROM_BACKGROUND, 6206 FLAG_DEBUG_LOG_RESOLUTION, 6207 FLAG_EXCLUDE_STOPPED_PACKAGES, 6208 FLAG_INCLUDE_STOPPED_PACKAGES, 6209 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, 6210 FLAG_GRANT_PREFIX_URI_PERMISSION, 6211 FLAG_DEBUG_TRIAGED_MISSING, 6212 FLAG_IGNORE_EPHEMERAL, 6213 FLAG_ACTIVITY_MATCH_EXTERNAL, 6214 FLAG_ACTIVITY_NO_HISTORY, 6215 FLAG_ACTIVITY_SINGLE_TOP, 6216 FLAG_ACTIVITY_NEW_TASK, 6217 FLAG_ACTIVITY_MULTIPLE_TASK, 6218 FLAG_ACTIVITY_CLEAR_TOP, 6219 FLAG_ACTIVITY_FORWARD_RESULT, 6220 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 6221 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 6222 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 6223 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 6224 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 6225 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6226 FLAG_ACTIVITY_NEW_DOCUMENT, 6227 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6228 FLAG_ACTIVITY_NO_USER_ACTION, 6229 FLAG_ACTIVITY_REORDER_TO_FRONT, 6230 FLAG_ACTIVITY_NO_ANIMATION, 6231 FLAG_ACTIVITY_CLEAR_TASK, 6232 FLAG_ACTIVITY_TASK_ON_HOME, 6233 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 6234 FLAG_ACTIVITY_LAUNCH_ADJACENT, 6235 FLAG_ACTIVITY_REQUIRE_NON_BROWSER, 6236 FLAG_ACTIVITY_REQUIRE_DEFAULT, 6237 FLAG_RECEIVER_REGISTERED_ONLY, 6238 FLAG_RECEIVER_REPLACE_PENDING, 6239 FLAG_RECEIVER_FOREGROUND, 6240 FLAG_RECEIVER_NO_ABORT, 6241 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 6242 FLAG_RECEIVER_BOOT_UPGRADE, 6243 FLAG_RECEIVER_INCLUDE_BACKGROUND, 6244 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 6245 FLAG_RECEIVER_FROM_SHELL, 6246 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 6247 FLAG_RECEIVER_OFFLOAD, 6248 }) 6249 @Retention(RetentionPolicy.SOURCE) 6250 public @interface Flags {} 6251 6252 /** @hide */ 6253 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 6254 FLAG_FROM_BACKGROUND, 6255 FLAG_DEBUG_LOG_RESOLUTION, 6256 FLAG_EXCLUDE_STOPPED_PACKAGES, 6257 FLAG_INCLUDE_STOPPED_PACKAGES, 6258 FLAG_DEBUG_TRIAGED_MISSING, 6259 FLAG_IGNORE_EPHEMERAL, 6260 FLAG_ACTIVITY_MATCH_EXTERNAL, 6261 FLAG_ACTIVITY_NO_HISTORY, 6262 FLAG_ACTIVITY_SINGLE_TOP, 6263 FLAG_ACTIVITY_NEW_TASK, 6264 FLAG_ACTIVITY_MULTIPLE_TASK, 6265 FLAG_ACTIVITY_CLEAR_TOP, 6266 FLAG_ACTIVITY_FORWARD_RESULT, 6267 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 6268 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 6269 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 6270 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 6271 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 6272 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6273 FLAG_ACTIVITY_NEW_DOCUMENT, 6274 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6275 FLAG_ACTIVITY_NO_USER_ACTION, 6276 FLAG_ACTIVITY_REORDER_TO_FRONT, 6277 FLAG_ACTIVITY_NO_ANIMATION, 6278 FLAG_ACTIVITY_CLEAR_TASK, 6279 FLAG_ACTIVITY_TASK_ON_HOME, 6280 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 6281 FLAG_ACTIVITY_LAUNCH_ADJACENT, 6282 FLAG_RECEIVER_REGISTERED_ONLY, 6283 FLAG_RECEIVER_REPLACE_PENDING, 6284 FLAG_RECEIVER_FOREGROUND, 6285 FLAG_RECEIVER_NO_ABORT, 6286 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 6287 FLAG_RECEIVER_BOOT_UPGRADE, 6288 FLAG_RECEIVER_INCLUDE_BACKGROUND, 6289 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 6290 FLAG_RECEIVER_FROM_SHELL, 6291 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 6292 FLAG_RECEIVER_OFFLOAD, 6293 }) 6294 @Retention(RetentionPolicy.SOURCE) 6295 public @interface MutableFlags {} 6296 6297 /** 6298 * If set, the recipient of this Intent will be granted permission to 6299 * perform read operations on the URI in the Intent's data and any URIs 6300 * specified in its ClipData. When applying to an Intent's ClipData, 6301 * all URIs as well as recursive traversals through data or other ClipData 6302 * in Intent items will be granted; only the grant flags of the top-level 6303 * Intent are used. 6304 */ 6305 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; 6306 /** 6307 * If set, the recipient of this Intent will be granted permission to 6308 * perform write operations on the URI in the Intent's data and any URIs 6309 * specified in its ClipData. When applying to an Intent's ClipData, 6310 * all URIs as well as recursive traversals through data or other ClipData 6311 * in Intent items will be granted; only the grant flags of the top-level 6312 * Intent are used. 6313 */ 6314 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; 6315 /** 6316 * Can be set by the caller to indicate that this Intent is coming from 6317 * a background operation, not from direct user interaction. 6318 */ 6319 public static final int FLAG_FROM_BACKGROUND = 0x00000004; 6320 /** 6321 * A flag you can enable for debugging: when set, log messages will be 6322 * printed during the resolution of this intent to show you what has 6323 * been found to create the final resolved list. 6324 */ 6325 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; 6326 /** 6327 * If set, this intent will not match any components in packages that 6328 * are currently stopped. If this is not set, then the default behavior 6329 * is to include such applications in the result. 6330 */ 6331 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; 6332 /** 6333 * If set, this intent will always match any components in packages that 6334 * are currently stopped. This is the default behavior when 6335 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these 6336 * flags are set, this one wins (it allows overriding of exclude for 6337 * places where the framework may automatically set the exclude flag). 6338 */ 6339 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; 6340 6341 /** 6342 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 6343 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be 6344 * persisted across device reboots until explicitly revoked with 6345 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the 6346 * grant for possible persisting; the receiving application must call 6347 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to 6348 * actually persist. 6349 * 6350 * @see ContentResolver#takePersistableUriPermission(Uri, int) 6351 * @see ContentResolver#releasePersistableUriPermission(Uri, int) 6352 * @see ContentResolver#getPersistedUriPermissions() 6353 * @see ContentResolver#getOutgoingPersistedUriPermissions() 6354 */ 6355 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; 6356 6357 /** 6358 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 6359 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant 6360 * applies to any URI that is a prefix match against the original granted 6361 * URI. (Without this flag, the URI must match exactly for access to be 6362 * granted.) Another URI is considered a prefix match only when scheme, 6363 * authority, and all path segments defined by the prefix are an exact 6364 * match. 6365 */ 6366 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; 6367 6368 /** 6369 * Flag used to automatically match intents based on their Direct Boot 6370 * awareness and the current user state. 6371 * <p> 6372 * Since the default behavior is to automatically apply the current user 6373 * state, this is effectively a sentinel value that doesn't change the 6374 * output of any queries based on its presence or absence. 6375 * <p> 6376 * Instead, this value can be useful in conjunction with 6377 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()} 6378 * to detect when a caller is relying on implicit automatic matching, 6379 * instead of confirming the explicit behavior they want. 6380 */ 6381 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100; 6382 6383 /** {@hide} */ 6384 @Deprecated 6385 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO; 6386 6387 /** 6388 * Internal flag used to indicate ephemeral applications should not be 6389 * considered when resolving the intent. 6390 * 6391 * @hide 6392 */ 6393 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200; 6394 6395 /** 6396 * If set, the new activity is not kept in the history stack. As soon as 6397 * the user navigates away from it, the activity is finished. This may also 6398 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory 6399 * noHistory} attribute. 6400 * 6401 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} 6402 * is never invoked when the current activity starts a new activity which 6403 * sets a result and finishes. 6404 */ 6405 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; 6406 /** 6407 * If set, the activity will not be launched if it is already running 6408 * at the top of the history stack. See 6409 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes"> 6410 * Tasks and Back Stack</a> for more information. 6411 */ 6412 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; 6413 /** 6414 * If set, this activity will become the start of a new task on this 6415 * history stack. A task (from the activity that started it to the 6416 * next task activity) defines an atomic group of activities that the 6417 * user can move to. Tasks can be moved to the foreground and background; 6418 * all of the activities inside of a particular task always remain in 6419 * the same order. See 6420 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6421 * Stack</a> for more information about tasks. 6422 * 6423 * <p>This flag is generally used by activities that want 6424 * to present a "launcher" style behavior: they give the user a list of 6425 * separate things that can be done, which otherwise run completely 6426 * independently of the activity launching them. 6427 * 6428 * <p>When using this flag, if a task is already running for the activity 6429 * you are now starting, then a new activity will not be started; instead, 6430 * the current task will simply be brought to the front of the screen with 6431 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag 6432 * to disable this behavior. 6433 * 6434 * <p>This flag can not be used when the caller is requesting a result from 6435 * the activity being launched. 6436 */ 6437 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; 6438 /** 6439 * This flag is used to create a new task and launch an activity into it. 6440 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} 6441 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would 6442 * search through existing tasks for ones matching this Intent. Only if no such 6443 * task is found would a new task be created. When paired with 6444 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip 6445 * the search for a matching task and unconditionally start a new task. 6446 * 6447 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this 6448 * flag unless you are implementing your own 6449 * top-level application launcher.</strong> Used in conjunction with 6450 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the 6451 * behavior of bringing an existing task to the foreground. When set, 6452 * a new task is <em>always</em> started to host the Activity for the 6453 * Intent, regardless of whether there is already an existing task running 6454 * the same thing. 6455 * 6456 * <p><strong>Because the default system does not include graphical task management, 6457 * you should not use this flag unless you provide some way for a user to 6458 * return back to the tasks you have launched.</strong> 6459 * 6460 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for 6461 * creating new document tasks. 6462 * 6463 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or 6464 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. 6465 * 6466 * <p>See 6467 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6468 * Stack</a> for more information about tasks. 6469 * 6470 * @see #FLAG_ACTIVITY_NEW_DOCUMENT 6471 * @see #FLAG_ACTIVITY_NEW_TASK 6472 */ 6473 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; 6474 /** 6475 * If set, and the activity being launched is already running in the 6476 * current task, then instead of launching a new instance of that activity, 6477 * all of the other activities on top of it will be closed and this Intent 6478 * will be delivered to the (now on top) old activity as a new Intent. 6479 * 6480 * <p>For example, consider a task consisting of the activities: A, B, C, D. 6481 * If D calls startActivity() with an Intent that resolves to the component 6482 * of activity B, then C and D will be finished and B receive the given 6483 * Intent, resulting in the stack now being: A, B. 6484 * 6485 * <p>The currently running instance of activity B in the above example will 6486 * either receive the new intent you are starting here in its 6487 * onNewIntent() method, or be itself finished and restarted with the 6488 * new intent. If it has declared its launch mode to be "multiple" (the 6489 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in 6490 * the same intent, then it will be finished and re-created; for all other 6491 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this 6492 * Intent will be delivered to the current instance's onNewIntent(). 6493 * 6494 * <p>This launch mode can also be used to good effect in conjunction with 6495 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity 6496 * of a task, it will bring any currently running instance of that task 6497 * to the foreground, and then clear it to its root state. This is 6498 * especially useful, for example, when launching an activity from the 6499 * notification manager. 6500 * 6501 * <p>See 6502 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6503 * Stack</a> for more information about tasks. 6504 */ 6505 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; 6506 /** 6507 * If set and this intent is being used to launch a new activity from an 6508 * existing one, then the reply target of the existing activity will be 6509 * transferred to the new activity. This way, the new activity can call 6510 * {@link android.app.Activity#setResult} and have that result sent back to 6511 * the reply target of the original activity. 6512 */ 6513 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; 6514 /** 6515 * If set and this intent is being used to launch a new activity from an 6516 * existing one, the current activity will not be counted as the top 6517 * activity for deciding whether the new intent should be delivered to 6518 * the top instead of starting a new one. The previous activity will 6519 * be used as the top, with the assumption being that the current activity 6520 * will finish itself immediately. 6521 */ 6522 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; 6523 /** 6524 * If set, the new activity is not kept in the list of recently launched 6525 * activities. 6526 */ 6527 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; 6528 /** 6529 * This flag is not normally set by application code, but set for you by 6530 * the system as described in the 6531 * {@link android.R.styleable#AndroidManifestActivity_launchMode 6532 * launchMode} documentation for the singleTask mode. 6533 */ 6534 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; 6535 /** 6536 * If set, and this activity is either being started in a new task or 6537 * bringing to the top an existing task, then it will be launched as 6538 * the front door of the task. This will result in the application of 6539 * any affinities needed to have that task in the proper state (either 6540 * moving activities to or from it), or simply resetting that task to 6541 * its initial state if needed. 6542 * 6543 * @see android.R.attr#allowTaskReparenting 6544 * @see android.R.attr#clearTaskOnLaunch 6545 * @see android.R.attr#finishOnTaskLaunch 6546 */ 6547 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; 6548 /** 6549 * This flag is not normally set by application code, but set for you by 6550 * the system if this activity is being launched from history. 6551 */ 6552 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; 6553 /** 6554 * @deprecated As of API 21 this performs identically to 6555 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. 6556 */ 6557 @Deprecated 6558 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; 6559 /** 6560 * This flag is used to open a document into a new task rooted at the activity launched 6561 * by this Intent. Through the use of this flag, or its equivalent attribute, 6562 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity 6563 * containing different documents will appear in the recent tasks list. 6564 * 6565 * <p>The use of the activity attribute form of this, 6566 * {@link android.R.attr#documentLaunchMode}, is 6567 * preferred over the Intent flag described here. The attribute form allows the 6568 * Activity to specify multiple document behavior for all launchers of the Activity 6569 * whereas using this flag requires each Intent that launches the Activity to specify it. 6570 * 6571 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for 6572 * it is kept after the activity is finished is different than the use of 6573 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if 6574 * this flag is being used to create a new recents entry, then by default that entry 6575 * will be removed once the activity is finished. You can modify this behavior with 6576 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. 6577 * 6578 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link 6579 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the 6580 * equivalent of the Activity manifest specifying {@link 6581 * android.R.attr#documentLaunchMode}="intoExisting". When used with 6582 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying 6583 * {@link android.R.attr#documentLaunchMode}="always". The flag is ignored even in 6584 * conjunction with {@link #FLAG_ACTIVITY_MULTIPLE_TASK} when the Activity manifest specifies 6585 * {@link android.R.attr#documentLaunchMode}="never". 6586 * 6587 * Refer to {@link android.R.attr#documentLaunchMode} for more information. 6588 * 6589 * @see android.R.attr#documentLaunchMode 6590 * @see #FLAG_ACTIVITY_MULTIPLE_TASK 6591 */ 6592 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; 6593 /** 6594 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} 6595 * callback from occurring on the current frontmost activity before it is 6596 * paused as the newly-started activity is brought to the front. 6597 * 6598 * <p>Typically, an activity can rely on that callback to indicate that an 6599 * explicit user action has caused their activity to be moved out of the 6600 * foreground. The callback marks an appropriate point in the activity's 6601 * lifecycle for it to dismiss any notifications that it intends to display 6602 * "until the user has seen them," such as a blinking LED. 6603 * 6604 * <p>If an activity is ever started via any non-user-driven events such as 6605 * phone-call receipt or an alarm handler, this flag should be passed to {@link 6606 * Context#startActivity Context.startActivity}, ensuring that the pausing 6607 * activity does not think the user has acknowledged its notification. 6608 */ 6609 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; 6610 /** 6611 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6612 * this flag will cause the launched activity to be brought to the front of its 6613 * task's history stack if it is already running. 6614 * 6615 * <p>For example, consider a task consisting of four activities: A, B, C, D. 6616 * If D calls startActivity() with an Intent that resolves to the component 6617 * of activity B, then B will be brought to the front of the history stack, 6618 * with this resulting order: A, C, D, B. 6619 * 6620 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also 6621 * specified. 6622 */ 6623 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; 6624 /** 6625 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6626 * this flag will prevent the system from applying an activity transition 6627 * animation to go to the next activity state. This doesn't mean an 6628 * animation will never run -- if another activity change happens that doesn't 6629 * specify this flag before the activity started here is displayed, then 6630 * that transition will be used. This flag can be put to good use 6631 * when you are going to do a series of activity operations but the 6632 * animation seen by the user shouldn't be driven by the first activity 6633 * change but rather a later one. 6634 */ 6635 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; 6636 /** 6637 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6638 * this flag will cause any existing task that would be associated with the 6639 * activity to be cleared before the activity is started. That is, the activity 6640 * becomes the new root of an otherwise empty task, and any old activities 6641 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 6642 */ 6643 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; 6644 /** 6645 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6646 * this flag will cause a newly launching task to be placed on top of the current 6647 * home activity task (if there is one). That is, pressing back from the task 6648 * will always return the user to home even if that was not the last activity they 6649 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 6650 */ 6651 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; 6652 /** 6653 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will 6654 * have its entry in recent tasks removed when the user closes it (with back 6655 * or however else it may finish()). If you would like to instead allow the 6656 * document to be kept in recents so that it can be re-launched, you can use 6657 * this flag. When set and the task's activity is finished, the recents 6658 * entry will remain in the interface for the user to re-launch it, like a 6659 * recents entry for a top-level application. 6660 * <p> 6661 * The receiving activity can override this request with 6662 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling 6663 * {@link android.app.Activity#finishAndRemoveTask() 6664 * Activity.finishAndRemoveTask()}. 6665 */ 6666 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; 6667 6668 /** 6669 * This flag is only used for split-screen multi-window mode. The new activity will be displayed 6670 * adjacent to the one launching it. This can only be used in conjunction with 6671 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is 6672 * required if you want a new instance of an existing activity to be created. 6673 */ 6674 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; 6675 6676 6677 /** 6678 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6679 * this flag will attempt to launch an instant app if no full app on the device can already 6680 * handle the intent. 6681 * <p> 6682 * When attempting to resolve instant apps externally, the following {@link Intent} properties 6683 * are supported: 6684 * <ul> 6685 * <li>{@link Intent#setAction(String)}</li> 6686 * <li>{@link Intent#addCategory(String)}</li> 6687 * <li>{@link Intent#setData(Uri)}</li> 6688 * <li>{@link Intent#setType(String)}</li> 6689 * <li>{@link Intent#setPackage(String)}</li> 6690 * <li>{@link Intent#addFlags(int)}</li> 6691 * </ul> 6692 * <p> 6693 * In the case that no instant app can be found, the installer will be launched to notify the 6694 * user that the intent could not be resolved. On devices that do not support instant apps, 6695 * the flag will be ignored. 6696 */ 6697 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800; 6698 6699 /** 6700 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 6701 * flag will only launch the intent if it resolves to a result that is not a browser. If no such 6702 * result exists, an {@link ActivityNotFoundException} will be thrown. 6703 */ 6704 public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400; 6705 6706 /** 6707 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 6708 * flag will only launch the intent if it resolves to a single result. If no such result exists 6709 * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException} 6710 * will be thrown. 6711 */ 6712 public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200; 6713 6714 /** 6715 * If set, when sending a broadcast only registered receivers will be 6716 * called -- no BroadcastReceiver components will be launched. 6717 */ 6718 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 6719 /** 6720 * If set, when sending a broadcast the new broadcast will replace 6721 * any existing pending broadcast that matches it. Matching is defined 6722 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning 6723 * true for the intents of the two broadcasts. When a match is found, 6724 * the new broadcast (and receivers associated with it) will replace the 6725 * existing one in the pending broadcast list, remaining at the same 6726 * position in the list. 6727 * 6728 * <p>This flag is most typically used with sticky broadcasts, which 6729 * only care about delivering the most recent values of the broadcast 6730 * to their receivers. 6731 */ 6732 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; 6733 /** 6734 * If set, when sending a broadcast the recipient is allowed to run at 6735 * foreground priority, with a shorter timeout interval. During normal 6736 * broadcasts the receivers are not automatically hoisted out of the 6737 * background priority class. 6738 */ 6739 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; 6740 /** 6741 * If set, when sending a broadcast the recipient will be run on the offload queue. 6742 * 6743 * @hide 6744 */ 6745 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000; 6746 /** 6747 * If this is an ordered broadcast, don't allow receivers to abort the broadcast. 6748 * They can still propagate results through to later receivers, but they can not prevent 6749 * later receivers from seeing the broadcast. 6750 */ 6751 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; 6752 /** 6753 * If set, when sending a broadcast <i>before the system has fully booted up 6754 * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only 6755 * registered receivers will be called -- no BroadcastReceiver components 6756 * will be launched. Sticky intent state will be recorded properly even 6757 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} 6758 * is specified in the broadcast intent, this flag is unnecessary. 6759 * 6760 * <p>This flag is only for use by system services (even services from mainline modules) as a 6761 * convenience to avoid having to implement a more complex mechanism around detection 6762 * of boot completion. 6763 * 6764 * <p>This is useful to system server mainline modules 6765 * 6766 * @hide 6767 */ 6768 @SystemApi 6769 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; 6770 /** 6771 * Set when this broadcast is for a boot upgrade, a special mode that 6772 * allows the broadcast to be sent before the system is ready and launches 6773 * the app process with no providers running in it. 6774 * @hide 6775 */ 6776 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; 6777 /** 6778 * If set, the broadcast will always go to manifest receivers in background (cached 6779 * or not running) apps, regardless of whether that would be done by default. By 6780 * default they will only receive broadcasts if the broadcast has specified an 6781 * explicit component or package name. 6782 * 6783 * NOTE: dumpstate uses this flag numerically, so when its value is changed 6784 * the broadcast code there must also be changed to match. 6785 * 6786 * @hide 6787 */ 6788 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; 6789 /** 6790 * If set, the broadcast will never go to manifest receivers in background (cached 6791 * or not running) apps, regardless of whether that would be done by default. By 6792 * default they will receive broadcasts if the broadcast has specified an 6793 * explicit component or package name. 6794 * @hide 6795 */ 6796 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; 6797 /** 6798 * If set, this broadcast is being sent from the shell. 6799 * @hide 6800 */ 6801 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; 6802 6803 /** 6804 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps 6805 * will not receive broadcasts. 6806 * 6807 * <em>This flag has no effect when used by an Instant App.</em> 6808 */ 6809 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000; 6810 6811 /** 6812 * @hide Flags that can't be changed with PendingIntent. 6813 */ 6814 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION 6815 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 6816 | FLAG_GRANT_PREFIX_URI_PERMISSION; 6817 6818 /** 6819 * Local flag indicating this instance was created by copy constructor. 6820 */ 6821 private static final int LOCAL_FLAG_FROM_COPY = 1 << 0; 6822 6823 /** 6824 * Local flag indicating this instance was created from a {@link Parcel}. 6825 */ 6826 private static final int LOCAL_FLAG_FROM_PARCEL = 1 << 1; 6827 6828 /** 6829 * Local flag indicating this instance was delivered through a protected 6830 * component, such as an activity that requires a signature permission, or a 6831 * protected broadcast. Note that this flag <em>cannot</em> be recursively 6832 * applied to any contained instances, since a malicious app may have 6833 * controlled them via {@link #fillIn(Intent, int)}. 6834 */ 6835 private static final int LOCAL_FLAG_FROM_PROTECTED_COMPONENT = 1 << 2; 6836 6837 /** 6838 * Local flag indicating this instance had unfiltered extras copied into it. This could be 6839 * from either {@link #putExtras(Intent)} when an unparceled Intent is provided or {@link 6840 * #putExtras(Bundle)} when the provided Bundle has not been unparceled. 6841 */ 6842 private static final int LOCAL_FLAG_UNFILTERED_EXTRAS = 1 << 3; 6843 6844 /** 6845 * Local flag indicating this instance was created from a {@link Uri}. 6846 */ 6847 private static final int LOCAL_FLAG_FROM_URI = 1 << 4; 6848 6849 // --------------------------------------------------------------------- 6850 // --------------------------------------------------------------------- 6851 // toUri() and parseUri() options. 6852 6853 /** @hide */ 6854 @IntDef(flag = true, prefix = { "URI_" }, value = { 6855 URI_ALLOW_UNSAFE, 6856 URI_ANDROID_APP_SCHEME, 6857 URI_INTENT_SCHEME, 6858 }) 6859 @Retention(RetentionPolicy.SOURCE) 6860 public @interface UriFlags {} 6861 6862 /** 6863 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 6864 * always has the "intent:" scheme. This syntax can be used when you want 6865 * to later disambiguate between URIs that are intended to describe an 6866 * Intent vs. all others that should be treated as raw URIs. When used 6867 * with {@link #parseUri}, any other scheme will result in a generic 6868 * VIEW action for that raw URI. 6869 */ 6870 public static final int URI_INTENT_SCHEME = 1<<0; 6871 6872 /** 6873 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 6874 * always has the "android-app:" scheme. This is a variation of 6875 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an 6876 * http/https URI being delivered to a specific package name. The format 6877 * is: 6878 * 6879 * <pre class="prettyprint"> 6880 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> 6881 * 6882 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, 6883 * you must also include a scheme; including a path also requires both a host and a scheme. 6884 * The final #Intent; fragment can be used without a scheme, host, or path. 6885 * Note that this can not be 6886 * used with intents that have a {@link #setSelector}, since the base intent 6887 * will always have an explicit package name.</p> 6888 * 6889 * <p>Some examples of how this scheme maps to Intent objects:</p> 6890 * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> 6891 * <colgroup align="left" /> 6892 * <colgroup align="left" /> 6893 * <thead> 6894 * <tr><th>URI</th> <th>Intent</th></tr> 6895 * </thead> 6896 * 6897 * <tbody> 6898 * <tr><td><code>android-app://com.example.app</code></td> 6899 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6900 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> 6901 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6902 * </table></td> 6903 * </tr> 6904 * <tr><td><code>android-app://com.example.app/http/example.com</code></td> 6905 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6906 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 6907 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> 6908 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6909 * </table></td> 6910 * </tr> 6911 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> 6912 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6913 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 6914 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 6915 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6916 * </table></td> 6917 * </tr> 6918 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> 6919 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6920 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 6921 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6922 * </table></td> 6923 * </tr> 6924 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> 6925 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6926 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 6927 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 6928 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6929 * </table></td> 6930 * </tr> 6931 * <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> 6932 * <td><table border="" style="margin:0" > 6933 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 6934 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6935 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> 6936 * </table></td> 6937 * </tr> 6938 * </tbody> 6939 * </table> 6940 */ 6941 public static final int URI_ANDROID_APP_SCHEME = 1<<1; 6942 6943 /** 6944 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing 6945 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, 6946 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, 6947 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the 6948 * generated Intent can not cause unexpected data access to happen. 6949 * 6950 * <p>If you do not trust the source of the URI being parsed, you should still do further 6951 * processing to protect yourself from it. In particular, when using it to start an 6952 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities 6953 * that can handle it.</p> 6954 */ 6955 public static final int URI_ALLOW_UNSAFE = 1<<2; 6956 6957 // --------------------------------------------------------------------- 6958 6959 private String mAction; 6960 private Uri mData; 6961 private String mType; 6962 private String mIdentifier; 6963 private String mPackage; 6964 private ComponentName mComponent; 6965 private int mFlags; 6966 /** Set of in-process flags which are never parceled */ 6967 private int mLocalFlags; 6968 private ArraySet<String> mCategories; 6969 @UnsupportedAppUsage 6970 private Bundle mExtras; 6971 private Rect mSourceBounds; 6972 private Intent mSelector; 6973 private ClipData mClipData; 6974 private int mContentUserHint = UserHandle.USER_CURRENT; 6975 /** Token to track instant app launches. Local only; do not copy cross-process. */ 6976 private String mLaunchToken; 6977 6978 // --------------------------------------------------------------------- 6979 6980 private static final int COPY_MODE_ALL = 0; 6981 private static final int COPY_MODE_FILTER = 1; 6982 private static final int COPY_MODE_HISTORY = 2; 6983 6984 /** @hide */ 6985 @IntDef(prefix = { "COPY_MODE_" }, value = { 6986 COPY_MODE_ALL, 6987 COPY_MODE_FILTER, 6988 COPY_MODE_HISTORY 6989 }) 6990 @Retention(RetentionPolicy.SOURCE) 6991 public @interface CopyMode {} 6992 6993 /** 6994 * Create an empty intent. 6995 */ Intent()6996 public Intent() { 6997 } 6998 6999 /** 7000 * Copy constructor. 7001 */ Intent(Intent o)7002 public Intent(Intent o) { 7003 this(o, COPY_MODE_ALL); 7004 } 7005 Intent(Intent o, @CopyMode int copyMode)7006 private Intent(Intent o, @CopyMode int copyMode) { 7007 this.mAction = o.mAction; 7008 this.mData = o.mData; 7009 this.mType = o.mType; 7010 this.mIdentifier = o.mIdentifier; 7011 this.mPackage = o.mPackage; 7012 this.mComponent = o.mComponent; 7013 7014 if (o.mCategories != null) { 7015 this.mCategories = new ArraySet<>(o.mCategories); 7016 } 7017 7018 // Inherit flags from the original, plus mark that we were 7019 // created by this copy constructor 7020 this.mLocalFlags = o.mLocalFlags; 7021 this.mLocalFlags |= LOCAL_FLAG_FROM_COPY; 7022 7023 if (copyMode != COPY_MODE_FILTER) { 7024 this.mFlags = o.mFlags; 7025 this.mContentUserHint = o.mContentUserHint; 7026 this.mLaunchToken = o.mLaunchToken; 7027 if (o.mSourceBounds != null) { 7028 this.mSourceBounds = new Rect(o.mSourceBounds); 7029 } 7030 if (o.mSelector != null) { 7031 this.mSelector = new Intent(o.mSelector); 7032 } 7033 7034 if (copyMode != COPY_MODE_HISTORY) { 7035 if (o.mExtras != null) { 7036 this.mExtras = new Bundle(o.mExtras); 7037 } 7038 if (o.mClipData != null) { 7039 this.mClipData = new ClipData(o.mClipData); 7040 } 7041 } else { 7042 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) { 7043 this.mExtras = Bundle.STRIPPED; 7044 } 7045 7046 // Also set "stripped" clip data when we ever log mClipData in the (broadcast) 7047 // history. 7048 } 7049 } 7050 } 7051 7052 @Override clone()7053 public Object clone() { 7054 return new Intent(this); 7055 } 7056 7057 /** 7058 * Make a clone of only the parts of the Intent that are relevant for 7059 * filter matching: the action, data, type, component, and categories. 7060 */ cloneFilter()7061 public @NonNull Intent cloneFilter() { 7062 return new Intent(this, COPY_MODE_FILTER); 7063 } 7064 7065 /** 7066 * Create an intent with a given action. All other fields (data, type, 7067 * class) are null. Note that the action <em>must</em> be in a 7068 * namespace because Intents are used globally in the system -- for 7069 * example the system VIEW action is android.intent.action.VIEW; an 7070 * application's custom action would be something like 7071 * com.google.app.myapp.CUSTOM_ACTION. 7072 * 7073 * @param action The Intent action, such as ACTION_VIEW. 7074 */ Intent(String action)7075 public Intent(String action) { 7076 setAction(action); 7077 } 7078 7079 /** 7080 * Create an intent with a given action and for a given data url. Note 7081 * that the action <em>must</em> be in a namespace because Intents are 7082 * used globally in the system -- for example the system VIEW action is 7083 * android.intent.action.VIEW; an application's custom action would be 7084 * something like com.google.app.myapp.CUSTOM_ACTION. 7085 * 7086 * <p><em>Note: scheme and host name matching in the Android framework is 7087 * case-sensitive, unlike the formal RFC. As a result, 7088 * you should always ensure that you write your Uri with these elements 7089 * using lower case letters, and normalize any Uris you receive from 7090 * outside of Android to ensure the scheme and host is lower case.</em></p> 7091 * 7092 * @param action The Intent action, such as ACTION_VIEW. 7093 * @param uri The Intent data URI. 7094 */ Intent(String action, Uri uri)7095 public Intent(String action, Uri uri) { 7096 setAction(action); 7097 mData = uri; 7098 } 7099 7100 /** 7101 * Create an intent for a specific component. All other fields (action, data, 7102 * type, class) are null, though they can be modified later with explicit 7103 * calls. This provides a convenient way to create an intent that is 7104 * intended to execute a hard-coded class name, rather than relying on the 7105 * system to find an appropriate class for you; see {@link #setComponent} 7106 * for more information on the repercussions of this. 7107 * 7108 * @param packageContext A Context of the application package implementing 7109 * this class. 7110 * @param cls The component class that is to be used for the intent. 7111 * 7112 * @see #setClass 7113 * @see #setComponent 7114 * @see #Intent(String, android.net.Uri , Context, Class) 7115 */ Intent(Context packageContext, Class<?> cls)7116 public Intent(Context packageContext, Class<?> cls) { 7117 mComponent = new ComponentName(packageContext, cls); 7118 } 7119 7120 /** 7121 * Create an intent for a specific component with a specified action and data. 7122 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to 7123 * construct the Intent and then calling {@link #setClass} to set its 7124 * class. 7125 * 7126 * <p><em>Note: scheme and host name matching in the Android framework is 7127 * case-sensitive, unlike the formal RFC. As a result, 7128 * you should always ensure that you write your Uri with these elements 7129 * using lower case letters, and normalize any Uris you receive from 7130 * outside of Android to ensure the scheme and host is lower case.</em></p> 7131 * 7132 * @param action The Intent action, such as ACTION_VIEW. 7133 * @param uri The Intent data URI. 7134 * @param packageContext A Context of the application package implementing 7135 * this class. 7136 * @param cls The component class that is to be used for the intent. 7137 * 7138 * @see #Intent(String, android.net.Uri) 7139 * @see #Intent(Context, Class) 7140 * @see #setClass 7141 * @see #setComponent 7142 */ Intent(String action, Uri uri, Context packageContext, Class<?> cls)7143 public Intent(String action, Uri uri, 7144 Context packageContext, Class<?> cls) { 7145 setAction(action); 7146 mData = uri; 7147 mComponent = new ComponentName(packageContext, cls); 7148 } 7149 7150 /** 7151 * Create an intent to launch the main (root) activity of a task. This 7152 * is the Intent that is started when the application's is launched from 7153 * Home. For anything else that wants to launch an application in the 7154 * same way, it is important that they use an Intent structured the same 7155 * way, and can use this function to ensure this is the case. 7156 * 7157 * <p>The returned Intent has the given Activity component as its explicit 7158 * component, {@link #ACTION_MAIN} as its action, and includes the 7159 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 7160 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 7161 * to do that through {@link #addFlags(int)} on the returned Intent. 7162 * 7163 * @param mainActivity The main activity component that this Intent will 7164 * launch. 7165 * @return Returns a newly created Intent that can be used to launch the 7166 * activity as a main application entry. 7167 * 7168 * @see #setClass 7169 * @see #setComponent 7170 */ makeMainActivity(ComponentName mainActivity)7171 public static Intent makeMainActivity(ComponentName mainActivity) { 7172 Intent intent = new Intent(ACTION_MAIN); 7173 intent.setComponent(mainActivity); 7174 intent.addCategory(CATEGORY_LAUNCHER); 7175 return intent; 7176 } 7177 7178 /** 7179 * Make an Intent for the main activity of an application, without 7180 * specifying a specific activity to run but giving a selector to find 7181 * the activity. This results in a final Intent that is structured 7182 * the same as when the application is launched from 7183 * Home. For anything else that wants to launch an application in the 7184 * same way, it is important that they use an Intent structured the same 7185 * way, and can use this function to ensure this is the case. 7186 * 7187 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the 7188 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 7189 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 7190 * to do that through {@link #addFlags(int)} on the returned Intent. 7191 * 7192 * @param selectorAction The action name of the Intent's selector. 7193 * @param selectorCategory The name of a category to add to the Intent's 7194 * selector. 7195 * @return Returns a newly created Intent that can be used to launch the 7196 * activity as a main application entry. 7197 * 7198 * @see #setSelector(Intent) 7199 */ makeMainSelectorActivity(String selectorAction, String selectorCategory)7200 public static Intent makeMainSelectorActivity(String selectorAction, 7201 String selectorCategory) { 7202 Intent intent = new Intent(ACTION_MAIN); 7203 intent.addCategory(CATEGORY_LAUNCHER); 7204 Intent selector = new Intent(); 7205 selector.setAction(selectorAction); 7206 selector.addCategory(selectorCategory); 7207 intent.setSelector(selector); 7208 return intent; 7209 } 7210 7211 /** 7212 * Make an Intent that can be used to re-launch an application's task 7213 * in its base state. This is like {@link #makeMainActivity(ComponentName)}, 7214 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and 7215 * {@link #FLAG_ACTIVITY_CLEAR_TASK}. 7216 * 7217 * @param mainActivity The activity component that is the root of the 7218 * task; this is the activity that has been published in the application's 7219 * manifest as the main launcher icon. 7220 * 7221 * @return Returns a newly created Intent that can be used to relaunch the 7222 * activity's task in its root state. 7223 */ makeRestartActivityTask(ComponentName mainActivity)7224 public static Intent makeRestartActivityTask(ComponentName mainActivity) { 7225 Intent intent = makeMainActivity(mainActivity); 7226 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 7227 | Intent.FLAG_ACTIVITY_CLEAR_TASK); 7228 return intent; 7229 } 7230 7231 /** 7232 * Call {@link #parseUri} with 0 flags. 7233 * @deprecated Use {@link #parseUri} instead. 7234 */ 7235 @Deprecated getIntent(String uri)7236 public static Intent getIntent(String uri) throws URISyntaxException { 7237 return parseUri(uri, 0); 7238 } 7239 7240 /** 7241 * Create an intent from a URI. This URI may encode the action, 7242 * category, and other intent fields, if it was returned by 7243 * {@link #toUri}. If the Intent was not generate by toUri(), its data 7244 * will be the entire URI and its action will be ACTION_VIEW. 7245 * 7246 * <p>The URI given here must not be relative -- that is, it must include 7247 * the scheme and full path. 7248 * 7249 * @param uri The URI to turn into an Intent. 7250 * @param flags Additional processing flags. 7251 * 7252 * @return Intent The newly created Intent object. 7253 * 7254 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax 7255 * it bad (as parsed by the Uri class) or the Intent data within the 7256 * URI is invalid. 7257 * 7258 * @see #toUri 7259 */ parseUri(String uri, @UriFlags int flags)7260 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException { 7261 Intent intent = parseUriInternal(uri, flags); 7262 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 7263 return intent; 7264 } 7265 7266 /** 7267 * @see #parseUri(String, int) 7268 */ parseUriInternal(String uri, @UriFlags int flags)7269 private static Intent parseUriInternal(String uri, @UriFlags int flags) 7270 throws URISyntaxException { 7271 int i = 0; 7272 try { 7273 final boolean androidApp = uri.startsWith("android-app:"); 7274 7275 // Validate intent scheme if requested. 7276 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { 7277 if (!uri.startsWith("intent:") && !androidApp) { 7278 Intent intent = new Intent(ACTION_VIEW); 7279 try { 7280 intent.setData(Uri.parse(uri)); 7281 } catch (IllegalArgumentException e) { 7282 throw new URISyntaxException(uri, e.getMessage()); 7283 } 7284 return intent; 7285 } 7286 } 7287 7288 i = uri.lastIndexOf("#"); 7289 // simple case 7290 if (i == -1) { 7291 if (!androidApp) { 7292 return new Intent(ACTION_VIEW, Uri.parse(uri)); 7293 } 7294 7295 // old format Intent URI 7296 } else if (!uri.startsWith("#Intent;", i)) { 7297 if (!androidApp) { 7298 return getIntentOld(uri, flags); 7299 } else { 7300 i = -1; 7301 } 7302 } 7303 7304 // new format 7305 Intent intent = new Intent(ACTION_VIEW); 7306 Intent baseIntent = intent; 7307 boolean explicitAction = false; 7308 boolean inSelector = false; 7309 7310 // fetch data part, if present 7311 String scheme = null; 7312 String data; 7313 if (i >= 0) { 7314 data = uri.substring(0, i); 7315 i += 8; // length of "#Intent;" 7316 } else { 7317 data = uri; 7318 } 7319 7320 // loop over contents of Intent, all name=value; 7321 while (i >= 0 && !uri.startsWith("end", i)) { 7322 int eq = uri.indexOf('=', i); 7323 if (eq < 0) eq = i-1; 7324 int semi = uri.indexOf(';', i); 7325 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : ""; 7326 7327 // action 7328 if (uri.startsWith("action=", i)) { 7329 intent.setAction(value); 7330 if (!inSelector) { 7331 explicitAction = true; 7332 } 7333 } 7334 7335 // categories 7336 else if (uri.startsWith("category=", i)) { 7337 intent.addCategory(value); 7338 } 7339 7340 // type 7341 else if (uri.startsWith("type=", i)) { 7342 intent.mType = value; 7343 } 7344 7345 // identifier 7346 else if (uri.startsWith("identifier=", i)) { 7347 intent.mIdentifier = value; 7348 } 7349 7350 // launch flags 7351 else if (uri.startsWith("launchFlags=", i)) { 7352 intent.mFlags = Integer.decode(value).intValue(); 7353 if ((flags& URI_ALLOW_UNSAFE) == 0) { 7354 intent.mFlags &= ~IMMUTABLE_FLAGS; 7355 } 7356 } 7357 7358 // package 7359 else if (uri.startsWith("package=", i)) { 7360 intent.mPackage = value; 7361 } 7362 7363 // component 7364 else if (uri.startsWith("component=", i)) { 7365 intent.mComponent = ComponentName.unflattenFromString(value); 7366 } 7367 7368 // scheme 7369 else if (uri.startsWith("scheme=", i)) { 7370 if (inSelector) { 7371 intent.mData = Uri.parse(value + ":"); 7372 } else { 7373 scheme = value; 7374 } 7375 } 7376 7377 // source bounds 7378 else if (uri.startsWith("sourceBounds=", i)) { 7379 intent.mSourceBounds = Rect.unflattenFromString(value); 7380 } 7381 7382 // selector 7383 else if (semi == (i+3) && uri.startsWith("SEL", i)) { 7384 intent = new Intent(); 7385 inSelector = true; 7386 } 7387 7388 // extra 7389 else { 7390 String key = Uri.decode(uri.substring(i + 2, eq)); 7391 // create Bundle if it doesn't already exist 7392 if (intent.mExtras == null) intent.mExtras = new Bundle(); 7393 Bundle b = intent.mExtras; 7394 // add EXTRA 7395 if (uri.startsWith("S.", i)) b.putString(key, value); 7396 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); 7397 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); 7398 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); 7399 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); 7400 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); 7401 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); 7402 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); 7403 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); 7404 else throw new URISyntaxException(uri, "unknown EXTRA type", i); 7405 } 7406 7407 // move to the next item 7408 i = semi + 1; 7409 } 7410 7411 if (inSelector) { 7412 // The Intent had a selector; fix it up. 7413 if (baseIntent.mPackage == null) { 7414 baseIntent.setSelector(intent); 7415 } 7416 intent = baseIntent; 7417 } 7418 7419 if (data != null) { 7420 if (data.startsWith("intent:")) { 7421 data = data.substring(7); 7422 if (scheme != null) { 7423 data = scheme + ':' + data; 7424 } 7425 } else if (data.startsWith("android-app:")) { 7426 if (data.charAt(12) == '/' && data.charAt(13) == '/') { 7427 // Correctly formed android-app, first part is package name. 7428 int end = data.indexOf('/', 14); 7429 if (end < 0) { 7430 // All we have is a package name. 7431 intent.mPackage = data.substring(14); 7432 if (!explicitAction) { 7433 intent.setAction(ACTION_MAIN); 7434 } 7435 data = ""; 7436 } else { 7437 // Target the Intent at the given package name always. 7438 String authority = null; 7439 intent.mPackage = data.substring(14, end); 7440 int newEnd; 7441 if ((end+1) < data.length()) { 7442 if ((newEnd=data.indexOf('/', end+1)) >= 0) { 7443 // Found a scheme, remember it. 7444 scheme = data.substring(end+1, newEnd); 7445 end = newEnd; 7446 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { 7447 // Found a authority, remember it. 7448 authority = data.substring(end+1, newEnd); 7449 end = newEnd; 7450 } 7451 } else { 7452 // All we have is a scheme. 7453 scheme = data.substring(end+1); 7454 } 7455 } 7456 if (scheme == null) { 7457 // If there was no scheme, then this just targets the package. 7458 if (!explicitAction) { 7459 intent.setAction(ACTION_MAIN); 7460 } 7461 data = ""; 7462 } else if (authority == null) { 7463 data = scheme + ":"; 7464 } else { 7465 data = scheme + "://" + authority + data.substring(end); 7466 } 7467 } 7468 } else { 7469 data = ""; 7470 } 7471 } 7472 7473 if (data.length() > 0) { 7474 try { 7475 intent.mData = Uri.parse(data); 7476 } catch (IllegalArgumentException e) { 7477 throw new URISyntaxException(uri, e.getMessage()); 7478 } 7479 } 7480 } 7481 7482 return intent; 7483 7484 } catch (IndexOutOfBoundsException e) { 7485 throw new URISyntaxException(uri, "illegal Intent URI format", i); 7486 } 7487 } 7488 7489 public static Intent getIntentOld(String uri) throws URISyntaxException { 7490 Intent intent = getIntentOld(uri, 0); 7491 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 7492 return intent; 7493 } 7494 7495 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException { 7496 Intent intent; 7497 7498 int i = uri.lastIndexOf('#'); 7499 if (i >= 0) { 7500 String action = null; 7501 final int intentFragmentStart = i; 7502 boolean isIntentFragment = false; 7503 7504 i++; 7505 7506 if (uri.regionMatches(i, "action(", 0, 7)) { 7507 isIntentFragment = true; 7508 i += 7; 7509 int j = uri.indexOf(')', i); 7510 action = uri.substring(i, j); 7511 i = j + 1; 7512 } 7513 7514 intent = new Intent(action); 7515 7516 if (uri.regionMatches(i, "categories(", 0, 11)) { 7517 isIntentFragment = true; 7518 i += 11; 7519 int j = uri.indexOf(')', i); 7520 while (i < j) { 7521 int sep = uri.indexOf('!', i); 7522 if (sep < 0 || sep > j) sep = j; 7523 if (i < sep) { 7524 intent.addCategory(uri.substring(i, sep)); 7525 } 7526 i = sep + 1; 7527 } 7528 i = j + 1; 7529 } 7530 7531 if (uri.regionMatches(i, "type(", 0, 5)) { 7532 isIntentFragment = true; 7533 i += 5; 7534 int j = uri.indexOf(')', i); 7535 intent.mType = uri.substring(i, j); 7536 i = j + 1; 7537 } 7538 7539 if (uri.regionMatches(i, "launchFlags(", 0, 12)) { 7540 isIntentFragment = true; 7541 i += 12; 7542 int j = uri.indexOf(')', i); 7543 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); 7544 if ((flags& URI_ALLOW_UNSAFE) == 0) { 7545 intent.mFlags &= ~IMMUTABLE_FLAGS; 7546 } 7547 i = j + 1; 7548 } 7549 7550 if (uri.regionMatches(i, "component(", 0, 10)) { 7551 isIntentFragment = true; 7552 i += 10; 7553 int j = uri.indexOf(')', i); 7554 int sep = uri.indexOf('!', i); 7555 if (sep >= 0 && sep < j) { 7556 String pkg = uri.substring(i, sep); 7557 String cls = uri.substring(sep + 1, j); 7558 intent.mComponent = new ComponentName(pkg, cls); 7559 } 7560 i = j + 1; 7561 } 7562 7563 if (uri.regionMatches(i, "extras(", 0, 7)) { 7564 isIntentFragment = true; 7565 i += 7; 7566 7567 final int closeParen = uri.indexOf(')', i); 7568 if (closeParen == -1) throw new URISyntaxException(uri, 7569 "EXTRA missing trailing ')'", i); 7570 7571 while (i < closeParen) { 7572 // fetch the key value 7573 int j = uri.indexOf('=', i); 7574 if (j <= i + 1 || i >= closeParen) { 7575 throw new URISyntaxException(uri, "EXTRA missing '='", i); 7576 } 7577 char type = uri.charAt(i); 7578 i++; 7579 String key = uri.substring(i, j); 7580 i = j + 1; 7581 7582 // get type-value 7583 j = uri.indexOf('!', i); 7584 if (j == -1 || j >= closeParen) j = closeParen; 7585 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); 7586 String value = uri.substring(i, j); 7587 i = j; 7588 7589 // create Bundle if it doesn't already exist 7590 if (intent.mExtras == null) intent.mExtras = new Bundle(); 7591 7592 // add item to bundle 7593 try { 7594 switch (type) { 7595 case 'S': 7596 intent.mExtras.putString(key, Uri.decode(value)); 7597 break; 7598 case 'B': 7599 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); 7600 break; 7601 case 'b': 7602 intent.mExtras.putByte(key, Byte.parseByte(value)); 7603 break; 7604 case 'c': 7605 intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); 7606 break; 7607 case 'd': 7608 intent.mExtras.putDouble(key, Double.parseDouble(value)); 7609 break; 7610 case 'f': 7611 intent.mExtras.putFloat(key, Float.parseFloat(value)); 7612 break; 7613 case 'i': 7614 intent.mExtras.putInt(key, Integer.parseInt(value)); 7615 break; 7616 case 'l': 7617 intent.mExtras.putLong(key, Long.parseLong(value)); 7618 break; 7619 case 's': 7620 intent.mExtras.putShort(key, Short.parseShort(value)); 7621 break; 7622 default: 7623 throw new URISyntaxException(uri, "EXTRA has unknown type", i); 7624 } 7625 } catch (NumberFormatException e) { 7626 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); 7627 } 7628 7629 char ch = uri.charAt(i); 7630 if (ch == ')') break; 7631 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); 7632 i++; 7633 } 7634 } 7635 7636 if (isIntentFragment) { 7637 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); 7638 } else { 7639 intent.mData = Uri.parse(uri); 7640 } 7641 7642 if (intent.mAction == null) { 7643 // By default, if no action is specified, then use VIEW. 7644 intent.mAction = ACTION_VIEW; 7645 } 7646 7647 } else { 7648 intent = new Intent(ACTION_VIEW, Uri.parse(uri)); 7649 } 7650 7651 return intent; 7652 } 7653 7654 /** @hide */ 7655 public interface CommandOptionHandler { 7656 boolean handleOption(String opt, ShellCommand cmd); 7657 } 7658 7659 /** @hide */ 7660 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 7661 @SuppressWarnings("AndroidFrameworkEfficientCollections") parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)7662 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) 7663 throws URISyntaxException { 7664 Intent intent = new Intent(); 7665 Intent baseIntent = intent; 7666 boolean hasIntentInfo = false; 7667 7668 Uri data = null; 7669 String type = null; 7670 7671 String opt; 7672 while ((opt=cmd.getNextOption()) != null) { 7673 switch (opt) { 7674 case "-a": 7675 intent.setAction(cmd.getNextArgRequired()); 7676 if (intent == baseIntent) { 7677 hasIntentInfo = true; 7678 } 7679 break; 7680 case "-d": 7681 data = Uri.parse(cmd.getNextArgRequired()); 7682 if (intent == baseIntent) { 7683 hasIntentInfo = true; 7684 } 7685 break; 7686 case "-t": 7687 type = cmd.getNextArgRequired(); 7688 if (intent == baseIntent) { 7689 hasIntentInfo = true; 7690 } 7691 break; 7692 case "-i": 7693 intent.setIdentifier(cmd.getNextArgRequired()); 7694 if (intent == baseIntent) { 7695 hasIntentInfo = true; 7696 } 7697 break; 7698 case "-c": 7699 intent.addCategory(cmd.getNextArgRequired()); 7700 if (intent == baseIntent) { 7701 hasIntentInfo = true; 7702 } 7703 break; 7704 case "-e": 7705 case "--es": { 7706 String key = cmd.getNextArgRequired(); 7707 String value = cmd.getNextArgRequired(); 7708 intent.putExtra(key, value); 7709 } 7710 break; 7711 case "--esn": { 7712 String key = cmd.getNextArgRequired(); 7713 intent.putExtra(key, (String) null); 7714 } 7715 break; 7716 case "--ei": { 7717 String key = cmd.getNextArgRequired(); 7718 String value = cmd.getNextArgRequired(); 7719 intent.putExtra(key, Integer.decode(value)); 7720 } 7721 break; 7722 case "--eu": { 7723 String key = cmd.getNextArgRequired(); 7724 String value = cmd.getNextArgRequired(); 7725 intent.putExtra(key, Uri.parse(value)); 7726 } 7727 break; 7728 case "--ecn": { 7729 String key = cmd.getNextArgRequired(); 7730 String value = cmd.getNextArgRequired(); 7731 ComponentName cn = ComponentName.unflattenFromString(value); 7732 if (cn == null) 7733 throw new IllegalArgumentException("Bad component name: " + value); 7734 intent.putExtra(key, cn); 7735 } 7736 break; 7737 case "--eia": { 7738 String key = cmd.getNextArgRequired(); 7739 String value = cmd.getNextArgRequired(); 7740 String[] strings = value.split(","); 7741 int[] list = new int[strings.length]; 7742 for (int i = 0; i < strings.length; i++) { 7743 list[i] = Integer.decode(strings[i]); 7744 } 7745 intent.putExtra(key, list); 7746 } 7747 break; 7748 case "--eial": { 7749 String key = cmd.getNextArgRequired(); 7750 String value = cmd.getNextArgRequired(); 7751 String[] strings = value.split(","); 7752 ArrayList<Integer> list = new ArrayList<>(strings.length); 7753 for (int i = 0; i < strings.length; i++) { 7754 list.add(Integer.decode(strings[i])); 7755 } 7756 intent.putExtra(key, list); 7757 } 7758 break; 7759 case "--el": { 7760 String key = cmd.getNextArgRequired(); 7761 String value = cmd.getNextArgRequired(); 7762 intent.putExtra(key, Long.valueOf(value)); 7763 } 7764 break; 7765 case "--ela": { 7766 String key = cmd.getNextArgRequired(); 7767 String value = cmd.getNextArgRequired(); 7768 String[] strings = value.split(","); 7769 long[] list = new long[strings.length]; 7770 for (int i = 0; i < strings.length; i++) { 7771 list[i] = Long.valueOf(strings[i]); 7772 } 7773 intent.putExtra(key, list); 7774 hasIntentInfo = true; 7775 } 7776 break; 7777 case "--elal": { 7778 String key = cmd.getNextArgRequired(); 7779 String value = cmd.getNextArgRequired(); 7780 String[] strings = value.split(","); 7781 ArrayList<Long> list = new ArrayList<>(strings.length); 7782 for (int i = 0; i < strings.length; i++) { 7783 list.add(Long.valueOf(strings[i])); 7784 } 7785 intent.putExtra(key, list); 7786 hasIntentInfo = true; 7787 } 7788 break; 7789 case "--ef": { 7790 String key = cmd.getNextArgRequired(); 7791 String value = cmd.getNextArgRequired(); 7792 intent.putExtra(key, Float.valueOf(value)); 7793 hasIntentInfo = true; 7794 } 7795 break; 7796 case "--efa": { 7797 String key = cmd.getNextArgRequired(); 7798 String value = cmd.getNextArgRequired(); 7799 String[] strings = value.split(","); 7800 float[] list = new float[strings.length]; 7801 for (int i = 0; i < strings.length; i++) { 7802 list[i] = Float.valueOf(strings[i]); 7803 } 7804 intent.putExtra(key, list); 7805 hasIntentInfo = true; 7806 } 7807 break; 7808 case "--efal": { 7809 String key = cmd.getNextArgRequired(); 7810 String value = cmd.getNextArgRequired(); 7811 String[] strings = value.split(","); 7812 ArrayList<Float> list = new ArrayList<>(strings.length); 7813 for (int i = 0; i < strings.length; i++) { 7814 list.add(Float.valueOf(strings[i])); 7815 } 7816 intent.putExtra(key, list); 7817 hasIntentInfo = true; 7818 } 7819 break; 7820 case "--esa": { 7821 String key = cmd.getNextArgRequired(); 7822 String value = cmd.getNextArgRequired(); 7823 // Split on commas unless they are preceeded by an escape. 7824 // The escape character must be escaped for the string and 7825 // again for the regex, thus four escape characters become one. 7826 String[] strings = value.split("(?<!\\\\),"); 7827 intent.putExtra(key, strings); 7828 hasIntentInfo = true; 7829 } 7830 break; 7831 case "--esal": { 7832 String key = cmd.getNextArgRequired(); 7833 String value = cmd.getNextArgRequired(); 7834 // Split on commas unless they are preceeded by an escape. 7835 // The escape character must be escaped for the string and 7836 // again for the regex, thus four escape characters become one. 7837 String[] strings = value.split("(?<!\\\\),"); 7838 ArrayList<String> list = new ArrayList<>(strings.length); 7839 for (int i = 0; i < strings.length; i++) { 7840 list.add(strings[i]); 7841 } 7842 intent.putExtra(key, list); 7843 hasIntentInfo = true; 7844 } 7845 break; 7846 case "--ez": { 7847 String key = cmd.getNextArgRequired(); 7848 String value = cmd.getNextArgRequired().toLowerCase(); 7849 // Boolean.valueOf() results in false for anything that is not "true", which is 7850 // error-prone in shell commands 7851 boolean arg; 7852 if ("true".equals(value) || "t".equals(value)) { 7853 arg = true; 7854 } else if ("false".equals(value) || "f".equals(value)) { 7855 arg = false; 7856 } else { 7857 try { 7858 arg = Integer.decode(value) != 0; 7859 } catch (NumberFormatException ex) { 7860 throw new IllegalArgumentException("Invalid boolean value: " + value); 7861 } 7862 } 7863 7864 intent.putExtra(key, arg); 7865 } 7866 break; 7867 case "-n": { 7868 String str = cmd.getNextArgRequired(); 7869 ComponentName cn = ComponentName.unflattenFromString(str); 7870 if (cn == null) 7871 throw new IllegalArgumentException("Bad component name: " + str); 7872 intent.setComponent(cn); 7873 if (intent == baseIntent) { 7874 hasIntentInfo = true; 7875 } 7876 } 7877 break; 7878 case "-p": { 7879 String str = cmd.getNextArgRequired(); 7880 intent.setPackage(str); 7881 if (intent == baseIntent) { 7882 hasIntentInfo = true; 7883 } 7884 } 7885 break; 7886 case "-f": 7887 String str = cmd.getNextArgRequired(); 7888 intent.setFlags(Integer.decode(str).intValue()); 7889 break; 7890 case "--grant-read-uri-permission": 7891 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 7892 break; 7893 case "--grant-write-uri-permission": 7894 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 7895 break; 7896 case "--grant-persistable-uri-permission": 7897 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); 7898 break; 7899 case "--grant-prefix-uri-permission": 7900 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); 7901 break; 7902 case "--exclude-stopped-packages": 7903 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); 7904 break; 7905 case "--include-stopped-packages": 7906 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); 7907 break; 7908 case "--debug-log-resolution": 7909 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); 7910 break; 7911 case "--activity-brought-to-front": 7912 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); 7913 break; 7914 case "--activity-clear-top": 7915 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 7916 break; 7917 case "--activity-clear-when-task-reset": 7918 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 7919 break; 7920 case "--activity-exclude-from-recents": 7921 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 7922 break; 7923 case "--activity-launched-from-history": 7924 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); 7925 break; 7926 case "--activity-multiple-task": 7927 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 7928 break; 7929 case "--activity-no-animation": 7930 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 7931 break; 7932 case "--activity-no-history": 7933 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 7934 break; 7935 case "--activity-no-user-action": 7936 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); 7937 break; 7938 case "--activity-previous-is-top": 7939 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); 7940 break; 7941 case "--activity-reorder-to-front": 7942 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 7943 break; 7944 case "--activity-reset-task-if-needed": 7945 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 7946 break; 7947 case "--activity-single-top": 7948 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 7949 break; 7950 case "--activity-clear-task": 7951 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 7952 break; 7953 case "--activity-task-on-home": 7954 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); 7955 break; 7956 case "--activity-match-external": 7957 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL); 7958 break; 7959 case "--receiver-registered-only": 7960 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); 7961 break; 7962 case "--receiver-replace-pending": 7963 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); 7964 break; 7965 case "--receiver-foreground": 7966 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 7967 break; 7968 case "--receiver-no-abort": 7969 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); 7970 break; 7971 case "--receiver-include-background": 7972 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 7973 break; 7974 case "--selector": 7975 intent.setDataAndType(data, type); 7976 intent = new Intent(); 7977 break; 7978 default: 7979 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { 7980 // Okay, caller handled this option. 7981 } else { 7982 throw new IllegalArgumentException("Unknown option: " + opt); 7983 } 7984 break; 7985 } 7986 } 7987 intent.setDataAndType(data, type); 7988 7989 final boolean hasSelector = intent != baseIntent; 7990 if (hasSelector) { 7991 // A selector was specified; fix up. 7992 baseIntent.setSelector(intent); 7993 intent = baseIntent; 7994 } 7995 7996 String arg = cmd.getNextArg(); 7997 baseIntent = null; 7998 if (arg == null) { 7999 if (hasSelector) { 8000 // If a selector has been specified, and no arguments 8001 // have been supplied for the main Intent, then we can 8002 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't 8003 // need to have a component name specified yet, the 8004 // selector will take care of that. 8005 baseIntent = new Intent(Intent.ACTION_MAIN); 8006 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8007 } 8008 } else if (arg.indexOf(':') >= 0) { 8009 // The argument is a URI. Fully parse it, and use that result 8010 // to fill in any data not specified so far. 8011 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME 8012 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); 8013 } else if (arg.indexOf('/') >= 0) { 8014 // The argument is a component name. Build an Intent to launch 8015 // it. 8016 baseIntent = new Intent(Intent.ACTION_MAIN); 8017 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8018 baseIntent.setComponent(ComponentName.unflattenFromString(arg)); 8019 } else { 8020 // Assume the argument is a package name. 8021 baseIntent = new Intent(Intent.ACTION_MAIN); 8022 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8023 baseIntent.setPackage(arg); 8024 } 8025 if (baseIntent != null) { 8026 Bundle extras = intent.getExtras(); 8027 intent.replaceExtras((Bundle)null); 8028 Bundle uriExtras = baseIntent.getExtras(); 8029 baseIntent.replaceExtras((Bundle)null); 8030 if (intent.getAction() != null && baseIntent.getCategories() != null) { 8031 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); 8032 for (String c : cats) { 8033 baseIntent.removeCategory(c); 8034 } 8035 } 8036 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); 8037 if (extras == null) { 8038 extras = uriExtras; 8039 } else if (uriExtras != null) { 8040 uriExtras.putAll(extras); 8041 extras = uriExtras; 8042 } 8043 intent.replaceExtras(extras); 8044 hasIntentInfo = true; 8045 } 8046 8047 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); 8048 return intent; 8049 } 8050 8051 /** @hide */ 8052 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) printIntentArgsHelp(PrintWriter pw, String prefix)8053 public static void printIntentArgsHelp(PrintWriter pw, String prefix) { 8054 final String[] lines = new String[] { 8055 "<INTENT> specifications include these flags and arguments:", 8056 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]", 8057 " [-c <CATEGORY> [-c <CATEGORY>] ...]", 8058 " [-n <COMPONENT_NAME>]", 8059 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", 8060 " [--esn <EXTRA_KEY> ...]", 8061 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", 8062 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", 8063 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", 8064 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", 8065 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", 8066 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", 8067 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8068 " (mutiple extras passed as Integer[])", 8069 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8070 " (mutiple extras passed as List<Integer>)", 8071 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8072 " (mutiple extras passed as Long[])", 8073 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8074 " (mutiple extras passed as List<Long>)", 8075 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8076 " (mutiple extras passed as Float[])", 8077 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8078 " (mutiple extras passed as List<Float>)", 8079 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8080 " (mutiple extras passed as String[]; to embed a comma into a string,", 8081 " escape it using \"\\,\")", 8082 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8083 " (mutiple extras passed as List<String>; to embed a comma into a string,", 8084 " escape it using \"\\,\")", 8085 " [-f <FLAG>]", 8086 " [--grant-read-uri-permission] [--grant-write-uri-permission]", 8087 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", 8088 " [--debug-log-resolution] [--exclude-stopped-packages]", 8089 " [--include-stopped-packages]", 8090 " [--activity-brought-to-front] [--activity-clear-top]", 8091 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", 8092 " [--activity-launched-from-history] [--activity-multiple-task]", 8093 " [--activity-no-animation] [--activity-no-history]", 8094 " [--activity-no-user-action] [--activity-previous-is-top]", 8095 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", 8096 " [--activity-single-top] [--activity-clear-task]", 8097 " [--activity-task-on-home] [--activity-match-external]", 8098 " [--receiver-registered-only] [--receiver-replace-pending]", 8099 " [--receiver-foreground] [--receiver-no-abort]", 8100 " [--receiver-include-background]", 8101 " [--selector]", 8102 " [<URI> | <PACKAGE> | <COMPONENT>]" 8103 }; 8104 for (String line : lines) { 8105 pw.print(prefix); 8106 pw.println(line); 8107 } 8108 } 8109 8110 /** 8111 * Retrieve the general action to be performed, such as 8112 * {@link #ACTION_VIEW}. The action describes the general way the rest of 8113 * the information in the intent should be interpreted -- most importantly, 8114 * what to do with the data returned by {@link #getData}. 8115 * 8116 * @return The action of this intent or null if none is specified. 8117 * 8118 * @see #setAction 8119 */ getAction()8120 public @Nullable String getAction() { 8121 return mAction; 8122 } 8123 8124 /** 8125 * Retrieve data this intent is operating on. This URI specifies the name 8126 * of the data; often it uses the content: scheme, specifying data in a 8127 * content provider. Other schemes may be handled by specific activities, 8128 * such as http: by the web browser. 8129 * 8130 * @return The URI of the data this intent is targeting or null. 8131 * 8132 * @see #getScheme 8133 * @see #setData 8134 */ getData()8135 public @Nullable Uri getData() { 8136 return mData; 8137 } 8138 8139 /** 8140 * The same as {@link #getData()}, but returns the URI as an encoded 8141 * String. 8142 */ getDataString()8143 public @Nullable String getDataString() { 8144 return mData != null ? mData.toString() : null; 8145 } 8146 8147 /** 8148 * Return the scheme portion of the intent's data. If the data is null or 8149 * does not include a scheme, null is returned. Otherwise, the scheme 8150 * prefix without the final ':' is returned, i.e. "http". 8151 * 8152 * <p>This is the same as calling getData().getScheme() (and checking for 8153 * null data). 8154 * 8155 * @return The scheme of this intent. 8156 * 8157 * @see #getData 8158 */ getScheme()8159 public @Nullable String getScheme() { 8160 return mData != null ? mData.getScheme() : null; 8161 } 8162 8163 /** 8164 * Retrieve any explicit MIME type included in the intent. This is usually 8165 * null, as the type is determined by the intent data. 8166 * 8167 * @return If a type was manually set, it is returned; else null is 8168 * returned. 8169 * 8170 * @see #resolveType(ContentResolver) 8171 * @see #setType 8172 */ getType()8173 public @Nullable String getType() { 8174 return mType; 8175 } 8176 8177 /** 8178 * Return the MIME data type of this intent. If the type field is 8179 * explicitly set, that is simply returned. Otherwise, if the data is set, 8180 * the type of that data is returned. If neither fields are set, a null is 8181 * returned. 8182 * 8183 * @return The MIME type of this intent. 8184 * 8185 * @see #getType 8186 * @see #resolveType(ContentResolver) 8187 */ resolveType(@onNull Context context)8188 public @Nullable String resolveType(@NonNull Context context) { 8189 return resolveType(context.getContentResolver()); 8190 } 8191 8192 /** 8193 * Return the MIME data type of this intent. If the type field is 8194 * explicitly set, that is simply returned. Otherwise, if the data is set, 8195 * the type of that data is returned. If neither fields are set, a null is 8196 * returned. 8197 * 8198 * @param resolver A ContentResolver that can be used to determine the MIME 8199 * type of the intent's data. 8200 * 8201 * @return The MIME type of this intent. 8202 * 8203 * @see #getType 8204 * @see #resolveType(Context) 8205 */ resolveType(@onNull ContentResolver resolver)8206 public @Nullable String resolveType(@NonNull ContentResolver resolver) { 8207 if (mType != null) { 8208 return mType; 8209 } 8210 if (mData != null) { 8211 if ("content".equals(mData.getScheme())) { 8212 return resolver.getType(mData); 8213 } 8214 } 8215 return null; 8216 } 8217 8218 /** 8219 * Return the MIME data type of this intent, only if it will be needed for 8220 * intent resolution. This is not generally useful for application code; 8221 * it is used by the frameworks for communicating with back-end system 8222 * services. 8223 * 8224 * @param resolver A ContentResolver that can be used to determine the MIME 8225 * type of the intent's data. 8226 * 8227 * @return The MIME type of this intent, or null if it is unknown or not 8228 * needed. 8229 */ resolveTypeIfNeeded(@onNull ContentResolver resolver)8230 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) { 8231 if (mComponent != null) { 8232 return mType; 8233 } 8234 return resolveType(resolver); 8235 } 8236 8237 /** 8238 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity 8239 * of the Intent to distinguish it from other Intents. 8240 * 8241 * @return The identifier of this intent or null if none is specified. 8242 * 8243 * @see #setIdentifier 8244 */ getIdentifier()8245 public @Nullable String getIdentifier() { 8246 return mIdentifier; 8247 } 8248 8249 /** 8250 * Check if a category exists in the intent. 8251 * 8252 * @param category The category to check. 8253 * 8254 * @return boolean True if the intent contains the category, else false. 8255 * 8256 * @see #getCategories 8257 * @see #addCategory 8258 */ hasCategory(String category)8259 public boolean hasCategory(String category) { 8260 return mCategories != null && mCategories.contains(category); 8261 } 8262 8263 /** 8264 * Return the set of all categories in the intent. If there are no categories, 8265 * returns NULL. 8266 * 8267 * @return The set of categories you can examine. Do not modify! 8268 * 8269 * @see #hasCategory 8270 * @see #addCategory 8271 */ getCategories()8272 public Set<String> getCategories() { 8273 return mCategories; 8274 } 8275 8276 /** 8277 * Return the specific selector associated with this Intent. If there is 8278 * none, returns null. See {@link #setSelector} for more information. 8279 * 8280 * @see #setSelector 8281 */ getSelector()8282 public @Nullable Intent getSelector() { 8283 return mSelector; 8284 } 8285 8286 /** 8287 * Return the {@link ClipData} associated with this Intent. If there is 8288 * none, returns null. See {@link #setClipData} for more information. 8289 * 8290 * @see #setClipData 8291 */ getClipData()8292 public @Nullable ClipData getClipData() { 8293 return mClipData; 8294 } 8295 8296 /** @hide */ getContentUserHint()8297 public int getContentUserHint() { 8298 return mContentUserHint; 8299 } 8300 8301 /** @hide */ getLaunchToken()8302 public String getLaunchToken() { 8303 return mLaunchToken; 8304 } 8305 8306 /** @hide */ setLaunchToken(String launchToken)8307 public void setLaunchToken(String launchToken) { 8308 mLaunchToken = launchToken; 8309 } 8310 8311 /** 8312 * Sets the ClassLoader that will be used when unmarshalling 8313 * any Parcelable values from the extras of this Intent. 8314 * 8315 * @param loader a ClassLoader, or null to use the default loader 8316 * at the time of unmarshalling. 8317 */ setExtrasClassLoader(@ullable ClassLoader loader)8318 public void setExtrasClassLoader(@Nullable ClassLoader loader) { 8319 if (mExtras != null) { 8320 mExtras.setClassLoader(loader); 8321 } 8322 } 8323 8324 /** 8325 * Returns true if an extra value is associated with the given name. 8326 * @param name the extra's name 8327 * @return true if the given extra is present. 8328 */ hasExtra(String name)8329 public boolean hasExtra(String name) { 8330 return mExtras != null && mExtras.containsKey(name); 8331 } 8332 8333 /** 8334 * Returns true if the Intent's extras contain a parcelled file descriptor. 8335 * @return true if the Intent contains a parcelled file descriptor. 8336 */ hasFileDescriptors()8337 public boolean hasFileDescriptors() { 8338 return mExtras != null && mExtras.hasFileDescriptors(); 8339 } 8340 8341 /** {@hide} */ 8342 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) setAllowFds(boolean allowFds)8343 public void setAllowFds(boolean allowFds) { 8344 if (mExtras != null) { 8345 mExtras.setAllowFds(allowFds); 8346 } 8347 } 8348 8349 /** {@hide} */ setDefusable(boolean defusable)8350 public void setDefusable(boolean defusable) { 8351 if (mExtras != null) { 8352 mExtras.setDefusable(defusable); 8353 } 8354 } 8355 8356 /** 8357 * Retrieve extended data from the intent. 8358 * 8359 * @param name The name of the desired item. 8360 * 8361 * @return the value of an item previously added with putExtra(), 8362 * or null if none was found. 8363 * 8364 * @deprecated 8365 * @hide 8366 */ 8367 @Deprecated 8368 @UnsupportedAppUsage getExtra(String name)8369 public Object getExtra(String name) { 8370 return getExtra(name, null); 8371 } 8372 8373 /** 8374 * Retrieve extended data from the intent. 8375 * 8376 * @param name The name of the desired item. 8377 * @param defaultValue the value to be returned if no value of the desired 8378 * type is stored with the given name. 8379 * 8380 * @return the value of an item previously added with putExtra(), 8381 * or the default value if none was found. 8382 * 8383 * @see #putExtra(String, boolean) 8384 */ getBooleanExtra(String name, boolean defaultValue)8385 public boolean getBooleanExtra(String name, boolean defaultValue) { 8386 return mExtras == null ? defaultValue : 8387 mExtras.getBoolean(name, defaultValue); 8388 } 8389 8390 /** 8391 * Retrieve extended data from the intent. 8392 * 8393 * @param name The name of the desired item. 8394 * @param defaultValue the value to be returned if no value of the desired 8395 * type is stored with the given name. 8396 * 8397 * @return the value of an item previously added with putExtra(), 8398 * or the default value if none was found. 8399 * 8400 * @see #putExtra(String, byte) 8401 */ getByteExtra(String name, byte defaultValue)8402 public byte getByteExtra(String name, byte defaultValue) { 8403 return mExtras == null ? defaultValue : 8404 mExtras.getByte(name, defaultValue); 8405 } 8406 8407 /** 8408 * Retrieve extended data from the intent. 8409 * 8410 * @param name The name of the desired item. 8411 * @param defaultValue the value to be returned if no value of the desired 8412 * type is stored with the given name. 8413 * 8414 * @return the value of an item previously added with putExtra(), 8415 * or the default value if none was found. 8416 * 8417 * @see #putExtra(String, short) 8418 */ getShortExtra(String name, short defaultValue)8419 public short getShortExtra(String name, short defaultValue) { 8420 return mExtras == null ? defaultValue : 8421 mExtras.getShort(name, defaultValue); 8422 } 8423 8424 /** 8425 * Retrieve extended data from the intent. 8426 * 8427 * @param name The name of the desired item. 8428 * @param defaultValue the value to be returned if no value of the desired 8429 * type is stored with the given name. 8430 * 8431 * @return the value of an item previously added with putExtra(), 8432 * or the default value if none was found. 8433 * 8434 * @see #putExtra(String, char) 8435 */ getCharExtra(String name, char defaultValue)8436 public char getCharExtra(String name, char defaultValue) { 8437 return mExtras == null ? defaultValue : 8438 mExtras.getChar(name, defaultValue); 8439 } 8440 8441 /** 8442 * Retrieve extended data from the intent. 8443 * 8444 * @param name The name of the desired item. 8445 * @param defaultValue the value to be returned if no value of the desired 8446 * type is stored with the given name. 8447 * 8448 * @return the value of an item previously added with putExtra(), 8449 * or the default value if none was found. 8450 * 8451 * @see #putExtra(String, int) 8452 */ getIntExtra(String name, int defaultValue)8453 public int getIntExtra(String name, int defaultValue) { 8454 return mExtras == null ? defaultValue : 8455 mExtras.getInt(name, defaultValue); 8456 } 8457 8458 /** 8459 * Retrieve extended data from the intent. 8460 * 8461 * @param name The name of the desired item. 8462 * @param defaultValue the value to be returned if no value of the desired 8463 * type is stored with the given name. 8464 * 8465 * @return the value of an item previously added with putExtra(), 8466 * or the default value if none was found. 8467 * 8468 * @see #putExtra(String, long) 8469 */ getLongExtra(String name, long defaultValue)8470 public long getLongExtra(String name, long defaultValue) { 8471 return mExtras == null ? defaultValue : 8472 mExtras.getLong(name, defaultValue); 8473 } 8474 8475 /** 8476 * Retrieve extended data from the intent. 8477 * 8478 * @param name The name of the desired item. 8479 * @param defaultValue the value to be returned if no value of the desired 8480 * type is stored with the given name. 8481 * 8482 * @return the value of an item previously added with putExtra(), 8483 * or the default value if no such item is present 8484 * 8485 * @see #putExtra(String, float) 8486 */ getFloatExtra(String name, float defaultValue)8487 public float getFloatExtra(String name, float defaultValue) { 8488 return mExtras == null ? defaultValue : 8489 mExtras.getFloat(name, defaultValue); 8490 } 8491 8492 /** 8493 * Retrieve extended data from the intent. 8494 * 8495 * @param name The name of the desired item. 8496 * @param defaultValue the value to be returned if no value of the desired 8497 * type is stored with the given name. 8498 * 8499 * @return the value of an item previously added with putExtra(), 8500 * or the default value if none was found. 8501 * 8502 * @see #putExtra(String, double) 8503 */ getDoubleExtra(String name, double defaultValue)8504 public double getDoubleExtra(String name, double defaultValue) { 8505 return mExtras == null ? defaultValue : 8506 mExtras.getDouble(name, defaultValue); 8507 } 8508 8509 /** 8510 * Retrieve extended data from the intent. 8511 * 8512 * @param name The name of the desired item. 8513 * 8514 * @return the value of an item previously added with putExtra(), 8515 * or null if no String value was found. 8516 * 8517 * @see #putExtra(String, String) 8518 */ getStringExtra(String name)8519 public @Nullable String getStringExtra(String name) { 8520 return mExtras == null ? null : mExtras.getString(name); 8521 } 8522 8523 /** 8524 * Retrieve extended data from the intent. 8525 * 8526 * @param name The name of the desired item. 8527 * 8528 * @return the value of an item previously added with putExtra(), 8529 * or null if no CharSequence value was found. 8530 * 8531 * @see #putExtra(String, CharSequence) 8532 */ getCharSequenceExtra(String name)8533 public @Nullable CharSequence getCharSequenceExtra(String name) { 8534 return mExtras == null ? null : mExtras.getCharSequence(name); 8535 } 8536 8537 /** 8538 * Retrieve extended data from the intent. 8539 * 8540 * @param name The name of the desired item. 8541 * 8542 * @return the value of an item previously added with putExtra(), 8543 * or null if no Parcelable value was found. 8544 * 8545 * @see #putExtra(String, Parcelable) 8546 */ getParcelableExtra(String name)8547 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) { 8548 return mExtras == null ? null : mExtras.<T>getParcelable(name); 8549 } 8550 8551 /** 8552 * Retrieve extended data from the intent. 8553 * 8554 * @param name The name of the desired item. 8555 * 8556 * @return the value of an item previously added with putExtra(), 8557 * or null if no Parcelable[] value was found. 8558 * 8559 * @see #putExtra(String, Parcelable[]) 8560 */ getParcelableArrayExtra(String name)8561 public @Nullable Parcelable[] getParcelableArrayExtra(String name) { 8562 return mExtras == null ? null : mExtras.getParcelableArray(name); 8563 } 8564 8565 /** 8566 * Retrieve extended data from the intent. 8567 * 8568 * @param name The name of the desired item. 8569 * 8570 * @return the value of an item previously added with 8571 * putParcelableArrayListExtra(), or null if no 8572 * ArrayList<Parcelable> value was found. 8573 * 8574 * @see #putParcelableArrayListExtra(String, ArrayList) 8575 */ getParcelableArrayListExtra(String name)8576 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { 8577 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); 8578 } 8579 8580 /** 8581 * Retrieve extended data from the intent. 8582 * 8583 * @param name The name of the desired item. 8584 * 8585 * @return the value of an item previously added with putExtra(), 8586 * or null if no Serializable value was found. 8587 * 8588 * @see #putExtra(String, Serializable) 8589 */ getSerializableExtra(String name)8590 public @Nullable Serializable getSerializableExtra(String name) { 8591 return mExtras == null ? null : mExtras.getSerializable(name); 8592 } 8593 8594 /** 8595 * Retrieve extended data from the intent. 8596 * 8597 * @param name The name of the desired item. 8598 * 8599 * @return the value of an item previously added with 8600 * putIntegerArrayListExtra(), or null if no 8601 * ArrayList<Integer> value was found. 8602 * 8603 * @see #putIntegerArrayListExtra(String, ArrayList) 8604 */ getIntegerArrayListExtra(String name)8605 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) { 8606 return mExtras == null ? null : mExtras.getIntegerArrayList(name); 8607 } 8608 8609 /** 8610 * Retrieve extended data from the intent. 8611 * 8612 * @param name The name of the desired item. 8613 * 8614 * @return the value of an item previously added with 8615 * putStringArrayListExtra(), or null if no 8616 * ArrayList<String> value was found. 8617 * 8618 * @see #putStringArrayListExtra(String, ArrayList) 8619 */ getStringArrayListExtra(String name)8620 public @Nullable ArrayList<String> getStringArrayListExtra(String name) { 8621 return mExtras == null ? null : mExtras.getStringArrayList(name); 8622 } 8623 8624 /** 8625 * Retrieve extended data from the intent. 8626 * 8627 * @param name The name of the desired item. 8628 * 8629 * @return the value of an item previously added with 8630 * putCharSequenceArrayListExtra, or null if no 8631 * ArrayList<CharSequence> value was found. 8632 * 8633 * @see #putCharSequenceArrayListExtra(String, ArrayList) 8634 */ getCharSequenceArrayListExtra(String name)8635 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { 8636 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); 8637 } 8638 8639 /** 8640 * Retrieve extended data from the intent. 8641 * 8642 * @param name The name of the desired item. 8643 * 8644 * @return the value of an item previously added with putExtra(), 8645 * or null if no boolean array value was found. 8646 * 8647 * @see #putExtra(String, boolean[]) 8648 */ getBooleanArrayExtra(String name)8649 public @Nullable boolean[] getBooleanArrayExtra(String name) { 8650 return mExtras == null ? null : mExtras.getBooleanArray(name); 8651 } 8652 8653 /** 8654 * Retrieve extended data from the intent. 8655 * 8656 * @param name The name of the desired item. 8657 * 8658 * @return the value of an item previously added with putExtra(), 8659 * or null if no byte array value was found. 8660 * 8661 * @see #putExtra(String, byte[]) 8662 */ getByteArrayExtra(String name)8663 public @Nullable byte[] getByteArrayExtra(String name) { 8664 return mExtras == null ? null : mExtras.getByteArray(name); 8665 } 8666 8667 /** 8668 * Retrieve extended data from the intent. 8669 * 8670 * @param name The name of the desired item. 8671 * 8672 * @return the value of an item previously added with putExtra(), 8673 * or null if no short array value was found. 8674 * 8675 * @see #putExtra(String, short[]) 8676 */ getShortArrayExtra(String name)8677 public @Nullable short[] getShortArrayExtra(String name) { 8678 return mExtras == null ? null : mExtras.getShortArray(name); 8679 } 8680 8681 /** 8682 * Retrieve extended data from the intent. 8683 * 8684 * @param name The name of the desired item. 8685 * 8686 * @return the value of an item previously added with putExtra(), 8687 * or null if no char array value was found. 8688 * 8689 * @see #putExtra(String, char[]) 8690 */ getCharArrayExtra(String name)8691 public @Nullable char[] getCharArrayExtra(String name) { 8692 return mExtras == null ? null : mExtras.getCharArray(name); 8693 } 8694 8695 /** 8696 * Retrieve extended data from the intent. 8697 * 8698 * @param name The name of the desired item. 8699 * 8700 * @return the value of an item previously added with putExtra(), 8701 * or null if no int array value was found. 8702 * 8703 * @see #putExtra(String, int[]) 8704 */ getIntArrayExtra(String name)8705 public @Nullable int[] getIntArrayExtra(String name) { 8706 return mExtras == null ? null : mExtras.getIntArray(name); 8707 } 8708 8709 /** 8710 * Retrieve extended data from the intent. 8711 * 8712 * @param name The name of the desired item. 8713 * 8714 * @return the value of an item previously added with putExtra(), 8715 * or null if no long array value was found. 8716 * 8717 * @see #putExtra(String, long[]) 8718 */ getLongArrayExtra(String name)8719 public @Nullable long[] getLongArrayExtra(String name) { 8720 return mExtras == null ? null : mExtras.getLongArray(name); 8721 } 8722 8723 /** 8724 * Retrieve extended data from the intent. 8725 * 8726 * @param name The name of the desired item. 8727 * 8728 * @return the value of an item previously added with putExtra(), 8729 * or null if no float array value was found. 8730 * 8731 * @see #putExtra(String, float[]) 8732 */ getFloatArrayExtra(String name)8733 public @Nullable float[] getFloatArrayExtra(String name) { 8734 return mExtras == null ? null : mExtras.getFloatArray(name); 8735 } 8736 8737 /** 8738 * Retrieve extended data from the intent. 8739 * 8740 * @param name The name of the desired item. 8741 * 8742 * @return the value of an item previously added with putExtra(), 8743 * or null if no double array value was found. 8744 * 8745 * @see #putExtra(String, double[]) 8746 */ getDoubleArrayExtra(String name)8747 public @Nullable double[] getDoubleArrayExtra(String name) { 8748 return mExtras == null ? null : mExtras.getDoubleArray(name); 8749 } 8750 8751 /** 8752 * Retrieve extended data from the intent. 8753 * 8754 * @param name The name of the desired item. 8755 * 8756 * @return the value of an item previously added with putExtra(), 8757 * or null if no String array value was found. 8758 * 8759 * @see #putExtra(String, String[]) 8760 */ getStringArrayExtra(String name)8761 public @Nullable String[] getStringArrayExtra(String name) { 8762 return mExtras == null ? null : mExtras.getStringArray(name); 8763 } 8764 8765 /** 8766 * Retrieve extended data from the intent. 8767 * 8768 * @param name The name of the desired item. 8769 * 8770 * @return the value of an item previously added with putExtra(), 8771 * or null if no CharSequence array value was found. 8772 * 8773 * @see #putExtra(String, CharSequence[]) 8774 */ getCharSequenceArrayExtra(String name)8775 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) { 8776 return mExtras == null ? null : mExtras.getCharSequenceArray(name); 8777 } 8778 8779 /** 8780 * Retrieve extended data from the intent. 8781 * 8782 * @param name The name of the desired item. 8783 * 8784 * @return the value of an item previously added with putExtra(), 8785 * or null if no Bundle value was found. 8786 * 8787 * @see #putExtra(String, Bundle) 8788 */ getBundleExtra(String name)8789 public @Nullable Bundle getBundleExtra(String name) { 8790 return mExtras == null ? null : mExtras.getBundle(name); 8791 } 8792 8793 /** 8794 * Retrieve extended data from the intent. 8795 * 8796 * @param name The name of the desired item. 8797 * 8798 * @return the value of an item previously added with putExtra(), 8799 * or null if no IBinder value was found. 8800 * 8801 * @see #putExtra(String, IBinder) 8802 * 8803 * @deprecated 8804 * @hide 8805 */ 8806 @Deprecated 8807 @UnsupportedAppUsage getIBinderExtra(String name)8808 public IBinder getIBinderExtra(String name) { 8809 return mExtras == null ? null : mExtras.getIBinder(name); 8810 } 8811 8812 /** 8813 * Retrieve extended data from the intent. 8814 * 8815 * @param name The name of the desired item. 8816 * @param defaultValue The default value to return in case no item is 8817 * associated with the key 'name' 8818 * 8819 * @return the value of an item previously added with putExtra(), 8820 * or defaultValue if none was found. 8821 * 8822 * @see #putExtra 8823 * 8824 * @deprecated 8825 * @hide 8826 */ 8827 @Deprecated 8828 @UnsupportedAppUsage getExtra(String name, Object defaultValue)8829 public Object getExtra(String name, Object defaultValue) { 8830 Object result = defaultValue; 8831 if (mExtras != null) { 8832 Object result2 = mExtras.get(name); 8833 if (result2 != null) { 8834 result = result2; 8835 } 8836 } 8837 8838 return result; 8839 } 8840 8841 /** 8842 * Retrieves a map of extended data from the intent. 8843 * 8844 * @return the map of all extras previously added with putExtra(), 8845 * or null if none have been added. 8846 */ getExtras()8847 public @Nullable Bundle getExtras() { 8848 return (mExtras != null) 8849 ? new Bundle(mExtras) 8850 : null; 8851 } 8852 8853 /** 8854 * Filter extras to only basic types. 8855 * @hide 8856 */ removeUnsafeExtras()8857 public void removeUnsafeExtras() { 8858 if (mExtras != null) { 8859 mExtras = mExtras.filterValues(); 8860 } 8861 } 8862 8863 /** 8864 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or 8865 * return itself as-is. 8866 * @hide 8867 */ canStripForHistory()8868 public boolean canStripForHistory() { 8869 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null); 8870 } 8871 8872 /** 8873 * Call it when the system needs to keep an intent for logging purposes to remove fields 8874 * that are not needed for logging. 8875 * @hide 8876 */ maybeStripForHistory()8877 public Intent maybeStripForHistory() { 8878 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras? 8879 8880 if (!canStripForHistory()) { 8881 return this; 8882 } 8883 return new Intent(this, COPY_MODE_HISTORY); 8884 } 8885 8886 /** 8887 * Retrieve any special flags associated with this intent. You will 8888 * normally just set them with {@link #setFlags} and let the system 8889 * take the appropriate action with them. 8890 * 8891 * @return The currently set flags. 8892 * @see #setFlags 8893 * @see #addFlags 8894 * @see #removeFlags 8895 */ getFlags()8896 public @Flags int getFlags() { 8897 return mFlags; 8898 } 8899 8900 /** @hide */ 8901 @UnsupportedAppUsage isExcludingStopped()8902 public boolean isExcludingStopped() { 8903 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) 8904 == FLAG_EXCLUDE_STOPPED_PACKAGES; 8905 } 8906 8907 /** 8908 * Retrieve the application package name this Intent is limited to. When 8909 * resolving an Intent, if non-null this limits the resolution to only 8910 * components in the given application package. 8911 * 8912 * @return The name of the application package for the Intent. 8913 * 8914 * @see #resolveActivity 8915 * @see #setPackage 8916 */ getPackage()8917 public @Nullable String getPackage() { 8918 return mPackage; 8919 } 8920 8921 /** 8922 * Retrieve the concrete component associated with the intent. When receiving 8923 * an intent, this is the component that was found to best handle it (that is, 8924 * yourself) and will always be non-null; in all other cases it will be 8925 * null unless explicitly set. 8926 * 8927 * @return The name of the application component to handle the intent. 8928 * 8929 * @see #resolveActivity 8930 * @see #setComponent 8931 */ getComponent()8932 public @Nullable ComponentName getComponent() { 8933 return mComponent; 8934 } 8935 8936 /** 8937 * Get the bounds of the sender of this intent, in screen coordinates. This can be 8938 * used as a hint to the receiver for animations and the like. Null means that there 8939 * is no source bounds. 8940 */ getSourceBounds()8941 public @Nullable Rect getSourceBounds() { 8942 return mSourceBounds; 8943 } 8944 8945 /** 8946 * Return the Activity component that should be used to handle this intent. 8947 * The appropriate component is determined based on the information in the 8948 * intent, evaluated as follows: 8949 * 8950 * <p>If {@link #getComponent} returns an explicit class, that is returned 8951 * without any further consideration. 8952 * 8953 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent 8954 * category to be considered. 8955 * 8956 * <p>If {@link #getAction} is non-NULL, the activity must handle this 8957 * action. 8958 * 8959 * <p>If {@link #resolveType} returns non-NULL, the activity must handle 8960 * this type. 8961 * 8962 * <p>If {@link #addCategory} has added any categories, the activity must 8963 * handle ALL of the categories specified. 8964 * 8965 * <p>If {@link #getPackage} is non-NULL, only activity components in 8966 * that application package will be considered. 8967 * 8968 * <p>If there are no activities that satisfy all of these conditions, a 8969 * null string is returned. 8970 * 8971 * <p>If multiple activities are found to satisfy the intent, the one with 8972 * the highest priority will be used. If there are multiple activities 8973 * with the same priority, the system will either pick the best activity 8974 * based on user preference, or resolve to a system class that will allow 8975 * the user to pick an activity and forward from there. 8976 * 8977 * <p>This method is implemented simply by calling 8978 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter 8979 * true.</p> 8980 * <p> This API is called for you as part of starting an activity from an 8981 * intent. You do not normally need to call it yourself.</p> 8982 * 8983 * @param pm The package manager with which to resolve the Intent. 8984 * 8985 * @return Name of the component implementing an activity that can 8986 * display the intent. 8987 * 8988 * @see #setComponent 8989 * @see #getComponent 8990 * @see #resolveActivityInfo 8991 */ resolveActivity(@onNull PackageManager pm)8992 public ComponentName resolveActivity(@NonNull PackageManager pm) { 8993 if (mComponent != null) { 8994 return mComponent; 8995 } 8996 8997 ResolveInfo info = pm.resolveActivity( 8998 this, PackageManager.MATCH_DEFAULT_ONLY); 8999 if (info != null) { 9000 return new ComponentName( 9001 info.activityInfo.applicationInfo.packageName, 9002 info.activityInfo.name); 9003 } 9004 9005 return null; 9006 } 9007 9008 /** 9009 * Resolve the Intent into an {@link ActivityInfo} 9010 * describing the activity that should execute the intent. Resolution 9011 * follows the same rules as described for {@link #resolveActivity}, but 9012 * you get back the completely information about the resolved activity 9013 * instead of just its class name. 9014 * 9015 * @param pm The package manager with which to resolve the Intent. 9016 * @param flags Addition information to retrieve as per 9017 * {@link PackageManager#getActivityInfo(ComponentName, int) 9018 * PackageManager.getActivityInfo()}. 9019 * 9020 * @return PackageManager.ActivityInfo 9021 * 9022 * @see #resolveActivity 9023 */ resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)9024 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm, 9025 @PackageManager.ComponentInfoFlags int flags) { 9026 ActivityInfo ai = null; 9027 if (mComponent != null) { 9028 try { 9029 ai = pm.getActivityInfo(mComponent, flags); 9030 } catch (PackageManager.NameNotFoundException e) { 9031 // ignore 9032 } 9033 } else { 9034 ResolveInfo info = pm.resolveActivity( 9035 this, PackageManager.MATCH_DEFAULT_ONLY | flags); 9036 if (info != null) { 9037 ai = info.activityInfo; 9038 } 9039 } 9040 9041 return ai; 9042 } 9043 9044 /** 9045 * Special function for use by the system to resolve service 9046 * intents to system apps. Throws an exception if there are 9047 * multiple potential matches to the Intent. Returns null if 9048 * there are no matches. 9049 * @hide 9050 */ 9051 @UnsupportedAppUsage resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)9052 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm, 9053 @PackageManager.ComponentInfoFlags int flags) { 9054 if (mComponent != null) { 9055 return mComponent; 9056 } 9057 9058 List<ResolveInfo> results = pm.queryIntentServices(this, flags); 9059 if (results == null) { 9060 return null; 9061 } 9062 ComponentName comp = null; 9063 for (int i=0; i<results.size(); i++) { 9064 ResolveInfo ri = results.get(i); 9065 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { 9066 continue; 9067 } 9068 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, 9069 ri.serviceInfo.name); 9070 if (comp != null) { 9071 throw new IllegalStateException("Multiple system services handle " + this 9072 + ": " + comp + ", " + foundComp); 9073 } 9074 comp = foundComp; 9075 } 9076 return comp; 9077 } 9078 9079 /** 9080 * Set the general action to be performed. 9081 * 9082 * @param action An action name, such as ACTION_VIEW. Application-specific 9083 * actions should be prefixed with the vendor's package name. 9084 * 9085 * @return Returns the same Intent object, for chaining multiple calls 9086 * into a single statement. 9087 * 9088 * @see #getAction 9089 */ setAction(@ullable String action)9090 public @NonNull Intent setAction(@Nullable String action) { 9091 mAction = action != null ? action.intern() : null; 9092 return this; 9093 } 9094 9095 /** 9096 * Set the data this intent is operating on. This method automatically 9097 * clears any type that was previously set by {@link #setType} or 9098 * {@link #setTypeAndNormalize}. 9099 * 9100 * <p><em>Note: scheme matching in the Android framework is 9101 * case-sensitive, unlike the formal RFC. As a result, 9102 * you should always write your Uri with a lower case scheme, 9103 * or use {@link Uri#normalizeScheme} or 9104 * {@link #setDataAndNormalize} 9105 * to ensure that the scheme is converted to lower case.</em> 9106 * 9107 * @param data The Uri of the data this intent is now targeting. 9108 * 9109 * @return Returns the same Intent object, for chaining multiple calls 9110 * into a single statement. 9111 * 9112 * @see #getData 9113 * @see #setDataAndNormalize 9114 * @see android.net.Uri#normalizeScheme() 9115 */ setData(@ullable Uri data)9116 public @NonNull Intent setData(@Nullable Uri data) { 9117 mData = data; 9118 mType = null; 9119 return this; 9120 } 9121 9122 /** 9123 * Normalize and set the data this intent is operating on. 9124 * 9125 * <p>This method automatically clears any type that was 9126 * previously set (for example, by {@link #setType}). 9127 * 9128 * <p>The data Uri is normalized using 9129 * {@link android.net.Uri#normalizeScheme} before it is set, 9130 * so really this is just a convenience method for 9131 * <pre> 9132 * setData(data.normalize()) 9133 * </pre> 9134 * 9135 * @param data The Uri of the data this intent is now targeting. 9136 * 9137 * @return Returns the same Intent object, for chaining multiple calls 9138 * into a single statement. 9139 * 9140 * @see #getData 9141 * @see #setType 9142 * @see android.net.Uri#normalizeScheme 9143 */ setDataAndNormalize(@onNull Uri data)9144 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) { 9145 return setData(data.normalizeScheme()); 9146 } 9147 9148 /** 9149 * Set an explicit MIME data type. 9150 * 9151 * <p>This is used to create intents that only specify a type and not data, 9152 * for example to indicate the type of data to return. 9153 * 9154 * <p>This method automatically clears any data that was 9155 * previously set (for example by {@link #setData}). 9156 * 9157 * <p><em>Note: MIME type matching in the Android framework is 9158 * case-sensitive, unlike formal RFC MIME types. As a result, 9159 * you should always write your MIME types with lower case letters, 9160 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} 9161 * to ensure that it is converted to lower case.</em> 9162 * 9163 * @param type The MIME type of the data being handled by this intent. 9164 * 9165 * @return Returns the same Intent object, for chaining multiple calls 9166 * into a single statement. 9167 * 9168 * @see #getType 9169 * @see #setTypeAndNormalize 9170 * @see #setDataAndType 9171 * @see #normalizeMimeType 9172 */ setType(@ullable String type)9173 public @NonNull Intent setType(@Nullable String type) { 9174 mData = null; 9175 mType = type; 9176 return this; 9177 } 9178 9179 /** 9180 * Normalize and set an explicit MIME data type. 9181 * 9182 * <p>This is used to create intents that only specify a type and not data, 9183 * for example to indicate the type of data to return. 9184 * 9185 * <p>This method automatically clears any data that was 9186 * previously set (for example by {@link #setData}). 9187 * 9188 * <p>The MIME type is normalized using 9189 * {@link #normalizeMimeType} before it is set, 9190 * so really this is just a convenience method for 9191 * <pre> 9192 * setType(Intent.normalizeMimeType(type)) 9193 * </pre> 9194 * 9195 * @param type The MIME type of the data being handled by this intent. 9196 * 9197 * @return Returns the same Intent object, for chaining multiple calls 9198 * into a single statement. 9199 * 9200 * @see #getType 9201 * @see #setData 9202 * @see #normalizeMimeType 9203 */ setTypeAndNormalize(@ullable String type)9204 public @NonNull Intent setTypeAndNormalize(@Nullable String type) { 9205 return setType(normalizeMimeType(type)); 9206 } 9207 9208 /** 9209 * (Usually optional) Set the data for the intent along with an explicit 9210 * MIME data type. This method should very rarely be used -- it allows you 9211 * to override the MIME type that would ordinarily be inferred from the 9212 * data with your own type given here. 9213 * 9214 * <p><em>Note: MIME type and Uri scheme matching in the 9215 * Android framework is case-sensitive, unlike the formal RFC definitions. 9216 * As a result, you should always write these elements with lower case letters, 9217 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or 9218 * {@link #setDataAndTypeAndNormalize} 9219 * to ensure that they are converted to lower case.</em> 9220 * 9221 * @param data The Uri of the data this intent is now targeting. 9222 * @param type The MIME type of the data being handled by this intent. 9223 * 9224 * @return Returns the same Intent object, for chaining multiple calls 9225 * into a single statement. 9226 * 9227 * @see #setType 9228 * @see #setData 9229 * @see #normalizeMimeType 9230 * @see android.net.Uri#normalizeScheme 9231 * @see #setDataAndTypeAndNormalize 9232 */ setDataAndType(@ullable Uri data, @Nullable String type)9233 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) { 9234 mData = data; 9235 mType = type; 9236 return this; 9237 } 9238 9239 /** 9240 * (Usually optional) Normalize and set both the data Uri and an explicit 9241 * MIME data type. This method should very rarely be used -- it allows you 9242 * to override the MIME type that would ordinarily be inferred from the 9243 * data with your own type given here. 9244 * 9245 * <p>The data Uri and the MIME type are normalize using 9246 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} 9247 * before they are set, so really this is just a convenience method for 9248 * <pre> 9249 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) 9250 * </pre> 9251 * 9252 * @param data The Uri of the data this intent is now targeting. 9253 * @param type The MIME type of the data being handled by this intent. 9254 * 9255 * @return Returns the same Intent object, for chaining multiple calls 9256 * into a single statement. 9257 * 9258 * @see #setType 9259 * @see #setData 9260 * @see #setDataAndType 9261 * @see #normalizeMimeType 9262 * @see android.net.Uri#normalizeScheme 9263 */ setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)9264 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) { 9265 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); 9266 } 9267 9268 /** 9269 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent, 9270 * allowing it to be unique from other Intents that would otherwise look the same. In 9271 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two 9272 * Intents are the same as with other fields like {@link #setAction}. However, unlike those 9273 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter}; 9274 * it is as if the identifier has not been set on the Intent. 9275 * 9276 * <p>This can be used, for example, to make this Intent unique from other Intents that 9277 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware 9278 * however that the receiver of the PendingIntent will see whatever you put in here.) The 9279 * structure of this string is completely undefined by the platform, however if you are going 9280 * to be exposing identifier strings across different applications you may need to define 9281 * your own structure if there is no central party defining the contents of this field.</p> 9282 * 9283 * @param identifier The identifier for this Intent. The contents of the string have no 9284 * meaning to the system, except whether they are exactly the same as 9285 * another identifier. 9286 * 9287 * @return Returns the same Intent object, for chaining multiple calls 9288 * into a single statement. 9289 * 9290 * @see #getIdentifier 9291 */ setIdentifier(@ullable String identifier)9292 public @NonNull Intent setIdentifier(@Nullable String identifier) { 9293 mIdentifier = identifier; 9294 return this; 9295 } 9296 9297 /** 9298 * Add a new category to the intent. Categories provide additional detail 9299 * about the action the intent performs. When resolving an intent, only 9300 * activities that provide <em>all</em> of the requested categories will be 9301 * used. 9302 * 9303 * @param category The desired category. This can be either one of the 9304 * predefined Intent categories, or a custom category in your own 9305 * namespace. 9306 * 9307 * @return Returns the same Intent object, for chaining multiple calls 9308 * into a single statement. 9309 * 9310 * @see #hasCategory 9311 * @see #removeCategory 9312 */ addCategory(String category)9313 public @NonNull Intent addCategory(String category) { 9314 if (mCategories == null) { 9315 mCategories = new ArraySet<String>(); 9316 } 9317 mCategories.add(category.intern()); 9318 return this; 9319 } 9320 9321 /** 9322 * Remove a category from an intent. 9323 * 9324 * @param category The category to remove. 9325 * 9326 * @see #addCategory 9327 */ removeCategory(String category)9328 public void removeCategory(String category) { 9329 if (mCategories != null) { 9330 mCategories.remove(category); 9331 if (mCategories.size() == 0) { 9332 mCategories = null; 9333 } 9334 } 9335 } 9336 9337 /** 9338 * Set a selector for this Intent. This is a modification to the kinds of 9339 * things the Intent will match. If the selector is set, it will be used 9340 * when trying to find entities that can handle the Intent, instead of the 9341 * main contents of the Intent. This allows you build an Intent containing 9342 * a generic protocol while targeting it more specifically. 9343 * 9344 * <p>An example of where this may be used is with things like 9345 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an 9346 * Intent that will launch the Browser application. However, the correct 9347 * main entry point of an application is actually {@link #ACTION_MAIN} 9348 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} 9349 * used to specify the actual Activity to launch. If you launch the browser 9350 * with something different, undesired behavior may happen if the user has 9351 * previously or later launches it the normal way, since they do not match. 9352 * Instead, you can build an Intent with the MAIN action (but no ComponentName 9353 * yet specified) and set a selector with {@link #ACTION_MAIN} and 9354 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. 9355 * 9356 * <p>Setting a selector does not impact the behavior of 9357 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the 9358 * desired behavior of a selector -- it does not impact the base meaning 9359 * of the Intent, just what kinds of things will be matched against it 9360 * when determining who can handle it.</p> 9361 * 9362 * <p>You can not use both a selector and {@link #setPackage(String)} on 9363 * the same base Intent.</p> 9364 * 9365 * @param selector The desired selector Intent; set to null to not use 9366 * a special selector. 9367 */ setSelector(@ullable Intent selector)9368 public void setSelector(@Nullable Intent selector) { 9369 if (selector == this) { 9370 throw new IllegalArgumentException( 9371 "Intent being set as a selector of itself"); 9372 } 9373 if (selector != null && mPackage != null) { 9374 throw new IllegalArgumentException( 9375 "Can't set selector when package name is already set"); 9376 } 9377 mSelector = selector; 9378 } 9379 9380 /** 9381 * Set a {@link ClipData} associated with this Intent. This replaces any 9382 * previously set ClipData. 9383 * 9384 * <p>The ClipData in an intent is not used for Intent matching or other 9385 * such operations. Semantically it is like extras, used to transmit 9386 * additional data with the Intent. The main feature of using this over 9387 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} 9388 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI 9389 * items included in the clip data. This is useful, in particular, if 9390 * you want to transmit an Intent containing multiple <code>content:</code> 9391 * URIs for which the recipient may not have global permission to access the 9392 * content provider. 9393 * 9394 * <p>If the ClipData contains items that are themselves Intents, any 9395 * grant flags in those Intents will be ignored. Only the top-level flags 9396 * of the main Intent are respected, and will be applied to all Uri or 9397 * Intent items in the clip (or sub-items of the clip). 9398 * 9399 * <p>The MIME type, label, and icon in the ClipData object are not 9400 * directly used by Intent. Applications should generally rely on the 9401 * MIME type of the Intent itself, not what it may find in the ClipData. 9402 * A common practice is to construct a ClipData for use with an Intent 9403 * with a MIME type of "*/*". 9404 * 9405 * @param clip The new clip to set. May be null to clear the current clip. 9406 */ setClipData(@ullable ClipData clip)9407 public void setClipData(@Nullable ClipData clip) { 9408 mClipData = clip; 9409 } 9410 9411 /** 9412 * This is NOT a secure mechanism to identify the user who sent the intent. 9413 * When the intent is sent to a different user, it is used to fix uris by adding the userId 9414 * who sent the intent. 9415 * @hide 9416 */ prepareToLeaveUser(int userId)9417 public void prepareToLeaveUser(int userId) { 9418 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. 9419 // We want mContentUserHint to refer to the original user, so don't do anything. 9420 if (mContentUserHint == UserHandle.USER_CURRENT) { 9421 mContentUserHint = userId; 9422 } 9423 } 9424 9425 /** 9426 * Add extended data to the intent. The name must include a package 9427 * prefix, for example the app com.android.contacts would use names 9428 * like "com.android.contacts.ShowAll". 9429 * 9430 * @param name The name of the extra data, with package prefix. 9431 * @param value The boolean data value. 9432 * 9433 * @return Returns the same Intent object, for chaining multiple calls 9434 * into a single statement. 9435 * 9436 * @see #putExtras 9437 * @see #removeExtra 9438 * @see #getBooleanExtra(String, boolean) 9439 */ putExtra(String name, boolean value)9440 public @NonNull Intent putExtra(String name, boolean value) { 9441 if (mExtras == null) { 9442 mExtras = new Bundle(); 9443 } 9444 mExtras.putBoolean(name, value); 9445 return this; 9446 } 9447 9448 /** 9449 * Add extended data to the intent. The name must include a package 9450 * prefix, for example the app com.android.contacts would use names 9451 * like "com.android.contacts.ShowAll". 9452 * 9453 * @param name The name of the extra data, with package prefix. 9454 * @param value The byte data value. 9455 * 9456 * @return Returns the same Intent object, for chaining multiple calls 9457 * into a single statement. 9458 * 9459 * @see #putExtras 9460 * @see #removeExtra 9461 * @see #getByteExtra(String, byte) 9462 */ putExtra(String name, byte value)9463 public @NonNull Intent putExtra(String name, byte value) { 9464 if (mExtras == null) { 9465 mExtras = new Bundle(); 9466 } 9467 mExtras.putByte(name, value); 9468 return this; 9469 } 9470 9471 /** 9472 * Add extended data to the intent. The name must include a package 9473 * prefix, for example the app com.android.contacts would use names 9474 * like "com.android.contacts.ShowAll". 9475 * 9476 * @param name The name of the extra data, with package prefix. 9477 * @param value The char data value. 9478 * 9479 * @return Returns the same Intent object, for chaining multiple calls 9480 * into a single statement. 9481 * 9482 * @see #putExtras 9483 * @see #removeExtra 9484 * @see #getCharExtra(String, char) 9485 */ putExtra(String name, char value)9486 public @NonNull Intent putExtra(String name, char value) { 9487 if (mExtras == null) { 9488 mExtras = new Bundle(); 9489 } 9490 mExtras.putChar(name, value); 9491 return this; 9492 } 9493 9494 /** 9495 * Add extended data to the intent. The name must include a package 9496 * prefix, for example the app com.android.contacts would use names 9497 * like "com.android.contacts.ShowAll". 9498 * 9499 * @param name The name of the extra data, with package prefix. 9500 * @param value The short data value. 9501 * 9502 * @return Returns the same Intent object, for chaining multiple calls 9503 * into a single statement. 9504 * 9505 * @see #putExtras 9506 * @see #removeExtra 9507 * @see #getShortExtra(String, short) 9508 */ putExtra(String name, short value)9509 public @NonNull Intent putExtra(String name, short value) { 9510 if (mExtras == null) { 9511 mExtras = new Bundle(); 9512 } 9513 mExtras.putShort(name, value); 9514 return this; 9515 } 9516 9517 /** 9518 * Add extended data to the intent. The name must include a package 9519 * prefix, for example the app com.android.contacts would use names 9520 * like "com.android.contacts.ShowAll". 9521 * 9522 * @param name The name of the extra data, with package prefix. 9523 * @param value The integer data value. 9524 * 9525 * @return Returns the same Intent object, for chaining multiple calls 9526 * into a single statement. 9527 * 9528 * @see #putExtras 9529 * @see #removeExtra 9530 * @see #getIntExtra(String, int) 9531 */ putExtra(String name, int value)9532 public @NonNull Intent putExtra(String name, int value) { 9533 if (mExtras == null) { 9534 mExtras = new Bundle(); 9535 } 9536 mExtras.putInt(name, value); 9537 return this; 9538 } 9539 9540 /** 9541 * Add extended data to the intent. The name must include a package 9542 * prefix, for example the app com.android.contacts would use names 9543 * like "com.android.contacts.ShowAll". 9544 * 9545 * @param name The name of the extra data, with package prefix. 9546 * @param value The long data value. 9547 * 9548 * @return Returns the same Intent object, for chaining multiple calls 9549 * into a single statement. 9550 * 9551 * @see #putExtras 9552 * @see #removeExtra 9553 * @see #getLongExtra(String, long) 9554 */ putExtra(String name, long value)9555 public @NonNull Intent putExtra(String name, long value) { 9556 if (mExtras == null) { 9557 mExtras = new Bundle(); 9558 } 9559 mExtras.putLong(name, value); 9560 return this; 9561 } 9562 9563 /** 9564 * Add extended data to the intent. The name must include a package 9565 * prefix, for example the app com.android.contacts would use names 9566 * like "com.android.contacts.ShowAll". 9567 * 9568 * @param name The name of the extra data, with package prefix. 9569 * @param value The float data value. 9570 * 9571 * @return Returns the same Intent object, for chaining multiple calls 9572 * into a single statement. 9573 * 9574 * @see #putExtras 9575 * @see #removeExtra 9576 * @see #getFloatExtra(String, float) 9577 */ putExtra(String name, float value)9578 public @NonNull Intent putExtra(String name, float value) { 9579 if (mExtras == null) { 9580 mExtras = new Bundle(); 9581 } 9582 mExtras.putFloat(name, value); 9583 return this; 9584 } 9585 9586 /** 9587 * Add extended data to the intent. The name must include a package 9588 * prefix, for example the app com.android.contacts would use names 9589 * like "com.android.contacts.ShowAll". 9590 * 9591 * @param name The name of the extra data, with package prefix. 9592 * @param value The double data value. 9593 * 9594 * @return Returns the same Intent object, for chaining multiple calls 9595 * into a single statement. 9596 * 9597 * @see #putExtras 9598 * @see #removeExtra 9599 * @see #getDoubleExtra(String, double) 9600 */ putExtra(String name, double value)9601 public @NonNull Intent putExtra(String name, double value) { 9602 if (mExtras == null) { 9603 mExtras = new Bundle(); 9604 } 9605 mExtras.putDouble(name, value); 9606 return this; 9607 } 9608 9609 /** 9610 * Add extended data to the intent. The name must include a package 9611 * prefix, for example the app com.android.contacts would use names 9612 * like "com.android.contacts.ShowAll". 9613 * 9614 * @param name The name of the extra data, with package prefix. 9615 * @param value The String data value. 9616 * 9617 * @return Returns the same Intent object, for chaining multiple calls 9618 * into a single statement. 9619 * 9620 * @see #putExtras 9621 * @see #removeExtra 9622 * @see #getStringExtra(String) 9623 */ putExtra(String name, @Nullable String value)9624 public @NonNull Intent putExtra(String name, @Nullable String value) { 9625 if (mExtras == null) { 9626 mExtras = new Bundle(); 9627 } 9628 mExtras.putString(name, value); 9629 return this; 9630 } 9631 9632 /** 9633 * Add extended data to the intent. The name must include a package 9634 * prefix, for example the app com.android.contacts would use names 9635 * like "com.android.contacts.ShowAll". 9636 * 9637 * @param name The name of the extra data, with package prefix. 9638 * @param value The CharSequence data value. 9639 * 9640 * @return Returns the same Intent object, for chaining multiple calls 9641 * into a single statement. 9642 * 9643 * @see #putExtras 9644 * @see #removeExtra 9645 * @see #getCharSequenceExtra(String) 9646 */ putExtra(String name, @Nullable CharSequence value)9647 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) { 9648 if (mExtras == null) { 9649 mExtras = new Bundle(); 9650 } 9651 mExtras.putCharSequence(name, value); 9652 return this; 9653 } 9654 9655 /** 9656 * Add extended data to the intent. The name must include a package 9657 * prefix, for example the app com.android.contacts would use names 9658 * like "com.android.contacts.ShowAll". 9659 * 9660 * @param name The name of the extra data, with package prefix. 9661 * @param value The Parcelable data value. 9662 * 9663 * @return Returns the same Intent object, for chaining multiple calls 9664 * into a single statement. 9665 * 9666 * @see #putExtras 9667 * @see #removeExtra 9668 * @see #getParcelableExtra(String) 9669 */ putExtra(String name, @Nullable Parcelable value)9670 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) { 9671 if (mExtras == null) { 9672 mExtras = new Bundle(); 9673 } 9674 mExtras.putParcelable(name, value); 9675 return this; 9676 } 9677 9678 /** 9679 * Add extended data to the intent. The name must include a package 9680 * prefix, for example the app com.android.contacts would use names 9681 * like "com.android.contacts.ShowAll". 9682 * 9683 * @param name The name of the extra data, with package prefix. 9684 * @param value The Parcelable[] data value. 9685 * 9686 * @return Returns the same Intent object, for chaining multiple calls 9687 * into a single statement. 9688 * 9689 * @see #putExtras 9690 * @see #removeExtra 9691 * @see #getParcelableArrayExtra(String) 9692 */ putExtra(String name, @Nullable Parcelable[] value)9693 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) { 9694 if (mExtras == null) { 9695 mExtras = new Bundle(); 9696 } 9697 mExtras.putParcelableArray(name, value); 9698 return this; 9699 } 9700 9701 /** 9702 * Add extended data to the intent. The name must include a package 9703 * prefix, for example the app com.android.contacts would use names 9704 * like "com.android.contacts.ShowAll". 9705 * 9706 * @param name The name of the extra data, with package prefix. 9707 * @param value The ArrayList<Parcelable> data value. 9708 * 9709 * @return Returns the same Intent object, for chaining multiple calls 9710 * into a single statement. 9711 * 9712 * @see #putExtras 9713 * @see #removeExtra 9714 * @see #getParcelableArrayListExtra(String) 9715 */ putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)9716 public @NonNull Intent putParcelableArrayListExtra(String name, 9717 @Nullable ArrayList<? extends Parcelable> value) { 9718 if (mExtras == null) { 9719 mExtras = new Bundle(); 9720 } 9721 mExtras.putParcelableArrayList(name, value); 9722 return this; 9723 } 9724 9725 /** 9726 * Add extended data to the intent. The name must include a package 9727 * prefix, for example the app com.android.contacts would use names 9728 * like "com.android.contacts.ShowAll". 9729 * 9730 * @param name The name of the extra data, with package prefix. 9731 * @param value The ArrayList<Integer> data value. 9732 * 9733 * @return Returns the same Intent object, for chaining multiple calls 9734 * into a single statement. 9735 * 9736 * @see #putExtras 9737 * @see #removeExtra 9738 * @see #getIntegerArrayListExtra(String) 9739 */ putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)9740 public @NonNull Intent putIntegerArrayListExtra(String name, 9741 @Nullable ArrayList<Integer> value) { 9742 if (mExtras == null) { 9743 mExtras = new Bundle(); 9744 } 9745 mExtras.putIntegerArrayList(name, value); 9746 return this; 9747 } 9748 9749 /** 9750 * Add extended data to the intent. The name must include a package 9751 * prefix, for example the app com.android.contacts would use names 9752 * like "com.android.contacts.ShowAll". 9753 * 9754 * @param name The name of the extra data, with package prefix. 9755 * @param value The ArrayList<String> data value. 9756 * 9757 * @return Returns the same Intent object, for chaining multiple calls 9758 * into a single statement. 9759 * 9760 * @see #putExtras 9761 * @see #removeExtra 9762 * @see #getStringArrayListExtra(String) 9763 */ putStringArrayListExtra(String name, @Nullable ArrayList<String> value)9764 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) { 9765 if (mExtras == null) { 9766 mExtras = new Bundle(); 9767 } 9768 mExtras.putStringArrayList(name, value); 9769 return this; 9770 } 9771 9772 /** 9773 * Add extended data to the intent. The name must include a package 9774 * prefix, for example the app com.android.contacts would use names 9775 * like "com.android.contacts.ShowAll". 9776 * 9777 * @param name The name of the extra data, with package prefix. 9778 * @param value The ArrayList<CharSequence> data value. 9779 * 9780 * @return Returns the same Intent object, for chaining multiple calls 9781 * into a single statement. 9782 * 9783 * @see #putExtras 9784 * @see #removeExtra 9785 * @see #getCharSequenceArrayListExtra(String) 9786 */ putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)9787 public @NonNull Intent putCharSequenceArrayListExtra(String name, 9788 @Nullable ArrayList<CharSequence> value) { 9789 if (mExtras == null) { 9790 mExtras = new Bundle(); 9791 } 9792 mExtras.putCharSequenceArrayList(name, value); 9793 return this; 9794 } 9795 9796 /** 9797 * Add extended data to the intent. The name must include a package 9798 * prefix, for example the app com.android.contacts would use names 9799 * like "com.android.contacts.ShowAll". 9800 * 9801 * @param name The name of the extra data, with package prefix. 9802 * @param value The Serializable data value. 9803 * 9804 * @return Returns the same Intent object, for chaining multiple calls 9805 * into a single statement. 9806 * 9807 * @see #putExtras 9808 * @see #removeExtra 9809 * @see #getSerializableExtra(String) 9810 */ putExtra(String name, @Nullable Serializable value)9811 public @NonNull Intent putExtra(String name, @Nullable Serializable value) { 9812 if (mExtras == null) { 9813 mExtras = new Bundle(); 9814 } 9815 mExtras.putSerializable(name, value); 9816 return this; 9817 } 9818 9819 /** 9820 * Add extended data to the intent. The name must include a package 9821 * prefix, for example the app com.android.contacts would use names 9822 * like "com.android.contacts.ShowAll". 9823 * 9824 * @param name The name of the extra data, with package prefix. 9825 * @param value The boolean array data value. 9826 * 9827 * @return Returns the same Intent object, for chaining multiple calls 9828 * into a single statement. 9829 * 9830 * @see #putExtras 9831 * @see #removeExtra 9832 * @see #getBooleanArrayExtra(String) 9833 */ putExtra(String name, @Nullable boolean[] value)9834 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) { 9835 if (mExtras == null) { 9836 mExtras = new Bundle(); 9837 } 9838 mExtras.putBooleanArray(name, value); 9839 return this; 9840 } 9841 9842 /** 9843 * Add extended data to the intent. The name must include a package 9844 * prefix, for example the app com.android.contacts would use names 9845 * like "com.android.contacts.ShowAll". 9846 * 9847 * @param name The name of the extra data, with package prefix. 9848 * @param value The byte array data value. 9849 * 9850 * @return Returns the same Intent object, for chaining multiple calls 9851 * into a single statement. 9852 * 9853 * @see #putExtras 9854 * @see #removeExtra 9855 * @see #getByteArrayExtra(String) 9856 */ putExtra(String name, @Nullable byte[] value)9857 public @NonNull Intent putExtra(String name, @Nullable byte[] value) { 9858 if (mExtras == null) { 9859 mExtras = new Bundle(); 9860 } 9861 mExtras.putByteArray(name, value); 9862 return this; 9863 } 9864 9865 /** 9866 * Add extended data to the intent. The name must include a package 9867 * prefix, for example the app com.android.contacts would use names 9868 * like "com.android.contacts.ShowAll". 9869 * 9870 * @param name The name of the extra data, with package prefix. 9871 * @param value The short array data value. 9872 * 9873 * @return Returns the same Intent object, for chaining multiple calls 9874 * into a single statement. 9875 * 9876 * @see #putExtras 9877 * @see #removeExtra 9878 * @see #getShortArrayExtra(String) 9879 */ putExtra(String name, @Nullable short[] value)9880 public @NonNull Intent putExtra(String name, @Nullable short[] value) { 9881 if (mExtras == null) { 9882 mExtras = new Bundle(); 9883 } 9884 mExtras.putShortArray(name, value); 9885 return this; 9886 } 9887 9888 /** 9889 * Add extended data to the intent. The name must include a package 9890 * prefix, for example the app com.android.contacts would use names 9891 * like "com.android.contacts.ShowAll". 9892 * 9893 * @param name The name of the extra data, with package prefix. 9894 * @param value The char array data value. 9895 * 9896 * @return Returns the same Intent object, for chaining multiple calls 9897 * into a single statement. 9898 * 9899 * @see #putExtras 9900 * @see #removeExtra 9901 * @see #getCharArrayExtra(String) 9902 */ putExtra(String name, @Nullable char[] value)9903 public @NonNull Intent putExtra(String name, @Nullable char[] value) { 9904 if (mExtras == null) { 9905 mExtras = new Bundle(); 9906 } 9907 mExtras.putCharArray(name, value); 9908 return this; 9909 } 9910 9911 /** 9912 * Add extended data to the intent. The name must include a package 9913 * prefix, for example the app com.android.contacts would use names 9914 * like "com.android.contacts.ShowAll". 9915 * 9916 * @param name The name of the extra data, with package prefix. 9917 * @param value The int array data value. 9918 * 9919 * @return Returns the same Intent object, for chaining multiple calls 9920 * into a single statement. 9921 * 9922 * @see #putExtras 9923 * @see #removeExtra 9924 * @see #getIntArrayExtra(String) 9925 */ putExtra(String name, @Nullable int[] value)9926 public @NonNull Intent putExtra(String name, @Nullable int[] value) { 9927 if (mExtras == null) { 9928 mExtras = new Bundle(); 9929 } 9930 mExtras.putIntArray(name, value); 9931 return this; 9932 } 9933 9934 /** 9935 * Add extended data to the intent. The name must include a package 9936 * prefix, for example the app com.android.contacts would use names 9937 * like "com.android.contacts.ShowAll". 9938 * 9939 * @param name The name of the extra data, with package prefix. 9940 * @param value The byte array data value. 9941 * 9942 * @return Returns the same Intent object, for chaining multiple calls 9943 * into a single statement. 9944 * 9945 * @see #putExtras 9946 * @see #removeExtra 9947 * @see #getLongArrayExtra(String) 9948 */ putExtra(String name, @Nullable long[] value)9949 public @NonNull Intent putExtra(String name, @Nullable long[] value) { 9950 if (mExtras == null) { 9951 mExtras = new Bundle(); 9952 } 9953 mExtras.putLongArray(name, value); 9954 return this; 9955 } 9956 9957 /** 9958 * Add extended data to the intent. The name must include a package 9959 * prefix, for example the app com.android.contacts would use names 9960 * like "com.android.contacts.ShowAll". 9961 * 9962 * @param name The name of the extra data, with package prefix. 9963 * @param value The float array data value. 9964 * 9965 * @return Returns the same Intent object, for chaining multiple calls 9966 * into a single statement. 9967 * 9968 * @see #putExtras 9969 * @see #removeExtra 9970 * @see #getFloatArrayExtra(String) 9971 */ putExtra(String name, @Nullable float[] value)9972 public @NonNull Intent putExtra(String name, @Nullable float[] value) { 9973 if (mExtras == null) { 9974 mExtras = new Bundle(); 9975 } 9976 mExtras.putFloatArray(name, value); 9977 return this; 9978 } 9979 9980 /** 9981 * Add extended data to the intent. The name must include a package 9982 * prefix, for example the app com.android.contacts would use names 9983 * like "com.android.contacts.ShowAll". 9984 * 9985 * @param name The name of the extra data, with package prefix. 9986 * @param value The double array data value. 9987 * 9988 * @return Returns the same Intent object, for chaining multiple calls 9989 * into a single statement. 9990 * 9991 * @see #putExtras 9992 * @see #removeExtra 9993 * @see #getDoubleArrayExtra(String) 9994 */ putExtra(String name, @Nullable double[] value)9995 public @NonNull Intent putExtra(String name, @Nullable double[] value) { 9996 if (mExtras == null) { 9997 mExtras = new Bundle(); 9998 } 9999 mExtras.putDoubleArray(name, value); 10000 return this; 10001 } 10002 10003 /** 10004 * Add extended data to the intent. The name must include a package 10005 * prefix, for example the app com.android.contacts would use names 10006 * like "com.android.contacts.ShowAll". 10007 * 10008 * @param name The name of the extra data, with package prefix. 10009 * @param value The String array data value. 10010 * 10011 * @return Returns the same Intent object, for chaining multiple calls 10012 * into a single statement. 10013 * 10014 * @see #putExtras 10015 * @see #removeExtra 10016 * @see #getStringArrayExtra(String) 10017 */ putExtra(String name, @Nullable String[] value)10018 public @NonNull Intent putExtra(String name, @Nullable String[] value) { 10019 if (mExtras == null) { 10020 mExtras = new Bundle(); 10021 } 10022 mExtras.putStringArray(name, value); 10023 return this; 10024 } 10025 10026 /** 10027 * Add extended data to the intent. The name must include a package 10028 * prefix, for example the app com.android.contacts would use names 10029 * like "com.android.contacts.ShowAll". 10030 * 10031 * @param name The name of the extra data, with package prefix. 10032 * @param value The CharSequence array data value. 10033 * 10034 * @return Returns the same Intent object, for chaining multiple calls 10035 * into a single statement. 10036 * 10037 * @see #putExtras 10038 * @see #removeExtra 10039 * @see #getCharSequenceArrayExtra(String) 10040 */ putExtra(String name, @Nullable CharSequence[] value)10041 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) { 10042 if (mExtras == null) { 10043 mExtras = new Bundle(); 10044 } 10045 mExtras.putCharSequenceArray(name, value); 10046 return this; 10047 } 10048 10049 /** 10050 * Add extended data to the intent. The name must include a package 10051 * prefix, for example the app com.android.contacts would use names 10052 * like "com.android.contacts.ShowAll". 10053 * 10054 * @param name The name of the extra data, with package prefix. 10055 * @param value The Bundle data value. 10056 * 10057 * @return Returns the same Intent object, for chaining multiple calls 10058 * into a single statement. 10059 * 10060 * @see #putExtras 10061 * @see #removeExtra 10062 * @see #getBundleExtra(String) 10063 */ putExtra(String name, @Nullable Bundle value)10064 public @NonNull Intent putExtra(String name, @Nullable Bundle value) { 10065 if (mExtras == null) { 10066 mExtras = new Bundle(); 10067 } 10068 mExtras.putBundle(name, value); 10069 return this; 10070 } 10071 10072 /** 10073 * Add extended data to the intent. The name must include a package 10074 * prefix, for example the app com.android.contacts would use names 10075 * like "com.android.contacts.ShowAll". 10076 * 10077 * @param name The name of the extra data, with package prefix. 10078 * @param value The IBinder data value. 10079 * 10080 * @return Returns the same Intent object, for chaining multiple calls 10081 * into a single statement. 10082 * 10083 * @see #putExtras 10084 * @see #removeExtra 10085 * @see #getIBinderExtra(String) 10086 * 10087 * @deprecated 10088 * @hide 10089 */ 10090 @Deprecated 10091 @UnsupportedAppUsage putExtra(String name, IBinder value)10092 public @NonNull Intent putExtra(String name, IBinder value) { 10093 if (mExtras == null) { 10094 mExtras = new Bundle(); 10095 } 10096 mExtras.putIBinder(name, value); 10097 return this; 10098 } 10099 10100 /** 10101 * Copy all extras in 'src' in to this intent. 10102 * 10103 * @param src Contains the extras to copy. 10104 * 10105 * @see #putExtra 10106 */ putExtras(@onNull Intent src)10107 public @NonNull Intent putExtras(@NonNull Intent src) { 10108 if (src.mExtras != null) { 10109 if (mExtras == null) { 10110 mExtras = new Bundle(src.mExtras); 10111 } else { 10112 mExtras.putAll(src.mExtras); 10113 } 10114 } 10115 // If the provided Intent was unparceled and this is not an Intent delivered to a protected 10116 // component then mark the extras as unfiltered. An Intent delivered to a protected 10117 // component had to come from a trusted component, and if unfiltered data was copied to the 10118 // delivered Intent then it would have been reported when that Intent left the sending 10119 // process. 10120 if ((src.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 10121 && (src.mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) { 10122 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 10123 } 10124 return this; 10125 } 10126 10127 /** 10128 * Add a set of extended data to the intent. The keys must include a package 10129 * prefix, for example the app com.android.contacts would use names 10130 * like "com.android.contacts.ShowAll". 10131 * 10132 * @param extras The Bundle of extras to add to this intent. 10133 * 10134 * @see #putExtra 10135 * @see #removeExtra 10136 */ putExtras(@onNull Bundle extras)10137 public @NonNull Intent putExtras(@NonNull Bundle extras) { 10138 // If the provided Bundle has not yet been unparceled then treat this as unfiltered extras. 10139 if (extras.isParcelled()) { 10140 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 10141 } 10142 if (mExtras == null) { 10143 mExtras = new Bundle(); 10144 } 10145 mExtras.putAll(extras); 10146 return this; 10147 } 10148 10149 /** 10150 * Completely replace the extras in the Intent with the extras in the 10151 * given Intent. 10152 * 10153 * @param src The exact extras contained in this Intent are copied 10154 * into the target intent, replacing any that were previously there. 10155 */ replaceExtras(@onNull Intent src)10156 public @NonNull Intent replaceExtras(@NonNull Intent src) { 10157 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; 10158 return this; 10159 } 10160 10161 /** 10162 * Completely replace the extras in the Intent with the given Bundle of 10163 * extras. 10164 * 10165 * @param extras The new set of extras in the Intent, or null to erase 10166 * all extras. 10167 */ replaceExtras(@ullable Bundle extras)10168 public @NonNull Intent replaceExtras(@Nullable Bundle extras) { 10169 mExtras = extras != null ? new Bundle(extras) : null; 10170 return this; 10171 } 10172 10173 /** 10174 * Remove extended data from the intent. 10175 * 10176 * @see #putExtra 10177 */ removeExtra(String name)10178 public void removeExtra(String name) { 10179 if (mExtras != null) { 10180 mExtras.remove(name); 10181 if (mExtras.size() == 0) { 10182 mExtras = null; 10183 } 10184 } 10185 } 10186 10187 /** 10188 * Set special flags controlling how this intent is handled. Most values 10189 * here depend on the type of component being executed by the Intent, 10190 * specifically the FLAG_ACTIVITY_* flags are all for use with 10191 * {@link Context#startActivity Context.startActivity()} and the 10192 * FLAG_RECEIVER_* flags are all for use with 10193 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. 10194 * 10195 * <p>See the 10196 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 10197 * Stack</a> documentation for important information on how some of these options impact 10198 * the behavior of your application. 10199 * 10200 * @param flags The desired flags. 10201 * @return Returns the same Intent object, for chaining multiple calls 10202 * into a single statement. 10203 * @see #getFlags 10204 * @see #addFlags 10205 * @see #removeFlags 10206 */ setFlags(@lags int flags)10207 public @NonNull Intent setFlags(@Flags int flags) { 10208 mFlags = flags; 10209 return this; 10210 } 10211 10212 /** 10213 * Add additional flags to the intent (or with existing flags value). 10214 * 10215 * @param flags The new flags to set. 10216 * @return Returns the same Intent object, for chaining multiple calls into 10217 * a single statement. 10218 * @see #setFlags 10219 * @see #getFlags 10220 * @see #removeFlags 10221 */ addFlags(@lags int flags)10222 public @NonNull Intent addFlags(@Flags int flags) { 10223 mFlags |= flags; 10224 return this; 10225 } 10226 10227 /** 10228 * Remove these flags from the intent. 10229 * 10230 * @param flags The flags to remove. 10231 * @see #setFlags 10232 * @see #getFlags 10233 * @see #addFlags 10234 */ removeFlags(@lags int flags)10235 public void removeFlags(@Flags int flags) { 10236 mFlags &= ~flags; 10237 } 10238 10239 /** 10240 * (Usually optional) Set an explicit application package name that limits 10241 * the components this Intent will resolve to. If left to the default 10242 * value of null, all components in all applications will considered. 10243 * If non-null, the Intent can only match the components in the given 10244 * application package. 10245 * 10246 * @param packageName The name of the application package to handle the 10247 * intent, or null to allow any application package. 10248 * 10249 * @return Returns the same Intent object, for chaining multiple calls 10250 * into a single statement. 10251 * 10252 * @see #getPackage 10253 * @see #resolveActivity 10254 */ setPackage(@ullable String packageName)10255 public @NonNull Intent setPackage(@Nullable String packageName) { 10256 if (packageName != null && mSelector != null) { 10257 throw new IllegalArgumentException( 10258 "Can't set package name when selector is already set"); 10259 } 10260 mPackage = packageName; 10261 return this; 10262 } 10263 10264 /** 10265 * (Usually optional) Explicitly set the component to handle the intent. 10266 * If left with the default value of null, the system will determine the 10267 * appropriate class to use based on the other fields (action, data, 10268 * type, categories) in the Intent. If this class is defined, the 10269 * specified class will always be used regardless of the other fields. You 10270 * should only set this value when you know you absolutely want a specific 10271 * class to be used; otherwise it is better to let the system find the 10272 * appropriate class so that you will respect the installed applications 10273 * and user preferences. 10274 * 10275 * @param component The name of the application component to handle the 10276 * intent, or null to let the system find one for you. 10277 * 10278 * @return Returns the same Intent object, for chaining multiple calls 10279 * into a single statement. 10280 * 10281 * @see #setClass 10282 * @see #setClassName(Context, String) 10283 * @see #setClassName(String, String) 10284 * @see #getComponent 10285 * @see #resolveActivity 10286 */ setComponent(@ullable ComponentName component)10287 public @NonNull Intent setComponent(@Nullable ComponentName component) { 10288 mComponent = component; 10289 return this; 10290 } 10291 10292 /** 10293 * Convenience for calling {@link #setComponent} with an 10294 * explicit class name. 10295 * 10296 * @param packageContext A Context of the application package implementing 10297 * this class. 10298 * @param className The name of a class inside of the application package 10299 * that will be used as the component for this Intent. 10300 * 10301 * @return Returns the same Intent object, for chaining multiple calls 10302 * into a single statement. 10303 * 10304 * @see #setComponent 10305 * @see #setClass 10306 */ setClassName(@onNull Context packageContext, @NonNull String className)10307 public @NonNull Intent setClassName(@NonNull Context packageContext, 10308 @NonNull String className) { 10309 mComponent = new ComponentName(packageContext, className); 10310 return this; 10311 } 10312 10313 /** 10314 * Convenience for calling {@link #setComponent} with an 10315 * explicit application package name and class name. 10316 * 10317 * @param packageName The name of the package implementing the desired 10318 * component. 10319 * @param className The name of a class inside of the application package 10320 * that will be used as the component for this Intent. 10321 * 10322 * @return Returns the same Intent object, for chaining multiple calls 10323 * into a single statement. 10324 * 10325 * @see #setComponent 10326 * @see #setClass 10327 */ setClassName(@onNull String packageName, @NonNull String className)10328 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) { 10329 mComponent = new ComponentName(packageName, className); 10330 return this; 10331 } 10332 10333 /** 10334 * Convenience for calling {@link #setComponent(ComponentName)} with the 10335 * name returned by a {@link Class} object. 10336 * 10337 * @param packageContext A Context of the application package implementing 10338 * this class. 10339 * @param cls The class name to set, equivalent to 10340 * <code>setClassName(context, cls.getName())</code>. 10341 * 10342 * @return Returns the same Intent object, for chaining multiple calls 10343 * into a single statement. 10344 * 10345 * @see #setComponent 10346 */ setClass(@onNull Context packageContext, @NonNull Class<?> cls)10347 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) { 10348 mComponent = new ComponentName(packageContext, cls); 10349 return this; 10350 } 10351 10352 /** 10353 * Set the bounds of the sender of this intent, in screen coordinates. This can be 10354 * used as a hint to the receiver for animations and the like. Null means that there 10355 * is no source bounds. 10356 */ setSourceBounds(@ullable Rect r)10357 public void setSourceBounds(@Nullable Rect r) { 10358 if (r != null) { 10359 mSourceBounds = new Rect(r); 10360 } else { 10361 mSourceBounds = null; 10362 } 10363 } 10364 10365 /** @hide */ 10366 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = { 10367 FILL_IN_ACTION, 10368 FILL_IN_DATA, 10369 FILL_IN_CATEGORIES, 10370 FILL_IN_COMPONENT, 10371 FILL_IN_PACKAGE, 10372 FILL_IN_SOURCE_BOUNDS, 10373 FILL_IN_SELECTOR, 10374 FILL_IN_CLIP_DATA 10375 }) 10376 @Retention(RetentionPolicy.SOURCE) 10377 public @interface FillInFlags {} 10378 10379 /** 10380 * Use with {@link #fillIn} to allow the current action value to be 10381 * overwritten, even if it is already set. 10382 */ 10383 public static final int FILL_IN_ACTION = 1<<0; 10384 10385 /** 10386 * Use with {@link #fillIn} to allow the current data or type value 10387 * overwritten, even if it is already set. 10388 */ 10389 public static final int FILL_IN_DATA = 1<<1; 10390 10391 /** 10392 * Use with {@link #fillIn} to allow the current categories to be 10393 * overwritten, even if they are already set. 10394 */ 10395 public static final int FILL_IN_CATEGORIES = 1<<2; 10396 10397 /** 10398 * Use with {@link #fillIn} to allow the current component value to be 10399 * overwritten, even if it is already set. 10400 */ 10401 public static final int FILL_IN_COMPONENT = 1<<3; 10402 10403 /** 10404 * Use with {@link #fillIn} to allow the current package value to be 10405 * overwritten, even if it is already set. 10406 */ 10407 public static final int FILL_IN_PACKAGE = 1<<4; 10408 10409 /** 10410 * Use with {@link #fillIn} to allow the current bounds rectangle to be 10411 * overwritten, even if it is already set. 10412 */ 10413 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; 10414 10415 /** 10416 * Use with {@link #fillIn} to allow the current selector to be 10417 * overwritten, even if it is already set. 10418 */ 10419 public static final int FILL_IN_SELECTOR = 1<<6; 10420 10421 /** 10422 * Use with {@link #fillIn} to allow the current ClipData to be 10423 * overwritten, even if it is already set. 10424 */ 10425 public static final int FILL_IN_CLIP_DATA = 1<<7; 10426 10427 /** 10428 * Use with {@link #fillIn} to allow the current identifier value to be 10429 * overwritten, even if it is already set. 10430 */ 10431 public static final int FILL_IN_IDENTIFIER = 1<<8; 10432 10433 /** 10434 * Copy the contents of <var>other</var> in to this object, but only 10435 * where fields are not defined by this object. For purposes of a field 10436 * being defined, the following pieces of data in the Intent are 10437 * considered to be separate fields: 10438 * 10439 * <ul> 10440 * <li> action, as set by {@link #setAction}. 10441 * <li> data Uri and MIME type, as set by {@link #setData(Uri)}, 10442 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. 10443 * <li> identifier, as set by {@link #setIdentifier}. 10444 * <li> categories, as set by {@link #addCategory}. 10445 * <li> package, as set by {@link #setPackage}. 10446 * <li> component, as set by {@link #setComponent(ComponentName)} or 10447 * related methods. 10448 * <li> source bounds, as set by {@link #setSourceBounds}. 10449 * <li> selector, as set by {@link #setSelector(Intent)}. 10450 * <li> clip data, as set by {@link #setClipData(ClipData)}. 10451 * <li> each top-level name in the associated extras. 10452 * </ul> 10453 * 10454 * <p>In addition, you can use the {@link #FILL_IN_ACTION}, 10455 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES}, 10456 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 10457 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override 10458 * the restriction where the corresponding field will not be replaced if 10459 * it is already set. 10460 * 10461 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} 10462 * is explicitly specified. The selector will only be copied if 10463 * {@link #FILL_IN_SELECTOR} is explicitly specified. 10464 * 10465 * <p>For example, consider Intent A with {data="foo", categories="bar"} 10466 * and Intent B with {action="gotit", data-type="some/thing", 10467 * categories="one","two"}. 10468 * 10469 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now 10470 * containing: {action="gotit", data-type="some/thing", 10471 * categories="bar"}. 10472 * 10473 * @param other Another Intent whose values are to be used to fill in 10474 * the current one. 10475 * @param flags Options to control which fields can be filled in. 10476 * 10477 * @return Returns a bit mask of {@link #FILL_IN_ACTION}, 10478 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 10479 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 10480 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were 10481 * changed. 10482 */ 10483 @FillInFlags fillIn(@onNull Intent other, @FillInFlags int flags)10484 public int fillIn(@NonNull Intent other, @FillInFlags int flags) { 10485 int changes = 0; 10486 boolean mayHaveCopiedUris = false; 10487 if (other.mAction != null 10488 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { 10489 mAction = other.mAction; 10490 changes |= FILL_IN_ACTION; 10491 } 10492 if ((other.mData != null || other.mType != null) 10493 && ((mData == null && mType == null) 10494 || (flags&FILL_IN_DATA) != 0)) { 10495 mData = other.mData; 10496 mType = other.mType; 10497 changes |= FILL_IN_DATA; 10498 mayHaveCopiedUris = true; 10499 } 10500 if (other.mIdentifier != null 10501 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) { 10502 mIdentifier = other.mIdentifier; 10503 changes |= FILL_IN_IDENTIFIER; 10504 } 10505 if (other.mCategories != null 10506 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { 10507 if (other.mCategories != null) { 10508 mCategories = new ArraySet<String>(other.mCategories); 10509 } 10510 changes |= FILL_IN_CATEGORIES; 10511 } 10512 if (other.mPackage != null 10513 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { 10514 // Only do this if mSelector is not set. 10515 if (mSelector == null) { 10516 mPackage = other.mPackage; 10517 changes |= FILL_IN_PACKAGE; 10518 } 10519 } 10520 // Selector is special: it can only be set if explicitly allowed, 10521 // for the same reason as the component name. 10522 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { 10523 if (mPackage == null) { 10524 mSelector = new Intent(other.mSelector); 10525 mPackage = null; 10526 changes |= FILL_IN_SELECTOR; 10527 } 10528 } 10529 if (other.mClipData != null 10530 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { 10531 mClipData = other.mClipData; 10532 changes |= FILL_IN_CLIP_DATA; 10533 mayHaveCopiedUris = true; 10534 } 10535 // Component is special: it can -only- be set if explicitly allowed, 10536 // since otherwise the sender could force the intent somewhere the 10537 // originator didn't intend. 10538 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { 10539 mComponent = other.mComponent; 10540 changes |= FILL_IN_COMPONENT; 10541 } 10542 mFlags |= other.mFlags; 10543 if (other.mSourceBounds != null 10544 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { 10545 mSourceBounds = new Rect(other.mSourceBounds); 10546 changes |= FILL_IN_SOURCE_BOUNDS; 10547 } 10548 if (mExtras == null) { 10549 if (other.mExtras != null) { 10550 mExtras = new Bundle(other.mExtras); 10551 mayHaveCopiedUris = true; 10552 } 10553 } else if (other.mExtras != null) { 10554 try { 10555 Bundle newb = new Bundle(other.mExtras); 10556 newb.putAll(mExtras); 10557 mExtras = newb; 10558 mayHaveCopiedUris = true; 10559 } catch (RuntimeException e) { 10560 // Modifying the extras can cause us to unparcel the contents 10561 // of the bundle, and if we do this in the system process that 10562 // may fail. We really should handle this (i.e., the Bundle 10563 // impl shouldn't be on top of a plain map), but for now just 10564 // ignore it and keep the original contents. :( 10565 Log.w(TAG, "Failure filling in extras", e); 10566 } 10567 } 10568 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT 10569 && other.mContentUserHint != UserHandle.USER_CURRENT) { 10570 mContentUserHint = other.mContentUserHint; 10571 } 10572 return changes; 10573 } 10574 10575 /** 10576 * Wrapper class holding an Intent and implementing comparisons on it for 10577 * the purpose of filtering. The class implements its 10578 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as 10579 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and 10580 * {@link android.content.Intent#filterHashCode()} filterHashCode()} 10581 * on the wrapped Intent. 10582 */ 10583 public static final class FilterComparison { 10584 private final Intent mIntent; 10585 private final int mHashCode; 10586 FilterComparison(Intent intent)10587 public FilterComparison(Intent intent) { 10588 mIntent = intent; 10589 mHashCode = intent.filterHashCode(); 10590 } 10591 10592 /** 10593 * Return the Intent that this FilterComparison represents. 10594 * @return Returns the Intent held by the FilterComparison. Do 10595 * not modify! 10596 */ getIntent()10597 public Intent getIntent() { 10598 return mIntent; 10599 } 10600 10601 @Override equals(@ullable Object obj)10602 public boolean equals(@Nullable Object obj) { 10603 if (obj instanceof FilterComparison) { 10604 Intent other = ((FilterComparison)obj).mIntent; 10605 return mIntent.filterEquals(other); 10606 } 10607 return false; 10608 } 10609 10610 @Override hashCode()10611 public int hashCode() { 10612 return mHashCode; 10613 } 10614 } 10615 10616 /** 10617 * Determine if two intents are the same for the purposes of intent 10618 * resolution (filtering). That is, if their action, data, type, identity, 10619 * class, and categories are the same. This does <em>not</em> compare 10620 * any extra data included in the intents. Note that technically when actually 10621 * matching against an {@link IntentFilter} the identifier is ignored, while here 10622 * it is directly compared for equality like the other fields. 10623 * 10624 * @param other The other Intent to compare against. 10625 * 10626 * @return Returns true if action, data, type, class, and categories 10627 * are the same. 10628 */ filterEquals(Intent other)10629 public boolean filterEquals(Intent other) { 10630 if (other == null) { 10631 return false; 10632 } 10633 if (!Objects.equals(this.mAction, other.mAction)) return false; 10634 if (!Objects.equals(this.mData, other.mData)) return false; 10635 if (!Objects.equals(this.mType, other.mType)) return false; 10636 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false; 10637 if (!(this.hasPackageEquivalentComponent() && other.hasPackageEquivalentComponent()) 10638 && !Objects.equals(this.mPackage, other.mPackage)) { 10639 return false; 10640 } 10641 if (!Objects.equals(this.mComponent, other.mComponent)) return false; 10642 if (!Objects.equals(this.mCategories, other.mCategories)) return false; 10643 10644 return true; 10645 } 10646 10647 /** 10648 * Return {@code true} if the component name is not null and is in the same package that this 10649 * intent limited to. otherwise return {@code false}. 10650 */ hasPackageEquivalentComponent()10651 private boolean hasPackageEquivalentComponent() { 10652 return mComponent != null 10653 && (mPackage == null || mPackage.equals(mComponent.getPackageName())); 10654 } 10655 10656 /** 10657 * Generate hash code that matches semantics of filterEquals(). 10658 * 10659 * @return Returns the hash value of the action, data, type, class, and 10660 * categories. 10661 * 10662 * @see #filterEquals 10663 */ filterHashCode()10664 public int filterHashCode() { 10665 int code = 0; 10666 if (mAction != null) { 10667 code += mAction.hashCode(); 10668 } 10669 if (mData != null) { 10670 code += mData.hashCode(); 10671 } 10672 if (mType != null) { 10673 code += mType.hashCode(); 10674 } 10675 if (mIdentifier != null) { 10676 code += mIdentifier.hashCode(); 10677 } 10678 if (mPackage != null) { 10679 code += mPackage.hashCode(); 10680 } 10681 if (mComponent != null) { 10682 code += mComponent.hashCode(); 10683 } 10684 if (mCategories != null) { 10685 code += mCategories.hashCode(); 10686 } 10687 return code; 10688 } 10689 10690 @Override toString()10691 public String toString() { 10692 StringBuilder b = new StringBuilder(128); 10693 10694 b.append("Intent { "); 10695 toShortString(b, true, true, true, false); 10696 b.append(" }"); 10697 10698 return b.toString(); 10699 } 10700 10701 /** @hide */ 10702 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) toInsecureString()10703 public String toInsecureString() { 10704 StringBuilder b = new StringBuilder(128); 10705 10706 b.append("Intent { "); 10707 toShortString(b, false, true, true, false); 10708 b.append(" }"); 10709 10710 return b.toString(); 10711 } 10712 10713 /** @hide */ toShortString(boolean secure, boolean comp, boolean extras, boolean clip)10714 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { 10715 StringBuilder b = new StringBuilder(128); 10716 toShortString(b, secure, comp, extras, clip); 10717 return b.toString(); 10718 } 10719 10720 /** @hide */ toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)10721 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, 10722 boolean clip) { 10723 boolean first = true; 10724 if (mAction != null) { 10725 b.append("act=").append(mAction); 10726 first = false; 10727 } 10728 if (mCategories != null) { 10729 if (!first) { 10730 b.append(' '); 10731 } 10732 first = false; 10733 b.append("cat=["); 10734 for (int i=0; i<mCategories.size(); i++) { 10735 if (i > 0) b.append(','); 10736 b.append(mCategories.valueAt(i)); 10737 } 10738 b.append("]"); 10739 } 10740 if (mData != null) { 10741 if (!first) { 10742 b.append(' '); 10743 } 10744 first = false; 10745 b.append("dat="); 10746 if (secure) { 10747 b.append(mData.toSafeString()); 10748 } else { 10749 b.append(mData); 10750 } 10751 } 10752 if (mType != null) { 10753 if (!first) { 10754 b.append(' '); 10755 } 10756 first = false; 10757 b.append("typ=").append(mType); 10758 } 10759 if (mIdentifier != null) { 10760 if (!first) { 10761 b.append(' '); 10762 } 10763 first = false; 10764 b.append("id=").append(mIdentifier); 10765 } 10766 if (mFlags != 0) { 10767 if (!first) { 10768 b.append(' '); 10769 } 10770 first = false; 10771 b.append("flg=0x").append(Integer.toHexString(mFlags)); 10772 } 10773 if (mPackage != null) { 10774 if (!first) { 10775 b.append(' '); 10776 } 10777 first = false; 10778 b.append("pkg=").append(mPackage); 10779 } 10780 if (comp && mComponent != null) { 10781 if (!first) { 10782 b.append(' '); 10783 } 10784 first = false; 10785 b.append("cmp=").append(mComponent.flattenToShortString()); 10786 } 10787 if (mSourceBounds != null) { 10788 if (!first) { 10789 b.append(' '); 10790 } 10791 first = false; 10792 b.append("bnds=").append(mSourceBounds.toShortString()); 10793 } 10794 if (mClipData != null) { 10795 if (!first) { 10796 b.append(' '); 10797 } 10798 b.append("clip={"); 10799 mClipData.toShortString(b, !clip || secure); 10800 first = false; 10801 b.append('}'); 10802 } 10803 if (extras && mExtras != null) { 10804 if (!first) { 10805 b.append(' '); 10806 } 10807 first = false; 10808 b.append("(has extras)"); 10809 } 10810 if (mContentUserHint != UserHandle.USER_CURRENT) { 10811 if (!first) { 10812 b.append(' '); 10813 } 10814 first = false; 10815 b.append("u=").append(mContentUserHint); 10816 } 10817 if (mSelector != null) { 10818 b.append(" sel="); 10819 mSelector.toShortString(b, secure, comp, extras, clip); 10820 b.append("}"); 10821 } 10822 } 10823 10824 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId)10825 public void dumpDebug(ProtoOutputStream proto, long fieldId) { 10826 // Same input parameters that toString() gives to toShortString(). 10827 dumpDebug(proto, fieldId, true, true, true, false); 10828 } 10829 10830 /** @hide */ dumpDebug(ProtoOutputStream proto)10831 public void dumpDebug(ProtoOutputStream proto) { 10832 // Same input parameters that toString() gives to toShortString(). 10833 dumpDebugWithoutFieldId(proto, true, true, true, false); 10834 } 10835 10836 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)10837 public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, 10838 boolean extras, boolean clip) { 10839 long token = proto.start(fieldId); 10840 dumpDebugWithoutFieldId(proto, secure, comp, extras, clip); 10841 proto.end(token); 10842 } 10843 dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)10844 private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, 10845 boolean extras, boolean clip) { 10846 if (mAction != null) { 10847 proto.write(IntentProto.ACTION, mAction); 10848 } 10849 if (mCategories != null) { 10850 for (String category : mCategories) { 10851 proto.write(IntentProto.CATEGORIES, category); 10852 } 10853 } 10854 if (mData != null) { 10855 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString()); 10856 } 10857 if (mType != null) { 10858 proto.write(IntentProto.TYPE, mType); 10859 } 10860 if (mIdentifier != null) { 10861 proto.write(IntentProto.IDENTIFIER, mIdentifier); 10862 } 10863 if (mFlags != 0) { 10864 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags)); 10865 } 10866 if (mPackage != null) { 10867 proto.write(IntentProto.PACKAGE, mPackage); 10868 } 10869 if (comp && mComponent != null) { 10870 mComponent.dumpDebug(proto, IntentProto.COMPONENT); 10871 } 10872 if (mSourceBounds != null) { 10873 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString()); 10874 } 10875 if (mClipData != null) { 10876 StringBuilder b = new StringBuilder(); 10877 mClipData.toShortString(b, !clip || secure); 10878 proto.write(IntentProto.CLIP_DATA, b.toString()); 10879 } 10880 if (extras && mExtras != null) { 10881 proto.write(IntentProto.EXTRAS, mExtras.toShortString()); 10882 } 10883 if (mContentUserHint != 0) { 10884 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint); 10885 } 10886 if (mSelector != null) { 10887 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip)); 10888 } 10889 } 10890 10891 /** 10892 * Call {@link #toUri} with 0 flags. 10893 * @deprecated Use {@link #toUri} instead. 10894 */ 10895 @Deprecated toURI()10896 public String toURI() { 10897 return toUri(0); 10898 } 10899 10900 /** 10901 * Convert this Intent into a String holding a URI representation of it. 10902 * The returned URI string has been properly URI encoded, so it can be 10903 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the 10904 * Intent's data as the base URI, with an additional fragment describing 10905 * the action, categories, type, flags, package, component, and extras. 10906 * 10907 * <p>You can convert the returned string back to an Intent with 10908 * {@link #getIntent}. 10909 * 10910 * @param flags Additional operating flags. 10911 * 10912 * @return Returns a URI encoding URI string describing the entire contents 10913 * of the Intent. 10914 */ toUri(@riFlags int flags)10915 public String toUri(@UriFlags int flags) { 10916 StringBuilder uri = new StringBuilder(128); 10917 if ((flags&URI_ANDROID_APP_SCHEME) != 0) { 10918 if (mPackage == null) { 10919 throw new IllegalArgumentException( 10920 "Intent must include an explicit package name to build an android-app: " 10921 + this); 10922 } 10923 uri.append("android-app://"); 10924 uri.append(mPackage); 10925 String scheme = null; 10926 if (mData != null) { 10927 scheme = mData.getScheme(); 10928 if (scheme != null) { 10929 uri.append('/'); 10930 uri.append(scheme); 10931 String authority = mData.getEncodedAuthority(); 10932 if (authority != null) { 10933 uri.append('/'); 10934 uri.append(authority); 10935 String path = mData.getEncodedPath(); 10936 if (path != null) { 10937 uri.append(path); 10938 } 10939 String queryParams = mData.getEncodedQuery(); 10940 if (queryParams != null) { 10941 uri.append('?'); 10942 uri.append(queryParams); 10943 } 10944 String fragment = mData.getEncodedFragment(); 10945 if (fragment != null) { 10946 uri.append('#'); 10947 uri.append(fragment); 10948 } 10949 } 10950 } 10951 } 10952 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, 10953 mPackage, flags); 10954 return uri.toString(); 10955 } 10956 String scheme = null; 10957 if (mData != null) { 10958 String data = mData.toString(); 10959 if ((flags&URI_INTENT_SCHEME) != 0) { 10960 final int N = data.length(); 10961 for (int i=0; i<N; i++) { 10962 char c = data.charAt(i); 10963 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 10964 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') { 10965 continue; 10966 } 10967 if (c == ':' && i > 0) { 10968 // Valid scheme. 10969 scheme = data.substring(0, i); 10970 uri.append("intent:"); 10971 data = data.substring(i+1); 10972 break; 10973 } 10974 10975 // No scheme. 10976 break; 10977 } 10978 } 10979 uri.append(data); 10980 10981 } else if ((flags&URI_INTENT_SCHEME) != 0) { 10982 uri.append("intent:"); 10983 } 10984 10985 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); 10986 10987 return uri.toString(); 10988 } 10989 toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10990 private void toUriFragment(StringBuilder uri, String scheme, String defAction, 10991 String defPackage, int flags) { 10992 StringBuilder frag = new StringBuilder(128); 10993 10994 toUriInner(frag, scheme, defAction, defPackage, flags); 10995 if (mSelector != null) { 10996 frag.append("SEL;"); 10997 // Note that for now we are not going to try to handle the 10998 // data part; not clear how to represent this as a URI, and 10999 // not much utility in it. 11000 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, 11001 null, null, flags); 11002 } 11003 11004 if (frag.length() > 0) { 11005 uri.append("#Intent;"); 11006 uri.append(frag); 11007 uri.append("end"); 11008 } 11009 } 11010 toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)11011 private void toUriInner(StringBuilder uri, String scheme, String defAction, 11012 String defPackage, int flags) { 11013 if (scheme != null) { 11014 uri.append("scheme=").append(scheme).append(';'); 11015 } 11016 if (mAction != null && !mAction.equals(defAction)) { 11017 uri.append("action=").append(Uri.encode(mAction)).append(';'); 11018 } 11019 if (mCategories != null) { 11020 for (int i=0; i<mCategories.size(); i++) { 11021 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';'); 11022 } 11023 } 11024 if (mType != null) { 11025 uri.append("type=").append(Uri.encode(mType, "/")).append(';'); 11026 } 11027 if (mIdentifier != null) { 11028 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';'); 11029 } 11030 if (mFlags != 0) { 11031 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); 11032 } 11033 if (mPackage != null && !mPackage.equals(defPackage)) { 11034 uri.append("package=").append(Uri.encode(mPackage)).append(';'); 11035 } 11036 if (mComponent != null) { 11037 uri.append("component=").append(Uri.encode( 11038 mComponent.flattenToShortString(), "/")).append(';'); 11039 } 11040 if (mSourceBounds != null) { 11041 uri.append("sourceBounds=") 11042 .append(Uri.encode(mSourceBounds.flattenToString())) 11043 .append(';'); 11044 } 11045 if (mExtras != null) { 11046 for (String key : mExtras.keySet()) { 11047 final Object value = mExtras.get(key); 11048 char entryType = 11049 value instanceof String ? 'S' : 11050 value instanceof Boolean ? 'B' : 11051 value instanceof Byte ? 'b' : 11052 value instanceof Character ? 'c' : 11053 value instanceof Double ? 'd' : 11054 value instanceof Float ? 'f' : 11055 value instanceof Integer ? 'i' : 11056 value instanceof Long ? 'l' : 11057 value instanceof Short ? 's' : 11058 '\0'; 11059 11060 if (entryType != '\0') { 11061 uri.append(entryType); 11062 uri.append('.'); 11063 uri.append(Uri.encode(key)); 11064 uri.append('='); 11065 uri.append(Uri.encode(value.toString())); 11066 uri.append(';'); 11067 } 11068 } 11069 } 11070 } 11071 describeContents()11072 public int describeContents() { 11073 return (mExtras != null) ? mExtras.describeContents() : 0; 11074 } 11075 writeToParcel(Parcel out, int flags)11076 public void writeToParcel(Parcel out, int flags) { 11077 out.writeString8(mAction); 11078 Uri.writeToParcel(out, mData); 11079 out.writeString8(mType); 11080 out.writeString8(mIdentifier); 11081 out.writeInt(mFlags); 11082 out.writeString8(mPackage); 11083 ComponentName.writeToParcel(mComponent, out); 11084 11085 if (mSourceBounds != null) { 11086 out.writeInt(1); 11087 mSourceBounds.writeToParcel(out, flags); 11088 } else { 11089 out.writeInt(0); 11090 } 11091 11092 if (mCategories != null) { 11093 final int N = mCategories.size(); 11094 out.writeInt(N); 11095 for (int i=0; i<N; i++) { 11096 out.writeString8(mCategories.valueAt(i)); 11097 } 11098 } else { 11099 out.writeInt(0); 11100 } 11101 11102 if (mSelector != null) { 11103 out.writeInt(1); 11104 mSelector.writeToParcel(out, flags); 11105 } else { 11106 out.writeInt(0); 11107 } 11108 11109 if (mClipData != null) { 11110 out.writeInt(1); 11111 mClipData.writeToParcel(out, flags); 11112 } else { 11113 out.writeInt(0); 11114 } 11115 out.writeInt(mContentUserHint); 11116 out.writeBundle(mExtras); 11117 } 11118 11119 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR 11120 = new Parcelable.Creator<Intent>() { 11121 public Intent createFromParcel(Parcel in) { 11122 return new Intent(in); 11123 } 11124 public Intent[] newArray(int size) { 11125 return new Intent[size]; 11126 } 11127 }; 11128 11129 /** @hide */ Intent(Parcel in)11130 protected Intent(Parcel in) { 11131 // Remember that we came from a remote process to help detect security 11132 // issues caused by later unsafe launches 11133 mLocalFlags = LOCAL_FLAG_FROM_PARCEL; 11134 readFromParcel(in); 11135 } 11136 readFromParcel(Parcel in)11137 public void readFromParcel(Parcel in) { 11138 setAction(in.readString8()); 11139 mData = Uri.CREATOR.createFromParcel(in); 11140 mType = in.readString8(); 11141 mIdentifier = in.readString8(); 11142 mFlags = in.readInt(); 11143 mPackage = in.readString8(); 11144 mComponent = ComponentName.readFromParcel(in); 11145 11146 if (in.readInt() != 0) { 11147 mSourceBounds = Rect.CREATOR.createFromParcel(in); 11148 } 11149 11150 int N = in.readInt(); 11151 if (N > 0) { 11152 mCategories = new ArraySet<String>(); 11153 int i; 11154 for (i=0; i<N; i++) { 11155 mCategories.add(in.readString8().intern()); 11156 } 11157 } else { 11158 mCategories = null; 11159 } 11160 11161 if (in.readInt() != 0) { 11162 mSelector = new Intent(in); 11163 } 11164 11165 if (in.readInt() != 0) { 11166 mClipData = new ClipData(in); 11167 } 11168 mContentUserHint = in.readInt(); 11169 mExtras = in.readBundle(); 11170 } 11171 11172 /** 11173 * Parses the "intent" element (and its children) from XML and instantiates 11174 * an Intent object. The given XML parser should be located at the tag 11175 * where parsing should start (often named "intent"), from which the 11176 * basic action, data, type, and package and class name will be 11177 * retrieved. The function will then parse in to any child elements, 11178 * looking for <category android:name="xxx"> tags to add categories and 11179 * <extra android:name="xxx" android:value="yyy"> to attach extra data 11180 * to the intent. 11181 * 11182 * @param resources The Resources to use when inflating resources. 11183 * @param parser The XML parser pointing at an "intent" tag. 11184 * @param attrs The AttributeSet interface for retrieving extended 11185 * attribute data at the current <var>parser</var> location. 11186 * @return An Intent object matching the XML data. 11187 * @throws XmlPullParserException If there was an XML parsing error. 11188 * @throws IOException If there was an I/O error. 11189 */ parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)11190 public static @NonNull Intent parseIntent(@NonNull Resources resources, 11191 @NonNull XmlPullParser parser, AttributeSet attrs) 11192 throws XmlPullParserException, IOException { 11193 Intent intent = new Intent(); 11194 11195 TypedArray sa = resources.obtainAttributes(attrs, 11196 com.android.internal.R.styleable.Intent); 11197 11198 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); 11199 11200 String data = sa.getString(com.android.internal.R.styleable.Intent_data); 11201 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); 11202 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); 11203 11204 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier)); 11205 11206 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); 11207 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); 11208 if (packageName != null && className != null) { 11209 intent.setComponent(new ComponentName(packageName, className)); 11210 } 11211 11212 sa.recycle(); 11213 11214 int outerDepth = parser.getDepth(); 11215 int type; 11216 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 11217 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 11218 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 11219 continue; 11220 } 11221 11222 String nodeName = parser.getName(); 11223 if (nodeName.equals(TAG_CATEGORIES)) { 11224 sa = resources.obtainAttributes(attrs, 11225 com.android.internal.R.styleable.IntentCategory); 11226 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); 11227 sa.recycle(); 11228 11229 if (cat != null) { 11230 intent.addCategory(cat); 11231 } 11232 XmlUtils.skipCurrentTag(parser); 11233 11234 } else if (nodeName.equals(TAG_EXTRA)) { 11235 if (intent.mExtras == null) { 11236 intent.mExtras = new Bundle(); 11237 } 11238 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); 11239 XmlUtils.skipCurrentTag(parser); 11240 11241 } else { 11242 XmlUtils.skipCurrentTag(parser); 11243 } 11244 } 11245 11246 return intent; 11247 } 11248 11249 /** @hide */ saveToXml(XmlSerializer out)11250 public void saveToXml(XmlSerializer out) throws IOException { 11251 if (mAction != null) { 11252 out.attribute(null, ATTR_ACTION, mAction); 11253 } 11254 if (mData != null) { 11255 out.attribute(null, ATTR_DATA, mData.toString()); 11256 } 11257 if (mType != null) { 11258 out.attribute(null, ATTR_TYPE, mType); 11259 } 11260 if (mIdentifier != null) { 11261 out.attribute(null, ATTR_IDENTIFIER, mIdentifier); 11262 } 11263 if (mComponent != null) { 11264 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); 11265 } 11266 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); 11267 11268 if (mCategories != null) { 11269 out.startTag(null, TAG_CATEGORIES); 11270 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { 11271 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); 11272 } 11273 out.endTag(null, TAG_CATEGORIES); 11274 } 11275 } 11276 11277 /** @hide */ restoreFromXml(XmlPullParser in)11278 public static Intent restoreFromXml(XmlPullParser in) throws IOException, 11279 XmlPullParserException { 11280 Intent intent = new Intent(); 11281 final int outerDepth = in.getDepth(); 11282 11283 int attrCount = in.getAttributeCount(); 11284 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 11285 final String attrName = in.getAttributeName(attrNdx); 11286 final String attrValue = in.getAttributeValue(attrNdx); 11287 if (ATTR_ACTION.equals(attrName)) { 11288 intent.setAction(attrValue); 11289 } else if (ATTR_DATA.equals(attrName)) { 11290 intent.setData(Uri.parse(attrValue)); 11291 } else if (ATTR_TYPE.equals(attrName)) { 11292 intent.setType(attrValue); 11293 } else if (ATTR_IDENTIFIER.equals(attrName)) { 11294 intent.setIdentifier(attrValue); 11295 } else if (ATTR_COMPONENT.equals(attrName)) { 11296 intent.setComponent(ComponentName.unflattenFromString(attrValue)); 11297 } else if (ATTR_FLAGS.equals(attrName)) { 11298 intent.setFlags(Integer.parseInt(attrValue, 16)); 11299 } else { 11300 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName); 11301 } 11302 } 11303 11304 int event; 11305 String name; 11306 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && 11307 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { 11308 if (event == XmlPullParser.START_TAG) { 11309 name = in.getName(); 11310 if (TAG_CATEGORIES.equals(name)) { 11311 attrCount = in.getAttributeCount(); 11312 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 11313 intent.addCategory(in.getAttributeValue(attrNdx)); 11314 } 11315 } else { 11316 Log.w(TAG, "restoreFromXml: unknown name=" + name); 11317 XmlUtils.skipCurrentTag(in); 11318 } 11319 } 11320 } 11321 11322 return intent; 11323 } 11324 11325 /** 11326 * Normalize a MIME data type. 11327 * 11328 * <p>A normalized MIME type has white-space trimmed, 11329 * content-type parameters removed, and is lower-case. 11330 * This aligns the type with Android best practices for 11331 * intent filtering. 11332 * 11333 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". 11334 * "text/x-vCard" becomes "text/x-vcard". 11335 * 11336 * <p>All MIME types received from outside Android (such as user input, 11337 * or external sources like Bluetooth, NFC, or the Internet) should 11338 * be normalized before they are used to create an Intent. 11339 * 11340 * @param type MIME data type to normalize 11341 * @return normalized MIME data type, or null if the input was null 11342 * @see #setType 11343 * @see #setTypeAndNormalize 11344 */ normalizeMimeType(@ullable String type)11345 public static @Nullable String normalizeMimeType(@Nullable String type) { 11346 if (type == null) { 11347 return null; 11348 } 11349 11350 type = type.trim().toLowerCase(Locale.ROOT); 11351 11352 final int semicolonIndex = type.indexOf(';'); 11353 if (semicolonIndex != -1) { 11354 type = type.substring(0, semicolonIndex); 11355 } 11356 return type; 11357 } 11358 11359 /** 11360 * Prepare this {@link Intent} to leave an app process. 11361 * 11362 * @hide 11363 */ 11364 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) prepareToLeaveProcess(Context context)11365 public void prepareToLeaveProcess(Context context) { 11366 final boolean leavingPackage = (mComponent == null) 11367 || !Objects.equals(mComponent.getPackageName(), context.getPackageName()); 11368 prepareToLeaveProcess(leavingPackage); 11369 } 11370 11371 /** 11372 * Prepare this {@link Intent} to leave an app process. 11373 * 11374 * @hide 11375 */ prepareToLeaveProcess(boolean leavingPackage)11376 public void prepareToLeaveProcess(boolean leavingPackage) { 11377 setAllowFds(false); 11378 11379 if (mSelector != null) { 11380 mSelector.prepareToLeaveProcess(leavingPackage); 11381 } 11382 if (mClipData != null) { 11383 mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); 11384 } 11385 11386 if (mExtras != null && !mExtras.isParcelled()) { 11387 final Object intent = mExtras.get(Intent.EXTRA_INTENT); 11388 if (intent instanceof Intent) { 11389 ((Intent) intent).prepareToLeaveProcess(leavingPackage); 11390 } 11391 } 11392 11393 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() 11394 && leavingPackage) { 11395 switch (mAction) { 11396 case ACTION_MEDIA_REMOVED: 11397 case ACTION_MEDIA_UNMOUNTED: 11398 case ACTION_MEDIA_CHECKING: 11399 case ACTION_MEDIA_NOFS: 11400 case ACTION_MEDIA_MOUNTED: 11401 case ACTION_MEDIA_SHARED: 11402 case ACTION_MEDIA_UNSHARED: 11403 case ACTION_MEDIA_BAD_REMOVAL: 11404 case ACTION_MEDIA_UNMOUNTABLE: 11405 case ACTION_MEDIA_EJECT: 11406 case ACTION_MEDIA_SCANNER_STARTED: 11407 case ACTION_MEDIA_SCANNER_FINISHED: 11408 case ACTION_MEDIA_SCANNER_SCAN_FILE: 11409 case ACTION_PACKAGE_NEEDS_VERIFICATION: 11410 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION: 11411 case ACTION_PACKAGE_VERIFIED: 11412 case ACTION_PACKAGE_ENABLE_ROLLBACK: 11413 // Ignore legacy actions 11414 break; 11415 default: 11416 mData.checkFileUriExposed("Intent.getData()"); 11417 } 11418 } 11419 11420 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() 11421 && leavingPackage) { 11422 switch (mAction) { 11423 case ACTION_PROVIDER_CHANGED: 11424 case QuickContact.ACTION_QUICK_CONTACT: 11425 // Ignore actions that don't need to grant 11426 break; 11427 default: 11428 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); 11429 } 11430 } 11431 11432 // Translate raw filesystem paths out of storage sandbox 11433 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null 11434 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) { 11435 final StorageManager sm = AppGlobals.getInitialApplication() 11436 .getSystemService(StorageManager.class); 11437 final File before = new File(mData.getPath()); 11438 final File after = sm.translateAppToSystem(before, 11439 android.os.Process.myPid(), android.os.Process.myUid()); 11440 if (!Objects.equals(before, after)) { 11441 Log.v(TAG, "Translated " + before + " to " + after); 11442 mData = Uri.fromFile(after); 11443 } 11444 } 11445 11446 // Detect cases where we're about to launch a potentially unsafe intent 11447 if (StrictMode.vmUnsafeIntentLaunchEnabled()) { 11448 if ((mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 11449 && (mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) { 11450 StrictMode.onUnsafeIntentLaunch(this); 11451 } else if ((mLocalFlags & LOCAL_FLAG_UNFILTERED_EXTRAS) != 0) { 11452 StrictMode.onUnsafeIntentLaunch(this); 11453 } else if ((mLocalFlags & LOCAL_FLAG_FROM_URI) != 0 11454 && !(mCategories != null && mCategories.contains(CATEGORY_BROWSABLE) 11455 && mComponent == null)) { 11456 // Since the docs for #URI_ALLOW_UNSAFE recommend setting the category to browsable 11457 // for an implicit Intent parsed from a URI a violation should be reported if these 11458 // conditions are not met. 11459 StrictMode.onUnsafeIntentLaunch(this); 11460 } 11461 } 11462 } 11463 11464 /** 11465 * @hide 11466 */ prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source)11467 public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) { 11468 // We just entered destination process, so we should be able to read all 11469 // parcelables inside. 11470 setDefusable(true); 11471 11472 if (mSelector != null) { 11473 // We can't recursively claim that this data is from a protected 11474 // component, since it may have been filled in by a malicious app 11475 mSelector.prepareToEnterProcess(false, source); 11476 } 11477 if (mClipData != null) { 11478 mClipData.prepareToEnterProcess(source); 11479 } 11480 11481 if (mContentUserHint != UserHandle.USER_CURRENT) { 11482 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { 11483 fixUris(mContentUserHint); 11484 mContentUserHint = UserHandle.USER_CURRENT; 11485 } 11486 } 11487 11488 if (fromProtectedComponent) { 11489 mLocalFlags |= LOCAL_FLAG_FROM_PROTECTED_COMPONENT; 11490 } 11491 11492 // Special attribution fix-up logic for any BluetoothDevice extras 11493 // passed via Bluetooth intents 11494 if (mAction != null && mAction.startsWith("android.bluetooth.") 11495 && hasExtra(BluetoothDevice.EXTRA_DEVICE)) { 11496 final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 11497 if (device != null) { 11498 device.prepareToEnterProcess(source); 11499 } 11500 } 11501 } 11502 11503 /** @hide */ hasWebURI()11504 public boolean hasWebURI() { 11505 if (getData() == null) { 11506 return false; 11507 } 11508 final String scheme = getScheme(); 11509 if (TextUtils.isEmpty(scheme)) { 11510 return false; 11511 } 11512 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS); 11513 } 11514 11515 /** @hide */ isWebIntent()11516 public boolean isWebIntent() { 11517 return ACTION_VIEW.equals(mAction) 11518 && hasWebURI(); 11519 } 11520 isImageCaptureIntent()11521 private boolean isImageCaptureIntent() { 11522 return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction) 11523 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction) 11524 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction)); 11525 } 11526 11527 /** @hide */ isImplicitImageCaptureIntent()11528 public boolean isImplicitImageCaptureIntent() { 11529 return mPackage == null && mComponent == null && isImageCaptureIntent(); 11530 } 11531 11532 /** 11533 * @hide 11534 */ fixUris(int contentUserHint)11535 public void fixUris(int contentUserHint) { 11536 Uri data = getData(); 11537 if (data != null) { 11538 mData = maybeAddUserId(data, contentUserHint); 11539 } 11540 if (mClipData != null) { 11541 mClipData.fixUris(contentUserHint); 11542 } 11543 String action = getAction(); 11544 if (ACTION_SEND.equals(action)) { 11545 final Uri stream = getParcelableExtra(EXTRA_STREAM); 11546 if (stream != null) { 11547 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); 11548 } 11549 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 11550 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 11551 if (streams != null) { 11552 ArrayList<Uri> newStreams = new ArrayList<Uri>(); 11553 for (int i = 0; i < streams.size(); i++) { 11554 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); 11555 } 11556 putParcelableArrayListExtra(EXTRA_STREAM, newStreams); 11557 } 11558 } else if (isImageCaptureIntent()) { 11559 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 11560 if (output != null) { 11561 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); 11562 } 11563 } 11564 } 11565 11566 /** 11567 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 11568 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 11569 * intents in {@link #ACTION_CHOOSER}. 11570 * 11571 * @return Whether any contents were migrated. 11572 * @hide 11573 */ migrateExtraStreamToClipData()11574 public boolean migrateExtraStreamToClipData() { 11575 return migrateExtraStreamToClipData(AppGlobals.getInitialApplication()); 11576 } 11577 11578 /** 11579 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 11580 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 11581 * intents in {@link #ACTION_CHOOSER}. 11582 * 11583 * @param context app context 11584 * @return Whether any contents were migrated. 11585 * @hide 11586 */ migrateExtraStreamToClipData(Context context)11587 public boolean migrateExtraStreamToClipData(Context context) { 11588 // Refuse to touch if extras already parcelled 11589 if (mExtras != null && mExtras.isParcelled()) return false; 11590 11591 // Bail when someone already gave us ClipData 11592 if (getClipData() != null) return false; 11593 11594 final String action = getAction(); 11595 if (ACTION_CHOOSER.equals(action)) { 11596 // Inspect contained intents to see if we need to migrate extras. We 11597 // don't promote ClipData to the parent, since ChooserActivity will 11598 // already start the picked item as the caller, and we can't combine 11599 // the flags in a safe way. 11600 11601 boolean migrated = false; 11602 try { 11603 final Intent intent = getParcelableExtra(EXTRA_INTENT); 11604 if (intent != null) { 11605 migrated |= intent.migrateExtraStreamToClipData(context); 11606 } 11607 } catch (ClassCastException e) { 11608 } 11609 try { 11610 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); 11611 if (intents != null) { 11612 for (int i = 0; i < intents.length; i++) { 11613 final Intent intent = (Intent) intents[i]; 11614 if (intent != null) { 11615 migrated |= intent.migrateExtraStreamToClipData(context); 11616 } 11617 } 11618 } 11619 } catch (ClassCastException e) { 11620 } 11621 return migrated; 11622 11623 } else if (ACTION_SEND.equals(action)) { 11624 try { 11625 final Uri stream = getParcelableExtra(EXTRA_STREAM); 11626 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); 11627 final String htmlText = getStringExtra(EXTRA_HTML_TEXT); 11628 if (stream != null || text != null || htmlText != null) { 11629 final ClipData clipData = new ClipData( 11630 null, new String[] { getType() }, 11631 new ClipData.Item(text, htmlText, null, stream)); 11632 setClipData(clipData); 11633 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 11634 return true; 11635 } 11636 } catch (ClassCastException e) { 11637 } 11638 11639 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 11640 try { 11641 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 11642 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); 11643 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); 11644 int num = -1; 11645 if (streams != null) { 11646 num = streams.size(); 11647 } 11648 if (texts != null) { 11649 if (num >= 0 && num != texts.size()) { 11650 // Wha...! F- you. 11651 return false; 11652 } 11653 num = texts.size(); 11654 } 11655 if (htmlTexts != null) { 11656 if (num >= 0 && num != htmlTexts.size()) { 11657 // Wha...! F- you. 11658 return false; 11659 } 11660 num = htmlTexts.size(); 11661 } 11662 if (num > 0) { 11663 final ClipData clipData = new ClipData( 11664 null, new String[] { getType() }, 11665 makeClipItem(streams, texts, htmlTexts, 0)); 11666 11667 for (int i = 1; i < num; i++) { 11668 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); 11669 } 11670 11671 setClipData(clipData); 11672 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 11673 return true; 11674 } 11675 } catch (ClassCastException e) { 11676 } 11677 } else if (isImageCaptureIntent()) { 11678 Uri output; 11679 try { 11680 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 11681 } catch (ClassCastException e) { 11682 return false; 11683 } 11684 11685 if (output != null) { 11686 output = maybeConvertFileToContentUri(context, output); 11687 putExtra(MediaStore.EXTRA_OUTPUT, output); 11688 11689 setClipData(ClipData.newRawUri("", output)); 11690 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); 11691 return true; 11692 } 11693 } 11694 11695 return false; 11696 } 11697 maybeConvertFileToContentUri(Context context, Uri uri)11698 private Uri maybeConvertFileToContentUri(Context context, Uri uri) { 11699 if (ContentResolver.SCHEME_FILE.equals(uri.getScheme()) 11700 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) { 11701 File file = new File(uri.getPath()); 11702 try { 11703 if (!file.exists()) file.createNewFile(); 11704 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath())); 11705 if (uri != null) { 11706 return uri; 11707 } 11708 } catch (IOException e) { 11709 Log.e(TAG, "Ignoring failure to create file " + file, e); 11710 } 11711 } 11712 return uri; 11713 } 11714 11715 /** 11716 * Convert the dock state to a human readable format. 11717 * @hide 11718 */ dockStateToString(int dock)11719 public static String dockStateToString(int dock) { 11720 switch (dock) { 11721 case EXTRA_DOCK_STATE_HE_DESK: 11722 return "EXTRA_DOCK_STATE_HE_DESK"; 11723 case EXTRA_DOCK_STATE_LE_DESK: 11724 return "EXTRA_DOCK_STATE_LE_DESK"; 11725 case EXTRA_DOCK_STATE_CAR: 11726 return "EXTRA_DOCK_STATE_CAR"; 11727 case EXTRA_DOCK_STATE_DESK: 11728 return "EXTRA_DOCK_STATE_DESK"; 11729 case EXTRA_DOCK_STATE_UNDOCKED: 11730 return "EXTRA_DOCK_STATE_UNDOCKED"; 11731 default: 11732 return Integer.toString(dock); 11733 } 11734 } 11735 makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)11736 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, 11737 ArrayList<String> htmlTexts, int which) { 11738 Uri uri = streams != null ? streams.get(which) : null; 11739 CharSequence text = texts != null ? texts.get(which) : null; 11740 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; 11741 return new ClipData.Item(text, htmlText, null, uri); 11742 } 11743 11744 /** @hide */ isDocument()11745 public boolean isDocument() { 11746 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; 11747 } 11748 } 11749