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.annotation.AnyRes; 22 import android.annotation.BroadcastBehavior; 23 import android.annotation.IntDef; 24 import android.annotation.NonNull; 25 import android.annotation.Nullable; 26 import android.annotation.RequiresPermission; 27 import android.annotation.SdkConstant; 28 import android.annotation.SdkConstant.SdkConstantType; 29 import android.annotation.SystemApi; 30 import android.annotation.TestApi; 31 import android.app.AppGlobals; 32 import android.compat.annotation.UnsupportedAppUsage; 33 import android.content.pm.ActivityInfo; 34 import android.content.pm.ApplicationInfo; 35 import android.content.pm.ComponentInfo; 36 import android.content.pm.PackageManager; 37 import android.content.pm.ResolveInfo; 38 import android.content.pm.ShortcutInfo; 39 import android.content.res.Resources; 40 import android.content.res.TypedArray; 41 import android.graphics.Rect; 42 import android.net.Uri; 43 import android.os.Build; 44 import android.os.Bundle; 45 import android.os.IBinder; 46 import android.os.IncidentManager; 47 import android.os.Parcel; 48 import android.os.Parcelable; 49 import android.os.PersistableBundle; 50 import android.os.Process; 51 import android.os.ResultReceiver; 52 import android.os.ShellCommand; 53 import android.os.StrictMode; 54 import android.os.UserHandle; 55 import android.os.storage.StorageManager; 56 import android.provider.ContactsContract.QuickContact; 57 import android.provider.DocumentsContract; 58 import android.provider.DocumentsProvider; 59 import android.provider.MediaStore; 60 import android.provider.OpenableColumns; 61 import android.telecom.PhoneAccount; 62 import android.telecom.TelecomManager; 63 import android.text.TextUtils; 64 import android.util.ArraySet; 65 import android.util.AttributeSet; 66 import android.util.Log; 67 import android.util.proto.ProtoOutputStream; 68 69 import com.android.internal.util.XmlUtils; 70 71 import org.xmlpull.v1.XmlPullParser; 72 import org.xmlpull.v1.XmlPullParserException; 73 import org.xmlpull.v1.XmlSerializer; 74 75 import java.io.File; 76 import java.io.IOException; 77 import java.io.PrintWriter; 78 import java.io.Serializable; 79 import java.lang.annotation.Retention; 80 import java.lang.annotation.RetentionPolicy; 81 import java.net.URISyntaxException; 82 import java.util.ArrayList; 83 import java.util.HashSet; 84 import java.util.List; 85 import java.util.Locale; 86 import java.util.Objects; 87 import java.util.Set; 88 89 /** 90 * An intent is an abstract description of an operation to be performed. It 91 * can be used with {@link Context#startActivity(Intent) startActivity} to 92 * launch an {@link android.app.Activity}, 93 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to 94 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, 95 * and {@link android.content.Context#startService} or 96 * {@link android.content.Context#bindService} to communicate with a 97 * background {@link android.app.Service}. 98 * 99 * <p>An Intent provides a facility for performing late runtime binding between the code in 100 * different applications. Its most significant use is in the launching of activities, where it 101 * can be thought of as the glue between activities. It is basically a passive data structure 102 * holding an abstract description of an action to be performed.</p> 103 * 104 * <div class="special reference"> 105 * <h3>Developer Guides</h3> 106 * <p>For information about how to create and resolve intents, read the 107 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> 108 * developer guide.</p> 109 * </div> 110 * 111 * <a name="IntentStructure"></a> 112 * <h3>Intent Structure</h3> 113 * <p>The primary pieces of information in an intent are:</p> 114 * 115 * <ul> 116 * <li> <p><b>action</b> -- The general action to be performed, such as 117 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, 118 * etc.</p> 119 * </li> 120 * <li> <p><b>data</b> -- The data to operate on, such as a person record 121 * in the contacts database, expressed as a {@link android.net.Uri}.</p> 122 * </li> 123 * </ul> 124 * 125 * 126 * <p>Some examples of action/data pairs are:</p> 127 * 128 * <ul> 129 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display 130 * information about the person whose identifier is "1".</p> 131 * </li> 132 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display 133 * the phone dialer with the person filled in.</p> 134 * </li> 135 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display 136 * the phone dialer with the given number filled in. Note how the 137 * VIEW action does what is considered the most reasonable thing for 138 * a particular URI.</p> 139 * </li> 140 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display 141 * the phone dialer with the given number filled in.</p> 142 * </li> 143 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit 144 * information about the person whose identifier is "1".</p> 145 * </li> 146 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display 147 * a list of people, which the user can browse through. This example is a 148 * typical top-level entry into the Contacts application, showing you the 149 * list of people. Selecting a particular person to view would result in a 150 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> } 151 * being used to start an activity to display that person.</p> 152 * </li> 153 * </ul> 154 * 155 * <p>In addition to these primary attributes, there are a number of secondary 156 * attributes that you can also include with an intent:</p> 157 * 158 * <ul> 159 * <li> <p><b>category</b> -- Gives additional information about the action 160 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should 161 * appear in the Launcher as a top-level application, while 162 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list 163 * of alternative actions the user can perform on a piece of data.</p> 164 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the 165 * intent data. Normally the type is inferred from the data itself. 166 * By setting this attribute, you disable that evaluation and force 167 * an explicit type.</p> 168 * <li> <p><b>component</b> -- Specifies an explicit name of a component 169 * class to use for the intent. Normally this is determined by looking 170 * at the other information in the intent (the action, data/type, and 171 * categories) and matching that with a component that can handle it. 172 * If this attribute is set then none of the evaluation is performed, 173 * and this component is used exactly as is. By specifying this attribute, 174 * all of the other Intent attributes become optional.</p> 175 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. 176 * This can be used to provide extended information to the component. 177 * For example, if we have a action to send an e-mail message, we could 178 * also include extra pieces of data here to supply a subject, body, 179 * etc.</p> 180 * </ul> 181 * 182 * <p>Here are some examples of other operations you can specify as intents 183 * using these additional parameters:</p> 184 * 185 * <ul> 186 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- 187 * Launch the home screen.</p> 188 * </li> 189 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 190 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI 191 * vnd.android.cursor.item/phone}</i></b> 192 * -- Display the list of people's phone numbers, allowing the user to 193 * browse through them and pick one and return it to the parent activity.</p> 194 * </li> 195 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 196 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> 197 * -- Display all pickers for data that can be opened with 198 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, 199 * allowing the user to pick one of them and then some data inside of it 200 * and returning the resulting URI to the caller. This can be used, 201 * for example, in an e-mail application to allow the user to pick some 202 * data to include as an attachment.</p> 203 * </li> 204 * </ul> 205 * 206 * <p>There are a variety of standard Intent action and category constants 207 * defined in the Intent class, but applications can also define their own. 208 * These strings use Java-style scoping, to ensure they are unique -- for 209 * example, the standard {@link #ACTION_VIEW} is called 210 * "android.intent.action.VIEW".</p> 211 * 212 * <p>Put together, the set of actions, data types, categories, and extra data 213 * defines a language for the system allowing for the expression of phrases 214 * such as "call john smith's cell". As applications are added to the system, 215 * they can extend this language by adding new actions, types, and categories, or 216 * they can modify the behavior of existing phrases by supplying their own 217 * activities that handle them.</p> 218 * 219 * <a name="IntentResolution"></a> 220 * <h3>Intent Resolution</h3> 221 * 222 * <p>There are two primary forms of intents you will use. 223 * 224 * <ul> 225 * <li> <p><b>Explicit Intents</b> have specified a component (via 226 * {@link #setComponent} or {@link #setClass}), which provides the exact 227 * class to be run. Often these will not include any other information, 228 * simply being a way for an application to launch various internal 229 * activities it has as the user interacts with the application. 230 * 231 * <li> <p><b>Implicit Intents</b> have not specified a component; 232 * instead, they must include enough information for the system to 233 * determine which of the available components is best to run for that 234 * intent. 235 * </ul> 236 * 237 * <p>When using implicit intents, given such an arbitrary intent we need to 238 * know what to do with it. This is handled by the process of <em>Intent 239 * resolution</em>, which maps an Intent to an {@link android.app.Activity}, 240 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or 241 * more activities/receivers) that can handle it.</p> 242 * 243 * <p>The intent resolution mechanism basically revolves around matching an 244 * Intent against all of the <intent-filter> descriptions in the 245 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} 246 * objects explicitly registered with {@link Context#registerReceiver}.) More 247 * details on this can be found in the documentation on the {@link 248 * IntentFilter} class.</p> 249 * 250 * <p>There are three pieces of information in the Intent that are used for 251 * resolution: the action, type, and category. Using this information, a query 252 * is done on the {@link PackageManager} for a component that can handle the 253 * intent. The appropriate component is determined based on the intent 254 * information supplied in the <code>AndroidManifest.xml</code> file as 255 * follows:</p> 256 * 257 * <ul> 258 * <li> <p>The <b>action</b>, if given, must be listed by the component as 259 * one it handles.</p> 260 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not 261 * already supplied in the Intent. Like the action, if a type is 262 * included in the intent (either explicitly or implicitly in its 263 * data), then this must be listed by the component as one it handles.</p> 264 * <li> For data that is not a <code>content:</code> URI and where no explicit 265 * type is included in the Intent, instead the <b>scheme</b> of the 266 * intent data (such as <code>http:</code> or <code>mailto:</code>) is 267 * considered. Again like the action, if we are matching a scheme it 268 * must be listed by the component as one it can handle. 269 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed 270 * by the activity as categories it handles. That is, if you include 271 * the categories {@link #CATEGORY_LAUNCHER} and 272 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components 273 * with an intent that lists <em>both</em> of those categories. 274 * Activities will very often need to support the 275 * {@link #CATEGORY_DEFAULT} so that they can be found by 276 * {@link Context#startActivity Context.startActivity()}.</p> 277 * </ul> 278 * 279 * <p>For example, consider the Note Pad sample application that 280 * allows a user to browse through a list of notes data and view details about 281 * individual items. Text in italics indicates places where you would replace a 282 * name with one specific to your own package.</p> 283 * 284 * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 285 * package="<i>com.android.notepad</i>"> 286 * <application android:icon="@drawable/app_notes" 287 * android:label="@string/app_name"> 288 * 289 * <provider class=".NotePadProvider" 290 * android:authorities="<i>com.google.provider.NotePad</i>" /> 291 * 292 * <activity class=".NotesList" android:label="@string/title_notes_list"> 293 * <intent-filter> 294 * <action android:name="android.intent.action.MAIN" /> 295 * <category android:name="android.intent.category.LAUNCHER" /> 296 * </intent-filter> 297 * <intent-filter> 298 * <action android:name="android.intent.action.VIEW" /> 299 * <action android:name="android.intent.action.EDIT" /> 300 * <action android:name="android.intent.action.PICK" /> 301 * <category android:name="android.intent.category.DEFAULT" /> 302 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 303 * </intent-filter> 304 * <intent-filter> 305 * <action android:name="android.intent.action.GET_CONTENT" /> 306 * <category android:name="android.intent.category.DEFAULT" /> 307 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 308 * </intent-filter> 309 * </activity> 310 * 311 * <activity class=".NoteEditor" android:label="@string/title_note"> 312 * <intent-filter android:label="@string/resolve_edit"> 313 * <action android:name="android.intent.action.VIEW" /> 314 * <action android:name="android.intent.action.EDIT" /> 315 * <category android:name="android.intent.category.DEFAULT" /> 316 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 317 * </intent-filter> 318 * 319 * <intent-filter> 320 * <action android:name="android.intent.action.INSERT" /> 321 * <category android:name="android.intent.category.DEFAULT" /> 322 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 323 * </intent-filter> 324 * 325 * </activity> 326 * 327 * <activity class=".TitleEditor" android:label="@string/title_edit_title" 328 * android:theme="@android:style/Theme.Dialog"> 329 * <intent-filter android:label="@string/resolve_title"> 330 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 331 * <category android:name="android.intent.category.DEFAULT" /> 332 * <category android:name="android.intent.category.ALTERNATIVE" /> 333 * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> 334 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 335 * </intent-filter> 336 * </activity> 337 * 338 * </application> 339 * </manifest></pre> 340 * 341 * <p>The first activity, 342 * <code>com.android.notepad.NotesList</code>, serves as our main 343 * entry into the app. It can do three things as described by its three intent 344 * templates: 345 * <ol> 346 * <li><pre> 347 * <intent-filter> 348 * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> 349 * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> 350 * </intent-filter></pre> 351 * <p>This provides a top-level entry into the NotePad application: the standard 352 * MAIN action is a main entry point (not requiring any other information in 353 * the Intent), and the LAUNCHER category says that this entry point should be 354 * listed in the application launcher.</p> 355 * <li><pre> 356 * <intent-filter> 357 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 358 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 359 * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> 360 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 361 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 362 * </intent-filter></pre> 363 * <p>This declares the things that the activity can do on a directory of 364 * notes. The type being supported is given with the <type> tag, where 365 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which 366 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can 367 * be retrieved which holds our note pad data (<code>vnd.google.note</code>). 368 * The activity allows the user to view or edit the directory of data (via 369 * the VIEW and EDIT actions), or to pick a particular note and return it 370 * to the caller (via the PICK action). Note also the DEFAULT category 371 * supplied here: this is <em>required</em> for the 372 * {@link Context#startActivity Context.startActivity} method to resolve your 373 * activity when its component name is not explicitly specified.</p> 374 * <li><pre> 375 * <intent-filter> 376 * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> 377 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 378 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 379 * </intent-filter></pre> 380 * <p>This filter describes the ability to return to the caller a note selected by 381 * the user without needing to know where it came from. The data type 382 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which 383 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can 384 * be retrieved which contains our note pad data (<code>vnd.google.note</code>). 385 * The GET_CONTENT action is similar to the PICK action, where the activity 386 * will return to its caller a piece of data selected by the user. Here, 387 * however, the caller specifies the type of data they desire instead of 388 * the type of data the user will be picking from.</p> 389 * </ol> 390 * 391 * <p>Given these capabilities, the following intents will resolve to the 392 * NotesList activity:</p> 393 * 394 * <ul> 395 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the 396 * activities that can be used as top-level entry points into an 397 * application.</p> 398 * <li> <p><b>{ action=android.app.action.MAIN, 399 * category=android.app.category.LAUNCHER }</b> is the actual intent 400 * used by the Launcher to populate its top-level list.</p> 401 * <li> <p><b>{ action=android.intent.action.VIEW 402 * data=content://com.google.provider.NotePad/notes }</b> 403 * displays a list of all the notes under 404 * "content://com.google.provider.NotePad/notes", which 405 * the user can browse through and see the details on.</p> 406 * <li> <p><b>{ action=android.app.action.PICK 407 * data=content://com.google.provider.NotePad/notes }</b> 408 * provides a list of the notes under 409 * "content://com.google.provider.NotePad/notes", from which 410 * the user can pick a note whose data URL is returned back to the caller.</p> 411 * <li> <p><b>{ action=android.app.action.GET_CONTENT 412 * type=vnd.android.cursor.item/vnd.google.note }</b> 413 * is similar to the pick action, but allows the caller to specify the 414 * kind of data they want back so that the system can find the appropriate 415 * activity to pick something of that data type.</p> 416 * </ul> 417 * 418 * <p>The second activity, 419 * <code>com.android.notepad.NoteEditor</code>, shows the user a single 420 * note entry and allows them to edit it. It can do two things as described 421 * by its two intent templates: 422 * <ol> 423 * <li><pre> 424 * <intent-filter android:label="@string/resolve_edit"> 425 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 426 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 427 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 428 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 429 * </intent-filter></pre> 430 * <p>The first, primary, purpose of this activity is to let the user interact 431 * with a single note, as decribed by the MIME type 432 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can 433 * either VIEW a note or allow the user to EDIT it. Again we support the 434 * DEFAULT category to allow the activity to be launched without explicitly 435 * specifying its component.</p> 436 * <li><pre> 437 * <intent-filter> 438 * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> 439 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 440 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 441 * </intent-filter></pre> 442 * <p>The secondary use of this activity is to insert a new note entry into 443 * an existing directory of notes. This is used when the user creates a new 444 * note: the INSERT action is executed on the directory of notes, causing 445 * this activity to run and have the user create the new note data which 446 * it then adds to the content provider.</p> 447 * </ol> 448 * 449 * <p>Given these capabilities, the following intents will resolve to the 450 * NoteEditor activity:</p> 451 * 452 * <ul> 453 * <li> <p><b>{ action=android.intent.action.VIEW 454 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 455 * shows the user the content of note <var>{ID}</var>.</p> 456 * <li> <p><b>{ action=android.app.action.EDIT 457 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 458 * allows the user to edit the content of note <var>{ID}</var>.</p> 459 * <li> <p><b>{ action=android.app.action.INSERT 460 * data=content://com.google.provider.NotePad/notes }</b> 461 * creates a new, empty note in the notes list at 462 * "content://com.google.provider.NotePad/notes" 463 * and allows the user to edit it. If they keep their changes, the URI 464 * of the newly created note is returned to the caller.</p> 465 * </ul> 466 * 467 * <p>The last activity, 468 * <code>com.android.notepad.TitleEditor</code>, allows the user to 469 * edit the title of a note. This could be implemented as a class that the 470 * application directly invokes (by explicitly setting its component in 471 * the Intent), but here we show a way you can publish alternative 472 * operations on existing data:</p> 473 * 474 * <pre> 475 * <intent-filter android:label="@string/resolve_title"> 476 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 477 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 478 * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> 479 * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> 480 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 481 * </intent-filter></pre> 482 * 483 * <p>In the single intent template here, we 484 * have created our own private action called 485 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to 486 * edit the title of a note. It must be invoked on a specific note 487 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous 488 * view and edit actions, but here displays and edits the title contained 489 * in the note data. 490 * 491 * <p>In addition to supporting the default category as usual, our title editor 492 * also supports two other standard categories: ALTERNATIVE and 493 * SELECTED_ALTERNATIVE. Implementing 494 * these categories allows others to find the special action it provides 495 * without directly knowing about it, through the 496 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or 497 * more often to build dynamic menu items with 498 * {@link android.view.Menu#addIntentOptions}. Note that in the intent 499 * template here was also supply an explicit name for the template 500 * (via <code>android:label="@string/resolve_title"</code>) to better control 501 * what the user sees when presented with this activity as an alternative 502 * action to the data they are viewing. 503 * 504 * <p>Given these capabilities, the following intent will resolve to the 505 * TitleEditor activity:</p> 506 * 507 * <ul> 508 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE 509 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 510 * displays and allows the user to edit the title associated 511 * with note <var>{ID}</var>.</p> 512 * </ul> 513 * 514 * <h3>Standard Activity Actions</h3> 515 * 516 * <p>These are the current standard actions that Intent defines for launching 517 * activities (usually through {@link Context#startActivity}. The most 518 * important, and by far most frequently used, are {@link #ACTION_MAIN} and 519 * {@link #ACTION_EDIT}. 520 * 521 * <ul> 522 * <li> {@link #ACTION_MAIN} 523 * <li> {@link #ACTION_VIEW} 524 * <li> {@link #ACTION_ATTACH_DATA} 525 * <li> {@link #ACTION_EDIT} 526 * <li> {@link #ACTION_PICK} 527 * <li> {@link #ACTION_CHOOSER} 528 * <li> {@link #ACTION_GET_CONTENT} 529 * <li> {@link #ACTION_DIAL} 530 * <li> {@link #ACTION_CALL} 531 * <li> {@link #ACTION_SEND} 532 * <li> {@link #ACTION_SENDTO} 533 * <li> {@link #ACTION_ANSWER} 534 * <li> {@link #ACTION_INSERT} 535 * <li> {@link #ACTION_DELETE} 536 * <li> {@link #ACTION_RUN} 537 * <li> {@link #ACTION_SYNC} 538 * <li> {@link #ACTION_PICK_ACTIVITY} 539 * <li> {@link #ACTION_SEARCH} 540 * <li> {@link #ACTION_WEB_SEARCH} 541 * <li> {@link #ACTION_FACTORY_TEST} 542 * </ul> 543 * 544 * <h3>Standard Broadcast Actions</h3> 545 * 546 * <p>These are the current standard actions that Intent defines for receiving 547 * broadcasts (usually through {@link Context#registerReceiver} or a 548 * <receiver> tag in a manifest). 549 * 550 * <ul> 551 * <li> {@link #ACTION_TIME_TICK} 552 * <li> {@link #ACTION_TIME_CHANGED} 553 * <li> {@link #ACTION_TIMEZONE_CHANGED} 554 * <li> {@link #ACTION_BOOT_COMPLETED} 555 * <li> {@link #ACTION_PACKAGE_ADDED} 556 * <li> {@link #ACTION_PACKAGE_CHANGED} 557 * <li> {@link #ACTION_PACKAGE_REMOVED} 558 * <li> {@link #ACTION_PACKAGE_RESTARTED} 559 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} 560 * <li> {@link #ACTION_PACKAGES_SUSPENDED} 561 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} 562 * <li> {@link #ACTION_UID_REMOVED} 563 * <li> {@link #ACTION_BATTERY_CHANGED} 564 * <li> {@link #ACTION_POWER_CONNECTED} 565 * <li> {@link #ACTION_POWER_DISCONNECTED} 566 * <li> {@link #ACTION_SHUTDOWN} 567 * </ul> 568 * 569 * <h3>Standard Categories</h3> 570 * 571 * <p>These are the current standard categories that can be used to further 572 * clarify an Intent via {@link #addCategory}. 573 * 574 * <ul> 575 * <li> {@link #CATEGORY_DEFAULT} 576 * <li> {@link #CATEGORY_BROWSABLE} 577 * <li> {@link #CATEGORY_TAB} 578 * <li> {@link #CATEGORY_ALTERNATIVE} 579 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} 580 * <li> {@link #CATEGORY_LAUNCHER} 581 * <li> {@link #CATEGORY_INFO} 582 * <li> {@link #CATEGORY_HOME} 583 * <li> {@link #CATEGORY_PREFERENCE} 584 * <li> {@link #CATEGORY_TEST} 585 * <li> {@link #CATEGORY_CAR_DOCK} 586 * <li> {@link #CATEGORY_DESK_DOCK} 587 * <li> {@link #CATEGORY_LE_DESK_DOCK} 588 * <li> {@link #CATEGORY_HE_DESK_DOCK} 589 * <li> {@link #CATEGORY_CAR_MODE} 590 * <li> {@link #CATEGORY_APP_MARKET} 591 * <li> {@link #CATEGORY_VR_HOME} 592 * </ul> 593 * 594 * <h3>Standard Extra Data</h3> 595 * 596 * <p>These are the current standard fields that can be used as extra data via 597 * {@link #putExtra}. 598 * 599 * <ul> 600 * <li> {@link #EXTRA_ALARM_COUNT} 601 * <li> {@link #EXTRA_BCC} 602 * <li> {@link #EXTRA_CC} 603 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} 604 * <li> {@link #EXTRA_DATA_REMOVED} 605 * <li> {@link #EXTRA_DOCK_STATE} 606 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} 607 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} 608 * <li> {@link #EXTRA_DOCK_STATE_CAR} 609 * <li> {@link #EXTRA_DOCK_STATE_DESK} 610 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} 611 * <li> {@link #EXTRA_DONT_KILL_APP} 612 * <li> {@link #EXTRA_EMAIL} 613 * <li> {@link #EXTRA_INITIAL_INTENTS} 614 * <li> {@link #EXTRA_INTENT} 615 * <li> {@link #EXTRA_KEY_EVENT} 616 * <li> {@link #EXTRA_ORIGINATING_URI} 617 * <li> {@link #EXTRA_PHONE_NUMBER} 618 * <li> {@link #EXTRA_REFERRER} 619 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} 620 * <li> {@link #EXTRA_REPLACING} 621 * <li> {@link #EXTRA_SHORTCUT_ICON} 622 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} 623 * <li> {@link #EXTRA_SHORTCUT_INTENT} 624 * <li> {@link #EXTRA_STREAM} 625 * <li> {@link #EXTRA_SHORTCUT_NAME} 626 * <li> {@link #EXTRA_SUBJECT} 627 * <li> {@link #EXTRA_TEMPLATE} 628 * <li> {@link #EXTRA_TEXT} 629 * <li> {@link #EXTRA_TITLE} 630 * <li> {@link #EXTRA_UID} 631 * </ul> 632 * 633 * <h3>Flags</h3> 634 * 635 * <p>These are the possible flags that can be used in the Intent via 636 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list 637 * of all possible flags. 638 */ 639 public class Intent implements Parcelable, Cloneable { 640 private static final String TAG = "Intent"; 641 642 private static final String ATTR_ACTION = "action"; 643 private static final String TAG_CATEGORIES = "categories"; 644 private static final String ATTR_CATEGORY = "category"; 645 private static final String TAG_EXTRA = "extra"; 646 private static final String ATTR_TYPE = "type"; 647 private static final String ATTR_IDENTIFIER = "ident"; 648 private static final String ATTR_COMPONENT = "component"; 649 private static final String ATTR_DATA = "data"; 650 private static final String ATTR_FLAGS = "flags"; 651 652 // --------------------------------------------------------------------- 653 // --------------------------------------------------------------------- 654 // Standard intent activity actions (see action variable). 655 656 /** 657 * Activity Action: Start as a main entry point, does not expect to 658 * receive data. 659 * <p>Input: nothing 660 * <p>Output: nothing 661 */ 662 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 663 public static final String ACTION_MAIN = "android.intent.action.MAIN"; 664 665 /** 666 * Activity Action: Display the data to the user. This is the most common 667 * action performed on data -- it is the generic action you can use on 668 * a piece of data to get the most reasonable thing to occur. For example, 669 * when used on a contacts entry it will view the entry; when used on a 670 * mailto: URI it will bring up a compose window filled with the information 671 * supplied by the URI; when used with a tel: URI it will invoke the 672 * dialer. 673 * <p>Input: {@link #getData} is URI from which to retrieve data. 674 * <p>Output: nothing. 675 */ 676 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 677 public static final String ACTION_VIEW = "android.intent.action.VIEW"; 678 679 /** 680 * Extra that can be included on activity intents coming from the storage UI 681 * when it launches sub-activities to manage various types of storage. For example, 682 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show 683 * the images on the device, and in that case also include this extra to tell the 684 * app it is coming from the storage UI so should help the user manage storage of 685 * this type. 686 */ 687 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE"; 688 689 /** 690 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is 691 * performed on a piece of data. 692 */ 693 public static final String ACTION_DEFAULT = ACTION_VIEW; 694 695 /** 696 * Activity Action: Quick view the data. Launches a quick viewer for 697 * a URI or a list of URIs. 698 * <p>Activities handling this intent action should handle the vast majority of 699 * MIME types rather than only specific ones. 700 * <p>Quick viewers must render the quick view image locally, and must not send 701 * file content outside current device. 702 * <p>Input: {@link #getData} is a mandatory content URI of the item to 703 * preview. {@link #getClipData} contains an optional list of content URIs 704 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an 705 * optional index of the URI in the clip data to show first. 706 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features 707 * that can be shown in the quick view UI. 708 * <p>Output: nothing. 709 * @see #EXTRA_INDEX 710 * @see #EXTRA_QUICK_VIEW_FEATURES 711 */ 712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 713 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; 714 715 /** 716 * Used to indicate that some piece of data should be attached to some other 717 * place. For example, image data could be attached to a contact. It is up 718 * to the recipient to decide where the data should be attached; the intent 719 * does not specify the ultimate destination. 720 * <p>Input: {@link #getData} is URI of data to be attached. 721 * <p>Output: nothing. 722 */ 723 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 724 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; 725 726 /** 727 * Activity Action: Provide explicit editable access to the given data. 728 * <p>Input: {@link #getData} is URI of data to be edited. 729 * <p>Output: nothing. 730 */ 731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 732 public static final String ACTION_EDIT = "android.intent.action.EDIT"; 733 734 /** 735 * Activity Action: Pick an existing item, or insert a new item, and then edit it. 736 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. 737 * The extras can contain type specific data to pass through to the editing/creating 738 * activity. 739 * <p>Output: The URI of the item that was picked. This must be a content: 740 * URI so that any receiver can access it. 741 */ 742 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 743 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; 744 745 /** 746 * Activity Action: Pick an item from the data, returning what was selected. 747 * <p>Input: {@link #getData} is URI containing a directory of data 748 * (vnd.android.cursor.dir/*) from which to pick an item. 749 * <p>Output: The URI of the item that was picked. 750 */ 751 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 752 public static final String ACTION_PICK = "android.intent.action.PICK"; 753 754 /** 755 * Activity Action: Creates a shortcut. 756 * <p>Input: Nothing.</p> 757 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> 758 * <p>For compatibility with older versions of android the intent may also contain three 759 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), 760 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE 761 * (value: ShortcutIconResource).</p> 762 * 763 * @see android.content.pm.ShortcutManager#createShortcutResultIntent 764 * @see #EXTRA_SHORTCUT_INTENT 765 * @see #EXTRA_SHORTCUT_NAME 766 * @see #EXTRA_SHORTCUT_ICON 767 * @see #EXTRA_SHORTCUT_ICON_RESOURCE 768 * @see android.content.Intent.ShortcutIconResource 769 */ 770 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 771 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; 772 773 /** 774 * The name of the extra used to define the Intent of a shortcut. 775 * 776 * @see #ACTION_CREATE_SHORTCUT 777 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 778 */ 779 @Deprecated 780 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; 781 /** 782 * The name of the extra used to define the name of a shortcut. 783 * 784 * @see #ACTION_CREATE_SHORTCUT 785 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 786 */ 787 @Deprecated 788 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; 789 /** 790 * The name of the extra used to define the icon, as a Bitmap, of a shortcut. 791 * 792 * @see #ACTION_CREATE_SHORTCUT 793 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 794 */ 795 @Deprecated 796 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; 797 /** 798 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. 799 * 800 * @see #ACTION_CREATE_SHORTCUT 801 * @see android.content.Intent.ShortcutIconResource 802 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 803 */ 804 @Deprecated 805 public static final String EXTRA_SHORTCUT_ICON_RESOURCE = 806 "android.intent.extra.shortcut.ICON_RESOURCE"; 807 808 /** 809 * An activity that provides a user interface for adjusting application preferences. 810 * Optional but recommended settings for all applications which have settings. 811 */ 812 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 813 public static final String ACTION_APPLICATION_PREFERENCES 814 = "android.intent.action.APPLICATION_PREFERENCES"; 815 816 /** 817 * Activity Action: Launch an activity showing the app information. 818 * For applications which install other applications (such as app stores), it is recommended 819 * to handle this action for providing the app information to the user. 820 * 821 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs 822 * to be displayed. 823 * <p>Output: Nothing. 824 */ 825 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 826 public static final String ACTION_SHOW_APP_INFO 827 = "android.intent.action.SHOW_APP_INFO"; 828 829 /** 830 * Represents a shortcut/live folder icon resource. 831 * 832 * @see Intent#ACTION_CREATE_SHORTCUT 833 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE 834 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER 835 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON 836 */ 837 public static class ShortcutIconResource implements Parcelable { 838 /** 839 * The package name of the application containing the icon. 840 */ 841 public String packageName; 842 843 /** 844 * The resource name of the icon, including package, name and type. 845 */ 846 public String resourceName; 847 848 /** 849 * Creates a new ShortcutIconResource for the specified context and resource 850 * identifier. 851 * 852 * @param context The context of the application. 853 * @param resourceId The resource identifier for the icon. 854 * @return A new ShortcutIconResource with the specified's context package name 855 * and icon resource identifier.`` 856 */ fromContext(Context context, @AnyRes int resourceId)857 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { 858 ShortcutIconResource icon = new ShortcutIconResource(); 859 icon.packageName = context.getPackageName(); 860 icon.resourceName = context.getResources().getResourceName(resourceId); 861 return icon; 862 } 863 864 /** 865 * Used to read a ShortcutIconResource from a Parcel. 866 */ 867 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR = 868 new Parcelable.Creator<ShortcutIconResource>() { 869 870 public ShortcutIconResource createFromParcel(Parcel source) { 871 ShortcutIconResource icon = new ShortcutIconResource(); 872 icon.packageName = source.readString(); 873 icon.resourceName = source.readString(); 874 return icon; 875 } 876 877 public ShortcutIconResource[] newArray(int size) { 878 return new ShortcutIconResource[size]; 879 } 880 }; 881 882 /** 883 * No special parcel contents. 884 */ describeContents()885 public int describeContents() { 886 return 0; 887 } 888 writeToParcel(Parcel dest, int flags)889 public void writeToParcel(Parcel dest, int flags) { 890 dest.writeString(packageName); 891 dest.writeString(resourceName); 892 } 893 894 @Override toString()895 public String toString() { 896 return resourceName; 897 } 898 } 899 900 /** 901 * Activity Action: Display an activity chooser, allowing the user to pick 902 * what they want to before proceeding. This can be used as an alternative 903 * to the standard activity picker that is displayed by the system when 904 * you try to start an activity with multiple possible matches, with these 905 * differences in behavior: 906 * <ul> 907 * <li>You can specify the title that will appear in the activity chooser. 908 * <li>The user does not have the option to make one of the matching 909 * activities a preferred activity, and all possible activities will 910 * always be shown even if one of them is currently marked as the 911 * preferred activity. 912 * </ul> 913 * <p> 914 * This action should be used when the user will naturally expect to 915 * select an activity in order to proceed. An example if when not to use 916 * it is when the user clicks on a "mailto:" link. They would naturally 917 * expect to go directly to their mail app, so startActivity() should be 918 * called directly: it will 919 * either launch the current preferred app, or put up a dialog allowing the 920 * user to pick an app to use and optionally marking that as preferred. 921 * <p> 922 * In contrast, if the user is selecting a menu item to send a picture 923 * they are viewing to someone else, there are many different things they 924 * may want to do at this point: send it through e-mail, upload it to a 925 * web service, etc. In this case the CHOOSER action should be used, to 926 * always present to the user a list of the things they can do, with a 927 * nice title given by the caller such as "Send this photo with:". 928 * <p> 929 * If you need to grant URI permissions through a chooser, you must specify 930 * the permissions to be granted on the ACTION_CHOOSER Intent 931 * <em>in addition</em> to the EXTRA_INTENT inside. This means using 932 * {@link #setClipData} to specify the URIs to be granted as well as 933 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 934 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. 935 * <p> 936 * As a convenience, an Intent of this form can be created with the 937 * {@link #createChooser} function. 938 * <p> 939 * Input: No data should be specified. get*Extra must have 940 * a {@link #EXTRA_INTENT} field containing the Intent being executed, 941 * and can optionally have a {@link #EXTRA_TITLE} field containing the 942 * title text to display in the chooser. 943 * <p> 944 * Output: Depends on the protocol of {@link #EXTRA_INTENT}. 945 */ 946 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 947 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; 948 949 /** 950 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 951 * 952 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 953 * target intent, also optionally supplying a title. If the target 954 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 955 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 956 * set in the returned chooser intent, with its ClipData set appropriately: 957 * either a direct reflection of {@link #getClipData()} if that is non-null, 958 * or a new ClipData built from {@link #getData()}. 959 * 960 * @param target The Intent that the user will be selecting an activity 961 * to perform. 962 * @param title Optional title that will be displayed in the chooser, 963 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 964 * @return Return a new Intent object that you can hand to 965 * {@link Context#startActivity(Intent) Context.startActivity()} and 966 * related methods. 967 */ createChooser(Intent target, CharSequence title)968 public static Intent createChooser(Intent target, CharSequence title) { 969 return createChooser(target, title, null); 970 } 971 972 /** 973 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 974 * 975 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 976 * target intent, also optionally supplying a title. If the target 977 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 978 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 979 * set in the returned chooser intent, with its ClipData set appropriately: 980 * either a direct reflection of {@link #getClipData()} if that is non-null, 981 * or a new ClipData built from {@link #getData()}.</p> 982 * 983 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback 984 * when the user makes a choice. This can be useful if the calling application wants 985 * to remember the last chosen target and surface it as a more prominent or one-touch 986 * affordance elsewhere in the UI for next time.</p> 987 * 988 * @param target The Intent that the user will be selecting an activity 989 * to perform. 990 * @param title Optional title that will be displayed in the chooser, 991 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 992 * @param sender Optional IntentSender to be called when a choice is made. 993 * @return Return a new Intent object that you can hand to 994 * {@link Context#startActivity(Intent) Context.startActivity()} and 995 * related methods. 996 */ createChooser(Intent target, CharSequence title, IntentSender sender)997 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) { 998 Intent intent = new Intent(ACTION_CHOOSER); 999 intent.putExtra(EXTRA_INTENT, target); 1000 if (title != null) { 1001 intent.putExtra(EXTRA_TITLE, title); 1002 } 1003 1004 if (sender != null) { 1005 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); 1006 } 1007 1008 // Migrate any clip data and flags from target. 1009 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION 1010 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 1011 | FLAG_GRANT_PREFIX_URI_PERMISSION); 1012 if (permFlags != 0) { 1013 ClipData targetClipData = target.getClipData(); 1014 if (targetClipData == null && target.getData() != null) { 1015 ClipData.Item item = new ClipData.Item(target.getData()); 1016 String[] mimeTypes; 1017 if (target.getType() != null) { 1018 mimeTypes = new String[] { target.getType() }; 1019 } else { 1020 mimeTypes = new String[] { }; 1021 } 1022 targetClipData = new ClipData(null, mimeTypes, item); 1023 } 1024 if (targetClipData != null) { 1025 intent.setClipData(targetClipData); 1026 intent.addFlags(permFlags); 1027 } 1028 } 1029 1030 return intent; 1031 } 1032 1033 /** 1034 * Activity Action: Allow the user to select a particular kind of data and 1035 * return it. This is different than {@link #ACTION_PICK} in that here we 1036 * just say what kind of data is desired, not a URI of existing data from 1037 * which the user can pick. An ACTION_GET_CONTENT could allow the user to 1038 * create the data as it runs (for example taking a picture or recording a 1039 * sound), let them browse over the web and download the desired data, 1040 * etc. 1041 * <p> 1042 * There are two main ways to use this action: if you want a specific kind 1043 * of data, such as a person contact, you set the MIME type to the kind of 1044 * data you want and launch it with {@link Context#startActivity(Intent)}. 1045 * The system will then launch the best application to select that kind 1046 * of data for you. 1047 * <p> 1048 * You may also be interested in any of a set of types of content the user 1049 * can pick. For example, an e-mail application that wants to allow the 1050 * user to add an attachment to an e-mail message can use this action to 1051 * bring up a list of all of the types of content the user can attach. 1052 * <p> 1053 * In this case, you should wrap the GET_CONTENT intent with a chooser 1054 * (through {@link #createChooser}), which will give the proper interface 1055 * for the user to pick how to send your data and allow you to specify 1056 * a prompt indicating what they are doing. You will usually specify a 1057 * broad MIME type (such as image/* or {@literal *}/*), resulting in a 1058 * broad range of content types the user can select from. 1059 * <p> 1060 * When using such a broad GET_CONTENT action, it is often desirable to 1061 * only pick from data that can be represented as a stream. This is 1062 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. 1063 * <p> 1064 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that 1065 * the launched content chooser only returns results representing data that 1066 * is locally available on the device. For example, if this extra is set 1067 * to true then an image picker should not show any pictures that are available 1068 * from a remote server but not already on the local device (thus requiring 1069 * they be downloaded when opened). 1070 * <p> 1071 * If the caller can handle multiple returned items (the user performing 1072 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} 1073 * to indicate this. 1074 * <p> 1075 * Input: {@link #getType} is the desired MIME type to retrieve. Note 1076 * that no URI is supplied in the intent, as there are no constraints on 1077 * where the returned data originally comes from. You may also include the 1078 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be 1079 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content 1080 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to 1081 * allow the user to select multiple items. 1082 * <p> 1083 * Output: The URI of the item that was picked. This must be a content: 1084 * URI so that any receiver can access it. 1085 */ 1086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1087 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; 1088 /** 1089 * Activity Action: Dial a number as specified by the data. This shows a 1090 * UI with the number being dialed, allowing the user to explicitly 1091 * initiate the call. 1092 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1093 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1094 * number. 1095 * <p>Output: nothing. 1096 */ 1097 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1098 public static final String ACTION_DIAL = "android.intent.action.DIAL"; 1099 /** 1100 * Activity Action: Perform a call to someone specified by the data. 1101 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1102 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1103 * number. 1104 * <p>Output: nothing. 1105 * 1106 * <p>Note: there will be restrictions on which applications can initiate a 1107 * call; most applications should use the {@link #ACTION_DIAL}. 1108 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency 1109 * numbers. Applications can <strong>dial</strong> emergency numbers using 1110 * {@link #ACTION_DIAL}, however. 1111 * 1112 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M} 1113 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE} 1114 * permission which is not granted, then attempting to use this action will 1115 * result in a {@link java.lang.SecurityException}. 1116 */ 1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1118 public static final String ACTION_CALL = "android.intent.action.CALL"; 1119 /** 1120 * Activity Action: Perform a call to an emergency number specified by the 1121 * data. 1122 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1123 * tel: URI of an explicit phone number. 1124 * <p>Output: nothing. 1125 * 1126 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on 1127 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} 1128 * extra (if specified) and may be placed on another {@link PhoneAccount} with the 1129 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external 1130 * factors, such as network conditions and Modem/SIM status. 1131 * @hide 1132 */ 1133 @SystemApi 1134 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1135 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; 1136 /** 1137 * Activity Action: Dial a emergency number specified by the data. This shows a 1138 * UI with the number being dialed, allowing the user to explicitly 1139 * initiate the call. 1140 * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData} 1141 * is a tel: URI of an explicit emergency phone number. 1142 * <p>Output: nothing. 1143 * @hide 1144 */ 1145 @SystemApi 1146 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1147 public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY"; 1148 /** 1149 * Activity action: Perform a call to any number (emergency or not) 1150 * specified by the data. 1151 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1152 * tel: URI of an explicit phone number. 1153 * <p>Output: nothing. 1154 * @hide 1155 */ 1156 @SystemApi 1157 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1158 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; 1159 1160 /** 1161 * Activity Action: Main entry point for carrier setup apps. 1162 * <p>Carrier apps that provide an implementation for this action may be invoked to configure 1163 * carrier service and typically require 1164 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to 1165 * fulfill their duties. 1166 */ 1167 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1168 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP"; 1169 /** 1170 * Activity Action: Send a message to someone specified by the data. 1171 * <p>Input: {@link #getData} is URI describing the target. 1172 * <p>Output: nothing. 1173 */ 1174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1175 public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; 1176 /** 1177 * Activity Action: Deliver some data to someone else. Who the data is 1178 * being delivered to is not specified; it is up to the receiver of this 1179 * action to ask the user where the data should be sent. 1180 * <p> 1181 * When launching a SEND intent, you should usually wrap it in a chooser 1182 * (through {@link #createChooser}), which will give the proper interface 1183 * for the user to pick how to send your data and allow you to specify 1184 * a prompt indicating what they are doing. 1185 * <p> 1186 * Input: {@link #getType} is the MIME type of the data being sent. 1187 * get*Extra can have either a {@link #EXTRA_TEXT} 1188 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If 1189 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it 1190 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* 1191 * if the MIME type is unknown (this will only allow senders that can 1192 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can 1193 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve 1194 * your text with HTML formatting. 1195 * <p> 1196 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1197 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1198 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1199 * content: URIs and other advanced features of {@link ClipData}. If 1200 * using this approach, you still must supply the same data through the 1201 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1202 * for compatibility with old applications. If you don't set a ClipData, 1203 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1204 * <p> 1205 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1206 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1207 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1208 * be openable only as asset typed files using 1209 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1210 * <p> 1211 * Optional standard extras, which may be interpreted by some recipients as 1212 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1213 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1214 * <p> 1215 * Output: nothing. 1216 */ 1217 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1218 public static final String ACTION_SEND = "android.intent.action.SEND"; 1219 /** 1220 * Activity Action: Deliver multiple data to someone else. 1221 * <p> 1222 * Like {@link #ACTION_SEND}, except the data is multiple. 1223 * <p> 1224 * Input: {@link #getType} is the MIME type of the data being sent. 1225 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link 1226 * #EXTRA_STREAM} field, containing the data to be sent. If using 1227 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} 1228 * for clients to retrieve your text with HTML formatting. 1229 * <p> 1230 * Multiple types are supported, and receivers should handle mixed types 1231 * whenever possible. The right way for the receiver to check them is to 1232 * use the content resolver on each URI. The intent sender should try to 1233 * put the most concrete mime type in the intent type, but it can fall 1234 * back to {@literal <type>/*} or {@literal *}/* as needed. 1235 * <p> 1236 * e.g. if you are sending image/jpg and image/jpg, the intent's type can 1237 * be image/jpg, but if you are sending image/jpg and image/png, then the 1238 * intent's type should be image/*. 1239 * <p> 1240 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1241 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1242 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1243 * content: URIs and other advanced features of {@link ClipData}. If 1244 * using this approach, you still must supply the same data through the 1245 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1246 * for compatibility with old applications. If you don't set a ClipData, 1247 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1248 * <p> 1249 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1250 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1251 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1252 * be openable only as asset typed files using 1253 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1254 * <p> 1255 * Optional standard extras, which may be interpreted by some recipients as 1256 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1257 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1258 * <p> 1259 * Output: nothing. 1260 */ 1261 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1262 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; 1263 /** 1264 * Activity Action: Handle an incoming phone call. 1265 * <p>Input: nothing. 1266 * <p>Output: nothing. 1267 */ 1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1269 public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; 1270 /** 1271 * Activity Action: Insert an empty item into the given container. 1272 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1273 * in which to place the data. 1274 * <p>Output: URI of the new data that was created. 1275 */ 1276 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1277 public static final String ACTION_INSERT = "android.intent.action.INSERT"; 1278 /** 1279 * Activity Action: Create a new item in the given container, initializing it 1280 * from the current contents of the clipboard. 1281 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1282 * in which to place the data. 1283 * <p>Output: URI of the new data that was created. 1284 */ 1285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1286 public static final String ACTION_PASTE = "android.intent.action.PASTE"; 1287 /** 1288 * Activity Action: Delete the given data from its container. 1289 * <p>Input: {@link #getData} is URI of data to be deleted. 1290 * <p>Output: nothing. 1291 */ 1292 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1293 public static final String ACTION_DELETE = "android.intent.action.DELETE"; 1294 /** 1295 * Activity Action: Run the data, whatever that means. 1296 * <p>Input: ? (Note: this is currently specific to the test harness.) 1297 * <p>Output: nothing. 1298 */ 1299 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1300 public static final String ACTION_RUN = "android.intent.action.RUN"; 1301 /** 1302 * Activity Action: Perform a data synchronization. 1303 * <p>Input: ? 1304 * <p>Output: ? 1305 */ 1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1307 public static final String ACTION_SYNC = "android.intent.action.SYNC"; 1308 /** 1309 * Activity Action: Pick an activity given an intent, returning the class 1310 * selected. 1311 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent 1312 * used with {@link PackageManager#queryIntentActivities} to determine the 1313 * set of activities from which to pick. 1314 * <p>Output: Class name of the activity that was selected. 1315 */ 1316 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1317 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; 1318 /** 1319 * Activity Action: Perform a search. 1320 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1321 * is the text to search for. If empty, simply 1322 * enter your search results Activity with the search UI activated. 1323 * <p>Output: nothing. 1324 */ 1325 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1326 public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; 1327 /** 1328 * Activity Action: Start the platform-defined tutorial 1329 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1330 * is the text to search for. If empty, simply 1331 * enter your search results Activity with the search UI activated. 1332 * <p>Output: nothing. 1333 */ 1334 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1335 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; 1336 /** 1337 * Activity Action: Perform a web search. 1338 * <p> 1339 * Input: {@link android.app.SearchManager#QUERY 1340 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is 1341 * a url starts with http or https, the site will be opened. If it is plain 1342 * text, Google search will be applied. 1343 * <p> 1344 * Output: nothing. 1345 */ 1346 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1347 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; 1348 1349 /** 1350 * Activity Action: Perform assist action. 1351 * <p> 1352 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1353 * additional optional contextual information about where the user was when they 1354 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer 1355 * information. 1356 * Output: nothing. 1357 */ 1358 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1359 public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; 1360 1361 /** 1362 * Activity Action: Perform voice assist action. 1363 * <p> 1364 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1365 * additional optional contextual information about where the user was when they 1366 * requested the voice assist. 1367 * Output: nothing. 1368 * @hide 1369 */ 1370 @SystemApi 1371 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1372 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; 1373 1374 /** 1375 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground 1376 * application package at the time the assist was invoked. 1377 */ 1378 public static final String EXTRA_ASSIST_PACKAGE 1379 = "android.intent.extra.ASSIST_PACKAGE"; 1380 1381 /** 1382 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground 1383 * application package at the time the assist was invoked. 1384 */ 1385 public static final String EXTRA_ASSIST_UID 1386 = "android.intent.extra.ASSIST_UID"; 1387 1388 /** 1389 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual 1390 * information supplied by the current foreground app at the time of the assist request. 1391 * This is a {@link Bundle} of additional data. 1392 */ 1393 public static final String EXTRA_ASSIST_CONTEXT 1394 = "android.intent.extra.ASSIST_CONTEXT"; 1395 1396 /** 1397 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a 1398 * keyboard as the primary input device for assistance. 1399 */ 1400 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = 1401 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; 1402 1403 /** 1404 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id 1405 * that was used to invoke the assist. 1406 */ 1407 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = 1408 "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; 1409 1410 /** 1411 * Activity Action: List all available applications. 1412 * <p>Input: Nothing. 1413 * <p>Output: nothing. 1414 */ 1415 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1416 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; 1417 /** 1418 * Activity Action: Show settings for choosing wallpaper. 1419 * <p>Input: Nothing. 1420 * <p>Output: Nothing. 1421 */ 1422 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1423 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; 1424 1425 /** 1426 * Activity Action: Show activity for reporting a bug. 1427 * <p>Input: Nothing. 1428 * <p>Output: Nothing. 1429 */ 1430 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1431 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; 1432 1433 /** 1434 * Activity Action: Main entry point for factory tests. Only used when 1435 * the device is booting in factory test node. The implementing package 1436 * must be installed in the system image. 1437 * <p>Input: nothing 1438 * <p>Output: nothing 1439 */ 1440 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1441 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; 1442 1443 /** 1444 * Activity Action: The user pressed the "call" button to go to the dialer 1445 * or other appropriate UI for placing a call. 1446 * <p>Input: Nothing. 1447 * <p>Output: Nothing. 1448 */ 1449 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1450 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; 1451 1452 /** 1453 * Activity Action: Start Voice Command. 1454 * <p>Input: Nothing. 1455 * <p>Output: Nothing. 1456 * <p class="note"> 1457 * In some cases, a matching Activity may not exist, so ensure you 1458 * safeguard against this. 1459 */ 1460 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1461 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; 1462 1463 /** 1464 * Activity Action: Start action associated with long pressing on the 1465 * search key. 1466 * <p>Input: Nothing. 1467 * <p>Output: Nothing. 1468 */ 1469 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1470 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; 1471 1472 /** 1473 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. 1474 * This intent is delivered to the package which installed the application, usually 1475 * Google Play. 1476 * <p>Input: No data is specified. The bug report is passed in using 1477 * an {@link #EXTRA_BUG_REPORT} field. 1478 * <p>Output: Nothing. 1479 * 1480 * @see #EXTRA_BUG_REPORT 1481 */ 1482 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1483 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; 1484 1485 /** 1486 * An incident or bug report has been taken, and a system app has requested it to be shared, 1487 * so trigger the confirmation screen. 1488 * 1489 * This will be sent directly to the registered receiver with the 1490 * android.permission.APPROVE_INCIDENT_REPORTS permission. 1491 * @hide 1492 */ 1493 @SystemApi 1494 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED = 1495 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED"; 1496 1497 /** 1498 * An incident report has been taken, and the user has approved it for sharing. 1499 * <p> 1500 * This will be sent directly to the registered receiver, which must have 1501 * both the DUMP and USAGE_STATS permissions. 1502 * <p> 1503 * After receiving this, the application should wait until a suitable time 1504 * (e.g. network available), get the list of available reports with 1505 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)} 1506 * and then when the reports have been successfully uploaded, call 1507 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}. 1508 * 1509 * @hide 1510 */ 1511 @SystemApi 1512 public static final String ACTION_INCIDENT_REPORT_READY = 1513 "android.intent.action.INCIDENT_REPORT_READY"; 1514 1515 /** 1516 * Activity Action: Show power usage information to the user. 1517 * <p>Input: Nothing. 1518 * <p>Output: Nothing. 1519 */ 1520 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1521 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; 1522 1523 /** 1524 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs 1525 * to run. 1526 * <p>Input: Nothing. 1527 * <p>Output: Nothing. 1528 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified 1529 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD} 1530 * @hide 1531 * @removed 1532 */ 1533 @Deprecated 1534 @SystemApi 1535 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = 1536 "android.intent.action.DEVICE_INITIALIZATION_WIZARD"; 1537 1538 /** 1539 * Activity Action: Setup wizard to launch after a platform update. This 1540 * activity should have a string meta-data field associated with it, 1541 * {@link #METADATA_SETUP_VERSION}, which defines the current version of 1542 * the platform for setup. The activity will be launched only if 1543 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the 1544 * same value. 1545 * <p>Input: Nothing. 1546 * <p>Output: Nothing. 1547 * @hide 1548 */ 1549 @SystemApi 1550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1551 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; 1552 1553 /** 1554 * Activity Action: Start the Keyboard Shortcuts Helper screen. 1555 * <p>Input: Nothing. 1556 * <p>Output: Nothing. 1557 * @hide 1558 */ 1559 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1560 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = 1561 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; 1562 1563 /** 1564 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. 1565 * <p>Input: Nothing. 1566 * <p>Output: Nothing. 1567 * @hide 1568 */ 1569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1570 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = 1571 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; 1572 1573 /** 1574 * Activity Action: Show settings for managing network data usage of a 1575 * specific application. Applications should define an activity that offers 1576 * options to control data usage. 1577 */ 1578 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1579 public static final String ACTION_MANAGE_NETWORK_USAGE = 1580 "android.intent.action.MANAGE_NETWORK_USAGE"; 1581 1582 /** 1583 * Activity Action: Launch application installer. 1584 * <p> 1585 * Input: The data must be a content: URI at which the application 1586 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, 1587 * you can also use "package:<package-name>" to install an application for the 1588 * current user that is already installed for another user. You can optionally supply 1589 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, 1590 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. 1591 * <p> 1592 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1593 * succeeded. 1594 * <p> 1595 * <strong>Note:</strong>If your app is targeting API level higher than 25 you 1596 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} 1597 * in order to launch the application installer. 1598 * </p> 1599 * 1600 * @see #EXTRA_INSTALLER_PACKAGE_NAME 1601 * @see #EXTRA_NOT_UNKNOWN_SOURCE 1602 * @see #EXTRA_RETURN_RESULT 1603 * 1604 * @deprecated use {@link android.content.pm.PackageInstaller} instead 1605 */ 1606 @Deprecated 1607 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1608 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; 1609 1610 /** 1611 * Activity Action: Activity to handle split installation failures. 1612 * <p>Splits may be installed dynamically. This happens when an Activity is launched, 1613 * but the split that contains the application isn't installed. When a split is 1614 * installed in this manner, the containing package usually doesn't know this is 1615 * happening. However, if an error occurs during installation, the containing 1616 * package can define a single activity handling this action to deal with such 1617 * failures. 1618 * <p>The activity handling this action must be in the base package. 1619 * <p> 1620 * Input: {@link #EXTRA_INTENT} the original intent that started split installation. 1621 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed. 1622 */ 1623 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1624 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE"; 1625 1626 /** 1627 * Activity Action: Launch instant application installer. 1628 * <p class="note"> 1629 * This is a protected intent that can only be sent by the system. 1630 * </p> 1631 * 1632 * @hide 1633 */ 1634 @SystemApi 1635 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1636 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE 1637 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE"; 1638 1639 /** 1640 * Service Action: Resolve instant application. 1641 * <p> 1642 * The system will have a persistent connection to this service. 1643 * This is a protected intent that can only be sent by the system. 1644 * </p> 1645 * 1646 * @hide 1647 */ 1648 @SystemApi 1649 @SdkConstant(SdkConstantType.SERVICE_ACTION) 1650 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE 1651 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; 1652 1653 /** 1654 * Activity Action: Launch instant app settings. 1655 * 1656 * <p class="note"> 1657 * This is a protected intent that can only be sent by the system. 1658 * </p> 1659 * 1660 * @hide 1661 */ 1662 @SystemApi 1663 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1664 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS 1665 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS"; 1666 1667 /** 1668 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1669 * package. Specifies the installer package name; this package will receive the 1670 * {@link #ACTION_APP_ERROR} intent. 1671 */ 1672 public static final String EXTRA_INSTALLER_PACKAGE_NAME 1673 = "android.intent.extra.INSTALLER_PACKAGE_NAME"; 1674 1675 /** 1676 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1677 * package. Specifies that the application being installed should not be 1678 * treated as coming from an unknown source, but as coming from the app 1679 * invoking the Intent. For this to work you must start the installer with 1680 * startActivityForResult(). 1681 */ 1682 public static final String EXTRA_NOT_UNKNOWN_SOURCE 1683 = "android.intent.extra.NOT_UNKNOWN_SOURCE"; 1684 1685 /** 1686 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and 1687 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent 1688 * data field originated from. 1689 */ 1690 public static final String EXTRA_ORIGINATING_URI 1691 = "android.intent.extra.ORIGINATING_URI"; 1692 1693 /** 1694 * This extra can be used with any Intent used to launch an activity, supplying information 1695 * about who is launching that activity. This field contains a {@link android.net.Uri} 1696 * object, typically an http: or https: URI of the web site that the referral came from; 1697 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify 1698 * a native application that it came from. 1699 * 1700 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} 1701 * instead of directly retrieving the extra. It is also valid for applications to 1702 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create 1703 * a string, not a Uri; the field here, if supplied, will always take precedence, 1704 * however.</p> 1705 * 1706 * @see #EXTRA_REFERRER_NAME 1707 */ 1708 public static final String EXTRA_REFERRER 1709 = "android.intent.extra.REFERRER"; 1710 1711 /** 1712 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather 1713 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can 1714 * not be created, in particular when Intent extras are supplied through the 1715 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} 1716 * schemes. 1717 * 1718 * @see #EXTRA_REFERRER 1719 */ 1720 public static final String EXTRA_REFERRER_NAME 1721 = "android.intent.extra.REFERRER_NAME"; 1722 1723 /** 1724 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and 1725 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install 1726 * Currently only a system app that hosts the provider authority "downloads" or holds the 1727 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this. 1728 * @hide 1729 */ 1730 @SystemApi 1731 public static final String EXTRA_ORIGINATING_UID 1732 = "android.intent.extra.ORIGINATING_UID"; 1733 1734 /** 1735 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1736 * package. Tells the installer UI to skip the confirmation with the user 1737 * if the .apk is replacing an existing one. 1738 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android 1739 * will no longer show an interstitial message about updating existing 1740 * applications so this is no longer needed. 1741 */ 1742 @Deprecated 1743 public static final String EXTRA_ALLOW_REPLACE 1744 = "android.intent.extra.ALLOW_REPLACE"; 1745 1746 /** 1747 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or 1748 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should 1749 * return to the application the result code of the install/uninstall. The returned result 1750 * code will be {@link android.app.Activity#RESULT_OK} on success or 1751 * {@link android.app.Activity#RESULT_FIRST_USER} on failure. 1752 */ 1753 public static final String EXTRA_RETURN_RESULT 1754 = "android.intent.extra.RETURN_RESULT"; 1755 1756 /** 1757 * Package manager install result code. @hide because result codes are not 1758 * yet ready to be exposed. 1759 */ 1760 public static final String EXTRA_INSTALL_RESULT 1761 = "android.intent.extra.INSTALL_RESULT"; 1762 1763 /** 1764 * Activity Action: Launch application uninstaller. 1765 * <p> 1766 * Input: The data must be a package: URI whose scheme specific part is 1767 * the package name of the current installed package to be uninstalled. 1768 * You can optionally supply {@link #EXTRA_RETURN_RESULT}. 1769 * <p> 1770 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1771 * succeeded. 1772 * <p> 1773 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} 1774 * since {@link Build.VERSION_CODES#P}. 1775 * 1776 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)} 1777 * instead 1778 */ 1779 @Deprecated 1780 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1781 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; 1782 1783 /** 1784 * Specify whether the package should be uninstalled for all users. 1785 * @hide because these should not be part of normal application flow. 1786 */ 1787 public static final String EXTRA_UNINSTALL_ALL_USERS 1788 = "android.intent.extra.UNINSTALL_ALL_USERS"; 1789 1790 /** 1791 * A string that associates with a metadata entry, indicating the last run version of the 1792 * platform that was setup. 1793 * 1794 * @see #ACTION_UPGRADE_SETUP 1795 * 1796 * @hide 1797 */ 1798 @SystemApi 1799 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; 1800 1801 /** 1802 * Activity action: Launch UI to manage the permissions of an app. 1803 * <p> 1804 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions 1805 * will be managed by the launched UI. 1806 * </p> 1807 * <p> 1808 * Output: Nothing. 1809 * </p> 1810 * 1811 * @see #EXTRA_PACKAGE_NAME 1812 * 1813 * @hide 1814 */ 1815 @SystemApi 1816 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1817 public static final String ACTION_MANAGE_APP_PERMISSIONS = 1818 "android.intent.action.MANAGE_APP_PERMISSIONS"; 1819 1820 /** 1821 * Activity action: Launch UI to manage a specific permissions of an app. 1822 * <p> 1823 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission 1824 * will be managed by the launched UI. 1825 * </p> 1826 * <p> 1827 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission 1828 * that should be managed by the launched UI. 1829 * </p> 1830 * <p> 1831 * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app. 1832 * </p> 1833 * <p> 1834 * Output: Nothing. 1835 * </p> 1836 * 1837 * @see #EXTRA_PACKAGE_NAME 1838 * @see #EXTRA_PERMISSION_NAME 1839 * @see #EXTRA_USER 1840 * 1841 * @hide 1842 */ 1843 @SystemApi 1844 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 1845 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1846 public static final String ACTION_MANAGE_APP_PERMISSION = 1847 "android.intent.action.MANAGE_APP_PERMISSION"; 1848 1849 /** 1850 * Activity action: Launch UI to manage permissions. 1851 * <p> 1852 * Input: Nothing. 1853 * </p> 1854 * <p> 1855 * Output: Nothing. 1856 * </p> 1857 * 1858 * @hide 1859 */ 1860 @SystemApi 1861 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1862 public static final String ACTION_MANAGE_PERMISSIONS = 1863 "android.intent.action.MANAGE_PERMISSIONS"; 1864 1865 /** 1866 * Activity action: Launch UI to review permissions for an app. 1867 * The system uses this intent if permission review for apps not 1868 * supporting the new runtime permissions model is enabled. In 1869 * this mode a permission review is required before any of the 1870 * app components can run. 1871 * <p> 1872 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose 1873 * permissions will be reviewed (mandatory). 1874 * </p> 1875 * <p> 1876 * Input: {@link #EXTRA_INTENT} specifies a pending intent to 1877 * be fired after the permission review (optional). 1878 * </p> 1879 * <p> 1880 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to 1881 * be invoked after the permission review (optional). 1882 * </p> 1883 * <p> 1884 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent 1885 * passed via {@link #EXTRA_INTENT} needs a result (optional). 1886 * </p> 1887 * <p> 1888 * Output: Nothing. 1889 * </p> 1890 * 1891 * @see #EXTRA_PACKAGE_NAME 1892 * @see #EXTRA_INTENT 1893 * @see #EXTRA_REMOTE_CALLBACK 1894 * @see #EXTRA_RESULT_NEEDED 1895 * 1896 * @hide 1897 */ 1898 @SystemApi 1899 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1900 public static final String ACTION_REVIEW_PERMISSIONS = 1901 "android.intent.action.REVIEW_PERMISSIONS"; 1902 1903 /** 1904 * Activity action: Launch UI to show information about the usage 1905 * of a given permission. This action would be handled by apps that 1906 * want to show details about how and why given permission is being 1907 * used. 1908 * <p> 1909 * <strong>Important:</strong>You must protect the activity that handles 1910 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE 1911 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the 1912 * system can launch this activity. The system will not launch 1913 * activities that are not properly protected. 1914 * 1915 * <p> 1916 * Input: {@code android.intent.extra.PERMISSION_NAME} specifies the permission 1917 * for which the launched UI would be targeted. 1918 * </p> 1919 * <p> 1920 * Output: Nothing. 1921 * </p> 1922 */ 1923 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1924 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 1925 public static final String ACTION_VIEW_PERMISSION_USAGE = 1926 "android.intent.action.VIEW_PERMISSION_USAGE"; 1927 1928 /** 1929 * Activity action: Launch UI to manage a default app. 1930 * <p> 1931 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed 1932 * by the launched UI. 1933 * </p> 1934 * <p> 1935 * Output: Nothing. 1936 * </p> 1937 * 1938 * @hide 1939 */ 1940 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 1941 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1942 @SystemApi 1943 public static final String ACTION_MANAGE_DEFAULT_APP = 1944 "android.intent.action.MANAGE_DEFAULT_APP"; 1945 1946 /** 1947 * Intent extra: A role name. 1948 * <p> 1949 * Type: String 1950 * </p> 1951 * 1952 * @see android.app.role.RoleManager 1953 * 1954 * @hide 1955 */ 1956 @SystemApi 1957 @TestApi 1958 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME"; 1959 1960 /** 1961 * Activity action: Launch UI to manage special app accesses. 1962 * <p> 1963 * Input: Nothing. 1964 * </p> 1965 * <p> 1966 * Output: Nothing. 1967 * </p> 1968 * 1969 * @hide 1970 */ 1971 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 1972 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1973 @SystemApi 1974 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES = 1975 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES"; 1976 1977 /** 1978 * Intent extra: A callback for reporting remote result as a bundle. 1979 * <p> 1980 * Type: IRemoteCallback 1981 * </p> 1982 * 1983 * @hide 1984 */ 1985 @SystemApi 1986 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; 1987 1988 /** 1989 * Intent extra: An app package name. 1990 * <p> 1991 * Type: String 1992 * </p> 1993 * 1994 */ 1995 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; 1996 1997 /** 1998 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an 1999 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}. 2000 * 2001 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the 2002 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}. 2003 * This is meant to enable the suspended app to better handle the state of being suspended. 2004 * 2005 * @see #ACTION_MY_PACKAGE_SUSPENDED 2006 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2007 * @see PackageManager#isPackageSuspended() 2008 * @see PackageManager#getSuspendedPackageAppExtras() 2009 */ 2010 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS"; 2011 2012 /** 2013 * Intent extra: An app split name. 2014 * <p> 2015 * Type: String 2016 * </p> 2017 */ 2018 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; 2019 2020 /** 2021 * Intent extra: A {@link ComponentName} value. 2022 * <p> 2023 * Type: String 2024 * </p> 2025 */ 2026 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME"; 2027 2028 /** 2029 * Intent extra: An extra for specifying whether a result is needed. 2030 * <p> 2031 * Type: boolean 2032 * </p> 2033 * 2034 * @hide 2035 */ 2036 @SystemApi 2037 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; 2038 2039 /** 2040 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on 2041 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}. 2042 * 2043 * @see PackageManager#isPackageSuspended() 2044 * @see #ACTION_PACKAGES_SUSPENDED 2045 * 2046 * @hide 2047 */ 2048 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS"; 2049 2050 /** 2051 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with 2052 * {@link #ACTION_SEND}. 2053 * 2054 * @see ShortcutInfo#getId() 2055 * 2056 * <p> 2057 * Type: String 2058 * </p> 2059 */ 2060 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID"; 2061 2062 /** 2063 * Activity action: Launch UI to manage which apps have a given permission. 2064 * <p> 2065 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group 2066 * which will be managed by the launched UI. 2067 * </p> 2068 * <p> 2069 * Output: Nothing. 2070 * </p> 2071 * 2072 * @see #EXTRA_PERMISSION_NAME 2073 * 2074 * @hide 2075 */ 2076 @SystemApi 2077 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2078 public static final String ACTION_MANAGE_PERMISSION_APPS = 2079 "android.intent.action.MANAGE_PERMISSION_APPS"; 2080 2081 /** 2082 * Intent extra: The name of a permission. 2083 * <p> 2084 * Type: String 2085 * </p> 2086 * 2087 * @hide 2088 */ 2089 @SystemApi 2090 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; 2091 2092 /** 2093 * Intent extra: The name of a permission group. 2094 * <p> 2095 * Type: String 2096 * </p> 2097 * 2098 * @hide 2099 */ 2100 @SystemApi 2101 public static final String EXTRA_PERMISSION_GROUP_NAME = 2102 "android.intent.extra.PERMISSION_GROUP_NAME"; 2103 2104 /** 2105 * Intent extra: The number of milliseconds. 2106 * <p> 2107 * Type: long 2108 * </p> 2109 */ 2110 public static final String EXTRA_DURATION_MILLIS = 2111 "android.intent.extra.DURATION_MILLIS"; 2112 2113 /** 2114 * Activity action: Launch UI to review app uses of permissions. 2115 * <p> 2116 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name 2117 * that will be displayed by the launched UI. Do not pass both this and 2118 * {@link #EXTRA_PERMISSION_GROUP_NAME} . 2119 * </p> 2120 * <p> 2121 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2122 * that will be displayed by the launched UI. Do not pass both this and 2123 * {@link #EXTRA_PERMISSION_NAME}. 2124 * </p> 2125 * <p> 2126 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2127 * activity to show (optional). Must be non-negative. 2128 * </p> 2129 * <p> 2130 * Output: Nothing. 2131 * </p> 2132 * <p class="note"> 2133 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2134 * </p> 2135 * 2136 * @see #EXTRA_PERMISSION_NAME 2137 * @see #EXTRA_PERMISSION_GROUP_NAME 2138 * @see #EXTRA_DURATION_MILLIS 2139 * 2140 * @hide 2141 */ 2142 @SystemApi 2143 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2144 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2145 public static final String ACTION_REVIEW_PERMISSION_USAGE = 2146 "android.intent.action.REVIEW_PERMISSION_USAGE"; 2147 2148 /** 2149 * Activity action: Launch UI to review ongoing app uses of permissions. 2150 * <p> 2151 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2152 * activity to show (optional). Must be non-negative. 2153 * </p> 2154 * <p> 2155 * Output: Nothing. 2156 * </p> 2157 * <p class="note"> 2158 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2159 * </p> 2160 * 2161 * @see #EXTRA_DURATION_MILLIS 2162 * 2163 * @hide 2164 */ 2165 @SystemApi 2166 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2167 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2168 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE = 2169 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE"; 2170 2171 /** 2172 * Activity action: Launch UI to review running accessibility services. 2173 * <p> 2174 * Input: Nothing. 2175 * </p> 2176 * <p> 2177 * Output: Nothing. 2178 * </p> 2179 * 2180 * @hide 2181 */ 2182 @SystemApi 2183 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES) 2184 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2185 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES = 2186 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"; 2187 2188 // --------------------------------------------------------------------- 2189 // --------------------------------------------------------------------- 2190 // Standard intent broadcast actions (see action variable). 2191 2192 /** 2193 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. 2194 * <p> 2195 * For historical reasons, the name of this broadcast action refers to the power 2196 * state of the screen but it is actually sent in response to changes in the 2197 * overall interactive state of the device. 2198 * </p><p> 2199 * This broadcast is sent when the device becomes non-interactive which may have 2200 * nothing to do with the screen turning off. To determine the 2201 * actual state of the screen, use {@link android.view.Display#getState}. 2202 * </p><p> 2203 * See {@link android.os.PowerManager#isInteractive} for details. 2204 * </p> 2205 * You <em>cannot</em> receive this through components declared in 2206 * manifests, only by explicitly registering for it with 2207 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2208 * Context.registerReceiver()}. 2209 * 2210 * <p class="note">This is a protected intent that can only be sent 2211 * by the system. 2212 */ 2213 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2214 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; 2215 2216 /** 2217 * Broadcast Action: Sent when the device wakes up and becomes interactive. 2218 * <p> 2219 * For historical reasons, the name of this broadcast action refers to the power 2220 * state of the screen but it is actually sent in response to changes in the 2221 * overall interactive state of the device. 2222 * </p><p> 2223 * This broadcast is sent when the device becomes interactive which may have 2224 * nothing to do with the screen turning on. To determine the 2225 * actual state of the screen, use {@link android.view.Display#getState}. 2226 * </p><p> 2227 * See {@link android.os.PowerManager#isInteractive} for details. 2228 * </p> 2229 * You <em>cannot</em> receive this through components declared in 2230 * manifests, only by explicitly registering for it with 2231 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2232 * Context.registerReceiver()}. 2233 * 2234 * <p class="note">This is a protected intent that can only be sent 2235 * by the system. 2236 */ 2237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2238 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; 2239 2240 /** 2241 * Broadcast Action: Sent after the system stops dreaming. 2242 * 2243 * <p class="note">This is a protected intent that can only be sent by the system. 2244 * It is only sent to registered receivers.</p> 2245 */ 2246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2247 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; 2248 2249 /** 2250 * Broadcast Action: Sent after the system starts dreaming. 2251 * 2252 * <p class="note">This is a protected intent that can only be sent by the system. 2253 * It is only sent to registered receivers.</p> 2254 */ 2255 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2256 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; 2257 2258 /** 2259 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the 2260 * keyguard is gone). 2261 * 2262 * <p class="note">This is a protected intent that can only be sent 2263 * by the system. 2264 */ 2265 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2266 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; 2267 2268 /** 2269 * Broadcast Action: The current time has changed. Sent every 2270 * minute. You <em>cannot</em> receive this through components declared 2271 * in manifests, only by explicitly registering for it with 2272 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2273 * Context.registerReceiver()}. 2274 * 2275 * <p class="note">This is a protected intent that can only be sent 2276 * by the system. 2277 */ 2278 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2279 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; 2280 /** 2281 * Broadcast Action: The time was set. 2282 */ 2283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2284 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; 2285 /** 2286 * Broadcast Action: The date has changed. 2287 */ 2288 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2289 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; 2290 /** 2291 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> 2292 * <ul> 2293 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li> 2294 * </ul> 2295 * 2296 * <p class="note">This is a protected intent that can only be sent 2297 * by the system. 2298 */ 2299 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2300 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; 2301 /** 2302 * Clear DNS Cache Action: This is broadcast when networks have changed and old 2303 * DNS entries should be tossed. 2304 * @hide 2305 */ 2306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2307 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE"; 2308 /** 2309 * Alarm Changed Action: This is broadcast when the AlarmClock 2310 * application's alarm is set or unset. It is used by the 2311 * AlarmClock application and the StatusBar service. 2312 * @hide 2313 */ 2314 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2315 @UnsupportedAppUsage 2316 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; 2317 2318 /** 2319 * Broadcast Action: This is broadcast once, after the user has finished 2320 * booting, but while still in the "locked" state. It can be used to perform 2321 * application-specific initialization, such as installing alarms. You must 2322 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} 2323 * permission in order to receive this broadcast. 2324 * <p> 2325 * This broadcast is sent immediately at boot by all devices (regardless of 2326 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or 2327 * higher. Upon receipt of this broadcast, the user is still locked and only 2328 * device-protected storage can be accessed safely. If you want to access 2329 * credential-protected storage, you need to wait for the user to be 2330 * unlocked (typically by entering their lock pattern or PIN for the first 2331 * time), after which the {@link #ACTION_USER_UNLOCKED} and 2332 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. 2333 * <p> 2334 * To receive this broadcast, your receiver component must be marked as 2335 * being {@link ComponentInfo#directBootAware}. 2336 * <p class="note"> 2337 * This is a protected intent that can only be sent by the system. 2338 * 2339 * @see Context#createDeviceProtectedStorageContext() 2340 */ 2341 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2342 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; 2343 2344 /** 2345 * Broadcast Action: This is broadcast once, after the user has finished 2346 * booting. It can be used to perform application-specific initialization, 2347 * such as installing alarms. You must hold the 2348 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in 2349 * order to receive this broadcast. 2350 * <p> 2351 * This broadcast is sent at boot by all devices (both with and without 2352 * direct boot support). Upon receipt of this broadcast, the user is 2353 * unlocked and both device-protected and credential-protected storage can 2354 * accessed safely. 2355 * <p> 2356 * If you need to run while the user is still locked (before they've entered 2357 * their lock pattern or PIN for the first time), you can listen for the 2358 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. 2359 * <p class="note"> 2360 * This is a protected intent that can only be sent by the system. 2361 */ 2362 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2363 @BroadcastBehavior(includeBackground = true) 2364 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; 2365 2366 /** 2367 * Broadcast Action: This is broadcast when a user action should request a 2368 * temporary system dialog to dismiss. Some examples of temporary system 2369 * dialogs are the notification window-shade and the recent tasks dialog. 2370 */ 2371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2372 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; 2373 /** 2374 * Broadcast Action: Trigger the download and eventual installation 2375 * of a package. 2376 * <p>Input: {@link #getData} is the URI of the package file to download. 2377 * 2378 * <p class="note">This is a protected intent that can only be sent 2379 * by the system. 2380 * 2381 * @deprecated This constant has never been used. 2382 */ 2383 @Deprecated 2384 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2385 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; 2386 /** 2387 * Broadcast Action: A new application package has been installed on the 2388 * device. The data contains the name of the package. Note that the 2389 * newly installed package does <em>not</em> receive this broadcast. 2390 * <p>May include the following extras: 2391 * <ul> 2392 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2393 * <li> {@link #EXTRA_REPLACING} is set to true if this is following 2394 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. 2395 * </ul> 2396 * 2397 * <p class="note">This is a protected intent that can only be sent 2398 * by the system. 2399 */ 2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2401 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; 2402 /** 2403 * Broadcast Action: A new version of an application package has been 2404 * installed, replacing an existing version that was previously installed. 2405 * The data contains the name of the package. 2406 * <p>May include the following extras: 2407 * <ul> 2408 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2409 * </ul> 2410 * 2411 * <p class="note">This is a protected intent that can only be sent 2412 * by the system. 2413 */ 2414 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2415 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; 2416 /** 2417 * Broadcast Action: A new version of your application has been installed 2418 * over an existing one. This is only sent to the application that was 2419 * replaced. It does not contain any additional data; to receive it, just 2420 * use an intent filter for this action. 2421 * 2422 * <p class="note">This is a protected intent that can only be sent 2423 * by the system. 2424 */ 2425 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2426 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; 2427 /** 2428 * Broadcast Action: An existing application package has been removed from 2429 * the device. The data contains the name of the package. The package 2430 * that is being removed does <em>not</em> receive this Intent. 2431 * <ul> 2432 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2433 * to the package. 2434 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2435 * application -- data and code -- is being removed. 2436 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2437 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2438 * </ul> 2439 * 2440 * <p class="note">This is a protected intent that can only be sent 2441 * by the system. 2442 */ 2443 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2444 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; 2445 /** 2446 * Broadcast Action: An existing application package has been completely 2447 * removed from the device. The data contains the name of the package. 2448 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when 2449 * {@link #EXTRA_DATA_REMOVED} is true and 2450 * {@link #EXTRA_REPLACING} is false of that broadcast. 2451 * 2452 * <ul> 2453 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2454 * to the package. 2455 * </ul> 2456 * 2457 * <p class="note">This is a protected intent that can only be sent 2458 * by the system. 2459 */ 2460 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2461 public static final String ACTION_PACKAGE_FULLY_REMOVED 2462 = "android.intent.action.PACKAGE_FULLY_REMOVED"; 2463 /** 2464 * Broadcast Action: An existing application package has been changed (for 2465 * example, a component has been enabled or disabled). The data contains 2466 * the name of the package. 2467 * <ul> 2468 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2469 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name 2470 * of the changed components (or the package name itself). 2471 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the 2472 * default action of restarting the application. 2473 * </ul> 2474 * 2475 * <p class="note">This is a protected intent that can only be sent 2476 * by the system. 2477 */ 2478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2479 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; 2480 /** 2481 * Broadcast Action: Sent to the system rollback manager when a package 2482 * needs to have rollback enabled. 2483 * <p class="note"> 2484 * This is a protected intent that can only be sent by the system. 2485 * </p> 2486 * 2487 * @hide This broadcast is used internally by the system. 2488 */ 2489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2490 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK = 2491 "android.intent.action.PACKAGE_ENABLE_ROLLBACK"; 2492 /** 2493 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain 2494 * package needs to be cancelled. 2495 * 2496 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager 2497 * that enabling a specific rollback has timed out. 2498 * 2499 * @hide 2500 */ 2501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2502 public static final String ACTION_CANCEL_ENABLE_ROLLBACK = 2503 "android.intent.action.CANCEL_ENABLE_ROLLBACK"; 2504 /** 2505 * Broadcast Action: A rollback has been committed. 2506 * 2507 * <p class="note">This is a protected intent that can only be sent 2508 * by the system. The receiver must hold MANAGE_ROLLBACK permission. 2509 * 2510 * @hide 2511 */ 2512 @SystemApi @TestApi 2513 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2514 public static final String ACTION_ROLLBACK_COMMITTED = 2515 "android.intent.action.ROLLBACK_COMMITTED"; 2516 /** 2517 * @hide 2518 * Broadcast Action: Ask system services if there is any reason to 2519 * restart the given package. The data contains the name of the 2520 * package. 2521 * <ul> 2522 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2523 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. 2524 * </ul> 2525 * 2526 * <p class="note">This is a protected intent that can only be sent 2527 * by the system. 2528 */ 2529 @SystemApi 2530 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2531 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; 2532 /** 2533 * Broadcast Action: The user has restarted a package, and all of its 2534 * processes have been killed. All runtime state 2535 * associated with it (processes, alarms, notifications, etc) should 2536 * be removed. Note that the restarted package does <em>not</em> 2537 * receive this broadcast. 2538 * The data contains the name of the package. 2539 * <ul> 2540 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2541 * </ul> 2542 * 2543 * <p class="note">This is a protected intent that can only be sent 2544 * by the system. 2545 */ 2546 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2547 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; 2548 /** 2549 * Broadcast Action: The user has cleared the data of a package. This should 2550 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of 2551 * its persistent data is erased and this broadcast sent. 2552 * Note that the cleared package does <em>not</em> 2553 * receive this broadcast. The data contains the name of the package. 2554 * <ul> 2555 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the 2556 * package whose data was cleared is an uninstalled instant app, then the UID 2557 * will be -1. The platform keeps some meta-data associated with instant apps 2558 * after they are uninstalled. 2559 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared 2560 * data was for an instant app. 2561 * </ul> 2562 * 2563 * <p class="note">This is a protected intent that can only be sent 2564 * by the system. 2565 */ 2566 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2567 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; 2568 /** 2569 * Broadcast Action: Packages have been suspended. 2570 * <p>Includes the following extras: 2571 * <ul> 2572 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended 2573 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended 2574 * </ul> 2575 * 2576 * <p class="note">This is a protected intent that can only be sent 2577 * by the system. It is only sent to registered receivers. 2578 */ 2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2580 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; 2581 /** 2582 * Broadcast Action: Packages have been unsuspended. 2583 * <p>Includes the following extras: 2584 * <ul> 2585 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended 2586 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended 2587 * </ul> 2588 * 2589 * <p class="note">This is a protected intent that can only be sent 2590 * by the system. It is only sent to registered receivers. 2591 */ 2592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2593 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; 2594 2595 /** 2596 * Broadcast Action: Distracting packages have been changed. 2597 * <p>Includes the following extras: 2598 * <ul> 2599 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed. 2600 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed. 2601 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages. 2602 * </ul> 2603 * 2604 * <p class="note">This is a protected intent that can only be sent 2605 * by the system. It is only sent to registered receivers. 2606 * 2607 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 2608 * @hide 2609 */ 2610 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2611 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED = 2612 "android.intent.action.DISTRACTING_PACKAGES_CHANGED"; 2613 2614 /** 2615 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent 2616 * whenever a package is put into a suspended state or any of its app extras change while in the 2617 * suspended state. 2618 * <p> Optionally includes the following extras: 2619 * <ul> 2620 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain 2621 * useful information for the app being suspended. 2622 * </ul> 2623 * <p class="note">This is a protected intent that can only be sent 2624 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2625 * the manifest.</em> 2626 * 2627 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2628 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2629 * @see PackageManager#isPackageSuspended() 2630 * @see PackageManager#getSuspendedPackageAppExtras() 2631 */ 2632 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2633 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED"; 2634 2635 /** 2636 * Activity Action: Started to show more details about why an application was suspended. 2637 * 2638 * <p>Whenever the system detects an activity launch for a suspended app, this action can 2639 * be used to show more details about the reason for suspension. 2640 * 2641 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity 2642 * handling this intent and protect it with 2643 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}. 2644 * 2645 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package. 2646 * 2647 * <p class="note">This is a protected intent that can only be sent 2648 * by the system. 2649 * 2650 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2651 * PersistableBundle, String) 2652 * @see PackageManager#isPackageSuspended() 2653 * @see #ACTION_PACKAGES_SUSPENDED 2654 * 2655 * @hide 2656 */ 2657 @SystemApi 2658 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2659 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS = 2660 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS"; 2661 2662 /** 2663 * Broadcast Action: Sent to a package that has been unsuspended. 2664 * 2665 * <p class="note">This is a protected intent that can only be sent 2666 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2667 * the manifest.</em> 2668 * 2669 * @see #ACTION_MY_PACKAGE_SUSPENDED 2670 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2671 * @see PackageManager#isPackageSuspended() 2672 * @see PackageManager#getSuspendedPackageAppExtras() 2673 */ 2674 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2675 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED"; 2676 2677 /** 2678 * Broadcast Action: A user ID has been removed from the system. The user 2679 * ID number is stored in the extra data under {@link #EXTRA_UID}. 2680 * 2681 * <p class="note">This is a protected intent that can only be sent 2682 * by the system. 2683 */ 2684 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2685 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; 2686 2687 /** 2688 * Broadcast Action: Sent to the installer package of an application when 2689 * that application is first launched (that is the first time it is moved 2690 * out of the stopped state). The data contains the name of the package. 2691 * 2692 * <p>When the application is first launched, the application itself doesn't receive this 2693 * broadcast.</p> 2694 * 2695 * <p class="note">This is a protected intent that can only be sent 2696 * by the system. 2697 */ 2698 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2699 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; 2700 2701 /** 2702 * Broadcast Action: Sent to the system package verifier when a package 2703 * needs to be verified. The data contains the package URI. 2704 * <p class="note"> 2705 * This is a protected intent that can only be sent by the system. 2706 * </p> 2707 */ 2708 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2709 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; 2710 2711 /** 2712 * Broadcast Action: Sent to the system package verifier when a package is 2713 * verified. The data contains the package URI. 2714 * <p class="note"> 2715 * This is a protected intent that can only be sent by the system. 2716 */ 2717 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2718 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; 2719 2720 /** 2721 * Broadcast Action: Sent to the system intent filter verifier when an 2722 * intent filter needs to be verified. The data contains the filter data 2723 * hosts to be verified against. 2724 * <p class="note"> 2725 * This is a protected intent that can only be sent by the system. 2726 * </p> 2727 * 2728 * @hide 2729 */ 2730 @SystemApi 2731 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2732 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; 2733 2734 /** 2735 * Broadcast Action: Resources for a set of packages (which were 2736 * previously unavailable) are currently 2737 * available since the media on which they exist is available. 2738 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 2739 * list of packages whose availability changed. 2740 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 2741 * list of uids of packages whose availability changed. 2742 * Note that the 2743 * packages in this list do <em>not</em> receive this broadcast. 2744 * The specified set of packages are now available on the system. 2745 * <p>Includes the following extras: 2746 * <ul> 2747 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 2748 * whose resources(were previously unavailable) are currently available. 2749 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the 2750 * packages whose resources(were previously unavailable) 2751 * are currently available. 2752 * </ul> 2753 * 2754 * <p class="note">This is a protected intent that can only be sent 2755 * by the system. 2756 */ 2757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2758 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = 2759 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; 2760 2761 /** 2762 * Broadcast Action: Resources for a set of packages are currently 2763 * unavailable since the media on which they exist is unavailable. 2764 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 2765 * list of packages whose availability changed. 2766 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 2767 * list of uids of packages whose availability changed. 2768 * The specified set of packages can no longer be 2769 * launched and are practically unavailable on the system. 2770 * <p>Inclues the following extras: 2771 * <ul> 2772 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 2773 * whose resources are no longer available. 2774 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages 2775 * whose resources are no longer available. 2776 * </ul> 2777 * 2778 * <p class="note">This is a protected intent that can only be sent 2779 * by the system. 2780 */ 2781 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2782 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = 2783 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; 2784 2785 /** 2786 * Broadcast Action: preferred activities have changed *explicitly*. 2787 * 2788 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. 2789 * when an app is installed or uninstalled, but in such cases this broadcast will *not* 2790 * be sent. 2791 * 2792 * {@link #EXTRA_USER_HANDLE} contains the user ID in question. 2793 * 2794 * @hide 2795 */ 2796 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2797 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = 2798 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; 2799 2800 2801 /** 2802 * Broadcast Action: The current system wallpaper has changed. See 2803 * {@link android.app.WallpaperManager} for retrieving the new wallpaper. 2804 * This should <em>only</em> be used to determine when the wallpaper 2805 * has changed to show the new wallpaper to the user. You should certainly 2806 * never, in response to this, change the wallpaper or other attributes of 2807 * it such as the suggested size. That would be crazy, right? You'd cause 2808 * all kinds of loops, especially if other apps are doing similar things, 2809 * right? Of course. So please don't do this. 2810 * 2811 * @deprecated Modern applications should use 2812 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER 2813 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper 2814 * shown behind their UI, rather than watching for this broadcast and 2815 * rendering the wallpaper on their own. 2816 */ 2817 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2818 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; 2819 /** 2820 * Broadcast Action: The current device {@link android.content.res.Configuration} 2821 * (orientation, locale, etc) has changed. When such a change happens, the 2822 * UIs (view hierarchy) will need to be rebuilt based on this new 2823 * information; for the most part, applications don't need to worry about 2824 * this, because the system will take care of stopping and restarting the 2825 * application to make sure it sees the new changes. Some system code that 2826 * can not be restarted will need to watch for this action and handle it 2827 * appropriately. 2828 * 2829 * <p class="note"> 2830 * You <em>cannot</em> receive this through components declared 2831 * in manifests, only by explicitly registering for it with 2832 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2833 * Context.registerReceiver()}. 2834 * 2835 * <p class="note">This is a protected intent that can only be sent 2836 * by the system. 2837 * 2838 * @see android.content.res.Configuration 2839 */ 2840 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2841 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; 2842 2843 /** 2844 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed 2845 * such that the device may be eligible for the installation of additional configuration splits. 2846 * Configuration properties that can trigger this broadcast include locale and display density. 2847 * 2848 * <p class="note"> 2849 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through 2850 * components declared in manifests. However, the receiver <em>must</em> hold the 2851 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. 2852 * 2853 * <p class="note"> 2854 * This is a protected intent that can only be sent by the system. 2855 * 2856 * @hide 2857 */ 2858 @SystemApi 2859 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2860 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = 2861 "android.intent.action.SPLIT_CONFIGURATION_CHANGED"; 2862 /** 2863 * Broadcast Action: The current device's locale has changed. 2864 * 2865 * <p class="note">This is a protected intent that can only be sent 2866 * by the system. 2867 */ 2868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2869 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; 2870 /** 2871 * Broadcast Action: This is a <em>sticky broadcast</em> containing the 2872 * charging state, level, and other information about the battery. 2873 * See {@link android.os.BatteryManager} for documentation on the 2874 * contents of the Intent. 2875 * 2876 * <p class="note"> 2877 * You <em>cannot</em> receive this through components declared 2878 * in manifests, only by explicitly registering for it with 2879 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2880 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, 2881 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, 2882 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related 2883 * broadcasts that are sent and can be received through manifest 2884 * receivers. 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_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; 2891 2892 2893 /** 2894 * Broadcast Action: Sent when the current battery level changes. 2895 * 2896 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle} 2897 * instances representing individual battery level changes with associated 2898 * extras from {@link #ACTION_BATTERY_CHANGED}. 2899 * 2900 * <p class="note"> 2901 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission. 2902 * 2903 * @hide 2904 */ 2905 @SystemApi 2906 public static final String ACTION_BATTERY_LEVEL_CHANGED = 2907 "android.intent.action.BATTERY_LEVEL_CHANGED"; 2908 /** 2909 * Broadcast Action: Indicates low battery condition on the device. 2910 * This broadcast corresponds to the "Low battery warning" system dialog. 2911 * 2912 * <p class="note">This is a protected intent that can only be sent 2913 * by the system. 2914 */ 2915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2916 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; 2917 /** 2918 * Broadcast Action: Indicates the battery is now okay after being low. 2919 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has 2920 * gone back up to an okay state. 2921 * 2922 * <p class="note">This is a protected intent that can only be sent 2923 * by the system. 2924 */ 2925 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2926 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; 2927 /** 2928 * Broadcast Action: External power has been connected to the device. 2929 * This is intended for applications that wish to register specifically to this notification. 2930 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 2931 * stay active to receive this notification. This action can be used to implement actions 2932 * that wait until power is available to trigger. 2933 * 2934 * <p class="note">This is a protected intent that can only be sent 2935 * by the system. 2936 */ 2937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2938 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; 2939 /** 2940 * Broadcast Action: External power has been removed from the device. 2941 * This is intended for applications that wish to register specifically to this notification. 2942 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 2943 * stay active to receive this notification. This action can be used to implement actions 2944 * that wait until power is available to trigger. 2945 * 2946 * <p class="note">This is a protected intent that can only be sent 2947 * by the system. 2948 */ 2949 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2950 public static final String ACTION_POWER_DISCONNECTED = 2951 "android.intent.action.ACTION_POWER_DISCONNECTED"; 2952 /** 2953 * Broadcast Action: Device is shutting down. 2954 * This is broadcast when the device is being shut down (completely turned 2955 * off, not sleeping). Once the broadcast is complete, the final shutdown 2956 * will proceed and all unsaved data lost. Apps will not normally need 2957 * to handle this, since the foreground activity will be paused as well. 2958 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered 2959 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2960 * Context.registerReceiver}. 2961 * 2962 * <p class="note">This is a protected intent that can only be sent 2963 * by the system. 2964 * <p>May include the following extras: 2965 * <ul> 2966 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this 2967 * shutdown is only for userspace processes. If not set, assumed to be false. 2968 * </ul> 2969 */ 2970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2971 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; 2972 /** 2973 * Activity Action: Start this activity to request system shutdown. 2974 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true 2975 * to request confirmation from the user before shutting down. The optional boolean 2976 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to 2977 * indicate that the shutdown is requested by the user. 2978 * 2979 * <p class="note">This is a protected intent that can only be sent 2980 * by the system. 2981 * 2982 * {@hide} 2983 */ 2984 public static final String ACTION_REQUEST_SHUTDOWN 2985 = "com.android.internal.intent.action.REQUEST_SHUTDOWN"; 2986 /** 2987 * Broadcast Action: A sticky broadcast that indicates low storage space 2988 * condition on the device 2989 * <p class="note"> 2990 * This is a protected intent that can only be sent by the system. 2991 * 2992 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 2993 * or above, this broadcast will no longer be delivered to any 2994 * {@link BroadcastReceiver} defined in your manifest. Instead, 2995 * apps are strongly encouraged to use the improved 2996 * {@link Context#getCacheDir()} behavior so the system can 2997 * automatically free up storage when needed. 2998 */ 2999 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3000 @Deprecated 3001 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; 3002 /** 3003 * Broadcast Action: Indicates low storage space condition on the device no 3004 * longer exists 3005 * <p class="note"> 3006 * This is a protected intent that can only be sent by the system. 3007 * 3008 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3009 * or above, this broadcast will no longer be delivered to any 3010 * {@link BroadcastReceiver} defined in your manifest. Instead, 3011 * apps are strongly encouraged to use the improved 3012 * {@link Context#getCacheDir()} behavior so the system can 3013 * automatically free up storage when needed. 3014 */ 3015 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3016 @Deprecated 3017 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; 3018 /** 3019 * Broadcast Action: A sticky broadcast that indicates a storage space full 3020 * condition on the device. This is intended for activities that want to be 3021 * able to fill the data partition completely, leaving only enough free 3022 * space to prevent system-wide SQLite failures. 3023 * <p class="note"> 3024 * This is a protected intent that can only be sent by the system. 3025 * 3026 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3027 * or above, this broadcast will no longer be delivered to any 3028 * {@link BroadcastReceiver} defined in your manifest. Instead, 3029 * apps are strongly encouraged to use the improved 3030 * {@link Context#getCacheDir()} behavior so the system can 3031 * automatically free up storage when needed. 3032 * @hide 3033 */ 3034 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3035 @Deprecated 3036 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; 3037 /** 3038 * Broadcast Action: Indicates storage space full condition on the device no 3039 * longer exists. 3040 * <p class="note"> 3041 * This is a protected intent that can only be sent by the system. 3042 * 3043 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3044 * or above, this broadcast will no longer be delivered to any 3045 * {@link BroadcastReceiver} defined in your manifest. Instead, 3046 * apps are strongly encouraged to use the improved 3047 * {@link Context#getCacheDir()} behavior so the system can 3048 * automatically free up storage when needed. 3049 * @hide 3050 */ 3051 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3052 @Deprecated 3053 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; 3054 /** 3055 * Broadcast Action: Indicates low memory condition notification acknowledged by user 3056 * and package management should be started. 3057 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW 3058 * notification. 3059 */ 3060 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3061 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; 3062 /** 3063 * Broadcast Action: The device has entered USB Mass Storage mode. 3064 * This is used mainly for the USB Settings panel. 3065 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3066 * when the SD card file system is mounted or unmounted 3067 * @deprecated replaced by android.os.storage.StorageEventListener 3068 */ 3069 @Deprecated 3070 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3071 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; 3072 3073 /** 3074 * Broadcast Action: The device has exited USB Mass Storage mode. 3075 * This is used mainly for the USB Settings panel. 3076 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3077 * when the SD card file system is mounted or unmounted 3078 * @deprecated replaced by android.os.storage.StorageEventListener 3079 */ 3080 @Deprecated 3081 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3082 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; 3083 3084 /** 3085 * Broadcast Action: External media has been removed. 3086 * The path to the mount point for the removed media is contained in the Intent.mData field. 3087 */ 3088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3089 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; 3090 3091 /** 3092 * Broadcast Action: External media is present, but not mounted at its mount point. 3093 * The path to the mount point for the unmounted media is contained in the Intent.mData field. 3094 */ 3095 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3096 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; 3097 3098 /** 3099 * Broadcast Action: External media is present, and being disk-checked 3100 * The path to the mount point for the checking media is contained in the Intent.mData field. 3101 */ 3102 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3103 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; 3104 3105 /** 3106 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) 3107 * The path to the mount point for the checking media is contained in the Intent.mData field. 3108 */ 3109 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3110 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; 3111 3112 /** 3113 * Broadcast Action: External media is present and mounted at its mount point. 3114 * The path to the mount point for the mounted media is contained in the Intent.mData field. 3115 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the 3116 * media was mounted read only. 3117 */ 3118 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3119 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; 3120 3121 /** 3122 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. 3123 * The path to the mount point for the shared media is contained in the Intent.mData field. 3124 */ 3125 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3126 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; 3127 3128 /** 3129 * Broadcast Action: External media is no longer being shared via USB mass storage. 3130 * The path to the mount point for the previously shared media is contained in the Intent.mData field. 3131 * 3132 * @hide 3133 */ 3134 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; 3135 3136 /** 3137 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. 3138 * The path to the mount point for the removed media is contained in the Intent.mData field. 3139 */ 3140 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3141 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; 3142 3143 /** 3144 * Broadcast Action: External media is present but cannot be mounted. 3145 * The path to the mount point for the unmountable media is contained in the Intent.mData field. 3146 */ 3147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3148 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; 3149 3150 /** 3151 * Broadcast Action: User has expressed the desire to remove the external storage media. 3152 * Applications should close all files they have open within the mount point when they receive this intent. 3153 * The path to the mount point for the media to be ejected is contained in the Intent.mData field. 3154 */ 3155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3156 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; 3157 3158 /** 3159 * Broadcast Action: The media scanner has started scanning a directory. 3160 * The path to the directory being scanned is contained in the Intent.mData field. 3161 */ 3162 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3163 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; 3164 3165 /** 3166 * Broadcast Action: The media scanner has finished scanning a directory. 3167 * The path to the scanned directory is contained in the Intent.mData field. 3168 */ 3169 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3170 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; 3171 3172 /** 3173 * Broadcast Action: Request the media scanner to scan a file and add it to 3174 * the media database. 3175 * <p> 3176 * The path to the file is contained in {@link Intent#getData()}. 3177 * 3178 * @deprecated Callers should migrate to inserting items directly into 3179 * {@link MediaStore}, where they will be automatically scanned 3180 * after each mutation. 3181 */ 3182 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3183 @Deprecated 3184 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; 3185 3186 /** 3187 * Broadcast Action: The "Media Button" was pressed. Includes a single 3188 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3189 * caused the broadcast. 3190 */ 3191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3192 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; 3193 3194 /** 3195 * Broadcast Action: The "Camera Button" was pressed. Includes a single 3196 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3197 * caused the broadcast. 3198 */ 3199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3200 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; 3201 3202 // *** NOTE: @todo(*) The following really should go into a more domain-specific 3203 // location; they are not general-purpose actions. 3204 3205 /** 3206 * Broadcast Action: A GTalk connection has been established. 3207 */ 3208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3209 public static final String ACTION_GTALK_SERVICE_CONNECTED = 3210 "android.intent.action.GTALK_CONNECTED"; 3211 3212 /** 3213 * Broadcast Action: A GTalk connection has been disconnected. 3214 */ 3215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3216 public static final String ACTION_GTALK_SERVICE_DISCONNECTED = 3217 "android.intent.action.GTALK_DISCONNECTED"; 3218 3219 /** 3220 * Broadcast Action: An input method has been changed. 3221 */ 3222 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3223 public static final String ACTION_INPUT_METHOD_CHANGED = 3224 "android.intent.action.INPUT_METHOD_CHANGED"; 3225 3226 /** 3227 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or 3228 * more radios have been turned off or on. The intent will have the following extra value:</p> 3229 * <ul> 3230 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, 3231 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been 3232 * turned off</li> 3233 * </ul> 3234 * 3235 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3236 */ 3237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3238 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; 3239 3240 /** 3241 * Broadcast Action: Some content providers have parts of their namespace 3242 * where they publish new events or items that the user may be especially 3243 * interested in. For these things, they may broadcast this action when the 3244 * set of interesting items change. 3245 * 3246 * For example, GmailProvider sends this notification when the set of unread 3247 * mail in the inbox changes. 3248 * 3249 * <p>The data of the intent identifies which part of which provider 3250 * changed. When queried through the content resolver, the data URI will 3251 * return the data set in question. 3252 * 3253 * <p>The intent will have the following extra values: 3254 * <ul> 3255 * <li><em>count</em> - The number of items in the data set. This is the 3256 * same as the number of items in the cursor returned by querying the 3257 * data URI. </li> 3258 * </ul> 3259 * 3260 * This intent will be sent at boot (if the count is non-zero) and when the 3261 * data set changes. It is possible for the data set to change without the 3262 * count changing (for example, if a new unread message arrives in the same 3263 * sync operation in which a message is archived). The phone should still 3264 * ring/vibrate/etc as normal in this case. 3265 */ 3266 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3267 public static final String ACTION_PROVIDER_CHANGED = 3268 "android.intent.action.PROVIDER_CHANGED"; 3269 3270 /** 3271 * Broadcast Action: Wired Headset plugged in or unplugged. 3272 * 3273 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value 3274 * and documentation. 3275 * <p>If the minimum SDK version of your application is 3276 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer 3277 * to the <code>AudioManager</code> constant in your receiver registration code instead. 3278 */ 3279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3280 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG; 3281 3282 /** 3283 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> 3284 * <ul> 3285 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> 3286 * </ul> 3287 * 3288 * <p class="note">This is a protected intent that can only be sent 3289 * by the system. 3290 * 3291 * @hide 3292 */ 3293 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3294 public static final String ACTION_ADVANCED_SETTINGS_CHANGED 3295 = "android.intent.action.ADVANCED_SETTINGS"; 3296 3297 /** 3298 * Broadcast Action: Sent after application restrictions are changed. 3299 * 3300 * <p class="note">This is a protected intent that can only be sent 3301 * by the system.</p> 3302 */ 3303 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3304 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = 3305 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; 3306 3307 /** 3308 * Broadcast Action: An outgoing call is about to be placed. 3309 * 3310 * <p>The Intent will have the following extra value:</p> 3311 * <ul> 3312 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - 3313 * the phone number originally intended to be dialed.</li> 3314 * </ul> 3315 * <p>Once the broadcast is finished, the resultData is used as the actual 3316 * number to call. If <code>null</code>, no call will be placed.</p> 3317 * <p>It is perfectly acceptable for multiple receivers to process the 3318 * outgoing call in turn: for example, a parental control application 3319 * might verify that the user is authorized to place the call at that 3320 * time, then a number-rewriting application might add an area code if 3321 * one was not specified.</p> 3322 * <p>For consistency, any receiver whose purpose is to prohibit phone 3323 * calls should have a priority of 0, to ensure it will see the final 3324 * phone number to be dialed. 3325 * Any receiver whose purpose is to rewrite phone numbers to be called 3326 * should have a positive priority. 3327 * Negative priorities are reserved for the system for this broadcast; 3328 * using them may cause problems.</p> 3329 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> 3330 * abort the broadcast.</p> 3331 * <p>Emergency calls cannot be intercepted using this mechanism, and 3332 * other calls cannot be modified to call emergency numbers using this 3333 * mechanism. 3334 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing 3335 * call to use their own service instead. Those apps should first prevent 3336 * the call from being placed by setting resultData to <code>null</code> 3337 * and then start their own app to make the call. 3338 * <p>You must hold the 3339 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} 3340 * permission to receive this Intent.</p> 3341 * 3342 * <p class="note">This is a protected intent that can only be sent 3343 * by the system. 3344 * 3345 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to 3346 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast. 3347 * This means that attempts to re-write the outgoing call by other apps using this intent will 3348 * be ignored. 3349 * </p> 3350 * 3351 * @deprecated Apps that redirect outgoing calls should use the 3352 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening 3353 * should use the {@link android.telecom.CallScreeningService} API. Apps which need to be 3354 * notified of basic call state should use 3355 * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine 3356 * when a new outgoing call is placed. 3357 */ 3358 @Deprecated 3359 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3360 public static final String ACTION_NEW_OUTGOING_CALL = 3361 "android.intent.action.NEW_OUTGOING_CALL"; 3362 3363 /** 3364 * Broadcast Action: Have the device reboot. This is only for use by 3365 * system code. 3366 * 3367 * <p class="note">This is a protected intent that can only be sent 3368 * by the system. 3369 */ 3370 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3371 public static final String ACTION_REBOOT = 3372 "android.intent.action.REBOOT"; 3373 3374 /** 3375 * Broadcast Action: A sticky broadcast for changes in the physical 3376 * docking state of the device. 3377 * 3378 * <p>The intent will have the following extra values: 3379 * <ul> 3380 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock 3381 * state, indicating which dock the device is physically in.</li> 3382 * </ul> 3383 * <p>This is intended for monitoring the current physical dock state. 3384 * See {@link android.app.UiModeManager} for the normal API dealing with 3385 * dock mode changes. 3386 */ 3387 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3388 public static final String ACTION_DOCK_EVENT = 3389 "android.intent.action.DOCK_EVENT"; 3390 3391 /** 3392 * Broadcast Action: A broadcast when idle maintenance can be started. 3393 * This means that the user is not interacting with the device and is 3394 * not expected to do so soon. Typical use of the idle maintenance is 3395 * to perform somehow expensive tasks that can be postponed at a moment 3396 * when they will not degrade user experience. 3397 * <p> 3398 * <p class="note">In order to keep the device responsive in case of an 3399 * unexpected user interaction, implementations of a maintenance task 3400 * should be interruptible. In such a scenario a broadcast with action 3401 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you 3402 * should not do the maintenance work in 3403 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a 3404 * maintenance service by {@link Context#startService(Intent)}. Also 3405 * you should hold a wake lock while your maintenance service is running 3406 * to prevent the device going to sleep. 3407 * </p> 3408 * <p> 3409 * <p class="note">This is a protected intent that can only be sent by 3410 * the system. 3411 * </p> 3412 * 3413 * @see #ACTION_IDLE_MAINTENANCE_END 3414 * 3415 * @hide 3416 */ 3417 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3418 public static final String ACTION_IDLE_MAINTENANCE_START = 3419 "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; 3420 3421 /** 3422 * Broadcast Action: A broadcast when idle maintenance should be stopped. 3423 * This means that the user was not interacting with the device as a result 3424 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} 3425 * was sent and now the user started interacting with the device. Typical 3426 * use of the idle maintenance is to perform somehow expensive tasks that 3427 * can be postponed at a moment when they will not degrade user experience. 3428 * <p> 3429 * <p class="note">In order to keep the device responsive in case of an 3430 * unexpected user interaction, implementations of a maintenance task 3431 * should be interruptible. Hence, on receiving a broadcast with this 3432 * action, the maintenance task should be interrupted as soon as possible. 3433 * In other words, you should not do the maintenance work in 3434 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the 3435 * maintenance service that was started on receiving of 3436 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake 3437 * lock you acquired when your maintenance service started. 3438 * </p> 3439 * <p class="note">This is a protected intent that can only be sent 3440 * by the system. 3441 * 3442 * @see #ACTION_IDLE_MAINTENANCE_START 3443 * 3444 * @hide 3445 */ 3446 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3447 public static final String ACTION_IDLE_MAINTENANCE_END = 3448 "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; 3449 3450 /** 3451 * Broadcast Action: a remote intent is to be broadcasted. 3452 * 3453 * A remote intent is used for remote RPC between devices. The remote intent 3454 * is serialized and sent from one device to another device. The receiving 3455 * device parses the remote intent and broadcasts it. Note that anyone can 3456 * broadcast a remote intent. However, if the intent receiver of the remote intent 3457 * does not trust intent broadcasts from arbitrary intent senders, it should require 3458 * the sender to hold certain permissions so only trusted sender's broadcast will be 3459 * let through. 3460 * @hide 3461 */ 3462 public static final String ACTION_REMOTE_INTENT = 3463 "com.google.android.c2dm.intent.RECEIVE"; 3464 3465 /** 3466 * Broadcast Action: This is broadcast once when the user is booting after a 3467 * system update. It can be used to perform cleanup or upgrades after a 3468 * system update. 3469 * <p> 3470 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} 3471 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's 3472 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only 3473 * sent to receivers in the system image. 3474 * 3475 * @hide 3476 */ 3477 @SystemApi 3478 public static final String ACTION_PRE_BOOT_COMPLETED = 3479 "android.intent.action.PRE_BOOT_COMPLETED"; 3480 3481 /** 3482 * Broadcast to a specific application to query any supported restrictions to impose 3483 * on restricted users. The broadcast intent contains an extra 3484 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted 3485 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or 3486 * String[] depending on the restriction type.<p/> 3487 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, 3488 * which is of type <code>ArrayList<RestrictionEntry></code>. It can also 3489 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. 3490 * The activity specified by that intent will be launched for a result which must contain 3491 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. 3492 * The keys and values of the returned restrictions will be persisted. 3493 * @see RestrictionEntry 3494 */ 3495 public static final String ACTION_GET_RESTRICTION_ENTRIES = 3496 "android.intent.action.GET_RESTRICTION_ENTRIES"; 3497 3498 /** 3499 * Sent the first time a user is starting, to allow system apps to 3500 * perform one time initialization. (This will not be seen by third 3501 * party applications because a newly initialized user does not have any 3502 * third party applications installed for it.) This is sent early in 3503 * starting the user, around the time the home app is started, before 3504 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground 3505 * broadcast, since it is part of a visible user interaction; be as quick 3506 * as possible when handling it. 3507 */ 3508 public static final String ACTION_USER_INITIALIZE = 3509 "android.intent.action.USER_INITIALIZE"; 3510 3511 /** 3512 * Sent when a user switch is happening, causing the process's user to be 3513 * brought to the foreground. This is only sent to receivers registered 3514 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3515 * Context.registerReceiver}. It is sent to the user that is going to the 3516 * foreground. This is sent as a foreground 3517 * broadcast, since it is part of a visible user interaction; be as quick 3518 * as possible when handling it. 3519 */ 3520 public static final String ACTION_USER_FOREGROUND = 3521 "android.intent.action.USER_FOREGROUND"; 3522 3523 /** 3524 * Sent when a user switch is happening, causing the process's user to be 3525 * sent to the background. This is only sent to receivers registered 3526 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3527 * Context.registerReceiver}. It is sent to the user that is going to the 3528 * background. This is sent as a foreground 3529 * broadcast, since it is part of a visible user interaction; be as quick 3530 * as possible when handling it. 3531 */ 3532 public static final String ACTION_USER_BACKGROUND = 3533 "android.intent.action.USER_BACKGROUND"; 3534 3535 /** 3536 * Broadcast sent to the system when a user is added. Carries an extra 3537 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to 3538 * all running users. You must hold 3539 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3540 * @hide 3541 */ 3542 @SystemApi 3543 public static final String ACTION_USER_ADDED = 3544 "android.intent.action.USER_ADDED"; 3545 3546 /** 3547 * Broadcast sent by the system when a user is started. Carries an extra 3548 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to 3549 * registered receivers, not manifest receivers. It is sent to the user 3550 * that has been started. This is sent as a foreground 3551 * broadcast, since it is part of a visible user interaction; be as quick 3552 * as possible when handling it. 3553 * @hide 3554 */ 3555 public static final String ACTION_USER_STARTED = 3556 "android.intent.action.USER_STARTED"; 3557 3558 /** 3559 * Broadcast sent when a user is in the process of starting. Carries an extra 3560 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only 3561 * sent to registered receivers, not manifest receivers. It is sent to all 3562 * users (including the one that is being started). You must hold 3563 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3564 * this broadcast. This is sent as a background broadcast, since 3565 * its result is not part of the primary UX flow; to safely keep track of 3566 * started/stopped state of a user you can use this in conjunction with 3567 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with 3568 * other user state broadcasts since those are foreground broadcasts so can 3569 * execute in a different order. 3570 * @hide 3571 */ 3572 public static final String ACTION_USER_STARTING = 3573 "android.intent.action.USER_STARTING"; 3574 3575 /** 3576 * Broadcast sent when a user is going to be stopped. Carries an extra 3577 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only 3578 * sent to registered receivers, not manifest receivers. It is sent to all 3579 * users (including the one that is being stopped). You must hold 3580 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3581 * this broadcast. The user will not stop until all receivers have 3582 * handled the broadcast. This is sent as a background broadcast, since 3583 * its result is not part of the primary UX flow; to safely keep track of 3584 * started/stopped state of a user you can use this in conjunction with 3585 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with 3586 * other user state broadcasts since those are foreground broadcasts so can 3587 * execute in a different order. 3588 * @hide 3589 */ 3590 public static final String ACTION_USER_STOPPING = 3591 "android.intent.action.USER_STOPPING"; 3592 3593 /** 3594 * Broadcast sent to the system when a user is stopped. Carries an extra 3595 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to 3596 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a 3597 * specific package. This is only sent to registered receivers, not manifest 3598 * receivers. It is sent to all running users <em>except</em> the one that 3599 * has just been stopped (which is no longer running). 3600 * @hide 3601 */ 3602 public static final String ACTION_USER_STOPPED = 3603 "android.intent.action.USER_STOPPED"; 3604 3605 /** 3606 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has 3607 * the userHandle of the user. It is sent to all running users except the 3608 * one that has been removed. The user will not be completely removed until all receivers have 3609 * handled the broadcast. You must hold 3610 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3611 * @hide 3612 */ 3613 @SystemApi 3614 public static final String ACTION_USER_REMOVED = 3615 "android.intent.action.USER_REMOVED"; 3616 3617 /** 3618 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has 3619 * the userHandle of the user to become the current one. This is only sent to 3620 * registered receivers, not manifest receivers. It is sent to all running users. 3621 * You must hold 3622 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3623 * @hide 3624 */ 3625 @UnsupportedAppUsage 3626 public static final String ACTION_USER_SWITCHED = 3627 "android.intent.action.USER_SWITCHED"; 3628 3629 /** 3630 * Broadcast Action: Sent when the credential-encrypted private storage has 3631 * become unlocked for the target user. This is only sent to registered 3632 * receivers, not manifest receivers. 3633 */ 3634 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3635 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; 3636 3637 /** 3638 * Broadcast sent to the system when a user's information changes. Carries an extra 3639 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. 3640 * This is only sent to registered receivers, not manifest receivers. It is sent to all users. 3641 * @hide 3642 */ 3643 public static final String ACTION_USER_INFO_CHANGED = 3644 "android.intent.action.USER_INFO_CHANGED"; 3645 3646 /** 3647 * Broadcast sent to the primary user when an associated managed profile is added (the profile 3648 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies 3649 * the UserHandle of the profile that was added. Only applications (for example Launchers) 3650 * that need to display merged content across both primary and managed profiles need to 3651 * worry about this broadcast. This is only sent to registered receivers, 3652 * not manifest receivers. 3653 */ 3654 public static final String ACTION_MANAGED_PROFILE_ADDED = 3655 "android.intent.action.MANAGED_PROFILE_ADDED"; 3656 3657 /** 3658 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an 3659 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. 3660 * Only applications (for example Launchers) that need to display merged content across both 3661 * primary and managed profiles need to worry about this broadcast. This is only sent to 3662 * registered receivers, not manifest receivers. 3663 */ 3664 public static final String ACTION_MANAGED_PROFILE_REMOVED = 3665 "android.intent.action.MANAGED_PROFILE_REMOVED"; 3666 3667 /** 3668 * Broadcast sent to the primary user when the credential-encrypted private storage for 3669 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that 3670 * specifies the UserHandle of the profile that was unlocked. Only applications (for example 3671 * Launchers) that need to display merged content across both primary and managed profiles 3672 * need to worry about this broadcast. This is only sent to registered receivers, 3673 * not manifest receivers. 3674 */ 3675 public static final String ACTION_MANAGED_PROFILE_UNLOCKED = 3676 "android.intent.action.MANAGED_PROFILE_UNLOCKED"; 3677 3678 /** 3679 * Broadcast sent to the primary user when an associated managed profile has become available. 3680 * Currently this includes when the user disables quiet mode for the profile. Carries an extra 3681 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, 3682 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state 3683 * of quiet mode. This is only sent to registered receivers, not manifest receivers. 3684 */ 3685 public static final String ACTION_MANAGED_PROFILE_AVAILABLE = 3686 "android.intent.action.MANAGED_PROFILE_AVAILABLE"; 3687 3688 /** 3689 * Broadcast sent to the primary user when an associated managed profile has become unavailable. 3690 * Currently this includes when the user enables quiet mode for the profile. Carries an extra 3691 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, 3692 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state 3693 * of quiet mode. This is only sent to registered receivers, not manifest receivers. 3694 */ 3695 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = 3696 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; 3697 3698 /** 3699 * Broadcast sent to the system user when the 'device locked' state changes for any user. 3700 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which 3701 * the device was locked or unlocked. 3702 * 3703 * This is only sent to registered receivers. 3704 * 3705 * @hide 3706 */ 3707 public static final String ACTION_DEVICE_LOCKED_CHANGED = 3708 "android.intent.action.DEVICE_LOCKED_CHANGED"; 3709 3710 /** 3711 * Sent when the user taps on the clock widget in the system's "quick settings" area. 3712 */ 3713 public static final String ACTION_QUICK_CLOCK = 3714 "android.intent.action.QUICK_CLOCK"; 3715 3716 /** 3717 * Activity Action: Shows the brightness setting dialog. 3718 * @hide 3719 */ 3720 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = 3721 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; 3722 3723 /** 3724 * Broadcast Action: A global button was pressed. Includes a single 3725 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3726 * caused the broadcast. 3727 * @hide 3728 */ 3729 @SystemApi 3730 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; 3731 3732 /** 3733 * Broadcast Action: Sent when media resource is granted. 3734 * <p> 3735 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource 3736 * granted. 3737 * </p> 3738 * <p class="note"> 3739 * This is a protected intent that can only be sent by the system. 3740 * </p> 3741 * <p class="note"> 3742 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. 3743 * </p> 3744 * 3745 * @hide 3746 */ 3747 public static final String ACTION_MEDIA_RESOURCE_GRANTED = 3748 "android.intent.action.MEDIA_RESOURCE_GRANTED"; 3749 3750 /** 3751 * Broadcast Action: An overlay package has changed. The data contains the 3752 * name of the overlay package which has changed. This is broadcast on all 3753 * changes to the OverlayInfo returned by {@link 3754 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The 3755 * most common change is a state change that will change whether the 3756 * overlay is enabled or not. 3757 * @hide 3758 */ 3759 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; 3760 3761 /** 3762 * Activity Action: Allow the user to select and return one or more existing 3763 * documents. When invoked, the system will display the various 3764 * {@link DocumentsProvider} instances installed on the device, letting the 3765 * user interactively navigate through them. These documents include local 3766 * media, such as photos and video, and documents provided by installed 3767 * cloud storage providers. 3768 * <p> 3769 * Each document is represented as a {@code content://} URI backed by a 3770 * {@link DocumentsProvider}, which can be opened as a stream with 3771 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 3772 * {@link android.provider.DocumentsContract.Document} metadata. 3773 * <p> 3774 * All selected documents are returned to the calling application with 3775 * persistable read and write permission grants. If you want to maintain 3776 * access to the documents across device reboots, you need to explicitly 3777 * take the persistable permissions using 3778 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. 3779 * <p> 3780 * Callers must indicate the acceptable document MIME types through 3781 * {@link #setType(String)}. For example, to select photos, use 3782 * {@code image/*}. If multiple disjoint MIME types are acceptable, define 3783 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to 3784 * {@literal *}/*. 3785 * <p> 3786 * If the caller can handle multiple returned items (the user performing 3787 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} 3788 * to indicate this. 3789 * <p> 3790 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 3791 * URIs that can be opened with 3792 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 3793 * <p> 3794 * Callers can set a document URI through 3795 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 3796 * location of documents navigator. System will do its best to launch the 3797 * navigator in the specified document if it's a folder, or the folder that 3798 * contains the specified document if not. 3799 * <p> 3800 * Output: The URI of the item that was picked, returned in 3801 * {@link #getData()}. This must be a {@code content://} URI so that any 3802 * receiver can access it. If multiple documents were selected, they are 3803 * returned in {@link #getClipData()}. 3804 * 3805 * @see DocumentsContract 3806 * @see #ACTION_OPEN_DOCUMENT_TREE 3807 * @see #ACTION_CREATE_DOCUMENT 3808 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 3809 */ 3810 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3811 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; 3812 3813 /** 3814 * Activity Action: Allow the user to create a new document. When invoked, 3815 * the system will display the various {@link DocumentsProvider} instances 3816 * installed on the device, letting the user navigate through them. The 3817 * returned document may be a newly created document with no content, or it 3818 * may be an existing document with the requested MIME type. 3819 * <p> 3820 * Each document is represented as a {@code content://} URI backed by a 3821 * {@link DocumentsProvider}, which can be opened as a stream with 3822 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 3823 * {@link android.provider.DocumentsContract.Document} metadata. 3824 * <p> 3825 * Callers must indicate the concrete MIME type of the document being 3826 * created by setting {@link #setType(String)}. This MIME type cannot be 3827 * changed after the document is created. 3828 * <p> 3829 * Callers can provide an initial display name through {@link #EXTRA_TITLE}, 3830 * but the user may change this value before creating the file. 3831 * <p> 3832 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 3833 * URIs that can be opened with 3834 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 3835 * <p> 3836 * Callers can set a document URI through 3837 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 3838 * location of documents navigator. System will do its best to launch the 3839 * navigator in the specified document if it's a folder, or the folder that 3840 * contains the specified document if not. 3841 * <p> 3842 * Output: The URI of the item that was created. This must be a 3843 * {@code content://} URI so that any receiver can access it. 3844 * 3845 * @see DocumentsContract 3846 * @see #ACTION_OPEN_DOCUMENT 3847 * @see #ACTION_OPEN_DOCUMENT_TREE 3848 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 3849 */ 3850 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3851 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; 3852 3853 /** 3854 * Activity Action: Allow the user to pick a directory subtree. When 3855 * invoked, the system will display the various {@link DocumentsProvider} 3856 * instances installed on the device, letting the user navigate through 3857 * them. Apps can fully manage documents within the returned directory. 3858 * <p> 3859 * To gain access to descendant (child, grandchild, etc) documents, use 3860 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and 3861 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} 3862 * with the returned URI. 3863 * <p> 3864 * Callers can set a document URI through 3865 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 3866 * location of documents navigator. System will do its best to launch the 3867 * navigator in the specified document if it's a folder, or the folder that 3868 * contains the specified document if not. 3869 * <p> 3870 * Output: The URI representing the selected directory tree. 3871 * 3872 * @see DocumentsContract 3873 */ 3874 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3875 public static final String 3876 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; 3877 3878 3879 /** 3880 * Activity Action: Perform text translation. 3881 * <p> 3882 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate. 3883 * <p> 3884 * Output: nothing. 3885 */ 3886 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3887 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE"; 3888 3889 /** 3890 * Activity Action: Define the meaning of the selected word(s). 3891 * <p> 3892 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define. 3893 * <p> 3894 * Output: nothing. 3895 */ 3896 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3897 public static final String ACTION_DEFINE = "android.intent.action.DEFINE"; 3898 3899 /** 3900 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or 3901 * exisiting sensor being disconnected. 3902 * 3903 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3904 * 3905 * {@hide} 3906 */ 3907 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3908 public static final String 3909 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; 3910 3911 /** 3912 * Deprecated - use ACTION_FACTORY_RESET instead. 3913 * @hide 3914 * @removed 3915 */ 3916 @Deprecated 3917 @SystemApi 3918 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; 3919 3920 /** 3921 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe) 3922 * is about to be performed. 3923 * @hide 3924 */ 3925 @SystemApi 3926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3927 public static final String ACTION_MASTER_CLEAR_NOTIFICATION 3928 = "android.intent.action.MASTER_CLEAR_NOTIFICATION"; 3929 3930 /** 3931 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 3932 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 3933 * 3934 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. 3935 * 3936 * @hide 3937 */ 3938 @Deprecated 3939 public static final String EXTRA_FORCE_MASTER_CLEAR = 3940 "android.intent.extra.FORCE_MASTER_CLEAR"; 3941 3942 /** 3943 * A broadcast action to trigger a factory reset. 3944 * 3945 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The 3946 * reason for the factory reset should be specified as {@link #EXTRA_REASON}. 3947 * 3948 * <p>Not for use by third-party applications. 3949 * 3950 * @see #EXTRA_FORCE_FACTORY_RESET 3951 * 3952 * {@hide} 3953 */ 3954 @SystemApi 3955 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3956 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; 3957 3958 /** 3959 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 3960 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 3961 * 3962 * <p>Not for use by third-party applications. 3963 * 3964 * @hide 3965 */ 3966 @SystemApi 3967 public static final String EXTRA_FORCE_FACTORY_RESET = 3968 "android.intent.extra.FORCE_FACTORY_RESET"; 3969 3970 /** 3971 * Broadcast action: report that a settings element is being restored from backup. The intent 3972 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting, 3973 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE 3974 * is the value of that settings entry prior to the restore operation, and 3975 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been 3976 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three 3977 * values are represented as strings, the fourth one as int. 3978 * 3979 * <p>This broadcast is sent only for settings provider entries known to require special handling 3980 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within 3981 * the provider's backup agent implementation. 3982 * 3983 * @see #EXTRA_SETTING_NAME 3984 * @see #EXTRA_SETTING_PREVIOUS_VALUE 3985 * @see #EXTRA_SETTING_NEW_VALUE 3986 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT 3987 * {@hide} 3988 */ 3989 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; 3990 3991 /** {@hide} */ 3992 public static final String EXTRA_SETTING_NAME = "setting_name"; 3993 /** {@hide} */ 3994 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; 3995 /** {@hide} */ 3996 public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; 3997 /** {@hide} */ 3998 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int"; 3999 4000 /** 4001 * Activity Action: Process a piece of text. 4002 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. 4003 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> 4004 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> 4005 */ 4006 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4007 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; 4008 4009 /** 4010 * Broadcast Action: The sim card state has changed. 4011 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here 4012 * because TelephonyIntents is an internal class. 4013 * The intent will have following extras.</p> 4014 * <p> 4015 * @see #EXTRA_SIM_STATE 4016 * @see #EXTRA_SIM_LOCKED_REASON 4017 * @see #EXTRA_REBROADCAST_ON_UNLOCK 4018 * 4019 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or 4020 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4021 * 4022 * @hide 4023 */ 4024 @Deprecated 4025 @SystemApi 4026 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4027 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED"; 4028 4029 /** 4030 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4031 * This will have one of the following intent values. 4032 * @see #SIM_STATE_UNKNOWN 4033 * @see #SIM_STATE_NOT_READY 4034 * @see #SIM_STATE_ABSENT 4035 * @see #SIM_STATE_PRESENT 4036 * @see #SIM_STATE_CARD_IO_ERROR 4037 * @see #SIM_STATE_CARD_RESTRICTED 4038 * @see #SIM_STATE_LOCKED 4039 * @see #SIM_STATE_READY 4040 * @see #SIM_STATE_IMSI 4041 * @see #SIM_STATE_LOADED 4042 * @hide 4043 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4044 */ 4045 @Deprecated 4046 @SystemApi 4047 public static final String EXTRA_SIM_STATE = "ss"; 4048 4049 /** 4050 * The intent value UNKNOWN represents the SIM state unknown 4051 * @hide 4052 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4053 */ 4054 @Deprecated 4055 @SystemApi 4056 public static final String SIM_STATE_UNKNOWN = "UNKNOWN"; 4057 4058 /** 4059 * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on 4060 * @hide 4061 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4062 */ 4063 @Deprecated 4064 @SystemApi 4065 public static final String SIM_STATE_NOT_READY = "NOT_READY"; 4066 4067 /** 4068 * The intent value ABSENT means the SIM card is missing 4069 * @hide 4070 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4071 */ 4072 @Deprecated 4073 @SystemApi 4074 public static final String SIM_STATE_ABSENT = "ABSENT"; 4075 4076 /** 4077 * The intent value PRESENT means the device has a SIM card inserted 4078 * @hide 4079 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4080 */ 4081 @Deprecated 4082 @SystemApi 4083 public static final String SIM_STATE_PRESENT = "PRESENT"; 4084 4085 /** 4086 * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error 4087 * @hide 4088 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4089 */ 4090 @Deprecated 4091 @SystemApi 4092 static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR"; 4093 4094 /** 4095 * The intent value CARD_RESTRICTED means card is present but not usable due to carrier 4096 * restrictions 4097 * @hide 4098 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4099 */ 4100 @Deprecated 4101 @SystemApi 4102 static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED"; 4103 4104 /** 4105 * The intent value LOCKED means the SIM is locked by PIN or by network 4106 * @hide 4107 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4108 */ 4109 @Deprecated 4110 @SystemApi 4111 public static final String SIM_STATE_LOCKED = "LOCKED"; 4112 4113 /** 4114 * The intent value READY means the SIM is ready to be accessed 4115 * @hide 4116 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4117 */ 4118 @Deprecated 4119 @SystemApi 4120 public static final String SIM_STATE_READY = "READY"; 4121 4122 /** 4123 * The intent value IMSI means the SIM IMSI is ready in property 4124 * @hide 4125 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4126 */ 4127 @Deprecated 4128 @SystemApi 4129 public static final String SIM_STATE_IMSI = "IMSI"; 4130 4131 /** 4132 * The intent value LOADED means all SIM records, including IMSI, are loaded 4133 * @hide 4134 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4135 */ 4136 @Deprecated 4137 @SystemApi 4138 public static final String SIM_STATE_LOADED = "LOADED"; 4139 4140 /** 4141 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4142 * This extra will have one of the following intent values. 4143 * <p> 4144 * @see #SIM_LOCKED_ON_PIN 4145 * @see #SIM_LOCKED_ON_PUK 4146 * @see #SIM_LOCKED_NETWORK 4147 * @see #SIM_ABSENT_ON_PERM_DISABLED 4148 * 4149 * @hide 4150 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4151 */ 4152 @Deprecated 4153 @SystemApi 4154 public static final String EXTRA_SIM_LOCKED_REASON = "reason"; 4155 4156 /** 4157 * The intent value PIN means the SIM is locked on PIN1 4158 * @hide 4159 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4160 */ 4161 @Deprecated 4162 @SystemApi 4163 public static final String SIM_LOCKED_ON_PIN = "PIN"; 4164 4165 /** 4166 * The intent value PUK means the SIM is locked on PUK1 4167 * @hide 4168 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4169 */ 4170 /* PUK means ICC is locked on PUK1 */ 4171 @Deprecated 4172 @SystemApi 4173 public static final String SIM_LOCKED_ON_PUK = "PUK"; 4174 4175 /** 4176 * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION 4177 * @hide 4178 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4179 */ 4180 @Deprecated 4181 @SystemApi 4182 public static final String SIM_LOCKED_NETWORK = "NETWORK"; 4183 4184 /** 4185 * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails 4186 * @hide 4187 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4188 */ 4189 @Deprecated 4190 @SystemApi 4191 public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED"; 4192 4193 /** 4194 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast 4195 * is a rebroadcast on unlock. Defaults to {@code false} if not specified. 4196 * 4197 * @hide 4198 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or 4199 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4200 */ 4201 @Deprecated 4202 @SystemApi 4203 public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock"; 4204 4205 /** 4206 * Broadcast Action: indicate that the phone service state has changed. 4207 * The intent will have the following extra values:</p> 4208 * <p> 4209 * @see #EXTRA_VOICE_REG_STATE 4210 * @see #EXTRA_DATA_REG_STATE 4211 * @see #EXTRA_VOICE_ROAMING_TYPE 4212 * @see #EXTRA_DATA_ROAMING_TYPE 4213 * @see #EXTRA_OPERATOR_ALPHA_LONG 4214 * @see #EXTRA_OPERATOR_ALPHA_SHORT 4215 * @see #EXTRA_OPERATOR_NUMERIC 4216 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG 4217 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT 4218 * @see #EXTRA_DATA_OPERATOR_NUMERIC 4219 * @see #EXTRA_MANUAL 4220 * @see #EXTRA_VOICE_RADIO_TECH 4221 * @see #EXTRA_DATA_RADIO_TECH 4222 * @see #EXTRA_CSS_INDICATOR 4223 * @see #EXTRA_NETWORK_ID 4224 * @see #EXTRA_SYSTEM_ID 4225 * @see #EXTRA_CDMA_ROAMING_INDICATOR 4226 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR 4227 * @see #EXTRA_EMERGENCY_ONLY 4228 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION 4229 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION 4230 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST 4231 * 4232 * <p class="note"> 4233 * Requires the READ_PHONE_STATE permission. 4234 * 4235 * <p class="note">This is a protected intent that can only be sent by the system. 4236 * @hide 4237 * @removed 4238 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper 4239 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and 4240 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState 4241 * for a given subscription id and field with a ContentObserver or using JobScheduler. 4242 */ 4243 @Deprecated 4244 @SystemApi 4245 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 4246 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE"; 4247 4248 /** 4249 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration 4250 * state. 4251 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4252 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4253 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4254 * @see android.telephony.ServiceState#STATE_POWER_OFF 4255 * @hide 4256 * @removed 4257 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}. 4258 */ 4259 @Deprecated 4260 @SystemApi 4261 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState"; 4262 4263 /** 4264 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state. 4265 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4266 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4267 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4268 * @see android.telephony.ServiceState#STATE_POWER_OFF 4269 * @hide 4270 * @removed 4271 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}. 4272 */ 4273 @Deprecated 4274 @SystemApi 4275 public static final String EXTRA_DATA_REG_STATE = "dataRegState"; 4276 4277 /** 4278 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming 4279 * type. 4280 * @hide 4281 * @removed 4282 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}. 4283 */ 4284 @Deprecated 4285 @SystemApi 4286 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType"; 4287 4288 /** 4289 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming 4290 * type. 4291 * @hide 4292 * @removed 4293 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}. 4294 */ 4295 @Deprecated 4296 @SystemApi 4297 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType"; 4298 4299 /** 4300 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4301 * registered voice operator name in long alphanumeric format. 4302 * {@code null} if the operator name is not known or unregistered. 4303 * @hide 4304 * @removed 4305 * @deprecated Use 4306 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}. 4307 */ 4308 @Deprecated 4309 @SystemApi 4310 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long"; 4311 4312 /** 4313 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4314 * registered voice operator name in short alphanumeric format. 4315 * {@code null} if the operator name is not known or unregistered. 4316 * @hide 4317 * @removed 4318 * @deprecated Use 4319 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}. 4320 */ 4321 @Deprecated 4322 @SystemApi 4323 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short"; 4324 4325 /** 4326 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4327 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile 4328 * network. 4329 * @hide 4330 * @removed 4331 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}. 4332 */ 4333 @Deprecated 4334 @SystemApi 4335 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric"; 4336 4337 /** 4338 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4339 * registered data operator name in long alphanumeric format. 4340 * {@code null} if the operator name is not known or unregistered. 4341 * @hide 4342 * @removed 4343 * @deprecated Use 4344 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}. 4345 */ 4346 @Deprecated 4347 @SystemApi 4348 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long"; 4349 4350 /** 4351 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4352 * registered data operator name in short alphanumeric format. 4353 * {@code null} if the operator name is not known or unregistered. 4354 * @hide 4355 * @removed 4356 * @deprecated Use 4357 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}. 4358 */ 4359 @Deprecated 4360 @SystemApi 4361 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short"; 4362 4363 /** 4364 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4365 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the 4366 * data operator. 4367 * @hide 4368 * @removed 4369 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}. 4370 */ 4371 @Deprecated 4372 @SystemApi 4373 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric"; 4374 4375 /** 4376 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current 4377 * network selection mode is manual. 4378 * Will be {@code true} if manual mode, {@code false} if automatic mode. 4379 * @hide 4380 * @removed 4381 * @deprecated Use 4382 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}. 4383 */ 4384 @Deprecated 4385 @SystemApi 4386 public static final String EXTRA_MANUAL = "manual"; 4387 4388 /** 4389 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice 4390 * radio technology. 4391 * @hide 4392 * @removed 4393 * @deprecated Use 4394 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}. 4395 */ 4396 @Deprecated 4397 @SystemApi 4398 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology"; 4399 4400 /** 4401 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data 4402 * radio technology. 4403 * @hide 4404 * @removed 4405 * @deprecated Use 4406 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}. 4407 */ 4408 @Deprecated 4409 @SystemApi 4410 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology"; 4411 4412 /** 4413 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service 4414 * support on CDMA network. 4415 * Will be {@code true} if support, {@code false} otherwise. 4416 * @hide 4417 * @removed 4418 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}. 4419 */ 4420 @Deprecated 4421 @SystemApi 4422 public static final String EXTRA_CSS_INDICATOR = "cssIndicator"; 4423 4424 /** 4425 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network 4426 * id. {@code Integer.MAX_VALUE} if unknown. 4427 * @hide 4428 * @removed 4429 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}. 4430 */ 4431 @Deprecated 4432 @SystemApi 4433 public static final String EXTRA_NETWORK_ID = "networkId"; 4434 4435 /** 4436 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id. 4437 * {@code Integer.MAX_VALUE} if unknown. 4438 * @hide 4439 * @removed 4440 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}. 4441 */ 4442 @Deprecated 4443 @SystemApi 4444 public static final String EXTRA_SYSTEM_ID = "systemId"; 4445 4446 /** 4447 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming 4448 * indicator if registered on a CDMA or EVDO system or {@code -1} if not. 4449 * @hide 4450 * @removed 4451 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}. 4452 */ 4453 @Deprecated 4454 @SystemApi 4455 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator"; 4456 4457 /** 4458 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming 4459 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not. 4460 * @hide 4461 * @removed 4462 * @deprecated Use 4463 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}. 4464 */ 4465 @Deprecated 4466 @SystemApi 4467 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator"; 4468 4469 /** 4470 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency 4471 * only mode. 4472 * {@code true} if in emergency only mode, {@code false} otherwise. 4473 * @hide 4474 * @removed 4475 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}. 4476 */ 4477 @Deprecated 4478 @SystemApi 4479 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly"; 4480 4481 /** 4482 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network 4483 * registration state is roaming. 4484 * {@code true} if registration indicates roaming, {@code false} otherwise 4485 * @hide 4486 * @removed 4487 * @deprecated Use 4488 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}. 4489 */ 4490 @Deprecated 4491 @SystemApi 4492 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION = 4493 "isDataRoamingFromRegistration"; 4494 4495 /** 4496 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier 4497 * aggregation is in use. 4498 * {@code true} if carrier aggregation is in use, {@code false} otherwise. 4499 * @hide 4500 * @removed 4501 * @deprecated Use 4502 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}. 4503 */ 4504 @Deprecated 4505 @SystemApi 4506 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation"; 4507 4508 /** 4509 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which 4510 * is reduced from the rsrp threshold while calculating signal strength level. 4511 * @hide 4512 * @removed 4513 */ 4514 @Deprecated 4515 @SystemApi 4516 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; 4517 4518 /** 4519 * The name of the extra used to define the text to be processed, as a 4520 * CharSequence. Note that this may be a styled CharSequence, so you must use 4521 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. 4522 */ 4523 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; 4524 /** 4525 * The name of the boolean extra used to define if the processed text will be used as read-only. 4526 */ 4527 public static final String EXTRA_PROCESS_TEXT_READONLY = 4528 "android.intent.extra.PROCESS_TEXT_READONLY"; 4529 4530 /** 4531 * Broadcast action: reports when a new thermal event has been reached. When the device 4532 * is reaching its maximum temperatue, the thermal level reported 4533 * {@hide} 4534 */ 4535 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4536 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; 4537 4538 /** {@hide} */ 4539 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; 4540 4541 /** 4542 * Thermal state when the device is normal. This state is sent in the 4543 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4544 * {@hide} 4545 */ 4546 public static final int EXTRA_THERMAL_STATE_NORMAL = 0; 4547 4548 /** 4549 * Thermal state where the device is approaching its maximum threshold. This state is sent in 4550 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4551 * {@hide} 4552 */ 4553 public static final int EXTRA_THERMAL_STATE_WARNING = 1; 4554 4555 /** 4556 * Thermal state where the device has reached its maximum threshold. This state is sent in the 4557 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4558 * {@hide} 4559 */ 4560 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; 4561 4562 /** 4563 * Broadcast Action: Indicates the dock in idle state while device is docked. 4564 * 4565 * <p class="note">This is a protected intent that can only be sent 4566 * by the system. 4567 * 4568 * @hide 4569 */ 4570 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE"; 4571 4572 /** 4573 * Broadcast Action: Indicates the dock in active state while device is docked. 4574 * 4575 * <p class="note">This is a protected intent that can only be sent 4576 * by the system. 4577 * 4578 * @hide 4579 */ 4580 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE"; 4581 4582 /** 4583 * Broadcast Action: Indicates that a new device customization has been 4584 * downloaded and applied (packages installed, runtime resource overlays 4585 * enabled, xml files copied, ...), and that it is time for components that 4586 * need to for example clear their caches to do so now. 4587 * 4588 * @hide 4589 */ 4590 @SystemApi 4591 public static final String ACTION_DEVICE_CUSTOMIZATION_READY = 4592 "android.intent.action.DEVICE_CUSTOMIZATION_READY"; 4593 4594 4595 /** 4596 * Activity Action: Display an activity state associated with an unique {@link LocusId}. 4597 * 4598 * <p>For example, a chat app could use the context to resume a conversation between 2 users. 4599 * 4600 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the 4601 * app domain. Should be stable across reboots and backup / restore. 4602 * <p>Output: nothing. 4603 */ 4604 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4605 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS"; 4606 4607 // --------------------------------------------------------------------- 4608 // --------------------------------------------------------------------- 4609 // Standard intent categories (see addCategory()). 4610 4611 /** 4612 * Set if the activity should be an option for the default action 4613 * (center press) to perform on a piece of data. Setting this will 4614 * hide from the user any activities without it set when performing an 4615 * action on some data. Note that this is normally -not- set in the 4616 * Intent when initiating an action -- it is for use in intent filters 4617 * specified in packages. 4618 */ 4619 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4620 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; 4621 /** 4622 * Activities that can be safely invoked from a browser must support this 4623 * category. For example, if the user is viewing a web page or an e-mail 4624 * and clicks on a link in the text, the Intent generated execute that 4625 * link will require the BROWSABLE category, so that only activities 4626 * supporting this category will be considered as possible actions. By 4627 * supporting this category, you are promising that there is nothing 4628 * damaging (without user intervention) that can happen by invoking any 4629 * matching Intent. 4630 */ 4631 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4632 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; 4633 /** 4634 * Categories for activities that can participate in voice interaction. 4635 * An activity that supports this category must be prepared to run with 4636 * no UI shown at all (though in some case it may have a UI shown), and 4637 * rely on {@link android.app.VoiceInteractor} to interact with the user. 4638 */ 4639 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4640 public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; 4641 /** 4642 * Set if the activity should be considered as an alternative action to 4643 * the data the user is currently viewing. See also 4644 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that 4645 * applies to the selection in a list of items. 4646 * 4647 * <p>Supporting this category means that you would like your activity to be 4648 * displayed in the set of alternative things the user can do, usually as 4649 * part of the current activity's options menu. You will usually want to 4650 * include a specific label in the <intent-filter> of this action 4651 * describing to the user what it does. 4652 * 4653 * <p>The action of IntentFilter with this category is important in that it 4654 * describes the specific action the target will perform. This generally 4655 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather 4656 * a specific name such as "com.android.camera.action.CROP. Only one 4657 * alternative of any particular action will be shown to the user, so using 4658 * a specific action like this makes sure that your alternative will be 4659 * displayed while also allowing other applications to provide their own 4660 * overrides of that particular action. 4661 */ 4662 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4663 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; 4664 /** 4665 * Set if the activity should be considered as an alternative selection 4666 * action to the data the user has currently selected. This is like 4667 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list 4668 * of items from which the user can select, giving them alternatives to the 4669 * default action that will be performed on it. 4670 */ 4671 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4672 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; 4673 /** 4674 * Intended to be used as a tab inside of a containing TabActivity. 4675 */ 4676 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4677 public static final String CATEGORY_TAB = "android.intent.category.TAB"; 4678 /** 4679 * Should be displayed in the top-level launcher. 4680 */ 4681 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4682 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; 4683 /** 4684 * Indicates an activity optimized for Leanback mode, and that should 4685 * be displayed in the Leanback launcher. 4686 */ 4687 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4688 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; 4689 /** 4690 * Indicates the preferred entry-point activity when an application is launched from a Car 4691 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a 4692 * fallback, or exclude the application entirely. 4693 * @hide 4694 */ 4695 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4696 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER"; 4697 /** 4698 * Indicates a Leanback settings activity to be displayed in the Leanback launcher. 4699 * @hide 4700 */ 4701 @SystemApi 4702 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; 4703 /** 4704 * Provides information about the package it is in; typically used if 4705 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide 4706 * a front-door to the user without having to be shown in the all apps list. 4707 */ 4708 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4709 public static final String CATEGORY_INFO = "android.intent.category.INFO"; 4710 /** 4711 * This is the home activity, that is the first activity that is displayed 4712 * when the device boots. 4713 */ 4714 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4715 public static final String CATEGORY_HOME = "android.intent.category.HOME"; 4716 /** 4717 * This is the home activity that is displayed when the device is finished setting up and ready 4718 * for use. 4719 * @hide 4720 */ 4721 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4722 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; 4723 /** 4724 * The home activity shown on secondary displays that support showing home activities. 4725 */ 4726 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4727 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME"; 4728 /** 4729 * This is the setup wizard activity, that is the first activity that is displayed 4730 * when the user sets up the device for the first time. 4731 * @hide 4732 */ 4733 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4734 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; 4735 /** 4736 * This is the home activity, that is the activity that serves as the launcher app 4737 * from there the user can start other apps. Often components with lower/higher 4738 * priority intent filters handle the home intent, for example SetupWizard, to 4739 * setup the device and we need to be able to distinguish the home app from these 4740 * setup helpers. 4741 * @hide 4742 */ 4743 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4744 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP"; 4745 /** 4746 * This activity is a preference panel. 4747 */ 4748 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4749 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; 4750 /** 4751 * This activity is a development preference panel. 4752 */ 4753 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4754 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; 4755 /** 4756 * Capable of running inside a parent activity container. 4757 */ 4758 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4759 public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; 4760 /** 4761 * This activity allows the user to browse and download new applications. 4762 */ 4763 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4764 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; 4765 /** 4766 * This activity may be exercised by the monkey or other automated test tools. 4767 */ 4768 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4769 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; 4770 /** 4771 * To be used as a test (not part of the normal user experience). 4772 */ 4773 public static final String CATEGORY_TEST = "android.intent.category.TEST"; 4774 /** 4775 * To be used as a unit test (run through the Test Harness). 4776 */ 4777 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; 4778 /** 4779 * To be used as a sample code example (not part of the normal user 4780 * experience). 4781 */ 4782 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; 4783 4784 /** 4785 * Used to indicate that an intent only wants URIs that can be opened with 4786 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs 4787 * must support at least the columns defined in {@link OpenableColumns} when 4788 * queried. 4789 * 4790 * @see #ACTION_GET_CONTENT 4791 * @see #ACTION_OPEN_DOCUMENT 4792 * @see #ACTION_CREATE_DOCUMENT 4793 */ 4794 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4795 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; 4796 4797 /** 4798 * Used to indicate that an intent filter can accept files which are not necessarily 4799 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but 4800 * at least streamable via 4801 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} 4802 * using one of the stream types exposed via 4803 * {@link ContentResolver#getStreamTypes(Uri, String)}. 4804 * 4805 * @see #ACTION_SEND 4806 * @see #ACTION_SEND_MULTIPLE 4807 */ 4808 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4809 public static final String CATEGORY_TYPED_OPENABLE = 4810 "android.intent.category.TYPED_OPENABLE"; 4811 4812 /** 4813 * To be used as code under test for framework instrumentation tests. 4814 */ 4815 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = 4816 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; 4817 /** 4818 * An activity to run when device is inserted into a car dock. 4819 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4820 * information, see {@link android.app.UiModeManager}. 4821 */ 4822 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4823 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; 4824 /** 4825 * An activity to run when device is inserted into a car dock. 4826 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4827 * information, see {@link android.app.UiModeManager}. 4828 */ 4829 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4830 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; 4831 /** 4832 * An activity to run when device is inserted into a analog (low end) dock. 4833 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4834 * information, see {@link android.app.UiModeManager}. 4835 */ 4836 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4837 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; 4838 4839 /** 4840 * An activity to run when device is inserted into a digital (high end) dock. 4841 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4842 * information, see {@link android.app.UiModeManager}. 4843 */ 4844 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4845 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK"; 4846 4847 /** 4848 * Used to indicate that the activity can be used in a car environment. 4849 */ 4850 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4851 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; 4852 4853 /** 4854 * An activity to use for the launcher when the device is placed in a VR Headset viewer. 4855 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4856 * information, see {@link android.app.UiModeManager}. 4857 */ 4858 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4859 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; 4860 // --------------------------------------------------------------------- 4861 // --------------------------------------------------------------------- 4862 // Application launch intent categories (see addCategory()). 4863 4864 /** 4865 * Used with {@link #ACTION_MAIN} to launch the browser application. 4866 * The activity should be able to browse the Internet. 4867 * <p>NOTE: This should not be used as the primary key of an Intent, 4868 * since it will not result in the app launching with the correct 4869 * action and category. Instead, use this with 4870 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4871 * Intent with this category in the selector.</p> 4872 */ 4873 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4874 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; 4875 4876 /** 4877 * Used with {@link #ACTION_MAIN} to launch the calculator application. 4878 * The activity should be able to perform standard arithmetic operations. 4879 * <p>NOTE: This should not be used as the primary key of an Intent, 4880 * since it will not result in the app launching with the correct 4881 * action and category. Instead, use this with 4882 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4883 * Intent with this category in the selector.</p> 4884 */ 4885 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4886 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; 4887 4888 /** 4889 * Used with {@link #ACTION_MAIN} to launch the calendar application. 4890 * The activity should be able to view and manipulate calendar entries. 4891 * <p>NOTE: This should not be used as the primary key of an Intent, 4892 * since it will not result in the app launching with the correct 4893 * action and category. Instead, use this with 4894 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4895 * Intent with this category in the selector.</p> 4896 */ 4897 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4898 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; 4899 4900 /** 4901 * Used with {@link #ACTION_MAIN} to launch the contacts application. 4902 * The activity should be able to view and manipulate address book entries. 4903 * <p>NOTE: This should not be used as the primary key of an Intent, 4904 * since it will not result in the app launching with the correct 4905 * action and category. Instead, use this with 4906 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4907 * Intent with this category in the selector.</p> 4908 */ 4909 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4910 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; 4911 4912 /** 4913 * Used with {@link #ACTION_MAIN} to launch the email application. 4914 * The activity should be able to send and receive email. 4915 * <p>NOTE: This should not be used as the primary key of an Intent, 4916 * since it will not result in the app launching with the correct 4917 * action and category. Instead, use this with 4918 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4919 * Intent with this category in the selector.</p> 4920 */ 4921 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4922 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; 4923 4924 /** 4925 * Used with {@link #ACTION_MAIN} to launch the gallery application. 4926 * The activity should be able to view and manipulate image and video files 4927 * stored on the device. 4928 * <p>NOTE: This should not be used as the primary key of an Intent, 4929 * since it will not result in the app launching with the correct 4930 * action and category. Instead, use this with 4931 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4932 * Intent with this category in the selector.</p> 4933 */ 4934 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4935 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; 4936 4937 /** 4938 * Used with {@link #ACTION_MAIN} to launch the maps application. 4939 * The activity should be able to show the user's current location and surroundings. 4940 * <p>NOTE: This should not be used as the primary key of an Intent, 4941 * since it will not result in the app launching with the correct 4942 * action and category. Instead, use this with 4943 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4944 * Intent with this category in the selector.</p> 4945 */ 4946 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4947 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; 4948 4949 /** 4950 * Used with {@link #ACTION_MAIN} to launch the messaging application. 4951 * The activity should be able to send and receive text messages. 4952 * <p>NOTE: This should not be used as the primary key of an Intent, 4953 * since it will not result in the app launching with the correct 4954 * action and category. Instead, use this with 4955 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4956 * Intent with this category in the selector.</p> 4957 */ 4958 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4959 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; 4960 4961 /** 4962 * Used with {@link #ACTION_MAIN} to launch the music application. 4963 * The activity should be able to play, browse, or manipulate music files 4964 * stored on the device. 4965 * <p>NOTE: This should not be used as the primary key of an Intent, 4966 * since it will not result in the app launching with the correct 4967 * action and category. Instead, use this with 4968 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4969 * Intent with this category in the selector.</p> 4970 */ 4971 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4972 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; 4973 4974 /** 4975 * Used with {@link #ACTION_MAIN} to launch the files application. 4976 * The activity should be able to browse and manage files stored on the device. 4977 * <p>NOTE: This should not be used as the primary key of an Intent, 4978 * since it will not result in the app launching with the correct 4979 * action and category. Instead, use this with 4980 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4981 * Intent with this category in the selector.</p> 4982 */ 4983 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4984 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES"; 4985 4986 // --------------------------------------------------------------------- 4987 // --------------------------------------------------------------------- 4988 // Standard extra data keys. 4989 4990 /** 4991 * The initial data to place in a newly created record. Use with 4992 * {@link #ACTION_INSERT}. The data here is a Map containing the same 4993 * fields as would be given to the underlying ContentProvider.insert() 4994 * call. 4995 */ 4996 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; 4997 4998 /** 4999 * A constant CharSequence that is associated with the Intent, used with 5000 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that 5001 * this may be a styled CharSequence, so you must use 5002 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to 5003 * retrieve it. 5004 */ 5005 public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; 5006 5007 /** 5008 * A constant String that is associated with the Intent, used with 5009 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} 5010 * as HTML formatted text. Note that you <em>must</em> also supply 5011 * {@link #EXTRA_TEXT}. 5012 */ 5013 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; 5014 5015 /** 5016 * A content: URI holding a stream of data associated with the Intent, 5017 * used with {@link #ACTION_SEND} to supply the data being sent. 5018 */ 5019 public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; 5020 5021 /** 5022 * A String[] holding e-mail addresses that should be delivered to. 5023 */ 5024 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; 5025 5026 /** 5027 * A String[] holding e-mail addresses that should be carbon copied. 5028 */ 5029 public static final String EXTRA_CC = "android.intent.extra.CC"; 5030 5031 /** 5032 * A String[] holding e-mail addresses that should be blind carbon copied. 5033 */ 5034 public static final String EXTRA_BCC = "android.intent.extra.BCC"; 5035 5036 /** 5037 * A constant string holding the desired subject line of a message. 5038 */ 5039 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; 5040 5041 /** 5042 * An Intent describing the choices you would like shown with 5043 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. 5044 */ 5045 public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; 5046 5047 /** 5048 * An int representing the user id to be used. 5049 * 5050 * @hide 5051 */ 5052 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; 5053 5054 /** 5055 * An int representing the task id to be retrieved. This is used when a launch from recents is 5056 * intercepted by another action such as credentials confirmation to remember which task should 5057 * be resumed when complete. 5058 * 5059 * @hide 5060 */ 5061 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; 5062 5063 /** 5064 * An Intent[] describing additional, alternate choices you would like shown with 5065 * {@link #ACTION_CHOOSER}. 5066 * 5067 * <p>An app may be capable of providing several different payload types to complete a 5068 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos 5069 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer 5070 * several different supported sending mechanisms for sharing, such as the actual "image/*" 5071 * photo data or a hosted link where the photos can be viewed.</p> 5072 * 5073 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the 5074 * first/primary/preferred intent in the set. Additional intents specified in 5075 * this extra are ordered; by default intents that appear earlier in the array will be 5076 * preferred over intents that appear later in the array as matches for the same 5077 * target component. To alter this preference, a calling app may also supply 5078 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> 5079 */ 5080 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; 5081 5082 /** 5083 * A {@link ComponentName ComponentName[]} describing components that should be filtered out 5084 * and omitted from a list of components presented to the user. 5085 * 5086 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components 5087 * in this array if it otherwise would have shown them. Useful for omitting specific targets 5088 * from your own package or other apps from your organization if the idea of sending to those 5089 * targets would be redundant with other app functionality. Filtered components will not 5090 * be able to present targets from an associated <code>ChooserTargetService</code>.</p> 5091 */ 5092 public static final String EXTRA_EXCLUDE_COMPONENTS 5093 = "android.intent.extra.EXCLUDE_COMPONENTS"; 5094 5095 /** 5096 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} 5097 * describing additional high-priority deep-link targets for the chooser to present to the user. 5098 * 5099 * <p>Targets provided in this way will be presented inline with all other targets provided 5100 * by services from other apps. They will be prioritized before other service targets, but 5101 * after those targets provided by sources that the user has manually pinned to the front.</p> 5102 * 5103 * @see #ACTION_CHOOSER 5104 */ 5105 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; 5106 5107 /** 5108 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection 5109 * from the chooser activity presented by {@link #ACTION_CHOOSER}. 5110 * 5111 * <p>An app preparing an action for another app to complete may wish to allow the user to 5112 * disambiguate between several options for completing the action based on the chosen target 5113 * or otherwise refine the action before it is invoked. 5114 * </p> 5115 * 5116 * <p>When sent, this IntentSender may be filled in with the following extras:</p> 5117 * <ul> 5118 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> 5119 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's 5120 * chosen target beyond the first</li> 5121 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity 5122 * should fill in and send once the disambiguation is complete</li> 5123 * </ul> 5124 */ 5125 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER 5126 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; 5127 5128 /** 5129 * An {@code ArrayList} of {@code String} annotations describing content for 5130 * {@link #ACTION_CHOOSER}. 5131 * 5132 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a 5133 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> 5134 * 5135 * <p>Annotations should describe the major components or topics of the content. It is up to 5136 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be 5137 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to 5138 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon 5139 * character. Performance on customized annotations can suffer, if they are rarely used for 5140 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the 5141 * following annotations when applicable.</p> 5142 * <ul> 5143 * <li>"product" represents that the topic of the content is mainly about products, e.g., 5144 * health & beauty, and office supplies.</li> 5145 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g., 5146 * happy, and sad.</li> 5147 * <li>"person" represents that the topic of the content is mainly about persons, e.g., 5148 * face, finger, standing, and walking.</li> 5149 * <li>"child" represents that the topic of the content is mainly about children, e.g., 5150 * child, and baby.</li> 5151 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li> 5152 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li> 5153 * <li>"party" represents that the topic of the content is mainly about parties.</li> 5154 * <li>"animal" represent that the topic of the content is mainly about animals.</li> 5155 * <li>"plant" represents that the topic of the content is mainly about plants, e.g., 5156 * flowers.</li> 5157 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li> 5158 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g. 5159 * sunglasses, jewelry, handbags and clothing.</li> 5160 * <li>"material" represents that the topic of the content is mainly about materials, e.g., 5161 * paper, and silk.</li> 5162 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like 5163 * cars, and boats.</li> 5164 * <li>"document" represents that the topic of the content is mainly about documents, e.g. 5165 * posters.</li> 5166 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts 5167 * and designs of houses.</li> 5168 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g., 5169 * Christmas and Thanksgiving.</li> 5170 * </ul> 5171 */ 5172 public static final String EXTRA_CONTENT_ANNOTATIONS 5173 = "android.intent.extra.CONTENT_ANNOTATIONS"; 5174 5175 /** 5176 * A {@link ResultReceiver} used to return data back to the sender. 5177 * 5178 * <p>Used to complete an app-specific 5179 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> 5180 * 5181 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent 5182 * used to start a {@link #ACTION_CHOOSER} activity this extra will be 5183 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent 5184 * when the user selects a target component from the chooser. It is up to the recipient 5185 * to send a result to this ResultReceiver to signal that disambiguation is complete 5186 * and that the chooser should invoke the user's choice.</p> 5187 * 5188 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent 5189 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser 5190 * to match and fill in the final Intent or ChooserTarget before starting it. 5191 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from 5192 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to 5193 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> 5194 * 5195 * <p>The result code passed to the ResultReceiver should be 5196 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's 5197 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if 5198 * the chooser should finish without starting a target.</p> 5199 */ 5200 public static final String EXTRA_RESULT_RECEIVER 5201 = "android.intent.extra.RESULT_RECEIVER"; 5202 5203 /** 5204 * A CharSequence dialog title to provide to the user when used with a 5205 * {@link #ACTION_CHOOSER}. 5206 */ 5207 public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; 5208 5209 /** 5210 * A Parcelable[] of {@link Intent} or 5211 * {@link android.content.pm.LabeledIntent} objects as set with 5212 * {@link #putExtra(String, Parcelable[])} of additional activities to place 5213 * a the front of the list of choices, when shown to the user with a 5214 * {@link #ACTION_CHOOSER}. 5215 */ 5216 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; 5217 5218 /** 5219 * A {@link IntentSender} to start after instant app installation success. 5220 * @hide 5221 */ 5222 @SystemApi 5223 public static final String EXTRA_INSTANT_APP_SUCCESS = 5224 "android.intent.extra.INSTANT_APP_SUCCESS"; 5225 5226 /** 5227 * A {@link IntentSender} to start after instant app installation failure. 5228 * @hide 5229 */ 5230 @SystemApi 5231 public static final String EXTRA_INSTANT_APP_FAILURE = 5232 "android.intent.extra.INSTANT_APP_FAILURE"; 5233 5234 /** 5235 * The host name that triggered an instant app resolution. 5236 * @hide 5237 */ 5238 @SystemApi 5239 public static final String EXTRA_INSTANT_APP_HOSTNAME = 5240 "android.intent.extra.INSTANT_APP_HOSTNAME"; 5241 5242 /** 5243 * An opaque token to track instant app resolution. 5244 * @hide 5245 */ 5246 @SystemApi 5247 public static final String EXTRA_INSTANT_APP_TOKEN = 5248 "android.intent.extra.INSTANT_APP_TOKEN"; 5249 5250 /** 5251 * The action that triggered an instant application resolution. 5252 * @hide 5253 */ 5254 @SystemApi 5255 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION"; 5256 5257 /** 5258 * An array of {@link Bundle}s containing details about resolved instant apps.. 5259 * @hide 5260 */ 5261 @SystemApi 5262 public static final String EXTRA_INSTANT_APP_BUNDLES = 5263 "android.intent.extra.INSTANT_APP_BUNDLES"; 5264 5265 /** 5266 * A {@link Bundle} of metadata that describes the instant application that needs to be 5267 * installed. This data is populated from the response to 5268 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered 5269 * instant application resolver. 5270 * @hide 5271 */ 5272 @SystemApi 5273 public static final String EXTRA_INSTANT_APP_EXTRAS = 5274 "android.intent.extra.INSTANT_APP_EXTRAS"; 5275 5276 /** 5277 * A boolean value indicating that the instant app resolver was unable to state with certainty 5278 * that it did or did not have an app for the sanitized {@link Intent} defined at 5279 * {@link #EXTRA_INTENT}. 5280 * @hide 5281 */ 5282 @SystemApi 5283 public static final String EXTRA_UNKNOWN_INSTANT_APP = 5284 "android.intent.extra.UNKNOWN_INSTANT_APP"; 5285 5286 /** 5287 * The version code of the app to install components from. 5288 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE). 5289 * @hide 5290 */ 5291 @Deprecated 5292 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; 5293 5294 /** 5295 * The version code of the app to install components from. 5296 * @hide 5297 */ 5298 @SystemApi 5299 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE"; 5300 5301 /** 5302 * The app that triggered the instant app installation. 5303 * @hide 5304 */ 5305 @SystemApi 5306 public static final String EXTRA_CALLING_PACKAGE 5307 = "android.intent.extra.CALLING_PACKAGE"; 5308 5309 /** 5310 * Optional calling app provided bundle containing additional launch information the 5311 * installer may use. 5312 * @hide 5313 */ 5314 @SystemApi 5315 public static final String EXTRA_VERIFICATION_BUNDLE 5316 = "android.intent.extra.VERIFICATION_BUNDLE"; 5317 5318 /** 5319 * A Bundle forming a mapping of potential target package names to different extras Bundles 5320 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with 5321 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not 5322 * be currently installed on the device. 5323 * 5324 * <p>An application may choose to provide alternate extras for the case where a user 5325 * selects an activity from a predetermined set of target packages. If the activity 5326 * the user selects from the chooser belongs to a package with its package name as 5327 * a key in this bundle, the corresponding extras for that package will be merged with 5328 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement 5329 * extra has the same key as an extra already present in the intent it will overwrite 5330 * the extra from the intent.</p> 5331 * 5332 * <p><em>Examples:</em> 5333 * <ul> 5334 * <li>An application may offer different {@link #EXTRA_TEXT} to an application 5335 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query 5336 * parameters for that target.</li> 5337 * <li>An application may offer additional metadata for known targets of a given intent 5338 * to pass along information only relevant to that target such as account or content 5339 * identifiers already known to that application.</li> 5340 * </ul></p> 5341 */ 5342 public static final String EXTRA_REPLACEMENT_EXTRAS = 5343 "android.intent.extra.REPLACEMENT_EXTRAS"; 5344 5345 /** 5346 * An {@link IntentSender} that will be notified if a user successfully chooses a target 5347 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender 5348 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the 5349 * {@link ComponentName} of the chosen component. 5350 * 5351 * <p>In some situations this callback may never come, for example if the user abandons 5352 * the chooser, switches to another task or any number of other reasons. Apps should not 5353 * be written assuming that this callback will always occur.</p> 5354 */ 5355 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = 5356 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; 5357 5358 /** 5359 * The {@link ComponentName} chosen by the user to complete an action. 5360 * 5361 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER 5362 */ 5363 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; 5364 5365 /** 5366 * A {@link android.view.KeyEvent} object containing the event that 5367 * triggered the creation of the Intent it is in. 5368 */ 5369 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; 5370 5371 /** 5372 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user 5373 * before shutting down. 5374 * 5375 * {@hide} 5376 */ 5377 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; 5378 5379 /** 5380 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is 5381 * requested by the user. 5382 * 5383 * {@hide} 5384 */ 5385 public static final String EXTRA_USER_REQUESTED_SHUTDOWN = 5386 "android.intent.extra.USER_REQUESTED_SHUTDOWN"; 5387 5388 /** 5389 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 5390 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action 5391 * of restarting the application. 5392 */ 5393 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; 5394 5395 /** 5396 * A String holding the phone number originally entered in 5397 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual 5398 * number to call in a {@link android.content.Intent#ACTION_CALL}. 5399 */ 5400 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; 5401 5402 /** 5403 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} 5404 * intents to supply the uid the package had been assigned. Also an optional 5405 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 5406 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same 5407 * purpose. 5408 */ 5409 public static final String EXTRA_UID = "android.intent.extra.UID"; 5410 5411 /** 5412 * @hide String array of package names. 5413 */ 5414 @SystemApi 5415 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; 5416 5417 /** 5418 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 5419 * intents to indicate whether this represents a full uninstall (removing 5420 * both the code and its data) or a partial uninstall (leaving its data, 5421 * implying that this is an update). 5422 */ 5423 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; 5424 5425 /** 5426 * @hide 5427 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 5428 * intents to indicate that at this point the package has been removed for 5429 * all users on the device. 5430 */ 5431 public static final String EXTRA_REMOVED_FOR_ALL_USERS 5432 = "android.intent.extra.REMOVED_FOR_ALL_USERS"; 5433 5434 /** 5435 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 5436 * intents to indicate that this is a replacement of the package, so this 5437 * broadcast will immediately be followed by an add broadcast for a 5438 * different version of the same package. 5439 */ 5440 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING"; 5441 5442 /** 5443 * Used as an int extra field in {@link android.app.AlarmManager} intents 5444 * to tell the application being invoked how many pending alarms are being 5445 * delievered with the intent. For one-shot alarms this will always be 1. 5446 * For recurring alarms, this might be greater than 1 if the device was 5447 * asleep or powered off at the time an earlier alarm would have been 5448 * delivered. 5449 */ 5450 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; 5451 5452 /** 5453 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} 5454 * intents to request the dock state. Possible values are 5455 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, 5456 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or 5457 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or 5458 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or 5459 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. 5460 */ 5461 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; 5462 5463 /** 5464 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5465 * to represent that the phone is not in any dock. 5466 */ 5467 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; 5468 5469 /** 5470 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5471 * to represent that the phone is in a desk dock. 5472 */ 5473 public static final int EXTRA_DOCK_STATE_DESK = 1; 5474 5475 /** 5476 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5477 * to represent that the phone is in a car dock. 5478 */ 5479 public static final int EXTRA_DOCK_STATE_CAR = 2; 5480 5481 /** 5482 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5483 * to represent that the phone is in a analog (low end) dock. 5484 */ 5485 public static final int EXTRA_DOCK_STATE_LE_DESK = 3; 5486 5487 /** 5488 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 5489 * to represent that the phone is in a digital (high end) dock. 5490 */ 5491 public static final int EXTRA_DOCK_STATE_HE_DESK = 4; 5492 5493 /** 5494 * Boolean that can be supplied as meta-data with a dock activity, to 5495 * indicate that the dock should take over the home key when it is active. 5496 */ 5497 public static final String METADATA_DOCK_HOME = "android.dock_home"; 5498 5499 /** 5500 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing 5501 * the bug report. 5502 */ 5503 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; 5504 5505 /** 5506 * Used in the extra field in the remote intent. It's astring token passed with the 5507 * remote intent. 5508 */ 5509 public static final String EXTRA_REMOTE_INTENT_TOKEN = 5510 "android.intent.extra.remote_intent_token"; 5511 5512 /** 5513 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field 5514 * will contain only the first name in the list. 5515 */ 5516 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = 5517 "android.intent.extra.changed_component_name"; 5518 5519 /** 5520 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, 5521 * and contains a string array of all of the components that have changed. If 5522 * the state of the overall package has changed, then it will contain an entry 5523 * with the package name itself. 5524 */ 5525 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = 5526 "android.intent.extra.changed_component_name_list"; 5527 5528 /** 5529 * This field is part of 5530 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 5531 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, 5532 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, 5533 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} 5534 * and contains a string array of all of the components that have changed. 5535 */ 5536 public static final String EXTRA_CHANGED_PACKAGE_LIST = 5537 "android.intent.extra.changed_package_list"; 5538 5539 /** 5540 * This field is part of 5541 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 5542 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 5543 * and contains an integer array of uids of all of the components 5544 * that have changed. 5545 */ 5546 public static final String EXTRA_CHANGED_UID_LIST = 5547 "android.intent.extra.changed_uid_list"; 5548 5549 /** 5550 * An integer denoting a bitwise combination of restrictions set on distracting packages via 5551 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)} 5552 * 5553 * @hide 5554 * @see PackageManager.DistractionRestriction 5555 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 5556 */ 5557 public static final String EXTRA_DISTRACTION_RESTRICTIONS = 5558 "android.intent.extra.distraction_restrictions"; 5559 5560 /** 5561 * @hide 5562 * Magic extra system code can use when binding, to give a label for 5563 * who it is that has bound to a service. This is an integer giving 5564 * a framework string resource that can be displayed to the user. 5565 */ 5566 public static final String EXTRA_CLIENT_LABEL = 5567 "android.intent.extra.client_label"; 5568 5569 /** 5570 * @hide 5571 * Magic extra system code can use when binding, to give a PendingIntent object 5572 * that can be launched for the user to disable the system's use of this 5573 * service. 5574 */ 5575 public static final String EXTRA_CLIENT_INTENT = 5576 "android.intent.extra.client_intent"; 5577 5578 /** 5579 * Extra used to indicate that an intent should only return data that is on 5580 * the local device. This is a boolean extra; the default is false. If true, 5581 * an implementation should only allow the user to select data that is 5582 * already on the device, not requiring it be downloaded from a remote 5583 * service when opened. 5584 * 5585 * @see #ACTION_GET_CONTENT 5586 * @see #ACTION_OPEN_DOCUMENT 5587 * @see #ACTION_OPEN_DOCUMENT_TREE 5588 * @see #ACTION_CREATE_DOCUMENT 5589 */ 5590 public static final String EXTRA_LOCAL_ONLY = 5591 "android.intent.extra.LOCAL_ONLY"; 5592 5593 /** 5594 * Extra used to indicate that an intent can allow the user to select and 5595 * return multiple items. This is a boolean extra; the default is false. If 5596 * true, an implementation is allowed to present the user with a UI where 5597 * they can pick multiple items that are all returned to the caller. When 5598 * this happens, they should be returned as the {@link #getClipData()} part 5599 * of the result Intent. 5600 * 5601 * @see #ACTION_GET_CONTENT 5602 * @see #ACTION_OPEN_DOCUMENT 5603 */ 5604 public static final String EXTRA_ALLOW_MULTIPLE = 5605 "android.intent.extra.ALLOW_MULTIPLE"; 5606 5607 /** 5608 * The integer userHandle carried with broadcast intents related to addition, removal and 5609 * switching of users and managed profiles - {@link #ACTION_USER_ADDED}, 5610 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. 5611 * 5612 * @hide 5613 */ 5614 public static final String EXTRA_USER_HANDLE = 5615 "android.intent.extra.user_handle"; 5616 5617 /** 5618 * The UserHandle carried with intents. 5619 */ 5620 public static final String EXTRA_USER = 5621 "android.intent.extra.USER"; 5622 5623 /** 5624 * Extra used in the response from a BroadcastReceiver that handles 5625 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is 5626 * <code>ArrayList<RestrictionEntry></code>. 5627 */ 5628 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; 5629 5630 /** 5631 * Extra sent in the intent to the BroadcastReceiver that handles 5632 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing 5633 * the restrictions as key/value pairs. 5634 */ 5635 public static final String EXTRA_RESTRICTIONS_BUNDLE = 5636 "android.intent.extra.restrictions_bundle"; 5637 5638 /** 5639 * Extra used in the response from a BroadcastReceiver that handles 5640 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. 5641 */ 5642 public static final String EXTRA_RESTRICTIONS_INTENT = 5643 "android.intent.extra.restrictions_intent"; 5644 5645 /** 5646 * Extra used to communicate a set of acceptable MIME types. The type of the 5647 * extra is {@code String[]}. Values may be a combination of concrete MIME 5648 * types (such as "image/png") and/or partial MIME types (such as 5649 * "audio/*"). 5650 * 5651 * @see #ACTION_GET_CONTENT 5652 * @see #ACTION_OPEN_DOCUMENT 5653 */ 5654 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; 5655 5656 /** 5657 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that 5658 * this shutdown is only for the user space of the system, not a complete shutdown. 5659 * When this is true, hardware devices can use this information to determine that 5660 * they shouldn't do a complete shutdown of their device since this is not a 5661 * complete shutdown down to the kernel, but only user space restarting. 5662 * The default if not supplied is false. 5663 */ 5664 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY 5665 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; 5666 5667 /** 5668 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the 5669 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, 5670 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and 5671 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative. 5672 * 5673 * @hide for internal use only. 5674 */ 5675 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = 5676 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; 5677 /** @hide */ 5678 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; 5679 /** @hide */ 5680 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; 5681 /** @hide */ 5682 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; 5683 5684 /** 5685 * Intent extra: the reason that the operation associated with this intent is being performed. 5686 * 5687 * <p>Type: String 5688 * @hide 5689 */ 5690 @SystemApi 5691 public static final String EXTRA_REASON = "android.intent.extra.REASON"; 5692 5693 /** 5694 * {@hide} 5695 * This extra will be send together with {@link #ACTION_FACTORY_RESET} 5696 */ 5697 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; 5698 5699 /** 5700 * {@hide} 5701 * This extra will be set to true when the user choose to wipe the data on eSIM during factory 5702 * reset for the device with eSIM. This extra will be sent together with 5703 * {@link #ACTION_FACTORY_RESET} 5704 */ 5705 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; 5706 5707 /** 5708 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM 5709 * activation request. 5710 * TODO: Add information about the structure and response data used with the pending intent. 5711 * @hide 5712 */ 5713 public static final String EXTRA_SIM_ACTIVATION_RESPONSE = 5714 "android.intent.extra.SIM_ACTIVATION_RESPONSE"; 5715 5716 /** 5717 * Optional index with semantics depending on the intent action. 5718 * 5719 * <p>The value must be an integer greater or equal to 0. 5720 * @see #ACTION_QUICK_VIEW 5721 */ 5722 public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; 5723 5724 /** 5725 * Tells the quick viewer to show additional UI actions suitable for the passed Uris, 5726 * such as opening in other apps, sharing, opening, editing, printing, deleting, 5727 * casting, etc. 5728 * 5729 * <p>The value is boolean. By default false. 5730 * @see #ACTION_QUICK_VIEW 5731 * @removed 5732 */ 5733 @Deprecated 5734 public static final String EXTRA_QUICK_VIEW_ADVANCED = 5735 "android.intent.extra.QUICK_VIEW_ADVANCED"; 5736 5737 /** 5738 * An optional extra of {@code String[]} indicating which quick view features should be made 5739 * available to the user in the quick view UI while handing a 5740 * {@link Intent#ACTION_QUICK_VIEW} intent. 5741 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer. 5742 * Quick viewer can implement features not listed below. 5743 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW}, 5744 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE}, 5745 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND}, 5746 * {@link QuickViewConstants#FEATURE_PRINT}. 5747 * <p> 5748 * Requirements: 5749 * <li>Quick viewer shouldn't show a feature if the feature is absent in 5750 * {@link #EXTRA_QUICK_VIEW_FEATURES}. 5751 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow 5752 * internal policies. 5753 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a 5754 * requirement that the feature be shown. Quick viewer may, according to its own policies, 5755 * disable or hide features. 5756 * 5757 * @see #ACTION_QUICK_VIEW 5758 */ 5759 public static final String EXTRA_QUICK_VIEW_FEATURES = 5760 "android.intent.extra.QUICK_VIEW_FEATURES"; 5761 5762 /** 5763 * Optional boolean extra indicating whether quiet mode has been switched on or off. 5764 * When a profile goes into quiet mode, all apps in the profile are killed and the 5765 * profile user is stopped. Widgets originating from the profile are masked, and app 5766 * launcher icons are grayed out. 5767 */ 5768 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; 5769 5770 /** 5771 * Optional CharSequence extra to provide a search query. 5772 * The format of this query is dependent on the receiving application. 5773 * 5774 * <p>Applicable to {@link Intent} with actions: 5775 * <ul> 5776 * <li>{@link Intent#ACTION_GET_CONTENT}</li> 5777 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li> 5778 * </ul> 5779 */ 5780 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY"; 5781 5782 /** 5783 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} 5784 * intents to specify the resource type granted. Possible values are 5785 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or 5786 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. 5787 * 5788 * @hide 5789 */ 5790 public static final String EXTRA_MEDIA_RESOURCE_TYPE = 5791 "android.intent.extra.MEDIA_RESOURCE_TYPE"; 5792 5793 /** 5794 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify 5795 * whether to show the chooser or not when there is only one application available 5796 * to choose from. 5797 */ 5798 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = 5799 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; 5800 5801 /** 5802 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 5803 * to represent that a video codec is allowed to use. 5804 * 5805 * @hide 5806 */ 5807 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; 5808 5809 /** 5810 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 5811 * to represent that a audio codec is allowed to use. 5812 * 5813 * @hide 5814 */ 5815 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; 5816 5817 /** 5818 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}. 5819 * 5820 * <p> 5821 * Type: {@link LocusId} 5822 * </p> 5823 */ 5824 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID"; 5825 5826 // --------------------------------------------------------------------- 5827 // --------------------------------------------------------------------- 5828 // Intent flags (see mFlags variable). 5829 5830 /** @hide */ 5831 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 5832 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, 5833 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) 5834 @Retention(RetentionPolicy.SOURCE) 5835 public @interface GrantUriMode {} 5836 5837 /** @hide */ 5838 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 5839 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) 5840 @Retention(RetentionPolicy.SOURCE) 5841 public @interface AccessUriMode {} 5842 5843 /** 5844 * Test if given mode flags specify an access mode, which must be at least 5845 * read and/or write. 5846 * 5847 * @hide 5848 */ isAccessUriMode(int modeFlags)5849 public static boolean isAccessUriMode(int modeFlags) { 5850 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION 5851 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; 5852 } 5853 5854 /** @hide */ 5855 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 5856 FLAG_GRANT_READ_URI_PERMISSION, 5857 FLAG_GRANT_WRITE_URI_PERMISSION, 5858 FLAG_FROM_BACKGROUND, 5859 FLAG_DEBUG_LOG_RESOLUTION, 5860 FLAG_EXCLUDE_STOPPED_PACKAGES, 5861 FLAG_INCLUDE_STOPPED_PACKAGES, 5862 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, 5863 FLAG_GRANT_PREFIX_URI_PERMISSION, 5864 FLAG_DEBUG_TRIAGED_MISSING, 5865 FLAG_IGNORE_EPHEMERAL, 5866 FLAG_ACTIVITY_MATCH_EXTERNAL, 5867 FLAG_ACTIVITY_NO_HISTORY, 5868 FLAG_ACTIVITY_SINGLE_TOP, 5869 FLAG_ACTIVITY_NEW_TASK, 5870 FLAG_ACTIVITY_MULTIPLE_TASK, 5871 FLAG_ACTIVITY_CLEAR_TOP, 5872 FLAG_ACTIVITY_FORWARD_RESULT, 5873 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 5874 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 5875 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 5876 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 5877 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 5878 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5879 FLAG_ACTIVITY_NEW_DOCUMENT, 5880 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5881 FLAG_ACTIVITY_NO_USER_ACTION, 5882 FLAG_ACTIVITY_REORDER_TO_FRONT, 5883 FLAG_ACTIVITY_NO_ANIMATION, 5884 FLAG_ACTIVITY_CLEAR_TASK, 5885 FLAG_ACTIVITY_TASK_ON_HOME, 5886 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 5887 FLAG_ACTIVITY_LAUNCH_ADJACENT, 5888 FLAG_RECEIVER_REGISTERED_ONLY, 5889 FLAG_RECEIVER_REPLACE_PENDING, 5890 FLAG_RECEIVER_FOREGROUND, 5891 FLAG_RECEIVER_NO_ABORT, 5892 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 5893 FLAG_RECEIVER_BOOT_UPGRADE, 5894 FLAG_RECEIVER_INCLUDE_BACKGROUND, 5895 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 5896 FLAG_RECEIVER_FROM_SHELL, 5897 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 5898 FLAG_RECEIVER_OFFLOAD, 5899 }) 5900 @Retention(RetentionPolicy.SOURCE) 5901 public @interface Flags {} 5902 5903 /** @hide */ 5904 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 5905 FLAG_FROM_BACKGROUND, 5906 FLAG_DEBUG_LOG_RESOLUTION, 5907 FLAG_EXCLUDE_STOPPED_PACKAGES, 5908 FLAG_INCLUDE_STOPPED_PACKAGES, 5909 FLAG_DEBUG_TRIAGED_MISSING, 5910 FLAG_IGNORE_EPHEMERAL, 5911 FLAG_ACTIVITY_MATCH_EXTERNAL, 5912 FLAG_ACTIVITY_NO_HISTORY, 5913 FLAG_ACTIVITY_SINGLE_TOP, 5914 FLAG_ACTIVITY_NEW_TASK, 5915 FLAG_ACTIVITY_MULTIPLE_TASK, 5916 FLAG_ACTIVITY_CLEAR_TOP, 5917 FLAG_ACTIVITY_FORWARD_RESULT, 5918 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 5919 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 5920 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 5921 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 5922 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 5923 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5924 FLAG_ACTIVITY_NEW_DOCUMENT, 5925 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5926 FLAG_ACTIVITY_NO_USER_ACTION, 5927 FLAG_ACTIVITY_REORDER_TO_FRONT, 5928 FLAG_ACTIVITY_NO_ANIMATION, 5929 FLAG_ACTIVITY_CLEAR_TASK, 5930 FLAG_ACTIVITY_TASK_ON_HOME, 5931 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 5932 FLAG_ACTIVITY_LAUNCH_ADJACENT, 5933 FLAG_RECEIVER_REGISTERED_ONLY, 5934 FLAG_RECEIVER_REPLACE_PENDING, 5935 FLAG_RECEIVER_FOREGROUND, 5936 FLAG_RECEIVER_NO_ABORT, 5937 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 5938 FLAG_RECEIVER_BOOT_UPGRADE, 5939 FLAG_RECEIVER_INCLUDE_BACKGROUND, 5940 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 5941 FLAG_RECEIVER_FROM_SHELL, 5942 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 5943 FLAG_RECEIVER_OFFLOAD, 5944 }) 5945 @Retention(RetentionPolicy.SOURCE) 5946 public @interface MutableFlags {} 5947 5948 /** 5949 * If set, the recipient of this Intent will be granted permission to 5950 * perform read operations on the URI in the Intent's data and any URIs 5951 * specified in its ClipData. When applying to an Intent's ClipData, 5952 * all URIs as well as recursive traversals through data or other ClipData 5953 * in Intent items will be granted; only the grant flags of the top-level 5954 * Intent are used. 5955 */ 5956 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; 5957 /** 5958 * If set, the recipient of this Intent will be granted permission to 5959 * perform write operations on the URI in the Intent's data and any URIs 5960 * specified in its ClipData. When applying to an Intent's ClipData, 5961 * all URIs as well as recursive traversals through data or other ClipData 5962 * in Intent items will be granted; only the grant flags of the top-level 5963 * Intent are used. 5964 */ 5965 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; 5966 /** 5967 * Can be set by the caller to indicate that this Intent is coming from 5968 * a background operation, not from direct user interaction. 5969 */ 5970 public static final int FLAG_FROM_BACKGROUND = 0x00000004; 5971 /** 5972 * A flag you can enable for debugging: when set, log messages will be 5973 * printed during the resolution of this intent to show you what has 5974 * been found to create the final resolved list. 5975 */ 5976 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; 5977 /** 5978 * If set, this intent will not match any components in packages that 5979 * are currently stopped. If this is not set, then the default behavior 5980 * is to include such applications in the result. 5981 */ 5982 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; 5983 /** 5984 * If set, this intent will always match any components in packages that 5985 * are currently stopped. This is the default behavior when 5986 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these 5987 * flags are set, this one wins (it allows overriding of exclude for 5988 * places where the framework may automatically set the exclude flag). 5989 */ 5990 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; 5991 5992 /** 5993 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 5994 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be 5995 * persisted across device reboots until explicitly revoked with 5996 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the 5997 * grant for possible persisting; the receiving application must call 5998 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to 5999 * actually persist. 6000 * 6001 * @see ContentResolver#takePersistableUriPermission(Uri, int) 6002 * @see ContentResolver#releasePersistableUriPermission(Uri, int) 6003 * @see ContentResolver#getPersistedUriPermissions() 6004 * @see ContentResolver#getOutgoingPersistedUriPermissions() 6005 */ 6006 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; 6007 6008 /** 6009 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 6010 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant 6011 * applies to any URI that is a prefix match against the original granted 6012 * URI. (Without this flag, the URI must match exactly for access to be 6013 * granted.) Another URI is considered a prefix match only when scheme, 6014 * authority, and all path segments defined by the prefix are an exact 6015 * match. 6016 */ 6017 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; 6018 6019 /** 6020 * Flag used to automatically match intents based on their Direct Boot 6021 * awareness and the current user state. 6022 * <p> 6023 * Since the default behavior is to automatically apply the current user 6024 * state, this is effectively a sentinel value that doesn't change the 6025 * output of any queries based on its presence or absence. 6026 * <p> 6027 * Instead, this value can be useful in conjunction with 6028 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()} 6029 * to detect when a caller is relying on implicit automatic matching, 6030 * instead of confirming the explicit behavior they want. 6031 */ 6032 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100; 6033 6034 /** {@hide} */ 6035 @Deprecated 6036 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO; 6037 6038 /** 6039 * Internal flag used to indicate ephemeral applications should not be 6040 * considered when resolving the intent. 6041 * 6042 * @hide 6043 */ 6044 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200; 6045 6046 /** 6047 * If set, the new activity is not kept in the history stack. As soon as 6048 * the user navigates away from it, the activity is finished. This may also 6049 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory 6050 * noHistory} attribute. 6051 * 6052 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} 6053 * is never invoked when the current activity starts a new activity which 6054 * sets a result and finishes. 6055 */ 6056 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; 6057 /** 6058 * If set, the activity will not be launched if it is already running 6059 * at the top of the history stack. 6060 */ 6061 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; 6062 /** 6063 * If set, this activity will become the start of a new task on this 6064 * history stack. A task (from the activity that started it to the 6065 * next task activity) defines an atomic group of activities that the 6066 * user can move to. Tasks can be moved to the foreground and background; 6067 * all of the activities inside of a particular task always remain in 6068 * the same order. See 6069 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6070 * Stack</a> for more information about tasks. 6071 * 6072 * <p>This flag is generally used by activities that want 6073 * to present a "launcher" style behavior: they give the user a list of 6074 * separate things that can be done, which otherwise run completely 6075 * independently of the activity launching them. 6076 * 6077 * <p>When using this flag, if a task is already running for the activity 6078 * you are now starting, then a new activity will not be started; instead, 6079 * the current task will simply be brought to the front of the screen with 6080 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag 6081 * to disable this behavior. 6082 * 6083 * <p>This flag can not be used when the caller is requesting a result from 6084 * the activity being launched. 6085 */ 6086 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; 6087 /** 6088 * This flag is used to create a new task and launch an activity into it. 6089 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} 6090 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would 6091 * search through existing tasks for ones matching this Intent. Only if no such 6092 * task is found would a new task be created. When paired with 6093 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip 6094 * the search for a matching task and unconditionally start a new task. 6095 * 6096 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this 6097 * flag unless you are implementing your own 6098 * top-level application launcher.</strong> Used in conjunction with 6099 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the 6100 * behavior of bringing an existing task to the foreground. When set, 6101 * a new task is <em>always</em> started to host the Activity for the 6102 * Intent, regardless of whether there is already an existing task running 6103 * the same thing. 6104 * 6105 * <p><strong>Because the default system does not include graphical task management, 6106 * you should not use this flag unless you provide some way for a user to 6107 * return back to the tasks you have launched.</strong> 6108 * 6109 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for 6110 * creating new document tasks. 6111 * 6112 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or 6113 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. 6114 * 6115 * <p>See 6116 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6117 * Stack</a> for more information about tasks. 6118 * 6119 * @see #FLAG_ACTIVITY_NEW_DOCUMENT 6120 * @see #FLAG_ACTIVITY_NEW_TASK 6121 */ 6122 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; 6123 /** 6124 * If set, and the activity being launched is already running in the 6125 * current task, then instead of launching a new instance of that activity, 6126 * all of the other activities on top of it will be closed and this Intent 6127 * will be delivered to the (now on top) old activity as a new Intent. 6128 * 6129 * <p>For example, consider a task consisting of the activities: A, B, C, D. 6130 * If D calls startActivity() with an Intent that resolves to the component 6131 * of activity B, then C and D will be finished and B receive the given 6132 * Intent, resulting in the stack now being: A, B. 6133 * 6134 * <p>The currently running instance of activity B in the above example will 6135 * either receive the new intent you are starting here in its 6136 * onNewIntent() method, or be itself finished and restarted with the 6137 * new intent. If it has declared its launch mode to be "multiple" (the 6138 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in 6139 * the same intent, then it will be finished and re-created; for all other 6140 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this 6141 * Intent will be delivered to the current instance's onNewIntent(). 6142 * 6143 * <p>This launch mode can also be used to good effect in conjunction with 6144 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity 6145 * of a task, it will bring any currently running instance of that task 6146 * to the foreground, and then clear it to its root state. This is 6147 * especially useful, for example, when launching an activity from the 6148 * notification manager. 6149 * 6150 * <p>See 6151 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6152 * Stack</a> for more information about tasks. 6153 */ 6154 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; 6155 /** 6156 * If set and this intent is being used to launch a new activity from an 6157 * existing one, then the reply target of the existing activity will be 6158 * transferred to the new activity. This way, the new activity can call 6159 * {@link android.app.Activity#setResult} and have that result sent back to 6160 * the reply target of the original activity. 6161 */ 6162 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; 6163 /** 6164 * If set and this intent is being used to launch a new activity from an 6165 * existing one, the current activity will not be counted as the top 6166 * activity for deciding whether the new intent should be delivered to 6167 * the top instead of starting a new one. The previous activity will 6168 * be used as the top, with the assumption being that the current activity 6169 * will finish itself immediately. 6170 */ 6171 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; 6172 /** 6173 * If set, the new activity is not kept in the list of recently launched 6174 * activities. 6175 */ 6176 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; 6177 /** 6178 * This flag is not normally set by application code, but set for you by 6179 * the system as described in the 6180 * {@link android.R.styleable#AndroidManifestActivity_launchMode 6181 * launchMode} documentation for the singleTask mode. 6182 */ 6183 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; 6184 /** 6185 * If set, and this activity is either being started in a new task or 6186 * bringing to the top an existing task, then it will be launched as 6187 * the front door of the task. This will result in the application of 6188 * any affinities needed to have that task in the proper state (either 6189 * moving activities to or from it), or simply resetting that task to 6190 * its initial state if needed. 6191 */ 6192 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; 6193 /** 6194 * This flag is not normally set by application code, but set for you by 6195 * the system if this activity is being launched from history 6196 * (longpress home key). 6197 */ 6198 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; 6199 /** 6200 * @deprecated As of API 21 this performs identically to 6201 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. 6202 */ 6203 @Deprecated 6204 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; 6205 /** 6206 * This flag is used to open a document into a new task rooted at the activity launched 6207 * by this Intent. Through the use of this flag, or its equivalent attribute, 6208 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity 6209 * containing different documents will appear in the recent tasks list. 6210 * 6211 * <p>The use of the activity attribute form of this, 6212 * {@link android.R.attr#documentLaunchMode}, is 6213 * preferred over the Intent flag described here. The attribute form allows the 6214 * Activity to specify multiple document behavior for all launchers of the Activity 6215 * whereas using this flag requires each Intent that launches the Activity to specify it. 6216 * 6217 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for 6218 * it is kept after the activity is finished is different than the use of 6219 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if 6220 * this flag is being used to create a new recents entry, then by default that entry 6221 * will be removed once the activity is finished. You can modify this behavior with 6222 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. 6223 * 6224 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link 6225 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the 6226 * equivalent of the Activity manifest specifying {@link 6227 * android.R.attr#documentLaunchMode}="intoExisting". When used with 6228 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying 6229 * {@link android.R.attr#documentLaunchMode}="always". 6230 * 6231 * Refer to {@link android.R.attr#documentLaunchMode} for more information. 6232 * 6233 * @see android.R.attr#documentLaunchMode 6234 * @see #FLAG_ACTIVITY_MULTIPLE_TASK 6235 */ 6236 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; 6237 /** 6238 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} 6239 * callback from occurring on the current frontmost activity before it is 6240 * paused as the newly-started activity is brought to the front. 6241 * 6242 * <p>Typically, an activity can rely on that callback to indicate that an 6243 * explicit user action has caused their activity to be moved out of the 6244 * foreground. The callback marks an appropriate point in the activity's 6245 * lifecycle for it to dismiss any notifications that it intends to display 6246 * "until the user has seen them," such as a blinking LED. 6247 * 6248 * <p>If an activity is ever started via any non-user-driven events such as 6249 * phone-call receipt or an alarm handler, this flag should be passed to {@link 6250 * Context#startActivity Context.startActivity}, ensuring that the pausing 6251 * activity does not think the user has acknowledged its notification. 6252 */ 6253 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; 6254 /** 6255 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6256 * this flag will cause the launched activity to be brought to the front of its 6257 * task's history stack if it is already running. 6258 * 6259 * <p>For example, consider a task consisting of four activities: A, B, C, D. 6260 * If D calls startActivity() with an Intent that resolves to the component 6261 * of activity B, then B will be brought to the front of the history stack, 6262 * with this resulting order: A, C, D, B. 6263 * 6264 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also 6265 * specified. 6266 */ 6267 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; 6268 /** 6269 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6270 * this flag will prevent the system from applying an activity transition 6271 * animation to go to the next activity state. This doesn't mean an 6272 * animation will never run -- if another activity change happens that doesn't 6273 * specify this flag before the activity started here is displayed, then 6274 * that transition will be used. This flag can be put to good use 6275 * when you are going to do a series of activity operations but the 6276 * animation seen by the user shouldn't be driven by the first activity 6277 * change but rather a later one. 6278 */ 6279 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; 6280 /** 6281 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6282 * this flag will cause any existing task that would be associated with the 6283 * activity to be cleared before the activity is started. That is, the activity 6284 * becomes the new root of an otherwise empty task, and any old activities 6285 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 6286 */ 6287 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; 6288 /** 6289 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6290 * this flag will cause a newly launching task to be placed on top of the current 6291 * home activity task (if there is one). That is, pressing back from the task 6292 * will always return the user to home even if that was not the last activity they 6293 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 6294 */ 6295 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; 6296 /** 6297 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will 6298 * have its entry in recent tasks removed when the user closes it (with back 6299 * or however else it may finish()). If you would like to instead allow the 6300 * document to be kept in recents so that it can be re-launched, you can use 6301 * this flag. When set and the task's activity is finished, the recents 6302 * entry will remain in the interface for the user to re-launch it, like a 6303 * recents entry for a top-level application. 6304 * <p> 6305 * The receiving activity can override this request with 6306 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling 6307 * {@link android.app.Activity#finishAndRemoveTask() 6308 * Activity.finishAndRemoveTask()}. 6309 */ 6310 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; 6311 6312 /** 6313 * This flag is only used in split-screen multi-window mode. The new activity will be displayed 6314 * adjacent to the one launching it. This can only be used in conjunction with 6315 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is 6316 * required if you want a new instance of an existing activity to be created. 6317 */ 6318 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; 6319 6320 6321 /** 6322 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6323 * this flag will attempt to launch an instant app if no full app on the device can already 6324 * handle the intent. 6325 * <p> 6326 * When attempting to resolve instant apps externally, the following {@link Intent} properties 6327 * are supported: 6328 * <ul> 6329 * <li>{@link Intent#setAction(String)}</li> 6330 * <li>{@link Intent#addCategory(String)}</li> 6331 * <li>{@link Intent#setData(Uri)}</li> 6332 * <li>{@link Intent#setType(String)}</li> 6333 * <li>{@link Intent#setPackage(String)}</li> 6334 * <li>{@link Intent#addFlags(int)}</li> 6335 * </ul> 6336 * <p> 6337 * In the case that no instant app can be found, the installer will be launched to notify the 6338 * user that the intent could not be resolved. On devices that do not support instant apps, 6339 * the flag will be ignored. 6340 */ 6341 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800; 6342 6343 /** 6344 * If set, when sending a broadcast only registered receivers will be 6345 * called -- no BroadcastReceiver components will be launched. 6346 */ 6347 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 6348 /** 6349 * If set, when sending a broadcast the new broadcast will replace 6350 * any existing pending broadcast that matches it. Matching is defined 6351 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning 6352 * true for the intents of the two broadcasts. When a match is found, 6353 * the new broadcast (and receivers associated with it) will replace the 6354 * existing one in the pending broadcast list, remaining at the same 6355 * position in the list. 6356 * 6357 * <p>This flag is most typically used with sticky broadcasts, which 6358 * only care about delivering the most recent values of the broadcast 6359 * to their receivers. 6360 */ 6361 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; 6362 /** 6363 * If set, when sending a broadcast the recipient is allowed to run at 6364 * foreground priority, with a shorter timeout interval. During normal 6365 * broadcasts the receivers are not automatically hoisted out of the 6366 * background priority class. 6367 */ 6368 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; 6369 /** 6370 * If set, when sending a broadcast the recipient will be run on the offload queue. 6371 * 6372 * @hide 6373 */ 6374 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000; 6375 /** 6376 * If this is an ordered broadcast, don't allow receivers to abort the broadcast. 6377 * They can still propagate results through to later receivers, but they can not prevent 6378 * later receivers from seeing the broadcast. 6379 */ 6380 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; 6381 /** 6382 * If set, when sending a broadcast <i>before boot has completed</i> only 6383 * registered receivers will be called -- no BroadcastReceiver components 6384 * will be launched. Sticky intent state will be recorded properly even 6385 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} 6386 * is specified in the broadcast intent, this flag is unnecessary. 6387 * 6388 * <p>This flag is only for use by system sevices as a convenience to 6389 * avoid having to implement a more complex mechanism around detection 6390 * of boot completion. 6391 * 6392 * @hide 6393 */ 6394 @UnsupportedAppUsage 6395 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; 6396 /** 6397 * Set when this broadcast is for a boot upgrade, a special mode that 6398 * allows the broadcast to be sent before the system is ready and launches 6399 * the app process with no providers running in it. 6400 * @hide 6401 */ 6402 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; 6403 /** 6404 * If set, the broadcast will always go to manifest receivers in background (cached 6405 * or not running) apps, regardless of whether that would be done by default. By 6406 * default they will only receive broadcasts if the broadcast has specified an 6407 * explicit component or package name. 6408 * 6409 * NOTE: dumpstate uses this flag numerically, so when its value is changed 6410 * the broadcast code there must also be changed to match. 6411 * 6412 * @hide 6413 */ 6414 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; 6415 /** 6416 * If set, the broadcast will never go to manifest receivers in background (cached 6417 * or not running) apps, regardless of whether that would be done by default. By 6418 * default they will receive broadcasts if the broadcast has specified an 6419 * explicit component or package name. 6420 * @hide 6421 */ 6422 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; 6423 /** 6424 * If set, this broadcast is being sent from the shell. 6425 * @hide 6426 */ 6427 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; 6428 6429 /** 6430 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps 6431 * will not receive broadcasts. 6432 * 6433 * <em>This flag has no effect when used by an Instant App.</em> 6434 */ 6435 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000; 6436 6437 /** 6438 * @hide Flags that can't be changed with PendingIntent. 6439 */ 6440 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION 6441 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 6442 | FLAG_GRANT_PREFIX_URI_PERMISSION; 6443 6444 // --------------------------------------------------------------------- 6445 // --------------------------------------------------------------------- 6446 // toUri() and parseUri() options. 6447 6448 /** @hide */ 6449 @IntDef(flag = true, prefix = { "URI_" }, value = { 6450 URI_ALLOW_UNSAFE, 6451 URI_ANDROID_APP_SCHEME, 6452 URI_INTENT_SCHEME, 6453 }) 6454 @Retention(RetentionPolicy.SOURCE) 6455 public @interface UriFlags {} 6456 6457 /** 6458 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 6459 * always has the "intent:" scheme. This syntax can be used when you want 6460 * to later disambiguate between URIs that are intended to describe an 6461 * Intent vs. all others that should be treated as raw URIs. When used 6462 * with {@link #parseUri}, any other scheme will result in a generic 6463 * VIEW action for that raw URI. 6464 */ 6465 public static final int URI_INTENT_SCHEME = 1<<0; 6466 6467 /** 6468 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 6469 * always has the "android-app:" scheme. This is a variation of 6470 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an 6471 * http/https URI being delivered to a specific package name. The format 6472 * is: 6473 * 6474 * <pre class="prettyprint"> 6475 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> 6476 * 6477 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, 6478 * you must also include a scheme; including a path also requires both a host and a scheme. 6479 * The final #Intent; fragment can be used without a scheme, host, or path. 6480 * Note that this can not be 6481 * used with intents that have a {@link #setSelector}, since the base intent 6482 * will always have an explicit package name.</p> 6483 * 6484 * <p>Some examples of how this scheme maps to Intent objects:</p> 6485 * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> 6486 * <colgroup align="left" /> 6487 * <colgroup align="left" /> 6488 * <thead> 6489 * <tr><th>URI</th> <th>Intent</th></tr> 6490 * </thead> 6491 * 6492 * <tbody> 6493 * <tr><td><code>android-app://com.example.app</code></td> 6494 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6495 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> 6496 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6497 * </table></td> 6498 * </tr> 6499 * <tr><td><code>android-app://com.example.app/http/example.com</code></td> 6500 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6501 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 6502 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> 6503 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6504 * </table></td> 6505 * </tr> 6506 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> 6507 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6508 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 6509 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 6510 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6511 * </table></td> 6512 * </tr> 6513 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> 6514 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6515 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 6516 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6517 * </table></td> 6518 * </tr> 6519 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> 6520 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 6521 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 6522 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 6523 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6524 * </table></td> 6525 * </tr> 6526 * <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> 6527 * <td><table border="" style="margin:0" > 6528 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 6529 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 6530 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> 6531 * </table></td> 6532 * </tr> 6533 * </tbody> 6534 * </table> 6535 */ 6536 public static final int URI_ANDROID_APP_SCHEME = 1<<1; 6537 6538 /** 6539 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing 6540 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, 6541 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, 6542 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the 6543 * generated Intent can not cause unexpected data access to happen. 6544 * 6545 * <p>If you do not trust the source of the URI being parsed, you should still do further 6546 * processing to protect yourself from it. In particular, when using it to start an 6547 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities 6548 * that can handle it.</p> 6549 */ 6550 public static final int URI_ALLOW_UNSAFE = 1<<2; 6551 6552 // --------------------------------------------------------------------- 6553 6554 private String mAction; 6555 private Uri mData; 6556 private String mType; 6557 private String mIdentifier; 6558 private String mPackage; 6559 private ComponentName mComponent; 6560 private int mFlags; 6561 private ArraySet<String> mCategories; 6562 @UnsupportedAppUsage 6563 private Bundle mExtras; 6564 private Rect mSourceBounds; 6565 private Intent mSelector; 6566 private ClipData mClipData; 6567 private int mContentUserHint = UserHandle.USER_CURRENT; 6568 /** Token to track instant app launches. Local only; do not copy cross-process. */ 6569 private String mLaunchToken; 6570 6571 // --------------------------------------------------------------------- 6572 6573 private static final int COPY_MODE_ALL = 0; 6574 private static final int COPY_MODE_FILTER = 1; 6575 private static final int COPY_MODE_HISTORY = 2; 6576 6577 /** @hide */ 6578 @IntDef(prefix = { "COPY_MODE_" }, value = { 6579 COPY_MODE_ALL, 6580 COPY_MODE_FILTER, 6581 COPY_MODE_HISTORY 6582 }) 6583 @Retention(RetentionPolicy.SOURCE) 6584 public @interface CopyMode {} 6585 6586 /** 6587 * Create an empty intent. 6588 */ Intent()6589 public Intent() { 6590 } 6591 6592 /** 6593 * Copy constructor. 6594 */ Intent(Intent o)6595 public Intent(Intent o) { 6596 this(o, COPY_MODE_ALL); 6597 } 6598 Intent(Intent o, @CopyMode int copyMode)6599 private Intent(Intent o, @CopyMode int copyMode) { 6600 this.mAction = o.mAction; 6601 this.mData = o.mData; 6602 this.mType = o.mType; 6603 this.mIdentifier = o.mIdentifier; 6604 this.mPackage = o.mPackage; 6605 this.mComponent = o.mComponent; 6606 6607 if (o.mCategories != null) { 6608 this.mCategories = new ArraySet<>(o.mCategories); 6609 } 6610 6611 if (copyMode != COPY_MODE_FILTER) { 6612 this.mFlags = o.mFlags; 6613 this.mContentUserHint = o.mContentUserHint; 6614 this.mLaunchToken = o.mLaunchToken; 6615 if (o.mSourceBounds != null) { 6616 this.mSourceBounds = new Rect(o.mSourceBounds); 6617 } 6618 if (o.mSelector != null) { 6619 this.mSelector = new Intent(o.mSelector); 6620 } 6621 6622 if (copyMode != COPY_MODE_HISTORY) { 6623 if (o.mExtras != null) { 6624 this.mExtras = new Bundle(o.mExtras); 6625 } 6626 if (o.mClipData != null) { 6627 this.mClipData = new ClipData(o.mClipData); 6628 } 6629 } else { 6630 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) { 6631 this.mExtras = Bundle.STRIPPED; 6632 } 6633 6634 // Also set "stripped" clip data when we ever log mClipData in the (broadcast) 6635 // history. 6636 } 6637 } 6638 } 6639 6640 @Override clone()6641 public Object clone() { 6642 return new Intent(this); 6643 } 6644 6645 /** 6646 * Make a clone of only the parts of the Intent that are relevant for 6647 * filter matching: the action, data, type, component, and categories. 6648 */ cloneFilter()6649 public @NonNull Intent cloneFilter() { 6650 return new Intent(this, COPY_MODE_FILTER); 6651 } 6652 6653 /** 6654 * Create an intent with a given action. All other fields (data, type, 6655 * class) are null. Note that the action <em>must</em> be in a 6656 * namespace because Intents are used globally in the system -- for 6657 * example the system VIEW action is android.intent.action.VIEW; an 6658 * application's custom action would be something like 6659 * com.google.app.myapp.CUSTOM_ACTION. 6660 * 6661 * @param action The Intent action, such as ACTION_VIEW. 6662 */ Intent(String action)6663 public Intent(String action) { 6664 setAction(action); 6665 } 6666 6667 /** 6668 * Create an intent with a given action and for a given data url. Note 6669 * that the action <em>must</em> be in a namespace because Intents are 6670 * used globally in the system -- for example the system VIEW action is 6671 * android.intent.action.VIEW; an application's custom action would be 6672 * something like com.google.app.myapp.CUSTOM_ACTION. 6673 * 6674 * <p><em>Note: scheme and host name matching in the Android framework is 6675 * case-sensitive, unlike the formal RFC. As a result, 6676 * you should always ensure that you write your Uri with these elements 6677 * using lower case letters, and normalize any Uris you receive from 6678 * outside of Android to ensure the scheme and host is lower case.</em></p> 6679 * 6680 * @param action The Intent action, such as ACTION_VIEW. 6681 * @param uri The Intent data URI. 6682 */ Intent(String action, Uri uri)6683 public Intent(String action, Uri uri) { 6684 setAction(action); 6685 mData = uri; 6686 } 6687 6688 /** 6689 * Create an intent for a specific component. All other fields (action, data, 6690 * type, class) are null, though they can be modified later with explicit 6691 * calls. This provides a convenient way to create an intent that is 6692 * intended to execute a hard-coded class name, rather than relying on the 6693 * system to find an appropriate class for you; see {@link #setComponent} 6694 * for more information on the repercussions of this. 6695 * 6696 * @param packageContext A Context of the application package implementing 6697 * this class. 6698 * @param cls The component class that is to be used for the intent. 6699 * 6700 * @see #setClass 6701 * @see #setComponent 6702 * @see #Intent(String, android.net.Uri , Context, Class) 6703 */ Intent(Context packageContext, Class<?> cls)6704 public Intent(Context packageContext, Class<?> cls) { 6705 mComponent = new ComponentName(packageContext, cls); 6706 } 6707 6708 /** 6709 * Create an intent for a specific component with a specified action and data. 6710 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to 6711 * construct the Intent and then calling {@link #setClass} to set its 6712 * class. 6713 * 6714 * <p><em>Note: scheme and host name matching in the Android framework is 6715 * case-sensitive, unlike the formal RFC. As a result, 6716 * you should always ensure that you write your Uri with these elements 6717 * using lower case letters, and normalize any Uris you receive from 6718 * outside of Android to ensure the scheme and host is lower case.</em></p> 6719 * 6720 * @param action The Intent action, such as ACTION_VIEW. 6721 * @param uri The Intent data URI. 6722 * @param packageContext A Context of the application package implementing 6723 * this class. 6724 * @param cls The component class that is to be used for the intent. 6725 * 6726 * @see #Intent(String, android.net.Uri) 6727 * @see #Intent(Context, Class) 6728 * @see #setClass 6729 * @see #setComponent 6730 */ Intent(String action, Uri uri, Context packageContext, Class<?> cls)6731 public Intent(String action, Uri uri, 6732 Context packageContext, Class<?> cls) { 6733 setAction(action); 6734 mData = uri; 6735 mComponent = new ComponentName(packageContext, cls); 6736 } 6737 6738 /** 6739 * Create an intent to launch the main (root) activity of a task. This 6740 * is the Intent that is started when the application's is launched from 6741 * Home. For anything else that wants to launch an application in the 6742 * same way, it is important that they use an Intent structured the same 6743 * way, and can use this function to ensure this is the case. 6744 * 6745 * <p>The returned Intent has the given Activity component as its explicit 6746 * component, {@link #ACTION_MAIN} as its action, and includes the 6747 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 6748 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 6749 * to do that through {@link #addFlags(int)} on the returned Intent. 6750 * 6751 * @param mainActivity The main activity component that this Intent will 6752 * launch. 6753 * @return Returns a newly created Intent that can be used to launch the 6754 * activity as a main application entry. 6755 * 6756 * @see #setClass 6757 * @see #setComponent 6758 */ makeMainActivity(ComponentName mainActivity)6759 public static Intent makeMainActivity(ComponentName mainActivity) { 6760 Intent intent = new Intent(ACTION_MAIN); 6761 intent.setComponent(mainActivity); 6762 intent.addCategory(CATEGORY_LAUNCHER); 6763 return intent; 6764 } 6765 6766 /** 6767 * Make an Intent for the main activity of an application, without 6768 * specifying a specific activity to run but giving a selector to find 6769 * the activity. This results in a final Intent that is structured 6770 * the same as when the application is launched from 6771 * Home. For anything else that wants to launch an application in the 6772 * same way, it is important that they use an Intent structured the same 6773 * way, and can use this function to ensure this is the case. 6774 * 6775 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the 6776 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 6777 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 6778 * to do that through {@link #addFlags(int)} on the returned Intent. 6779 * 6780 * @param selectorAction The action name of the Intent's selector. 6781 * @param selectorCategory The name of a category to add to the Intent's 6782 * selector. 6783 * @return Returns a newly created Intent that can be used to launch the 6784 * activity as a main application entry. 6785 * 6786 * @see #setSelector(Intent) 6787 */ makeMainSelectorActivity(String selectorAction, String selectorCategory)6788 public static Intent makeMainSelectorActivity(String selectorAction, 6789 String selectorCategory) { 6790 Intent intent = new Intent(ACTION_MAIN); 6791 intent.addCategory(CATEGORY_LAUNCHER); 6792 Intent selector = new Intent(); 6793 selector.setAction(selectorAction); 6794 selector.addCategory(selectorCategory); 6795 intent.setSelector(selector); 6796 return intent; 6797 } 6798 6799 /** 6800 * Make an Intent that can be used to re-launch an application's task 6801 * in its base state. This is like {@link #makeMainActivity(ComponentName)}, 6802 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and 6803 * {@link #FLAG_ACTIVITY_CLEAR_TASK}. 6804 * 6805 * @param mainActivity The activity component that is the root of the 6806 * task; this is the activity that has been published in the application's 6807 * manifest as the main launcher icon. 6808 * 6809 * @return Returns a newly created Intent that can be used to relaunch the 6810 * activity's task in its root state. 6811 */ makeRestartActivityTask(ComponentName mainActivity)6812 public static Intent makeRestartActivityTask(ComponentName mainActivity) { 6813 Intent intent = makeMainActivity(mainActivity); 6814 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 6815 | Intent.FLAG_ACTIVITY_CLEAR_TASK); 6816 return intent; 6817 } 6818 6819 /** 6820 * Call {@link #parseUri} with 0 flags. 6821 * @deprecated Use {@link #parseUri} instead. 6822 */ 6823 @Deprecated getIntent(String uri)6824 public static Intent getIntent(String uri) throws URISyntaxException { 6825 return parseUri(uri, 0); 6826 } 6827 6828 /** 6829 * Create an intent from a URI. This URI may encode the action, 6830 * category, and other intent fields, if it was returned by 6831 * {@link #toUri}. If the Intent was not generate by toUri(), its data 6832 * will be the entire URI and its action will be ACTION_VIEW. 6833 * 6834 * <p>The URI given here must not be relative -- that is, it must include 6835 * the scheme and full path. 6836 * 6837 * @param uri The URI to turn into an Intent. 6838 * @param flags Additional processing flags. 6839 * 6840 * @return Intent The newly created Intent object. 6841 * 6842 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax 6843 * it bad (as parsed by the Uri class) or the Intent data within the 6844 * URI is invalid. 6845 * 6846 * @see #toUri 6847 */ parseUri(String uri, @UriFlags int flags)6848 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException { 6849 int i = 0; 6850 try { 6851 final boolean androidApp = uri.startsWith("android-app:"); 6852 6853 // Validate intent scheme if requested. 6854 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { 6855 if (!uri.startsWith("intent:") && !androidApp) { 6856 Intent intent = new Intent(ACTION_VIEW); 6857 try { 6858 intent.setData(Uri.parse(uri)); 6859 } catch (IllegalArgumentException e) { 6860 throw new URISyntaxException(uri, e.getMessage()); 6861 } 6862 return intent; 6863 } 6864 } 6865 6866 i = uri.lastIndexOf("#"); 6867 // simple case 6868 if (i == -1) { 6869 if (!androidApp) { 6870 return new Intent(ACTION_VIEW, Uri.parse(uri)); 6871 } 6872 6873 // old format Intent URI 6874 } else if (!uri.startsWith("#Intent;", i)) { 6875 if (!androidApp) { 6876 return getIntentOld(uri, flags); 6877 } else { 6878 i = -1; 6879 } 6880 } 6881 6882 // new format 6883 Intent intent = new Intent(ACTION_VIEW); 6884 Intent baseIntent = intent; 6885 boolean explicitAction = false; 6886 boolean inSelector = false; 6887 6888 // fetch data part, if present 6889 String scheme = null; 6890 String data; 6891 if (i >= 0) { 6892 data = uri.substring(0, i); 6893 i += 8; // length of "#Intent;" 6894 } else { 6895 data = uri; 6896 } 6897 6898 // loop over contents of Intent, all name=value; 6899 while (i >= 0 && !uri.startsWith("end", i)) { 6900 int eq = uri.indexOf('=', i); 6901 if (eq < 0) eq = i-1; 6902 int semi = uri.indexOf(';', i); 6903 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : ""; 6904 6905 // action 6906 if (uri.startsWith("action=", i)) { 6907 intent.setAction(value); 6908 if (!inSelector) { 6909 explicitAction = true; 6910 } 6911 } 6912 6913 // categories 6914 else if (uri.startsWith("category=", i)) { 6915 intent.addCategory(value); 6916 } 6917 6918 // type 6919 else if (uri.startsWith("type=", i)) { 6920 intent.mType = value; 6921 } 6922 6923 // identifier 6924 else if (uri.startsWith("identifier=", i)) { 6925 intent.mIdentifier = value; 6926 } 6927 6928 // launch flags 6929 else if (uri.startsWith("launchFlags=", i)) { 6930 intent.mFlags = Integer.decode(value).intValue(); 6931 if ((flags& URI_ALLOW_UNSAFE) == 0) { 6932 intent.mFlags &= ~IMMUTABLE_FLAGS; 6933 } 6934 } 6935 6936 // package 6937 else if (uri.startsWith("package=", i)) { 6938 intent.mPackage = value; 6939 } 6940 6941 // component 6942 else if (uri.startsWith("component=", i)) { 6943 intent.mComponent = ComponentName.unflattenFromString(value); 6944 } 6945 6946 // scheme 6947 else if (uri.startsWith("scheme=", i)) { 6948 if (inSelector) { 6949 intent.mData = Uri.parse(value + ":"); 6950 } else { 6951 scheme = value; 6952 } 6953 } 6954 6955 // source bounds 6956 else if (uri.startsWith("sourceBounds=", i)) { 6957 intent.mSourceBounds = Rect.unflattenFromString(value); 6958 } 6959 6960 // selector 6961 else if (semi == (i+3) && uri.startsWith("SEL", i)) { 6962 intent = new Intent(); 6963 inSelector = true; 6964 } 6965 6966 // extra 6967 else { 6968 String key = Uri.decode(uri.substring(i + 2, eq)); 6969 // create Bundle if it doesn't already exist 6970 if (intent.mExtras == null) intent.mExtras = new Bundle(); 6971 Bundle b = intent.mExtras; 6972 // add EXTRA 6973 if (uri.startsWith("S.", i)) b.putString(key, value); 6974 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); 6975 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); 6976 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); 6977 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); 6978 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); 6979 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); 6980 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); 6981 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); 6982 else throw new URISyntaxException(uri, "unknown EXTRA type", i); 6983 } 6984 6985 // move to the next item 6986 i = semi + 1; 6987 } 6988 6989 if (inSelector) { 6990 // The Intent had a selector; fix it up. 6991 if (baseIntent.mPackage == null) { 6992 baseIntent.setSelector(intent); 6993 } 6994 intent = baseIntent; 6995 } 6996 6997 if (data != null) { 6998 if (data.startsWith("intent:")) { 6999 data = data.substring(7); 7000 if (scheme != null) { 7001 data = scheme + ':' + data; 7002 } 7003 } else if (data.startsWith("android-app:")) { 7004 if (data.charAt(12) == '/' && data.charAt(13) == '/') { 7005 // Correctly formed android-app, first part is package name. 7006 int end = data.indexOf('/', 14); 7007 if (end < 0) { 7008 // All we have is a package name. 7009 intent.mPackage = data.substring(14); 7010 if (!explicitAction) { 7011 intent.setAction(ACTION_MAIN); 7012 } 7013 data = ""; 7014 } else { 7015 // Target the Intent at the given package name always. 7016 String authority = null; 7017 intent.mPackage = data.substring(14, end); 7018 int newEnd; 7019 if ((end+1) < data.length()) { 7020 if ((newEnd=data.indexOf('/', end+1)) >= 0) { 7021 // Found a scheme, remember it. 7022 scheme = data.substring(end+1, newEnd); 7023 end = newEnd; 7024 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { 7025 // Found a authority, remember it. 7026 authority = data.substring(end+1, newEnd); 7027 end = newEnd; 7028 } 7029 } else { 7030 // All we have is a scheme. 7031 scheme = data.substring(end+1); 7032 } 7033 } 7034 if (scheme == null) { 7035 // If there was no scheme, then this just targets the package. 7036 if (!explicitAction) { 7037 intent.setAction(ACTION_MAIN); 7038 } 7039 data = ""; 7040 } else if (authority == null) { 7041 data = scheme + ":"; 7042 } else { 7043 data = scheme + "://" + authority + data.substring(end); 7044 } 7045 } 7046 } else { 7047 data = ""; 7048 } 7049 } 7050 7051 if (data.length() > 0) { 7052 try { 7053 intent.mData = Uri.parse(data); 7054 } catch (IllegalArgumentException e) { 7055 throw new URISyntaxException(uri, e.getMessage()); 7056 } 7057 } 7058 } 7059 7060 return intent; 7061 7062 } catch (IndexOutOfBoundsException e) { 7063 throw new URISyntaxException(uri, "illegal Intent URI format", i); 7064 } 7065 } 7066 7067 public static Intent getIntentOld(String uri) throws URISyntaxException { 7068 return getIntentOld(uri, 0); 7069 } 7070 7071 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException { 7072 Intent intent; 7073 7074 int i = uri.lastIndexOf('#'); 7075 if (i >= 0) { 7076 String action = null; 7077 final int intentFragmentStart = i; 7078 boolean isIntentFragment = false; 7079 7080 i++; 7081 7082 if (uri.regionMatches(i, "action(", 0, 7)) { 7083 isIntentFragment = true; 7084 i += 7; 7085 int j = uri.indexOf(')', i); 7086 action = uri.substring(i, j); 7087 i = j + 1; 7088 } 7089 7090 intent = new Intent(action); 7091 7092 if (uri.regionMatches(i, "categories(", 0, 11)) { 7093 isIntentFragment = true; 7094 i += 11; 7095 int j = uri.indexOf(')', i); 7096 while (i < j) { 7097 int sep = uri.indexOf('!', i); 7098 if (sep < 0 || sep > j) sep = j; 7099 if (i < sep) { 7100 intent.addCategory(uri.substring(i, sep)); 7101 } 7102 i = sep + 1; 7103 } 7104 i = j + 1; 7105 } 7106 7107 if (uri.regionMatches(i, "type(", 0, 5)) { 7108 isIntentFragment = true; 7109 i += 5; 7110 int j = uri.indexOf(')', i); 7111 intent.mType = uri.substring(i, j); 7112 i = j + 1; 7113 } 7114 7115 if (uri.regionMatches(i, "launchFlags(", 0, 12)) { 7116 isIntentFragment = true; 7117 i += 12; 7118 int j = uri.indexOf(')', i); 7119 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); 7120 if ((flags& URI_ALLOW_UNSAFE) == 0) { 7121 intent.mFlags &= ~IMMUTABLE_FLAGS; 7122 } 7123 i = j + 1; 7124 } 7125 7126 if (uri.regionMatches(i, "component(", 0, 10)) { 7127 isIntentFragment = true; 7128 i += 10; 7129 int j = uri.indexOf(')', i); 7130 int sep = uri.indexOf('!', i); 7131 if (sep >= 0 && sep < j) { 7132 String pkg = uri.substring(i, sep); 7133 String cls = uri.substring(sep + 1, j); 7134 intent.mComponent = new ComponentName(pkg, cls); 7135 } 7136 i = j + 1; 7137 } 7138 7139 if (uri.regionMatches(i, "extras(", 0, 7)) { 7140 isIntentFragment = true; 7141 i += 7; 7142 7143 final int closeParen = uri.indexOf(')', i); 7144 if (closeParen == -1) throw new URISyntaxException(uri, 7145 "EXTRA missing trailing ')'", i); 7146 7147 while (i < closeParen) { 7148 // fetch the key value 7149 int j = uri.indexOf('=', i); 7150 if (j <= i + 1 || i >= closeParen) { 7151 throw new URISyntaxException(uri, "EXTRA missing '='", i); 7152 } 7153 char type = uri.charAt(i); 7154 i++; 7155 String key = uri.substring(i, j); 7156 i = j + 1; 7157 7158 // get type-value 7159 j = uri.indexOf('!', i); 7160 if (j == -1 || j >= closeParen) j = closeParen; 7161 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); 7162 String value = uri.substring(i, j); 7163 i = j; 7164 7165 // create Bundle if it doesn't already exist 7166 if (intent.mExtras == null) intent.mExtras = new Bundle(); 7167 7168 // add item to bundle 7169 try { 7170 switch (type) { 7171 case 'S': 7172 intent.mExtras.putString(key, Uri.decode(value)); 7173 break; 7174 case 'B': 7175 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); 7176 break; 7177 case 'b': 7178 intent.mExtras.putByte(key, Byte.parseByte(value)); 7179 break; 7180 case 'c': 7181 intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); 7182 break; 7183 case 'd': 7184 intent.mExtras.putDouble(key, Double.parseDouble(value)); 7185 break; 7186 case 'f': 7187 intent.mExtras.putFloat(key, Float.parseFloat(value)); 7188 break; 7189 case 'i': 7190 intent.mExtras.putInt(key, Integer.parseInt(value)); 7191 break; 7192 case 'l': 7193 intent.mExtras.putLong(key, Long.parseLong(value)); 7194 break; 7195 case 's': 7196 intent.mExtras.putShort(key, Short.parseShort(value)); 7197 break; 7198 default: 7199 throw new URISyntaxException(uri, "EXTRA has unknown type", i); 7200 } 7201 } catch (NumberFormatException e) { 7202 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); 7203 } 7204 7205 char ch = uri.charAt(i); 7206 if (ch == ')') break; 7207 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); 7208 i++; 7209 } 7210 } 7211 7212 if (isIntentFragment) { 7213 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); 7214 } else { 7215 intent.mData = Uri.parse(uri); 7216 } 7217 7218 if (intent.mAction == null) { 7219 // By default, if no action is specified, then use VIEW. 7220 intent.mAction = ACTION_VIEW; 7221 } 7222 7223 } else { 7224 intent = new Intent(ACTION_VIEW, Uri.parse(uri)); 7225 } 7226 7227 return intent; 7228 } 7229 7230 /** @hide */ 7231 public interface CommandOptionHandler { 7232 boolean handleOption(String opt, ShellCommand cmd); 7233 } 7234 7235 /** @hide */ 7236 @UnsupportedAppUsage parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)7237 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) 7238 throws URISyntaxException { 7239 Intent intent = new Intent(); 7240 Intent baseIntent = intent; 7241 boolean hasIntentInfo = false; 7242 7243 Uri data = null; 7244 String type = null; 7245 7246 String opt; 7247 while ((opt=cmd.getNextOption()) != null) { 7248 switch (opt) { 7249 case "-a": 7250 intent.setAction(cmd.getNextArgRequired()); 7251 if (intent == baseIntent) { 7252 hasIntentInfo = true; 7253 } 7254 break; 7255 case "-d": 7256 data = Uri.parse(cmd.getNextArgRequired()); 7257 if (intent == baseIntent) { 7258 hasIntentInfo = true; 7259 } 7260 break; 7261 case "-t": 7262 type = cmd.getNextArgRequired(); 7263 if (intent == baseIntent) { 7264 hasIntentInfo = true; 7265 } 7266 break; 7267 case "-i": 7268 intent.setIdentifier(cmd.getNextArgRequired()); 7269 if (intent == baseIntent) { 7270 hasIntentInfo = true; 7271 } 7272 break; 7273 case "-c": 7274 intent.addCategory(cmd.getNextArgRequired()); 7275 if (intent == baseIntent) { 7276 hasIntentInfo = true; 7277 } 7278 break; 7279 case "-e": 7280 case "--es": { 7281 String key = cmd.getNextArgRequired(); 7282 String value = cmd.getNextArgRequired(); 7283 intent.putExtra(key, value); 7284 } 7285 break; 7286 case "--esn": { 7287 String key = cmd.getNextArgRequired(); 7288 intent.putExtra(key, (String) null); 7289 } 7290 break; 7291 case "--ei": { 7292 String key = cmd.getNextArgRequired(); 7293 String value = cmd.getNextArgRequired(); 7294 intent.putExtra(key, Integer.decode(value)); 7295 } 7296 break; 7297 case "--eu": { 7298 String key = cmd.getNextArgRequired(); 7299 String value = cmd.getNextArgRequired(); 7300 intent.putExtra(key, Uri.parse(value)); 7301 } 7302 break; 7303 case "--ecn": { 7304 String key = cmd.getNextArgRequired(); 7305 String value = cmd.getNextArgRequired(); 7306 ComponentName cn = ComponentName.unflattenFromString(value); 7307 if (cn == null) 7308 throw new IllegalArgumentException("Bad component name: " + value); 7309 intent.putExtra(key, cn); 7310 } 7311 break; 7312 case "--eia": { 7313 String key = cmd.getNextArgRequired(); 7314 String value = cmd.getNextArgRequired(); 7315 String[] strings = value.split(","); 7316 int[] list = new int[strings.length]; 7317 for (int i = 0; i < strings.length; i++) { 7318 list[i] = Integer.decode(strings[i]); 7319 } 7320 intent.putExtra(key, list); 7321 } 7322 break; 7323 case "--eial": { 7324 String key = cmd.getNextArgRequired(); 7325 String value = cmd.getNextArgRequired(); 7326 String[] strings = value.split(","); 7327 ArrayList<Integer> list = new ArrayList<>(strings.length); 7328 for (int i = 0; i < strings.length; i++) { 7329 list.add(Integer.decode(strings[i])); 7330 } 7331 intent.putExtra(key, list); 7332 } 7333 break; 7334 case "--el": { 7335 String key = cmd.getNextArgRequired(); 7336 String value = cmd.getNextArgRequired(); 7337 intent.putExtra(key, Long.valueOf(value)); 7338 } 7339 break; 7340 case "--ela": { 7341 String key = cmd.getNextArgRequired(); 7342 String value = cmd.getNextArgRequired(); 7343 String[] strings = value.split(","); 7344 long[] list = new long[strings.length]; 7345 for (int i = 0; i < strings.length; i++) { 7346 list[i] = Long.valueOf(strings[i]); 7347 } 7348 intent.putExtra(key, list); 7349 hasIntentInfo = true; 7350 } 7351 break; 7352 case "--elal": { 7353 String key = cmd.getNextArgRequired(); 7354 String value = cmd.getNextArgRequired(); 7355 String[] strings = value.split(","); 7356 ArrayList<Long> list = new ArrayList<>(strings.length); 7357 for (int i = 0; i < strings.length; i++) { 7358 list.add(Long.valueOf(strings[i])); 7359 } 7360 intent.putExtra(key, list); 7361 hasIntentInfo = true; 7362 } 7363 break; 7364 case "--ef": { 7365 String key = cmd.getNextArgRequired(); 7366 String value = cmd.getNextArgRequired(); 7367 intent.putExtra(key, Float.valueOf(value)); 7368 hasIntentInfo = true; 7369 } 7370 break; 7371 case "--efa": { 7372 String key = cmd.getNextArgRequired(); 7373 String value = cmd.getNextArgRequired(); 7374 String[] strings = value.split(","); 7375 float[] list = new float[strings.length]; 7376 for (int i = 0; i < strings.length; i++) { 7377 list[i] = Float.valueOf(strings[i]); 7378 } 7379 intent.putExtra(key, list); 7380 hasIntentInfo = true; 7381 } 7382 break; 7383 case "--efal": { 7384 String key = cmd.getNextArgRequired(); 7385 String value = cmd.getNextArgRequired(); 7386 String[] strings = value.split(","); 7387 ArrayList<Float> list = new ArrayList<>(strings.length); 7388 for (int i = 0; i < strings.length; i++) { 7389 list.add(Float.valueOf(strings[i])); 7390 } 7391 intent.putExtra(key, list); 7392 hasIntentInfo = true; 7393 } 7394 break; 7395 case "--esa": { 7396 String key = cmd.getNextArgRequired(); 7397 String value = cmd.getNextArgRequired(); 7398 // Split on commas unless they are preceeded by an escape. 7399 // The escape character must be escaped for the string and 7400 // again for the regex, thus four escape characters become one. 7401 String[] strings = value.split("(?<!\\\\),"); 7402 intent.putExtra(key, strings); 7403 hasIntentInfo = true; 7404 } 7405 break; 7406 case "--esal": { 7407 String key = cmd.getNextArgRequired(); 7408 String value = cmd.getNextArgRequired(); 7409 // Split on commas unless they are preceeded by an escape. 7410 // The escape character must be escaped for the string and 7411 // again for the regex, thus four escape characters become one. 7412 String[] strings = value.split("(?<!\\\\),"); 7413 ArrayList<String> list = new ArrayList<>(strings.length); 7414 for (int i = 0; i < strings.length; i++) { 7415 list.add(strings[i]); 7416 } 7417 intent.putExtra(key, list); 7418 hasIntentInfo = true; 7419 } 7420 break; 7421 case "--ez": { 7422 String key = cmd.getNextArgRequired(); 7423 String value = cmd.getNextArgRequired().toLowerCase(); 7424 // Boolean.valueOf() results in false for anything that is not "true", which is 7425 // error-prone in shell commands 7426 boolean arg; 7427 if ("true".equals(value) || "t".equals(value)) { 7428 arg = true; 7429 } else if ("false".equals(value) || "f".equals(value)) { 7430 arg = false; 7431 } else { 7432 try { 7433 arg = Integer.decode(value) != 0; 7434 } catch (NumberFormatException ex) { 7435 throw new IllegalArgumentException("Invalid boolean value: " + value); 7436 } 7437 } 7438 7439 intent.putExtra(key, arg); 7440 } 7441 break; 7442 case "-n": { 7443 String str = cmd.getNextArgRequired(); 7444 ComponentName cn = ComponentName.unflattenFromString(str); 7445 if (cn == null) 7446 throw new IllegalArgumentException("Bad component name: " + str); 7447 intent.setComponent(cn); 7448 if (intent == baseIntent) { 7449 hasIntentInfo = true; 7450 } 7451 } 7452 break; 7453 case "-p": { 7454 String str = cmd.getNextArgRequired(); 7455 intent.setPackage(str); 7456 if (intent == baseIntent) { 7457 hasIntentInfo = true; 7458 } 7459 } 7460 break; 7461 case "-f": 7462 String str = cmd.getNextArgRequired(); 7463 intent.setFlags(Integer.decode(str).intValue()); 7464 break; 7465 case "--grant-read-uri-permission": 7466 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 7467 break; 7468 case "--grant-write-uri-permission": 7469 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 7470 break; 7471 case "--grant-persistable-uri-permission": 7472 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); 7473 break; 7474 case "--grant-prefix-uri-permission": 7475 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); 7476 break; 7477 case "--exclude-stopped-packages": 7478 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); 7479 break; 7480 case "--include-stopped-packages": 7481 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); 7482 break; 7483 case "--debug-log-resolution": 7484 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); 7485 break; 7486 case "--activity-brought-to-front": 7487 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); 7488 break; 7489 case "--activity-clear-top": 7490 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 7491 break; 7492 case "--activity-clear-when-task-reset": 7493 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 7494 break; 7495 case "--activity-exclude-from-recents": 7496 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 7497 break; 7498 case "--activity-launched-from-history": 7499 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); 7500 break; 7501 case "--activity-multiple-task": 7502 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 7503 break; 7504 case "--activity-no-animation": 7505 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 7506 break; 7507 case "--activity-no-history": 7508 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 7509 break; 7510 case "--activity-no-user-action": 7511 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); 7512 break; 7513 case "--activity-previous-is-top": 7514 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); 7515 break; 7516 case "--activity-reorder-to-front": 7517 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 7518 break; 7519 case "--activity-reset-task-if-needed": 7520 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 7521 break; 7522 case "--activity-single-top": 7523 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 7524 break; 7525 case "--activity-clear-task": 7526 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 7527 break; 7528 case "--activity-task-on-home": 7529 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); 7530 break; 7531 case "--activity-match-external": 7532 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL); 7533 break; 7534 case "--receiver-registered-only": 7535 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); 7536 break; 7537 case "--receiver-replace-pending": 7538 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); 7539 break; 7540 case "--receiver-foreground": 7541 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 7542 break; 7543 case "--receiver-no-abort": 7544 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); 7545 break; 7546 case "--receiver-include-background": 7547 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 7548 break; 7549 case "--selector": 7550 intent.setDataAndType(data, type); 7551 intent = new Intent(); 7552 break; 7553 default: 7554 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { 7555 // Okay, caller handled this option. 7556 } else { 7557 throw new IllegalArgumentException("Unknown option: " + opt); 7558 } 7559 break; 7560 } 7561 } 7562 intent.setDataAndType(data, type); 7563 7564 final boolean hasSelector = intent != baseIntent; 7565 if (hasSelector) { 7566 // A selector was specified; fix up. 7567 baseIntent.setSelector(intent); 7568 intent = baseIntent; 7569 } 7570 7571 String arg = cmd.getNextArg(); 7572 baseIntent = null; 7573 if (arg == null) { 7574 if (hasSelector) { 7575 // If a selector has been specified, and no arguments 7576 // have been supplied for the main Intent, then we can 7577 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't 7578 // need to have a component name specified yet, the 7579 // selector will take care of that. 7580 baseIntent = new Intent(Intent.ACTION_MAIN); 7581 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 7582 } 7583 } else if (arg.indexOf(':') >= 0) { 7584 // The argument is a URI. Fully parse it, and use that result 7585 // to fill in any data not specified so far. 7586 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME 7587 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); 7588 } else if (arg.indexOf('/') >= 0) { 7589 // The argument is a component name. Build an Intent to launch 7590 // it. 7591 baseIntent = new Intent(Intent.ACTION_MAIN); 7592 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 7593 baseIntent.setComponent(ComponentName.unflattenFromString(arg)); 7594 } else { 7595 // Assume the argument is a package name. 7596 baseIntent = new Intent(Intent.ACTION_MAIN); 7597 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 7598 baseIntent.setPackage(arg); 7599 } 7600 if (baseIntent != null) { 7601 Bundle extras = intent.getExtras(); 7602 intent.replaceExtras((Bundle)null); 7603 Bundle uriExtras = baseIntent.getExtras(); 7604 baseIntent.replaceExtras((Bundle)null); 7605 if (intent.getAction() != null && baseIntent.getCategories() != null) { 7606 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); 7607 for (String c : cats) { 7608 baseIntent.removeCategory(c); 7609 } 7610 } 7611 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); 7612 if (extras == null) { 7613 extras = uriExtras; 7614 } else if (uriExtras != null) { 7615 uriExtras.putAll(extras); 7616 extras = uriExtras; 7617 } 7618 intent.replaceExtras(extras); 7619 hasIntentInfo = true; 7620 } 7621 7622 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); 7623 return intent; 7624 } 7625 7626 /** @hide */ 7627 @UnsupportedAppUsage printIntentArgsHelp(PrintWriter pw, String prefix)7628 public static void printIntentArgsHelp(PrintWriter pw, String prefix) { 7629 final String[] lines = new String[] { 7630 "<INTENT> specifications include these flags and arguments:", 7631 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]", 7632 " [-c <CATEGORY> [-c <CATEGORY>] ...]", 7633 " [-n <COMPONENT_NAME>]", 7634 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", 7635 " [--esn <EXTRA_KEY> ...]", 7636 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", 7637 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", 7638 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", 7639 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", 7640 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", 7641 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", 7642 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 7643 " (mutiple extras passed as Integer[])", 7644 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 7645 " (mutiple extras passed as List<Integer>)", 7646 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 7647 " (mutiple extras passed as Long[])", 7648 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 7649 " (mutiple extras passed as List<Long>)", 7650 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 7651 " (mutiple extras passed as Float[])", 7652 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 7653 " (mutiple extras passed as List<Float>)", 7654 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 7655 " (mutiple extras passed as String[]; to embed a comma into a string,", 7656 " escape it using \"\\,\")", 7657 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 7658 " (mutiple extras passed as List<String>; to embed a comma into a string,", 7659 " escape it using \"\\,\")", 7660 " [-f <FLAG>]", 7661 " [--grant-read-uri-permission] [--grant-write-uri-permission]", 7662 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", 7663 " [--debug-log-resolution] [--exclude-stopped-packages]", 7664 " [--include-stopped-packages]", 7665 " [--activity-brought-to-front] [--activity-clear-top]", 7666 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", 7667 " [--activity-launched-from-history] [--activity-multiple-task]", 7668 " [--activity-no-animation] [--activity-no-history]", 7669 " [--activity-no-user-action] [--activity-previous-is-top]", 7670 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", 7671 " [--activity-single-top] [--activity-clear-task]", 7672 " [--activity-task-on-home] [--activity-match-external]", 7673 " [--receiver-registered-only] [--receiver-replace-pending]", 7674 " [--receiver-foreground] [--receiver-no-abort]", 7675 " [--receiver-include-background]", 7676 " [--selector]", 7677 " [<URI> | <PACKAGE> | <COMPONENT>]" 7678 }; 7679 for (String line : lines) { 7680 pw.print(prefix); 7681 pw.println(line); 7682 } 7683 } 7684 7685 /** 7686 * Retrieve the general action to be performed, such as 7687 * {@link #ACTION_VIEW}. The action describes the general way the rest of 7688 * the information in the intent should be interpreted -- most importantly, 7689 * what to do with the data returned by {@link #getData}. 7690 * 7691 * @return The action of this intent or null if none is specified. 7692 * 7693 * @see #setAction 7694 */ getAction()7695 public @Nullable String getAction() { 7696 return mAction; 7697 } 7698 7699 /** 7700 * Retrieve data this intent is operating on. This URI specifies the name 7701 * of the data; often it uses the content: scheme, specifying data in a 7702 * content provider. Other schemes may be handled by specific activities, 7703 * such as http: by the web browser. 7704 * 7705 * @return The URI of the data this intent is targeting or null. 7706 * 7707 * @see #getScheme 7708 * @see #setData 7709 */ getData()7710 public @Nullable Uri getData() { 7711 return mData; 7712 } 7713 7714 /** 7715 * The same as {@link #getData()}, but returns the URI as an encoded 7716 * String. 7717 */ getDataString()7718 public @Nullable String getDataString() { 7719 return mData != null ? mData.toString() : null; 7720 } 7721 7722 /** 7723 * Return the scheme portion of the intent's data. If the data is null or 7724 * does not include a scheme, null is returned. Otherwise, the scheme 7725 * prefix without the final ':' is returned, i.e. "http". 7726 * 7727 * <p>This is the same as calling getData().getScheme() (and checking for 7728 * null data). 7729 * 7730 * @return The scheme of this intent. 7731 * 7732 * @see #getData 7733 */ getScheme()7734 public @Nullable String getScheme() { 7735 return mData != null ? mData.getScheme() : null; 7736 } 7737 7738 /** 7739 * Retrieve any explicit MIME type included in the intent. This is usually 7740 * null, as the type is determined by the intent data. 7741 * 7742 * @return If a type was manually set, it is returned; else null is 7743 * returned. 7744 * 7745 * @see #resolveType(ContentResolver) 7746 * @see #setType 7747 */ getType()7748 public @Nullable String getType() { 7749 return mType; 7750 } 7751 7752 /** 7753 * Return the MIME data type of this intent. If the type field is 7754 * explicitly set, that is simply returned. Otherwise, if the data is set, 7755 * the type of that data is returned. If neither fields are set, a null is 7756 * returned. 7757 * 7758 * @return The MIME type of this intent. 7759 * 7760 * @see #getType 7761 * @see #resolveType(ContentResolver) 7762 */ resolveType(@onNull Context context)7763 public @Nullable String resolveType(@NonNull Context context) { 7764 return resolveType(context.getContentResolver()); 7765 } 7766 7767 /** 7768 * Return the MIME data type of this intent. If the type field is 7769 * explicitly set, that is simply returned. Otherwise, if the data is set, 7770 * the type of that data is returned. If neither fields are set, a null is 7771 * returned. 7772 * 7773 * @param resolver A ContentResolver that can be used to determine the MIME 7774 * type of the intent's data. 7775 * 7776 * @return The MIME type of this intent. 7777 * 7778 * @see #getType 7779 * @see #resolveType(Context) 7780 */ resolveType(@onNull ContentResolver resolver)7781 public @Nullable String resolveType(@NonNull ContentResolver resolver) { 7782 if (mType != null) { 7783 return mType; 7784 } 7785 if (mData != null) { 7786 if ("content".equals(mData.getScheme())) { 7787 return resolver.getType(mData); 7788 } 7789 } 7790 return null; 7791 } 7792 7793 /** 7794 * Return the MIME data type of this intent, only if it will be needed for 7795 * intent resolution. This is not generally useful for application code; 7796 * it is used by the frameworks for communicating with back-end system 7797 * services. 7798 * 7799 * @param resolver A ContentResolver that can be used to determine the MIME 7800 * type of the intent's data. 7801 * 7802 * @return The MIME type of this intent, or null if it is unknown or not 7803 * needed. 7804 */ resolveTypeIfNeeded(@onNull ContentResolver resolver)7805 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) { 7806 if (mComponent != null) { 7807 return mType; 7808 } 7809 return resolveType(resolver); 7810 } 7811 7812 /** 7813 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity 7814 * of the Intent to distinguish it from other Intents. 7815 * 7816 * @return The identifier of this intent or null if none is specified. 7817 * 7818 * @see #setIdentifier 7819 */ getIdentifier()7820 public @Nullable String getIdentifier() { 7821 return mIdentifier; 7822 } 7823 7824 /** 7825 * Check if a category exists in the intent. 7826 * 7827 * @param category The category to check. 7828 * 7829 * @return boolean True if the intent contains the category, else false. 7830 * 7831 * @see #getCategories 7832 * @see #addCategory 7833 */ hasCategory(String category)7834 public boolean hasCategory(String category) { 7835 return mCategories != null && mCategories.contains(category); 7836 } 7837 7838 /** 7839 * Return the set of all categories in the intent. If there are no categories, 7840 * returns NULL. 7841 * 7842 * @return The set of categories you can examine. Do not modify! 7843 * 7844 * @see #hasCategory 7845 * @see #addCategory 7846 */ getCategories()7847 public Set<String> getCategories() { 7848 return mCategories; 7849 } 7850 7851 /** 7852 * Return the specific selector associated with this Intent. If there is 7853 * none, returns null. See {@link #setSelector} for more information. 7854 * 7855 * @see #setSelector 7856 */ getSelector()7857 public @Nullable Intent getSelector() { 7858 return mSelector; 7859 } 7860 7861 /** 7862 * Return the {@link ClipData} associated with this Intent. If there is 7863 * none, returns null. See {@link #setClipData} for more information. 7864 * 7865 * @see #setClipData 7866 */ getClipData()7867 public @Nullable ClipData getClipData() { 7868 return mClipData; 7869 } 7870 7871 /** @hide */ getContentUserHint()7872 public int getContentUserHint() { 7873 return mContentUserHint; 7874 } 7875 7876 /** @hide */ getLaunchToken()7877 public String getLaunchToken() { 7878 return mLaunchToken; 7879 } 7880 7881 /** @hide */ setLaunchToken(String launchToken)7882 public void setLaunchToken(String launchToken) { 7883 mLaunchToken = launchToken; 7884 } 7885 7886 /** 7887 * Sets the ClassLoader that will be used when unmarshalling 7888 * any Parcelable values from the extras of this Intent. 7889 * 7890 * @param loader a ClassLoader, or null to use the default loader 7891 * at the time of unmarshalling. 7892 */ setExtrasClassLoader(@ullable ClassLoader loader)7893 public void setExtrasClassLoader(@Nullable ClassLoader loader) { 7894 if (mExtras != null) { 7895 mExtras.setClassLoader(loader); 7896 } 7897 } 7898 7899 /** 7900 * Returns true if an extra value is associated with the given name. 7901 * @param name the extra's name 7902 * @return true if the given extra is present. 7903 */ hasExtra(String name)7904 public boolean hasExtra(String name) { 7905 return mExtras != null && mExtras.containsKey(name); 7906 } 7907 7908 /** 7909 * Returns true if the Intent's extras contain a parcelled file descriptor. 7910 * @return true if the Intent contains a parcelled file descriptor. 7911 */ hasFileDescriptors()7912 public boolean hasFileDescriptors() { 7913 return mExtras != null && mExtras.hasFileDescriptors(); 7914 } 7915 7916 /** {@hide} */ 7917 @UnsupportedAppUsage setAllowFds(boolean allowFds)7918 public void setAllowFds(boolean allowFds) { 7919 if (mExtras != null) { 7920 mExtras.setAllowFds(allowFds); 7921 } 7922 } 7923 7924 /** {@hide} */ setDefusable(boolean defusable)7925 public void setDefusable(boolean defusable) { 7926 if (mExtras != null) { 7927 mExtras.setDefusable(defusable); 7928 } 7929 } 7930 7931 /** 7932 * Retrieve extended data from the intent. 7933 * 7934 * @param name The name of the desired item. 7935 * 7936 * @return the value of an item previously added with putExtra(), 7937 * or null if none was found. 7938 * 7939 * @deprecated 7940 * @hide 7941 */ 7942 @Deprecated 7943 @UnsupportedAppUsage getExtra(String name)7944 public Object getExtra(String name) { 7945 return getExtra(name, null); 7946 } 7947 7948 /** 7949 * Retrieve extended data from the intent. 7950 * 7951 * @param name The name of the desired item. 7952 * @param defaultValue the value to be returned if no value of the desired 7953 * type is stored with the given name. 7954 * 7955 * @return the value of an item previously added with putExtra(), 7956 * or the default value if none was found. 7957 * 7958 * @see #putExtra(String, boolean) 7959 */ getBooleanExtra(String name, boolean defaultValue)7960 public boolean getBooleanExtra(String name, boolean defaultValue) { 7961 return mExtras == null ? defaultValue : 7962 mExtras.getBoolean(name, defaultValue); 7963 } 7964 7965 /** 7966 * Retrieve extended data from the intent. 7967 * 7968 * @param name The name of the desired item. 7969 * @param defaultValue the value to be returned if no value of the desired 7970 * type is stored with the given name. 7971 * 7972 * @return the value of an item previously added with putExtra(), 7973 * or the default value if none was found. 7974 * 7975 * @see #putExtra(String, byte) 7976 */ getByteExtra(String name, byte defaultValue)7977 public byte getByteExtra(String name, byte defaultValue) { 7978 return mExtras == null ? defaultValue : 7979 mExtras.getByte(name, defaultValue); 7980 } 7981 7982 /** 7983 * Retrieve extended data from the intent. 7984 * 7985 * @param name The name of the desired item. 7986 * @param defaultValue the value to be returned if no value of the desired 7987 * type is stored with the given name. 7988 * 7989 * @return the value of an item previously added with putExtra(), 7990 * or the default value if none was found. 7991 * 7992 * @see #putExtra(String, short) 7993 */ getShortExtra(String name, short defaultValue)7994 public short getShortExtra(String name, short defaultValue) { 7995 return mExtras == null ? defaultValue : 7996 mExtras.getShort(name, defaultValue); 7997 } 7998 7999 /** 8000 * Retrieve extended data from the intent. 8001 * 8002 * @param name The name of the desired item. 8003 * @param defaultValue the value to be returned if no value of the desired 8004 * type is stored with the given name. 8005 * 8006 * @return the value of an item previously added with putExtra(), 8007 * or the default value if none was found. 8008 * 8009 * @see #putExtra(String, char) 8010 */ getCharExtra(String name, char defaultValue)8011 public char getCharExtra(String name, char defaultValue) { 8012 return mExtras == null ? defaultValue : 8013 mExtras.getChar(name, defaultValue); 8014 } 8015 8016 /** 8017 * Retrieve extended data from the intent. 8018 * 8019 * @param name The name of the desired item. 8020 * @param defaultValue the value to be returned if no value of the desired 8021 * type is stored with the given name. 8022 * 8023 * @return the value of an item previously added with putExtra(), 8024 * or the default value if none was found. 8025 * 8026 * @see #putExtra(String, int) 8027 */ getIntExtra(String name, int defaultValue)8028 public int getIntExtra(String name, int defaultValue) { 8029 return mExtras == null ? defaultValue : 8030 mExtras.getInt(name, defaultValue); 8031 } 8032 8033 /** 8034 * Retrieve extended data from the intent. 8035 * 8036 * @param name The name of the desired item. 8037 * @param defaultValue the value to be returned if no value of the desired 8038 * type is stored with the given name. 8039 * 8040 * @return the value of an item previously added with putExtra(), 8041 * or the default value if none was found. 8042 * 8043 * @see #putExtra(String, long) 8044 */ getLongExtra(String name, long defaultValue)8045 public long getLongExtra(String name, long defaultValue) { 8046 return mExtras == null ? defaultValue : 8047 mExtras.getLong(name, defaultValue); 8048 } 8049 8050 /** 8051 * Retrieve extended data from the intent. 8052 * 8053 * @param name The name of the desired item. 8054 * @param defaultValue the value to be returned if no value of the desired 8055 * type is stored with the given name. 8056 * 8057 * @return the value of an item previously added with putExtra(), 8058 * or the default value if no such item is present 8059 * 8060 * @see #putExtra(String, float) 8061 */ getFloatExtra(String name, float defaultValue)8062 public float getFloatExtra(String name, float defaultValue) { 8063 return mExtras == null ? defaultValue : 8064 mExtras.getFloat(name, defaultValue); 8065 } 8066 8067 /** 8068 * Retrieve extended data from the intent. 8069 * 8070 * @param name The name of the desired item. 8071 * @param defaultValue the value to be returned if no value of the desired 8072 * type is stored with the given name. 8073 * 8074 * @return the value of an item previously added with putExtra(), 8075 * or the default value if none was found. 8076 * 8077 * @see #putExtra(String, double) 8078 */ getDoubleExtra(String name, double defaultValue)8079 public double getDoubleExtra(String name, double defaultValue) { 8080 return mExtras == null ? defaultValue : 8081 mExtras.getDouble(name, defaultValue); 8082 } 8083 8084 /** 8085 * Retrieve extended data from the intent. 8086 * 8087 * @param name The name of the desired item. 8088 * 8089 * @return the value of an item previously added with putExtra(), 8090 * or null if no String value was found. 8091 * 8092 * @see #putExtra(String, String) 8093 */ getStringExtra(String name)8094 public @Nullable String getStringExtra(String name) { 8095 return mExtras == null ? null : mExtras.getString(name); 8096 } 8097 8098 /** 8099 * Retrieve extended data from the intent. 8100 * 8101 * @param name The name of the desired item. 8102 * 8103 * @return the value of an item previously added with putExtra(), 8104 * or null if no CharSequence value was found. 8105 * 8106 * @see #putExtra(String, CharSequence) 8107 */ getCharSequenceExtra(String name)8108 public @Nullable CharSequence getCharSequenceExtra(String name) { 8109 return mExtras == null ? null : mExtras.getCharSequence(name); 8110 } 8111 8112 /** 8113 * Retrieve extended data from the intent. 8114 * 8115 * @param name The name of the desired item. 8116 * 8117 * @return the value of an item previously added with putExtra(), 8118 * or null if no Parcelable value was found. 8119 * 8120 * @see #putExtra(String, Parcelable) 8121 */ getParcelableExtra(String name)8122 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) { 8123 return mExtras == null ? null : mExtras.<T>getParcelable(name); 8124 } 8125 8126 /** 8127 * Retrieve extended data from the intent. 8128 * 8129 * @param name The name of the desired item. 8130 * 8131 * @return the value of an item previously added with putExtra(), 8132 * or null if no Parcelable[] value was found. 8133 * 8134 * @see #putExtra(String, Parcelable[]) 8135 */ getParcelableArrayExtra(String name)8136 public @Nullable Parcelable[] getParcelableArrayExtra(String name) { 8137 return mExtras == null ? null : mExtras.getParcelableArray(name); 8138 } 8139 8140 /** 8141 * Retrieve extended data from the intent. 8142 * 8143 * @param name The name of the desired item. 8144 * 8145 * @return the value of an item previously added with 8146 * putParcelableArrayListExtra(), or null if no 8147 * ArrayList<Parcelable> value was found. 8148 * 8149 * @see #putParcelableArrayListExtra(String, ArrayList) 8150 */ getParcelableArrayListExtra(String name)8151 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { 8152 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); 8153 } 8154 8155 /** 8156 * Retrieve extended data from the intent. 8157 * 8158 * @param name The name of the desired item. 8159 * 8160 * @return the value of an item previously added with putExtra(), 8161 * or null if no Serializable value was found. 8162 * 8163 * @see #putExtra(String, Serializable) 8164 */ getSerializableExtra(String name)8165 public @Nullable Serializable getSerializableExtra(String name) { 8166 return mExtras == null ? null : mExtras.getSerializable(name); 8167 } 8168 8169 /** 8170 * Retrieve extended data from the intent. 8171 * 8172 * @param name The name of the desired item. 8173 * 8174 * @return the value of an item previously added with 8175 * putIntegerArrayListExtra(), or null if no 8176 * ArrayList<Integer> value was found. 8177 * 8178 * @see #putIntegerArrayListExtra(String, ArrayList) 8179 */ getIntegerArrayListExtra(String name)8180 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) { 8181 return mExtras == null ? null : mExtras.getIntegerArrayList(name); 8182 } 8183 8184 /** 8185 * Retrieve extended data from the intent. 8186 * 8187 * @param name The name of the desired item. 8188 * 8189 * @return the value of an item previously added with 8190 * putStringArrayListExtra(), or null if no 8191 * ArrayList<String> value was found. 8192 * 8193 * @see #putStringArrayListExtra(String, ArrayList) 8194 */ getStringArrayListExtra(String name)8195 public @Nullable ArrayList<String> getStringArrayListExtra(String name) { 8196 return mExtras == null ? null : mExtras.getStringArrayList(name); 8197 } 8198 8199 /** 8200 * Retrieve extended data from the intent. 8201 * 8202 * @param name The name of the desired item. 8203 * 8204 * @return the value of an item previously added with 8205 * putCharSequenceArrayListExtra, or null if no 8206 * ArrayList<CharSequence> value was found. 8207 * 8208 * @see #putCharSequenceArrayListExtra(String, ArrayList) 8209 */ getCharSequenceArrayListExtra(String name)8210 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { 8211 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); 8212 } 8213 8214 /** 8215 * Retrieve extended data from the intent. 8216 * 8217 * @param name The name of the desired item. 8218 * 8219 * @return the value of an item previously added with putExtra(), 8220 * or null if no boolean array value was found. 8221 * 8222 * @see #putExtra(String, boolean[]) 8223 */ getBooleanArrayExtra(String name)8224 public @Nullable boolean[] getBooleanArrayExtra(String name) { 8225 return mExtras == null ? null : mExtras.getBooleanArray(name); 8226 } 8227 8228 /** 8229 * Retrieve extended data from the intent. 8230 * 8231 * @param name The name of the desired item. 8232 * 8233 * @return the value of an item previously added with putExtra(), 8234 * or null if no byte array value was found. 8235 * 8236 * @see #putExtra(String, byte[]) 8237 */ getByteArrayExtra(String name)8238 public @Nullable byte[] getByteArrayExtra(String name) { 8239 return mExtras == null ? null : mExtras.getByteArray(name); 8240 } 8241 8242 /** 8243 * Retrieve extended data from the intent. 8244 * 8245 * @param name The name of the desired item. 8246 * 8247 * @return the value of an item previously added with putExtra(), 8248 * or null if no short array value was found. 8249 * 8250 * @see #putExtra(String, short[]) 8251 */ getShortArrayExtra(String name)8252 public @Nullable short[] getShortArrayExtra(String name) { 8253 return mExtras == null ? null : mExtras.getShortArray(name); 8254 } 8255 8256 /** 8257 * Retrieve extended data from the intent. 8258 * 8259 * @param name The name of the desired item. 8260 * 8261 * @return the value of an item previously added with putExtra(), 8262 * or null if no char array value was found. 8263 * 8264 * @see #putExtra(String, char[]) 8265 */ getCharArrayExtra(String name)8266 public @Nullable char[] getCharArrayExtra(String name) { 8267 return mExtras == null ? null : mExtras.getCharArray(name); 8268 } 8269 8270 /** 8271 * Retrieve extended data from the intent. 8272 * 8273 * @param name The name of the desired item. 8274 * 8275 * @return the value of an item previously added with putExtra(), 8276 * or null if no int array value was found. 8277 * 8278 * @see #putExtra(String, int[]) 8279 */ getIntArrayExtra(String name)8280 public @Nullable int[] getIntArrayExtra(String name) { 8281 return mExtras == null ? null : mExtras.getIntArray(name); 8282 } 8283 8284 /** 8285 * Retrieve extended data from the intent. 8286 * 8287 * @param name The name of the desired item. 8288 * 8289 * @return the value of an item previously added with putExtra(), 8290 * or null if no long array value was found. 8291 * 8292 * @see #putExtra(String, long[]) 8293 */ getLongArrayExtra(String name)8294 public @Nullable long[] getLongArrayExtra(String name) { 8295 return mExtras == null ? null : mExtras.getLongArray(name); 8296 } 8297 8298 /** 8299 * Retrieve extended data from the intent. 8300 * 8301 * @param name The name of the desired item. 8302 * 8303 * @return the value of an item previously added with putExtra(), 8304 * or null if no float array value was found. 8305 * 8306 * @see #putExtra(String, float[]) 8307 */ getFloatArrayExtra(String name)8308 public @Nullable float[] getFloatArrayExtra(String name) { 8309 return mExtras == null ? null : mExtras.getFloatArray(name); 8310 } 8311 8312 /** 8313 * Retrieve extended data from the intent. 8314 * 8315 * @param name The name of the desired item. 8316 * 8317 * @return the value of an item previously added with putExtra(), 8318 * or null if no double array value was found. 8319 * 8320 * @see #putExtra(String, double[]) 8321 */ getDoubleArrayExtra(String name)8322 public @Nullable double[] getDoubleArrayExtra(String name) { 8323 return mExtras == null ? null : mExtras.getDoubleArray(name); 8324 } 8325 8326 /** 8327 * Retrieve extended data from the intent. 8328 * 8329 * @param name The name of the desired item. 8330 * 8331 * @return the value of an item previously added with putExtra(), 8332 * or null if no String array value was found. 8333 * 8334 * @see #putExtra(String, String[]) 8335 */ getStringArrayExtra(String name)8336 public @Nullable String[] getStringArrayExtra(String name) { 8337 return mExtras == null ? null : mExtras.getStringArray(name); 8338 } 8339 8340 /** 8341 * Retrieve extended data from the intent. 8342 * 8343 * @param name The name of the desired item. 8344 * 8345 * @return the value of an item previously added with putExtra(), 8346 * or null if no CharSequence array value was found. 8347 * 8348 * @see #putExtra(String, CharSequence[]) 8349 */ getCharSequenceArrayExtra(String name)8350 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) { 8351 return mExtras == null ? null : mExtras.getCharSequenceArray(name); 8352 } 8353 8354 /** 8355 * Retrieve extended data from the intent. 8356 * 8357 * @param name The name of the desired item. 8358 * 8359 * @return the value of an item previously added with putExtra(), 8360 * or null if no Bundle value was found. 8361 * 8362 * @see #putExtra(String, Bundle) 8363 */ getBundleExtra(String name)8364 public @Nullable Bundle getBundleExtra(String name) { 8365 return mExtras == null ? null : mExtras.getBundle(name); 8366 } 8367 8368 /** 8369 * Retrieve extended data from the intent. 8370 * 8371 * @param name The name of the desired item. 8372 * 8373 * @return the value of an item previously added with putExtra(), 8374 * or null if no IBinder value was found. 8375 * 8376 * @see #putExtra(String, IBinder) 8377 * 8378 * @deprecated 8379 * @hide 8380 */ 8381 @Deprecated 8382 @UnsupportedAppUsage getIBinderExtra(String name)8383 public IBinder getIBinderExtra(String name) { 8384 return mExtras == null ? null : mExtras.getIBinder(name); 8385 } 8386 8387 /** 8388 * Retrieve extended data from the intent. 8389 * 8390 * @param name The name of the desired item. 8391 * @param defaultValue The default value to return in case no item is 8392 * associated with the key 'name' 8393 * 8394 * @return the value of an item previously added with putExtra(), 8395 * or defaultValue if none was found. 8396 * 8397 * @see #putExtra 8398 * 8399 * @deprecated 8400 * @hide 8401 */ 8402 @Deprecated 8403 @UnsupportedAppUsage getExtra(String name, Object defaultValue)8404 public Object getExtra(String name, Object defaultValue) { 8405 Object result = defaultValue; 8406 if (mExtras != null) { 8407 Object result2 = mExtras.get(name); 8408 if (result2 != null) { 8409 result = result2; 8410 } 8411 } 8412 8413 return result; 8414 } 8415 8416 /** 8417 * Retrieves a map of extended data from the intent. 8418 * 8419 * @return the map of all extras previously added with putExtra(), 8420 * or null if none have been added. 8421 */ getExtras()8422 public @Nullable Bundle getExtras() { 8423 return (mExtras != null) 8424 ? new Bundle(mExtras) 8425 : null; 8426 } 8427 8428 /** 8429 * Filter extras to only basic types. 8430 * @hide 8431 */ removeUnsafeExtras()8432 public void removeUnsafeExtras() { 8433 if (mExtras != null) { 8434 mExtras = mExtras.filterValues(); 8435 } 8436 } 8437 8438 /** 8439 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or 8440 * return itself as-is. 8441 * @hide 8442 */ canStripForHistory()8443 public boolean canStripForHistory() { 8444 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null); 8445 } 8446 8447 /** 8448 * Call it when the system needs to keep an intent for logging purposes to remove fields 8449 * that are not needed for logging. 8450 * @hide 8451 */ maybeStripForHistory()8452 public Intent maybeStripForHistory() { 8453 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras? 8454 8455 if (!canStripForHistory()) { 8456 return this; 8457 } 8458 return new Intent(this, COPY_MODE_HISTORY); 8459 } 8460 8461 /** 8462 * Retrieve any special flags associated with this intent. You will 8463 * normally just set them with {@link #setFlags} and let the system 8464 * take the appropriate action with them. 8465 * 8466 * @return The currently set flags. 8467 * @see #setFlags 8468 * @see #addFlags 8469 * @see #removeFlags 8470 */ getFlags()8471 public @Flags int getFlags() { 8472 return mFlags; 8473 } 8474 8475 /** @hide */ 8476 @UnsupportedAppUsage isExcludingStopped()8477 public boolean isExcludingStopped() { 8478 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) 8479 == FLAG_EXCLUDE_STOPPED_PACKAGES; 8480 } 8481 8482 /** 8483 * Retrieve the application package name this Intent is limited to. When 8484 * resolving an Intent, if non-null this limits the resolution to only 8485 * components in the given application package. 8486 * 8487 * @return The name of the application package for the Intent. 8488 * 8489 * @see #resolveActivity 8490 * @see #setPackage 8491 */ getPackage()8492 public @Nullable String getPackage() { 8493 return mPackage; 8494 } 8495 8496 /** 8497 * Retrieve the concrete component associated with the intent. When receiving 8498 * an intent, this is the component that was found to best handle it (that is, 8499 * yourself) and will always be non-null; in all other cases it will be 8500 * null unless explicitly set. 8501 * 8502 * @return The name of the application component to handle the intent. 8503 * 8504 * @see #resolveActivity 8505 * @see #setComponent 8506 */ getComponent()8507 public @Nullable ComponentName getComponent() { 8508 return mComponent; 8509 } 8510 8511 /** 8512 * Get the bounds of the sender of this intent, in screen coordinates. This can be 8513 * used as a hint to the receiver for animations and the like. Null means that there 8514 * is no source bounds. 8515 */ getSourceBounds()8516 public @Nullable Rect getSourceBounds() { 8517 return mSourceBounds; 8518 } 8519 8520 /** 8521 * Return the Activity component that should be used to handle this intent. 8522 * The appropriate component is determined based on the information in the 8523 * intent, evaluated as follows: 8524 * 8525 * <p>If {@link #getComponent} returns an explicit class, that is returned 8526 * without any further consideration. 8527 * 8528 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent 8529 * category to be considered. 8530 * 8531 * <p>If {@link #getAction} is non-NULL, the activity must handle this 8532 * action. 8533 * 8534 * <p>If {@link #resolveType} returns non-NULL, the activity must handle 8535 * this type. 8536 * 8537 * <p>If {@link #addCategory} has added any categories, the activity must 8538 * handle ALL of the categories specified. 8539 * 8540 * <p>If {@link #getPackage} is non-NULL, only activity components in 8541 * that application package will be considered. 8542 * 8543 * <p>If there are no activities that satisfy all of these conditions, a 8544 * null string is returned. 8545 * 8546 * <p>If multiple activities are found to satisfy the intent, the one with 8547 * the highest priority will be used. If there are multiple activities 8548 * with the same priority, the system will either pick the best activity 8549 * based on user preference, or resolve to a system class that will allow 8550 * the user to pick an activity and forward from there. 8551 * 8552 * <p>This method is implemented simply by calling 8553 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter 8554 * true.</p> 8555 * <p> This API is called for you as part of starting an activity from an 8556 * intent. You do not normally need to call it yourself.</p> 8557 * 8558 * @param pm The package manager with which to resolve the Intent. 8559 * 8560 * @return Name of the component implementing an activity that can 8561 * display the intent. 8562 * 8563 * @see #setComponent 8564 * @see #getComponent 8565 * @see #resolveActivityInfo 8566 */ resolveActivity(@onNull PackageManager pm)8567 public ComponentName resolveActivity(@NonNull PackageManager pm) { 8568 if (mComponent != null) { 8569 return mComponent; 8570 } 8571 8572 ResolveInfo info = pm.resolveActivity( 8573 this, PackageManager.MATCH_DEFAULT_ONLY); 8574 if (info != null) { 8575 return new ComponentName( 8576 info.activityInfo.applicationInfo.packageName, 8577 info.activityInfo.name); 8578 } 8579 8580 return null; 8581 } 8582 8583 /** 8584 * Resolve the Intent into an {@link ActivityInfo} 8585 * describing the activity that should execute the intent. Resolution 8586 * follows the same rules as described for {@link #resolveActivity}, but 8587 * you get back the completely information about the resolved activity 8588 * instead of just its class name. 8589 * 8590 * @param pm The package manager with which to resolve the Intent. 8591 * @param flags Addition information to retrieve as per 8592 * {@link PackageManager#getActivityInfo(ComponentName, int) 8593 * PackageManager.getActivityInfo()}. 8594 * 8595 * @return PackageManager.ActivityInfo 8596 * 8597 * @see #resolveActivity 8598 */ resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)8599 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm, 8600 @PackageManager.ComponentInfoFlags int flags) { 8601 ActivityInfo ai = null; 8602 if (mComponent != null) { 8603 try { 8604 ai = pm.getActivityInfo(mComponent, flags); 8605 } catch (PackageManager.NameNotFoundException e) { 8606 // ignore 8607 } 8608 } else { 8609 ResolveInfo info = pm.resolveActivity( 8610 this, PackageManager.MATCH_DEFAULT_ONLY | flags); 8611 if (info != null) { 8612 ai = info.activityInfo; 8613 } 8614 } 8615 8616 return ai; 8617 } 8618 8619 /** 8620 * Special function for use by the system to resolve service 8621 * intents to system apps. Throws an exception if there are 8622 * multiple potential matches to the Intent. Returns null if 8623 * there are no matches. 8624 * @hide 8625 */ 8626 @UnsupportedAppUsage resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)8627 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm, 8628 @PackageManager.ComponentInfoFlags int flags) { 8629 if (mComponent != null) { 8630 return mComponent; 8631 } 8632 8633 List<ResolveInfo> results = pm.queryIntentServices(this, flags); 8634 if (results == null) { 8635 return null; 8636 } 8637 ComponentName comp = null; 8638 for (int i=0; i<results.size(); i++) { 8639 ResolveInfo ri = results.get(i); 8640 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { 8641 continue; 8642 } 8643 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, 8644 ri.serviceInfo.name); 8645 if (comp != null) { 8646 throw new IllegalStateException("Multiple system services handle " + this 8647 + ": " + comp + ", " + foundComp); 8648 } 8649 comp = foundComp; 8650 } 8651 return comp; 8652 } 8653 8654 /** 8655 * Set the general action to be performed. 8656 * 8657 * @param action An action name, such as ACTION_VIEW. Application-specific 8658 * actions should be prefixed with the vendor's package name. 8659 * 8660 * @return Returns the same Intent object, for chaining multiple calls 8661 * into a single statement. 8662 * 8663 * @see #getAction 8664 */ setAction(@ullable String action)8665 public @NonNull Intent setAction(@Nullable String action) { 8666 mAction = action != null ? action.intern() : null; 8667 return this; 8668 } 8669 8670 /** 8671 * Set the data this intent is operating on. This method automatically 8672 * clears any type that was previously set by {@link #setType} or 8673 * {@link #setTypeAndNormalize}. 8674 * 8675 * <p><em>Note: scheme matching in the Android framework is 8676 * case-sensitive, unlike the formal RFC. As a result, 8677 * you should always write your Uri with a lower case scheme, 8678 * or use {@link Uri#normalizeScheme} or 8679 * {@link #setDataAndNormalize} 8680 * to ensure that the scheme is converted to lower case.</em> 8681 * 8682 * @param data The Uri of the data this intent is now targeting. 8683 * 8684 * @return Returns the same Intent object, for chaining multiple calls 8685 * into a single statement. 8686 * 8687 * @see #getData 8688 * @see #setDataAndNormalize 8689 * @see android.net.Uri#normalizeScheme() 8690 */ setData(@ullable Uri data)8691 public @NonNull Intent setData(@Nullable Uri data) { 8692 mData = data; 8693 mType = null; 8694 return this; 8695 } 8696 8697 /** 8698 * Normalize and set the data this intent is operating on. 8699 * 8700 * <p>This method automatically clears any type that was 8701 * previously set (for example, by {@link #setType}). 8702 * 8703 * <p>The data Uri is normalized using 8704 * {@link android.net.Uri#normalizeScheme} before it is set, 8705 * so really this is just a convenience method for 8706 * <pre> 8707 * setData(data.normalize()) 8708 * </pre> 8709 * 8710 * @param data The Uri of the data this intent is now targeting. 8711 * 8712 * @return Returns the same Intent object, for chaining multiple calls 8713 * into a single statement. 8714 * 8715 * @see #getData 8716 * @see #setType 8717 * @see android.net.Uri#normalizeScheme 8718 */ setDataAndNormalize(@onNull Uri data)8719 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) { 8720 return setData(data.normalizeScheme()); 8721 } 8722 8723 /** 8724 * Set an explicit MIME data type. 8725 * 8726 * <p>This is used to create intents that only specify a type and not data, 8727 * for example to indicate the type of data to return. 8728 * 8729 * <p>This method automatically clears any data that was 8730 * previously set (for example by {@link #setData}). 8731 * 8732 * <p><em>Note: MIME type matching in the Android framework is 8733 * case-sensitive, unlike formal RFC MIME types. As a result, 8734 * you should always write your MIME types with lower case letters, 8735 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} 8736 * to ensure that it is converted to lower case.</em> 8737 * 8738 * @param type The MIME type of the data being handled by this intent. 8739 * 8740 * @return Returns the same Intent object, for chaining multiple calls 8741 * into a single statement. 8742 * 8743 * @see #getType 8744 * @see #setTypeAndNormalize 8745 * @see #setDataAndType 8746 * @see #normalizeMimeType 8747 */ setType(@ullable String type)8748 public @NonNull Intent setType(@Nullable String type) { 8749 mData = null; 8750 mType = type; 8751 return this; 8752 } 8753 8754 /** 8755 * Normalize and set an explicit MIME data type. 8756 * 8757 * <p>This is used to create intents that only specify a type and not data, 8758 * for example to indicate the type of data to return. 8759 * 8760 * <p>This method automatically clears any data that was 8761 * previously set (for example by {@link #setData}). 8762 * 8763 * <p>The MIME type is normalized using 8764 * {@link #normalizeMimeType} before it is set, 8765 * so really this is just a convenience method for 8766 * <pre> 8767 * setType(Intent.normalizeMimeType(type)) 8768 * </pre> 8769 * 8770 * @param type The MIME type of the data being handled by this intent. 8771 * 8772 * @return Returns the same Intent object, for chaining multiple calls 8773 * into a single statement. 8774 * 8775 * @see #getType 8776 * @see #setData 8777 * @see #normalizeMimeType 8778 */ setTypeAndNormalize(@ullable String type)8779 public @NonNull Intent setTypeAndNormalize(@Nullable String type) { 8780 return setType(normalizeMimeType(type)); 8781 } 8782 8783 /** 8784 * (Usually optional) Set the data for the intent along with an explicit 8785 * MIME data type. This method should very rarely be used -- it allows you 8786 * to override the MIME type that would ordinarily be inferred from the 8787 * data with your own type given here. 8788 * 8789 * <p><em>Note: MIME type and Uri scheme matching in the 8790 * Android framework is case-sensitive, unlike the formal RFC definitions. 8791 * As a result, you should always write these elements with lower case letters, 8792 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or 8793 * {@link #setDataAndTypeAndNormalize} 8794 * to ensure that they are converted to lower case.</em> 8795 * 8796 * @param data The Uri of the data this intent is now targeting. 8797 * @param type The MIME type of the data being handled by this intent. 8798 * 8799 * @return Returns the same Intent object, for chaining multiple calls 8800 * into a single statement. 8801 * 8802 * @see #setType 8803 * @see #setData 8804 * @see #normalizeMimeType 8805 * @see android.net.Uri#normalizeScheme 8806 * @see #setDataAndTypeAndNormalize 8807 */ setDataAndType(@ullable Uri data, @Nullable String type)8808 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) { 8809 mData = data; 8810 mType = type; 8811 return this; 8812 } 8813 8814 /** 8815 * (Usually optional) Normalize and set both the data Uri and an explicit 8816 * MIME data type. This method should very rarely be used -- it allows you 8817 * to override the MIME type that would ordinarily be inferred from the 8818 * data with your own type given here. 8819 * 8820 * <p>The data Uri and the MIME type are normalize using 8821 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} 8822 * before they are set, so really this is just a convenience method for 8823 * <pre> 8824 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) 8825 * </pre> 8826 * 8827 * @param data The Uri of the data this intent is now targeting. 8828 * @param type The MIME type of the data being handled by this intent. 8829 * 8830 * @return Returns the same Intent object, for chaining multiple calls 8831 * into a single statement. 8832 * 8833 * @see #setType 8834 * @see #setData 8835 * @see #setDataAndType 8836 * @see #normalizeMimeType 8837 * @see android.net.Uri#normalizeScheme 8838 */ setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)8839 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) { 8840 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); 8841 } 8842 8843 /** 8844 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent, 8845 * allowing it to be unique from other Intents that would otherwise look the same. In 8846 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two 8847 * Intents are the same as with other fields like {@link #setAction}. However, unlike those 8848 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter}; 8849 * it is as if the identifier has not been set on the Intent. 8850 * 8851 * <p>This can be used, for example, to make this Intent unique from other Intents that 8852 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware 8853 * however that the receiver of the PendingIntent will see whatever you put in here.) The 8854 * structure of this string is completely undefined by the platform, however if you are going 8855 * to be exposing identifier strings across different applications you may need to define 8856 * your own structure if there is no central party defining the contents of this field.</p> 8857 * 8858 * @param identifier The identifier for this Intent. The contents of the string have no 8859 * meaning to the system, except whether they are exactly the same as 8860 * another identifier. 8861 * 8862 * @return Returns the same Intent object, for chaining multiple calls 8863 * into a single statement. 8864 * 8865 * @see #getIdentifier 8866 */ setIdentifier(@ullable String identifier)8867 public @NonNull Intent setIdentifier(@Nullable String identifier) { 8868 mIdentifier = identifier; 8869 return this; 8870 } 8871 8872 /** 8873 * Add a new category to the intent. Categories provide additional detail 8874 * about the action the intent performs. When resolving an intent, only 8875 * activities that provide <em>all</em> of the requested categories will be 8876 * used. 8877 * 8878 * @param category The desired category. This can be either one of the 8879 * predefined Intent categories, or a custom category in your own 8880 * namespace. 8881 * 8882 * @return Returns the same Intent object, for chaining multiple calls 8883 * into a single statement. 8884 * 8885 * @see #hasCategory 8886 * @see #removeCategory 8887 */ addCategory(String category)8888 public @NonNull Intent addCategory(String category) { 8889 if (mCategories == null) { 8890 mCategories = new ArraySet<String>(); 8891 } 8892 mCategories.add(category.intern()); 8893 return this; 8894 } 8895 8896 /** 8897 * Remove a category from an intent. 8898 * 8899 * @param category The category to remove. 8900 * 8901 * @see #addCategory 8902 */ removeCategory(String category)8903 public void removeCategory(String category) { 8904 if (mCategories != null) { 8905 mCategories.remove(category); 8906 if (mCategories.size() == 0) { 8907 mCategories = null; 8908 } 8909 } 8910 } 8911 8912 /** 8913 * Set a selector for this Intent. This is a modification to the kinds of 8914 * things the Intent will match. If the selector is set, it will be used 8915 * when trying to find entities that can handle the Intent, instead of the 8916 * main contents of the Intent. This allows you build an Intent containing 8917 * a generic protocol while targeting it more specifically. 8918 * 8919 * <p>An example of where this may be used is with things like 8920 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an 8921 * Intent that will launch the Browser application. However, the correct 8922 * main entry point of an application is actually {@link #ACTION_MAIN} 8923 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} 8924 * used to specify the actual Activity to launch. If you launch the browser 8925 * with something different, undesired behavior may happen if the user has 8926 * previously or later launches it the normal way, since they do not match. 8927 * Instead, you can build an Intent with the MAIN action (but no ComponentName 8928 * yet specified) and set a selector with {@link #ACTION_MAIN} and 8929 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. 8930 * 8931 * <p>Setting a selector does not impact the behavior of 8932 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the 8933 * desired behavior of a selector -- it does not impact the base meaning 8934 * of the Intent, just what kinds of things will be matched against it 8935 * when determining who can handle it.</p> 8936 * 8937 * <p>You can not use both a selector and {@link #setPackage(String)} on 8938 * the same base Intent.</p> 8939 * 8940 * @param selector The desired selector Intent; set to null to not use 8941 * a special selector. 8942 */ setSelector(@ullable Intent selector)8943 public void setSelector(@Nullable Intent selector) { 8944 if (selector == this) { 8945 throw new IllegalArgumentException( 8946 "Intent being set as a selector of itself"); 8947 } 8948 if (selector != null && mPackage != null) { 8949 throw new IllegalArgumentException( 8950 "Can't set selector when package name is already set"); 8951 } 8952 mSelector = selector; 8953 } 8954 8955 /** 8956 * Set a {@link ClipData} associated with this Intent. This replaces any 8957 * previously set ClipData. 8958 * 8959 * <p>The ClipData in an intent is not used for Intent matching or other 8960 * such operations. Semantically it is like extras, used to transmit 8961 * additional data with the Intent. The main feature of using this over 8962 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} 8963 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI 8964 * items included in the clip data. This is useful, in particular, if 8965 * you want to transmit an Intent containing multiple <code>content:</code> 8966 * URIs for which the recipient may not have global permission to access the 8967 * content provider. 8968 * 8969 * <p>If the ClipData contains items that are themselves Intents, any 8970 * grant flags in those Intents will be ignored. Only the top-level flags 8971 * of the main Intent are respected, and will be applied to all Uri or 8972 * Intent items in the clip (or sub-items of the clip). 8973 * 8974 * <p>The MIME type, label, and icon in the ClipData object are not 8975 * directly used by Intent. Applications should generally rely on the 8976 * MIME type of the Intent itself, not what it may find in the ClipData. 8977 * A common practice is to construct a ClipData for use with an Intent 8978 * with a MIME type of "*/*". 8979 * 8980 * @param clip The new clip to set. May be null to clear the current clip. 8981 */ setClipData(@ullable ClipData clip)8982 public void setClipData(@Nullable ClipData clip) { 8983 mClipData = clip; 8984 } 8985 8986 /** 8987 * This is NOT a secure mechanism to identify the user who sent the intent. 8988 * When the intent is sent to a different user, it is used to fix uris by adding the userId 8989 * who sent the intent. 8990 * @hide 8991 */ prepareToLeaveUser(int userId)8992 public void prepareToLeaveUser(int userId) { 8993 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. 8994 // We want mContentUserHint to refer to the original user, so don't do anything. 8995 if (mContentUserHint == UserHandle.USER_CURRENT) { 8996 mContentUserHint = userId; 8997 } 8998 } 8999 9000 /** 9001 * Add extended data to the intent. The name must include a package 9002 * prefix, for example the app com.android.contacts would use names 9003 * like "com.android.contacts.ShowAll". 9004 * 9005 * @param name The name of the extra data, with package prefix. 9006 * @param value The boolean data value. 9007 * 9008 * @return Returns the same Intent object, for chaining multiple calls 9009 * into a single statement. 9010 * 9011 * @see #putExtras 9012 * @see #removeExtra 9013 * @see #getBooleanExtra(String, boolean) 9014 */ putExtra(String name, boolean value)9015 public @NonNull Intent putExtra(String name, boolean value) { 9016 if (mExtras == null) { 9017 mExtras = new Bundle(); 9018 } 9019 mExtras.putBoolean(name, value); 9020 return this; 9021 } 9022 9023 /** 9024 * Add extended data to the intent. The name must include a package 9025 * prefix, for example the app com.android.contacts would use names 9026 * like "com.android.contacts.ShowAll". 9027 * 9028 * @param name The name of the extra data, with package prefix. 9029 * @param value The byte data value. 9030 * 9031 * @return Returns the same Intent object, for chaining multiple calls 9032 * into a single statement. 9033 * 9034 * @see #putExtras 9035 * @see #removeExtra 9036 * @see #getByteExtra(String, byte) 9037 */ putExtra(String name, byte value)9038 public @NonNull Intent putExtra(String name, byte value) { 9039 if (mExtras == null) { 9040 mExtras = new Bundle(); 9041 } 9042 mExtras.putByte(name, value); 9043 return this; 9044 } 9045 9046 /** 9047 * Add extended data to the intent. The name must include a package 9048 * prefix, for example the app com.android.contacts would use names 9049 * like "com.android.contacts.ShowAll". 9050 * 9051 * @param name The name of the extra data, with package prefix. 9052 * @param value The char data value. 9053 * 9054 * @return Returns the same Intent object, for chaining multiple calls 9055 * into a single statement. 9056 * 9057 * @see #putExtras 9058 * @see #removeExtra 9059 * @see #getCharExtra(String, char) 9060 */ putExtra(String name, char value)9061 public @NonNull Intent putExtra(String name, char value) { 9062 if (mExtras == null) { 9063 mExtras = new Bundle(); 9064 } 9065 mExtras.putChar(name, value); 9066 return this; 9067 } 9068 9069 /** 9070 * Add extended data to the intent. The name must include a package 9071 * prefix, for example the app com.android.contacts would use names 9072 * like "com.android.contacts.ShowAll". 9073 * 9074 * @param name The name of the extra data, with package prefix. 9075 * @param value The short data value. 9076 * 9077 * @return Returns the same Intent object, for chaining multiple calls 9078 * into a single statement. 9079 * 9080 * @see #putExtras 9081 * @see #removeExtra 9082 * @see #getShortExtra(String, short) 9083 */ putExtra(String name, short value)9084 public @NonNull Intent putExtra(String name, short value) { 9085 if (mExtras == null) { 9086 mExtras = new Bundle(); 9087 } 9088 mExtras.putShort(name, value); 9089 return this; 9090 } 9091 9092 /** 9093 * Add extended data to the intent. The name must include a package 9094 * prefix, for example the app com.android.contacts would use names 9095 * like "com.android.contacts.ShowAll". 9096 * 9097 * @param name The name of the extra data, with package prefix. 9098 * @param value The integer data value. 9099 * 9100 * @return Returns the same Intent object, for chaining multiple calls 9101 * into a single statement. 9102 * 9103 * @see #putExtras 9104 * @see #removeExtra 9105 * @see #getIntExtra(String, int) 9106 */ putExtra(String name, int value)9107 public @NonNull Intent putExtra(String name, int value) { 9108 if (mExtras == null) { 9109 mExtras = new Bundle(); 9110 } 9111 mExtras.putInt(name, value); 9112 return this; 9113 } 9114 9115 /** 9116 * Add extended data to the intent. The name must include a package 9117 * prefix, for example the app com.android.contacts would use names 9118 * like "com.android.contacts.ShowAll". 9119 * 9120 * @param name The name of the extra data, with package prefix. 9121 * @param value The long data value. 9122 * 9123 * @return Returns the same Intent object, for chaining multiple calls 9124 * into a single statement. 9125 * 9126 * @see #putExtras 9127 * @see #removeExtra 9128 * @see #getLongExtra(String, long) 9129 */ putExtra(String name, long value)9130 public @NonNull Intent putExtra(String name, long value) { 9131 if (mExtras == null) { 9132 mExtras = new Bundle(); 9133 } 9134 mExtras.putLong(name, value); 9135 return this; 9136 } 9137 9138 /** 9139 * Add extended data to the intent. The name must include a package 9140 * prefix, for example the app com.android.contacts would use names 9141 * like "com.android.contacts.ShowAll". 9142 * 9143 * @param name The name of the extra data, with package prefix. 9144 * @param value The float data value. 9145 * 9146 * @return Returns the same Intent object, for chaining multiple calls 9147 * into a single statement. 9148 * 9149 * @see #putExtras 9150 * @see #removeExtra 9151 * @see #getFloatExtra(String, float) 9152 */ putExtra(String name, float value)9153 public @NonNull Intent putExtra(String name, float value) { 9154 if (mExtras == null) { 9155 mExtras = new Bundle(); 9156 } 9157 mExtras.putFloat(name, value); 9158 return this; 9159 } 9160 9161 /** 9162 * Add extended data to the intent. The name must include a package 9163 * prefix, for example the app com.android.contacts would use names 9164 * like "com.android.contacts.ShowAll". 9165 * 9166 * @param name The name of the extra data, with package prefix. 9167 * @param value The double data value. 9168 * 9169 * @return Returns the same Intent object, for chaining multiple calls 9170 * into a single statement. 9171 * 9172 * @see #putExtras 9173 * @see #removeExtra 9174 * @see #getDoubleExtra(String, double) 9175 */ putExtra(String name, double value)9176 public @NonNull Intent putExtra(String name, double value) { 9177 if (mExtras == null) { 9178 mExtras = new Bundle(); 9179 } 9180 mExtras.putDouble(name, value); 9181 return this; 9182 } 9183 9184 /** 9185 * Add extended data to the intent. The name must include a package 9186 * prefix, for example the app com.android.contacts would use names 9187 * like "com.android.contacts.ShowAll". 9188 * 9189 * @param name The name of the extra data, with package prefix. 9190 * @param value The String data value. 9191 * 9192 * @return Returns the same Intent object, for chaining multiple calls 9193 * into a single statement. 9194 * 9195 * @see #putExtras 9196 * @see #removeExtra 9197 * @see #getStringExtra(String) 9198 */ putExtra(String name, @Nullable String value)9199 public @NonNull Intent putExtra(String name, @Nullable String value) { 9200 if (mExtras == null) { 9201 mExtras = new Bundle(); 9202 } 9203 mExtras.putString(name, value); 9204 return this; 9205 } 9206 9207 /** 9208 * Add extended data to the intent. The name must include a package 9209 * prefix, for example the app com.android.contacts would use names 9210 * like "com.android.contacts.ShowAll". 9211 * 9212 * @param name The name of the extra data, with package prefix. 9213 * @param value The CharSequence data value. 9214 * 9215 * @return Returns the same Intent object, for chaining multiple calls 9216 * into a single statement. 9217 * 9218 * @see #putExtras 9219 * @see #removeExtra 9220 * @see #getCharSequenceExtra(String) 9221 */ putExtra(String name, @Nullable CharSequence value)9222 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) { 9223 if (mExtras == null) { 9224 mExtras = new Bundle(); 9225 } 9226 mExtras.putCharSequence(name, value); 9227 return this; 9228 } 9229 9230 /** 9231 * Add extended data to the intent. The name must include a package 9232 * prefix, for example the app com.android.contacts would use names 9233 * like "com.android.contacts.ShowAll". 9234 * 9235 * @param name The name of the extra data, with package prefix. 9236 * @param value The Parcelable data value. 9237 * 9238 * @return Returns the same Intent object, for chaining multiple calls 9239 * into a single statement. 9240 * 9241 * @see #putExtras 9242 * @see #removeExtra 9243 * @see #getParcelableExtra(String) 9244 */ putExtra(String name, @Nullable Parcelable value)9245 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) { 9246 if (mExtras == null) { 9247 mExtras = new Bundle(); 9248 } 9249 mExtras.putParcelable(name, value); 9250 return this; 9251 } 9252 9253 /** 9254 * Add extended data to the intent. The name must include a package 9255 * prefix, for example the app com.android.contacts would use names 9256 * like "com.android.contacts.ShowAll". 9257 * 9258 * @param name The name of the extra data, with package prefix. 9259 * @param value The Parcelable[] data value. 9260 * 9261 * @return Returns the same Intent object, for chaining multiple calls 9262 * into a single statement. 9263 * 9264 * @see #putExtras 9265 * @see #removeExtra 9266 * @see #getParcelableArrayExtra(String) 9267 */ putExtra(String name, @Nullable Parcelable[] value)9268 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) { 9269 if (mExtras == null) { 9270 mExtras = new Bundle(); 9271 } 9272 mExtras.putParcelableArray(name, value); 9273 return this; 9274 } 9275 9276 /** 9277 * Add extended data to the intent. The name must include a package 9278 * prefix, for example the app com.android.contacts would use names 9279 * like "com.android.contacts.ShowAll". 9280 * 9281 * @param name The name of the extra data, with package prefix. 9282 * @param value The ArrayList<Parcelable> data value. 9283 * 9284 * @return Returns the same Intent object, for chaining multiple calls 9285 * into a single statement. 9286 * 9287 * @see #putExtras 9288 * @see #removeExtra 9289 * @see #getParcelableArrayListExtra(String) 9290 */ putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)9291 public @NonNull Intent putParcelableArrayListExtra(String name, 9292 @Nullable ArrayList<? extends Parcelable> value) { 9293 if (mExtras == null) { 9294 mExtras = new Bundle(); 9295 } 9296 mExtras.putParcelableArrayList(name, value); 9297 return this; 9298 } 9299 9300 /** 9301 * Add extended data to the intent. The name must include a package 9302 * prefix, for example the app com.android.contacts would use names 9303 * like "com.android.contacts.ShowAll". 9304 * 9305 * @param name The name of the extra data, with package prefix. 9306 * @param value The ArrayList<Integer> data value. 9307 * 9308 * @return Returns the same Intent object, for chaining multiple calls 9309 * into a single statement. 9310 * 9311 * @see #putExtras 9312 * @see #removeExtra 9313 * @see #getIntegerArrayListExtra(String) 9314 */ putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)9315 public @NonNull Intent putIntegerArrayListExtra(String name, 9316 @Nullable ArrayList<Integer> value) { 9317 if (mExtras == null) { 9318 mExtras = new Bundle(); 9319 } 9320 mExtras.putIntegerArrayList(name, value); 9321 return this; 9322 } 9323 9324 /** 9325 * Add extended data to the intent. The name must include a package 9326 * prefix, for example the app com.android.contacts would use names 9327 * like "com.android.contacts.ShowAll". 9328 * 9329 * @param name The name of the extra data, with package prefix. 9330 * @param value The ArrayList<String> data value. 9331 * 9332 * @return Returns the same Intent object, for chaining multiple calls 9333 * into a single statement. 9334 * 9335 * @see #putExtras 9336 * @see #removeExtra 9337 * @see #getStringArrayListExtra(String) 9338 */ putStringArrayListExtra(String name, @Nullable ArrayList<String> value)9339 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) { 9340 if (mExtras == null) { 9341 mExtras = new Bundle(); 9342 } 9343 mExtras.putStringArrayList(name, value); 9344 return this; 9345 } 9346 9347 /** 9348 * Add extended data to the intent. The name must include a package 9349 * prefix, for example the app com.android.contacts would use names 9350 * like "com.android.contacts.ShowAll". 9351 * 9352 * @param name The name of the extra data, with package prefix. 9353 * @param value The ArrayList<CharSequence> data value. 9354 * 9355 * @return Returns the same Intent object, for chaining multiple calls 9356 * into a single statement. 9357 * 9358 * @see #putExtras 9359 * @see #removeExtra 9360 * @see #getCharSequenceArrayListExtra(String) 9361 */ putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)9362 public @NonNull Intent putCharSequenceArrayListExtra(String name, 9363 @Nullable ArrayList<CharSequence> value) { 9364 if (mExtras == null) { 9365 mExtras = new Bundle(); 9366 } 9367 mExtras.putCharSequenceArrayList(name, value); 9368 return this; 9369 } 9370 9371 /** 9372 * Add extended data to the intent. The name must include a package 9373 * prefix, for example the app com.android.contacts would use names 9374 * like "com.android.contacts.ShowAll". 9375 * 9376 * @param name The name of the extra data, with package prefix. 9377 * @param value The Serializable data value. 9378 * 9379 * @return Returns the same Intent object, for chaining multiple calls 9380 * into a single statement. 9381 * 9382 * @see #putExtras 9383 * @see #removeExtra 9384 * @see #getSerializableExtra(String) 9385 */ putExtra(String name, @Nullable Serializable value)9386 public @NonNull Intent putExtra(String name, @Nullable Serializable value) { 9387 if (mExtras == null) { 9388 mExtras = new Bundle(); 9389 } 9390 mExtras.putSerializable(name, value); 9391 return this; 9392 } 9393 9394 /** 9395 * Add extended data to the intent. The name must include a package 9396 * prefix, for example the app com.android.contacts would use names 9397 * like "com.android.contacts.ShowAll". 9398 * 9399 * @param name The name of the extra data, with package prefix. 9400 * @param value The boolean array data value. 9401 * 9402 * @return Returns the same Intent object, for chaining multiple calls 9403 * into a single statement. 9404 * 9405 * @see #putExtras 9406 * @see #removeExtra 9407 * @see #getBooleanArrayExtra(String) 9408 */ putExtra(String name, @Nullable boolean[] value)9409 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) { 9410 if (mExtras == null) { 9411 mExtras = new Bundle(); 9412 } 9413 mExtras.putBooleanArray(name, value); 9414 return this; 9415 } 9416 9417 /** 9418 * Add extended data to the intent. The name must include a package 9419 * prefix, for example the app com.android.contacts would use names 9420 * like "com.android.contacts.ShowAll". 9421 * 9422 * @param name The name of the extra data, with package prefix. 9423 * @param value The byte array data value. 9424 * 9425 * @return Returns the same Intent object, for chaining multiple calls 9426 * into a single statement. 9427 * 9428 * @see #putExtras 9429 * @see #removeExtra 9430 * @see #getByteArrayExtra(String) 9431 */ putExtra(String name, @Nullable byte[] value)9432 public @NonNull Intent putExtra(String name, @Nullable byte[] value) { 9433 if (mExtras == null) { 9434 mExtras = new Bundle(); 9435 } 9436 mExtras.putByteArray(name, value); 9437 return this; 9438 } 9439 9440 /** 9441 * Add extended data to the intent. The name must include a package 9442 * prefix, for example the app com.android.contacts would use names 9443 * like "com.android.contacts.ShowAll". 9444 * 9445 * @param name The name of the extra data, with package prefix. 9446 * @param value The short array data value. 9447 * 9448 * @return Returns the same Intent object, for chaining multiple calls 9449 * into a single statement. 9450 * 9451 * @see #putExtras 9452 * @see #removeExtra 9453 * @see #getShortArrayExtra(String) 9454 */ putExtra(String name, @Nullable short[] value)9455 public @NonNull Intent putExtra(String name, @Nullable short[] value) { 9456 if (mExtras == null) { 9457 mExtras = new Bundle(); 9458 } 9459 mExtras.putShortArray(name, value); 9460 return this; 9461 } 9462 9463 /** 9464 * Add extended data to the intent. The name must include a package 9465 * prefix, for example the app com.android.contacts would use names 9466 * like "com.android.contacts.ShowAll". 9467 * 9468 * @param name The name of the extra data, with package prefix. 9469 * @param value The char array data value. 9470 * 9471 * @return Returns the same Intent object, for chaining multiple calls 9472 * into a single statement. 9473 * 9474 * @see #putExtras 9475 * @see #removeExtra 9476 * @see #getCharArrayExtra(String) 9477 */ putExtra(String name, @Nullable char[] value)9478 public @NonNull Intent putExtra(String name, @Nullable char[] value) { 9479 if (mExtras == null) { 9480 mExtras = new Bundle(); 9481 } 9482 mExtras.putCharArray(name, value); 9483 return this; 9484 } 9485 9486 /** 9487 * Add extended data to the intent. The name must include a package 9488 * prefix, for example the app com.android.contacts would use names 9489 * like "com.android.contacts.ShowAll". 9490 * 9491 * @param name The name of the extra data, with package prefix. 9492 * @param value The int array data value. 9493 * 9494 * @return Returns the same Intent object, for chaining multiple calls 9495 * into a single statement. 9496 * 9497 * @see #putExtras 9498 * @see #removeExtra 9499 * @see #getIntArrayExtra(String) 9500 */ putExtra(String name, @Nullable int[] value)9501 public @NonNull Intent putExtra(String name, @Nullable int[] value) { 9502 if (mExtras == null) { 9503 mExtras = new Bundle(); 9504 } 9505 mExtras.putIntArray(name, value); 9506 return this; 9507 } 9508 9509 /** 9510 * Add extended data to the intent. The name must include a package 9511 * prefix, for example the app com.android.contacts would use names 9512 * like "com.android.contacts.ShowAll". 9513 * 9514 * @param name The name of the extra data, with package prefix. 9515 * @param value The byte array data value. 9516 * 9517 * @return Returns the same Intent object, for chaining multiple calls 9518 * into a single statement. 9519 * 9520 * @see #putExtras 9521 * @see #removeExtra 9522 * @see #getLongArrayExtra(String) 9523 */ putExtra(String name, @Nullable long[] value)9524 public @NonNull Intent putExtra(String name, @Nullable long[] value) { 9525 if (mExtras == null) { 9526 mExtras = new Bundle(); 9527 } 9528 mExtras.putLongArray(name, value); 9529 return this; 9530 } 9531 9532 /** 9533 * Add extended data to the intent. The name must include a package 9534 * prefix, for example the app com.android.contacts would use names 9535 * like "com.android.contacts.ShowAll". 9536 * 9537 * @param name The name of the extra data, with package prefix. 9538 * @param value The float array data value. 9539 * 9540 * @return Returns the same Intent object, for chaining multiple calls 9541 * into a single statement. 9542 * 9543 * @see #putExtras 9544 * @see #removeExtra 9545 * @see #getFloatArrayExtra(String) 9546 */ putExtra(String name, @Nullable float[] value)9547 public @NonNull Intent putExtra(String name, @Nullable float[] value) { 9548 if (mExtras == null) { 9549 mExtras = new Bundle(); 9550 } 9551 mExtras.putFloatArray(name, value); 9552 return this; 9553 } 9554 9555 /** 9556 * Add extended data to the intent. The name must include a package 9557 * prefix, for example the app com.android.contacts would use names 9558 * like "com.android.contacts.ShowAll". 9559 * 9560 * @param name The name of the extra data, with package prefix. 9561 * @param value The double array data value. 9562 * 9563 * @return Returns the same Intent object, for chaining multiple calls 9564 * into a single statement. 9565 * 9566 * @see #putExtras 9567 * @see #removeExtra 9568 * @see #getDoubleArrayExtra(String) 9569 */ putExtra(String name, @Nullable double[] value)9570 public @NonNull Intent putExtra(String name, @Nullable double[] value) { 9571 if (mExtras == null) { 9572 mExtras = new Bundle(); 9573 } 9574 mExtras.putDoubleArray(name, value); 9575 return this; 9576 } 9577 9578 /** 9579 * Add extended data to the intent. The name must include a package 9580 * prefix, for example the app com.android.contacts would use names 9581 * like "com.android.contacts.ShowAll". 9582 * 9583 * @param name The name of the extra data, with package prefix. 9584 * @param value The String array data value. 9585 * 9586 * @return Returns the same Intent object, for chaining multiple calls 9587 * into a single statement. 9588 * 9589 * @see #putExtras 9590 * @see #removeExtra 9591 * @see #getStringArrayExtra(String) 9592 */ putExtra(String name, @Nullable String[] value)9593 public @NonNull Intent putExtra(String name, @Nullable String[] value) { 9594 if (mExtras == null) { 9595 mExtras = new Bundle(); 9596 } 9597 mExtras.putStringArray(name, value); 9598 return this; 9599 } 9600 9601 /** 9602 * Add extended data to the intent. The name must include a package 9603 * prefix, for example the app com.android.contacts would use names 9604 * like "com.android.contacts.ShowAll". 9605 * 9606 * @param name The name of the extra data, with package prefix. 9607 * @param value The CharSequence array data value. 9608 * 9609 * @return Returns the same Intent object, for chaining multiple calls 9610 * into a single statement. 9611 * 9612 * @see #putExtras 9613 * @see #removeExtra 9614 * @see #getCharSequenceArrayExtra(String) 9615 */ putExtra(String name, @Nullable CharSequence[] value)9616 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) { 9617 if (mExtras == null) { 9618 mExtras = new Bundle(); 9619 } 9620 mExtras.putCharSequenceArray(name, value); 9621 return this; 9622 } 9623 9624 /** 9625 * Add extended data to the intent. The name must include a package 9626 * prefix, for example the app com.android.contacts would use names 9627 * like "com.android.contacts.ShowAll". 9628 * 9629 * @param name The name of the extra data, with package prefix. 9630 * @param value The Bundle data value. 9631 * 9632 * @return Returns the same Intent object, for chaining multiple calls 9633 * into a single statement. 9634 * 9635 * @see #putExtras 9636 * @see #removeExtra 9637 * @see #getBundleExtra(String) 9638 */ putExtra(String name, @Nullable Bundle value)9639 public @NonNull Intent putExtra(String name, @Nullable Bundle value) { 9640 if (mExtras == null) { 9641 mExtras = new Bundle(); 9642 } 9643 mExtras.putBundle(name, value); 9644 return this; 9645 } 9646 9647 /** 9648 * Add extended data to the intent. The name must include a package 9649 * prefix, for example the app com.android.contacts would use names 9650 * like "com.android.contacts.ShowAll". 9651 * 9652 * @param name The name of the extra data, with package prefix. 9653 * @param value The IBinder data value. 9654 * 9655 * @return Returns the same Intent object, for chaining multiple calls 9656 * into a single statement. 9657 * 9658 * @see #putExtras 9659 * @see #removeExtra 9660 * @see #getIBinderExtra(String) 9661 * 9662 * @deprecated 9663 * @hide 9664 */ 9665 @Deprecated 9666 @UnsupportedAppUsage putExtra(String name, IBinder value)9667 public @NonNull Intent putExtra(String name, IBinder value) { 9668 if (mExtras == null) { 9669 mExtras = new Bundle(); 9670 } 9671 mExtras.putIBinder(name, value); 9672 return this; 9673 } 9674 9675 /** 9676 * Copy all extras in 'src' in to this intent. 9677 * 9678 * @param src Contains the extras to copy. 9679 * 9680 * @see #putExtra 9681 */ putExtras(@onNull Intent src)9682 public @NonNull Intent putExtras(@NonNull Intent src) { 9683 if (src.mExtras != null) { 9684 if (mExtras == null) { 9685 mExtras = new Bundle(src.mExtras); 9686 } else { 9687 mExtras.putAll(src.mExtras); 9688 } 9689 } 9690 return this; 9691 } 9692 9693 /** 9694 * Add a set of extended data to the intent. The keys must include a package 9695 * prefix, for example the app com.android.contacts would use names 9696 * like "com.android.contacts.ShowAll". 9697 * 9698 * @param extras The Bundle of extras to add to this intent. 9699 * 9700 * @see #putExtra 9701 * @see #removeExtra 9702 */ putExtras(@onNull Bundle extras)9703 public @NonNull Intent putExtras(@NonNull Bundle extras) { 9704 if (mExtras == null) { 9705 mExtras = new Bundle(); 9706 } 9707 mExtras.putAll(extras); 9708 return this; 9709 } 9710 9711 /** 9712 * Completely replace the extras in the Intent with the extras in the 9713 * given Intent. 9714 * 9715 * @param src The exact extras contained in this Intent are copied 9716 * into the target intent, replacing any that were previously there. 9717 */ replaceExtras(@onNull Intent src)9718 public @NonNull Intent replaceExtras(@NonNull Intent src) { 9719 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; 9720 return this; 9721 } 9722 9723 /** 9724 * Completely replace the extras in the Intent with the given Bundle of 9725 * extras. 9726 * 9727 * @param extras The new set of extras in the Intent, or null to erase 9728 * all extras. 9729 */ replaceExtras(@ullable Bundle extras)9730 public @NonNull Intent replaceExtras(@Nullable Bundle extras) { 9731 mExtras = extras != null ? new Bundle(extras) : null; 9732 return this; 9733 } 9734 9735 /** 9736 * Remove extended data from the intent. 9737 * 9738 * @see #putExtra 9739 */ removeExtra(String name)9740 public void removeExtra(String name) { 9741 if (mExtras != null) { 9742 mExtras.remove(name); 9743 if (mExtras.size() == 0) { 9744 mExtras = null; 9745 } 9746 } 9747 } 9748 9749 /** 9750 * Set special flags controlling how this intent is handled. Most values 9751 * here depend on the type of component being executed by the Intent, 9752 * specifically the FLAG_ACTIVITY_* flags are all for use with 9753 * {@link Context#startActivity Context.startActivity()} and the 9754 * FLAG_RECEIVER_* flags are all for use with 9755 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. 9756 * 9757 * <p>See the 9758 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 9759 * Stack</a> documentation for important information on how some of these options impact 9760 * the behavior of your application. 9761 * 9762 * @param flags The desired flags. 9763 * @return Returns the same Intent object, for chaining multiple calls 9764 * into a single statement. 9765 * @see #getFlags 9766 * @see #addFlags 9767 * @see #removeFlags 9768 */ setFlags(@lags int flags)9769 public @NonNull Intent setFlags(@Flags int flags) { 9770 mFlags = flags; 9771 return this; 9772 } 9773 9774 /** 9775 * Add additional flags to the intent (or with existing flags value). 9776 * 9777 * @param flags The new flags to set. 9778 * @return Returns the same Intent object, for chaining multiple calls into 9779 * a single statement. 9780 * @see #setFlags 9781 * @see #getFlags 9782 * @see #removeFlags 9783 */ addFlags(@lags int flags)9784 public @NonNull Intent addFlags(@Flags int flags) { 9785 mFlags |= flags; 9786 return this; 9787 } 9788 9789 /** 9790 * Remove these flags from the intent. 9791 * 9792 * @param flags The flags to remove. 9793 * @see #setFlags 9794 * @see #getFlags 9795 * @see #addFlags 9796 */ removeFlags(@lags int flags)9797 public void removeFlags(@Flags int flags) { 9798 mFlags &= ~flags; 9799 } 9800 9801 /** 9802 * (Usually optional) Set an explicit application package name that limits 9803 * the components this Intent will resolve to. If left to the default 9804 * value of null, all components in all applications will considered. 9805 * If non-null, the Intent can only match the components in the given 9806 * application package. 9807 * 9808 * @param packageName The name of the application package to handle the 9809 * intent, or null to allow any application package. 9810 * 9811 * @return Returns the same Intent object, for chaining multiple calls 9812 * into a single statement. 9813 * 9814 * @see #getPackage 9815 * @see #resolveActivity 9816 */ setPackage(@ullable String packageName)9817 public @NonNull Intent setPackage(@Nullable String packageName) { 9818 if (packageName != null && mSelector != null) { 9819 throw new IllegalArgumentException( 9820 "Can't set package name when selector is already set"); 9821 } 9822 mPackage = packageName; 9823 return this; 9824 } 9825 9826 /** 9827 * (Usually optional) Explicitly set the component to handle the intent. 9828 * If left with the default value of null, the system will determine the 9829 * appropriate class to use based on the other fields (action, data, 9830 * type, categories) in the Intent. If this class is defined, the 9831 * specified class will always be used regardless of the other fields. You 9832 * should only set this value when you know you absolutely want a specific 9833 * class to be used; otherwise it is better to let the system find the 9834 * appropriate class so that you will respect the installed applications 9835 * and user preferences. 9836 * 9837 * @param component The name of the application component to handle the 9838 * intent, or null to let the system find one for you. 9839 * 9840 * @return Returns the same Intent object, for chaining multiple calls 9841 * into a single statement. 9842 * 9843 * @see #setClass 9844 * @see #setClassName(Context, String) 9845 * @see #setClassName(String, String) 9846 * @see #getComponent 9847 * @see #resolveActivity 9848 */ setComponent(@ullable ComponentName component)9849 public @NonNull Intent setComponent(@Nullable ComponentName component) { 9850 mComponent = component; 9851 return this; 9852 } 9853 9854 /** 9855 * Convenience for calling {@link #setComponent} with an 9856 * explicit class name. 9857 * 9858 * @param packageContext A Context of the application package implementing 9859 * this class. 9860 * @param className The name of a class inside of the application package 9861 * that will be used as the component for this Intent. 9862 * 9863 * @return Returns the same Intent object, for chaining multiple calls 9864 * into a single statement. 9865 * 9866 * @see #setComponent 9867 * @see #setClass 9868 */ setClassName(@onNull Context packageContext, @NonNull String className)9869 public @NonNull Intent setClassName(@NonNull Context packageContext, 9870 @NonNull String className) { 9871 mComponent = new ComponentName(packageContext, className); 9872 return this; 9873 } 9874 9875 /** 9876 * Convenience for calling {@link #setComponent} with an 9877 * explicit application package name and class name. 9878 * 9879 * @param packageName The name of the package implementing the desired 9880 * component. 9881 * @param className The name of a class inside of the application package 9882 * that will be used as the component for this Intent. 9883 * 9884 * @return Returns the same Intent object, for chaining multiple calls 9885 * into a single statement. 9886 * 9887 * @see #setComponent 9888 * @see #setClass 9889 */ setClassName(@onNull String packageName, @NonNull String className)9890 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) { 9891 mComponent = new ComponentName(packageName, className); 9892 return this; 9893 } 9894 9895 /** 9896 * Convenience for calling {@link #setComponent(ComponentName)} with the 9897 * name returned by a {@link Class} object. 9898 * 9899 * @param packageContext A Context of the application package implementing 9900 * this class. 9901 * @param cls The class name to set, equivalent to 9902 * <code>setClassName(context, cls.getName())</code>. 9903 * 9904 * @return Returns the same Intent object, for chaining multiple calls 9905 * into a single statement. 9906 * 9907 * @see #setComponent 9908 */ setClass(@onNull Context packageContext, @NonNull Class<?> cls)9909 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) { 9910 mComponent = new ComponentName(packageContext, cls); 9911 return this; 9912 } 9913 9914 /** 9915 * Set the bounds of the sender of this intent, in screen coordinates. This can be 9916 * used as a hint to the receiver for animations and the like. Null means that there 9917 * is no source bounds. 9918 */ setSourceBounds(@ullable Rect r)9919 public void setSourceBounds(@Nullable Rect r) { 9920 if (r != null) { 9921 mSourceBounds = new Rect(r); 9922 } else { 9923 mSourceBounds = null; 9924 } 9925 } 9926 9927 /** @hide */ 9928 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = { 9929 FILL_IN_ACTION, 9930 FILL_IN_DATA, 9931 FILL_IN_CATEGORIES, 9932 FILL_IN_COMPONENT, 9933 FILL_IN_PACKAGE, 9934 FILL_IN_SOURCE_BOUNDS, 9935 FILL_IN_SELECTOR, 9936 FILL_IN_CLIP_DATA 9937 }) 9938 @Retention(RetentionPolicy.SOURCE) 9939 public @interface FillInFlags {} 9940 9941 /** 9942 * Use with {@link #fillIn} to allow the current action value to be 9943 * overwritten, even if it is already set. 9944 */ 9945 public static final int FILL_IN_ACTION = 1<<0; 9946 9947 /** 9948 * Use with {@link #fillIn} to allow the current data or type value 9949 * overwritten, even if it is already set. 9950 */ 9951 public static final int FILL_IN_DATA = 1<<1; 9952 9953 /** 9954 * Use with {@link #fillIn} to allow the current categories to be 9955 * overwritten, even if they are already set. 9956 */ 9957 public static final int FILL_IN_CATEGORIES = 1<<2; 9958 9959 /** 9960 * Use with {@link #fillIn} to allow the current component value to be 9961 * overwritten, even if it is already set. 9962 */ 9963 public static final int FILL_IN_COMPONENT = 1<<3; 9964 9965 /** 9966 * Use with {@link #fillIn} to allow the current package value to be 9967 * overwritten, even if it is already set. 9968 */ 9969 public static final int FILL_IN_PACKAGE = 1<<4; 9970 9971 /** 9972 * Use with {@link #fillIn} to allow the current bounds rectangle to be 9973 * overwritten, even if it is already set. 9974 */ 9975 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; 9976 9977 /** 9978 * Use with {@link #fillIn} to allow the current selector to be 9979 * overwritten, even if it is already set. 9980 */ 9981 public static final int FILL_IN_SELECTOR = 1<<6; 9982 9983 /** 9984 * Use with {@link #fillIn} to allow the current ClipData to be 9985 * overwritten, even if it is already set. 9986 */ 9987 public static final int FILL_IN_CLIP_DATA = 1<<7; 9988 9989 /** 9990 * Use with {@link #fillIn} to allow the current identifier value to be 9991 * overwritten, even if it is already set. 9992 */ 9993 public static final int FILL_IN_IDENTIFIER = 1<<8; 9994 9995 /** 9996 * Copy the contents of <var>other</var> in to this object, but only 9997 * where fields are not defined by this object. For purposes of a field 9998 * being defined, the following pieces of data in the Intent are 9999 * considered to be separate fields: 10000 * 10001 * <ul> 10002 * <li> action, as set by {@link #setAction}. 10003 * <li> data Uri and MIME type, as set by {@link #setData(Uri)}, 10004 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. 10005 * <li> identifier, as set by {@link #setIdentifier}. 10006 * <li> categories, as set by {@link #addCategory}. 10007 * <li> package, as set by {@link #setPackage}. 10008 * <li> component, as set by {@link #setComponent(ComponentName)} or 10009 * related methods. 10010 * <li> source bounds, as set by {@link #setSourceBounds}. 10011 * <li> selector, as set by {@link #setSelector(Intent)}. 10012 * <li> clip data, as set by {@link #setClipData(ClipData)}. 10013 * <li> each top-level name in the associated extras. 10014 * </ul> 10015 * 10016 * <p>In addition, you can use the {@link #FILL_IN_ACTION}, 10017 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES}, 10018 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 10019 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override 10020 * the restriction where the corresponding field will not be replaced if 10021 * it is already set. 10022 * 10023 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} 10024 * is explicitly specified. The selector will only be copied if 10025 * {@link #FILL_IN_SELECTOR} is explicitly specified. 10026 * 10027 * <p>For example, consider Intent A with {data="foo", categories="bar"} 10028 * and Intent B with {action="gotit", data-type="some/thing", 10029 * categories="one","two"}. 10030 * 10031 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now 10032 * containing: {action="gotit", data-type="some/thing", 10033 * categories="bar"}. 10034 * 10035 * @param other Another Intent whose values are to be used to fill in 10036 * the current one. 10037 * @param flags Options to control which fields can be filled in. 10038 * 10039 * @return Returns a bit mask of {@link #FILL_IN_ACTION}, 10040 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 10041 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 10042 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were 10043 * changed. 10044 */ 10045 @FillInFlags fillIn(@onNull Intent other, @FillInFlags int flags)10046 public int fillIn(@NonNull Intent other, @FillInFlags int flags) { 10047 int changes = 0; 10048 boolean mayHaveCopiedUris = false; 10049 if (other.mAction != null 10050 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { 10051 mAction = other.mAction; 10052 changes |= FILL_IN_ACTION; 10053 } 10054 if ((other.mData != null || other.mType != null) 10055 && ((mData == null && mType == null) 10056 || (flags&FILL_IN_DATA) != 0)) { 10057 mData = other.mData; 10058 mType = other.mType; 10059 changes |= FILL_IN_DATA; 10060 mayHaveCopiedUris = true; 10061 } 10062 if (other.mIdentifier != null 10063 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) { 10064 mIdentifier = other.mIdentifier; 10065 changes |= FILL_IN_IDENTIFIER; 10066 } 10067 if (other.mCategories != null 10068 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { 10069 if (other.mCategories != null) { 10070 mCategories = new ArraySet<String>(other.mCategories); 10071 } 10072 changes |= FILL_IN_CATEGORIES; 10073 } 10074 if (other.mPackage != null 10075 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { 10076 // Only do this if mSelector is not set. 10077 if (mSelector == null) { 10078 mPackage = other.mPackage; 10079 changes |= FILL_IN_PACKAGE; 10080 } 10081 } 10082 // Selector is special: it can only be set if explicitly allowed, 10083 // for the same reason as the component name. 10084 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { 10085 if (mPackage == null) { 10086 mSelector = new Intent(other.mSelector); 10087 mPackage = null; 10088 changes |= FILL_IN_SELECTOR; 10089 } 10090 } 10091 if (other.mClipData != null 10092 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { 10093 mClipData = other.mClipData; 10094 changes |= FILL_IN_CLIP_DATA; 10095 mayHaveCopiedUris = true; 10096 } 10097 // Component is special: it can -only- be set if explicitly allowed, 10098 // since otherwise the sender could force the intent somewhere the 10099 // originator didn't intend. 10100 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { 10101 mComponent = other.mComponent; 10102 changes |= FILL_IN_COMPONENT; 10103 } 10104 mFlags |= other.mFlags; 10105 if (other.mSourceBounds != null 10106 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { 10107 mSourceBounds = new Rect(other.mSourceBounds); 10108 changes |= FILL_IN_SOURCE_BOUNDS; 10109 } 10110 if (mExtras == null) { 10111 if (other.mExtras != null) { 10112 mExtras = new Bundle(other.mExtras); 10113 mayHaveCopiedUris = true; 10114 } 10115 } else if (other.mExtras != null) { 10116 try { 10117 Bundle newb = new Bundle(other.mExtras); 10118 newb.putAll(mExtras); 10119 mExtras = newb; 10120 mayHaveCopiedUris = true; 10121 } catch (RuntimeException e) { 10122 // Modifying the extras can cause us to unparcel the contents 10123 // of the bundle, and if we do this in the system process that 10124 // may fail. We really should handle this (i.e., the Bundle 10125 // impl shouldn't be on top of a plain map), but for now just 10126 // ignore it and keep the original contents. :( 10127 Log.w(TAG, "Failure filling in extras", e); 10128 } 10129 } 10130 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT 10131 && other.mContentUserHint != UserHandle.USER_CURRENT) { 10132 mContentUserHint = other.mContentUserHint; 10133 } 10134 return changes; 10135 } 10136 10137 /** 10138 * Wrapper class holding an Intent and implementing comparisons on it for 10139 * the purpose of filtering. The class implements its 10140 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as 10141 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and 10142 * {@link android.content.Intent#filterHashCode()} filterHashCode()} 10143 * on the wrapped Intent. 10144 */ 10145 public static final class FilterComparison { 10146 private final Intent mIntent; 10147 private final int mHashCode; 10148 FilterComparison(Intent intent)10149 public FilterComparison(Intent intent) { 10150 mIntent = intent; 10151 mHashCode = intent.filterHashCode(); 10152 } 10153 10154 /** 10155 * Return the Intent that this FilterComparison represents. 10156 * @return Returns the Intent held by the FilterComparison. Do 10157 * not modify! 10158 */ getIntent()10159 public Intent getIntent() { 10160 return mIntent; 10161 } 10162 10163 @Override equals(Object obj)10164 public boolean equals(Object obj) { 10165 if (obj instanceof FilterComparison) { 10166 Intent other = ((FilterComparison)obj).mIntent; 10167 return mIntent.filterEquals(other); 10168 } 10169 return false; 10170 } 10171 10172 @Override hashCode()10173 public int hashCode() { 10174 return mHashCode; 10175 } 10176 } 10177 10178 /** 10179 * Determine if two intents are the same for the purposes of intent 10180 * resolution (filtering). That is, if their action, data, type, identity, 10181 * class, and categories are the same. This does <em>not</em> compare 10182 * any extra data included in the intents. Note that technically when actually 10183 * matching against an {@link IntentFilter} the identifier is ignored, while here 10184 * it is directly compared for equality like the other fields. 10185 * 10186 * @param other The other Intent to compare against. 10187 * 10188 * @return Returns true if action, data, type, class, and categories 10189 * are the same. 10190 */ filterEquals(Intent other)10191 public boolean filterEquals(Intent other) { 10192 if (other == null) { 10193 return false; 10194 } 10195 if (!Objects.equals(this.mAction, other.mAction)) return false; 10196 if (!Objects.equals(this.mData, other.mData)) return false; 10197 if (!Objects.equals(this.mType, other.mType)) return false; 10198 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false; 10199 if (!Objects.equals(this.mPackage, other.mPackage)) return false; 10200 if (!Objects.equals(this.mComponent, other.mComponent)) return false; 10201 if (!Objects.equals(this.mCategories, other.mCategories)) return false; 10202 10203 return true; 10204 } 10205 10206 /** 10207 * Generate hash code that matches semantics of filterEquals(). 10208 * 10209 * @return Returns the hash value of the action, data, type, class, and 10210 * categories. 10211 * 10212 * @see #filterEquals 10213 */ filterHashCode()10214 public int filterHashCode() { 10215 int code = 0; 10216 if (mAction != null) { 10217 code += mAction.hashCode(); 10218 } 10219 if (mData != null) { 10220 code += mData.hashCode(); 10221 } 10222 if (mType != null) { 10223 code += mType.hashCode(); 10224 } 10225 if (mIdentifier != null) { 10226 code += mIdentifier.hashCode(); 10227 } 10228 if (mPackage != null) { 10229 code += mPackage.hashCode(); 10230 } 10231 if (mComponent != null) { 10232 code += mComponent.hashCode(); 10233 } 10234 if (mCategories != null) { 10235 code += mCategories.hashCode(); 10236 } 10237 return code; 10238 } 10239 10240 @Override toString()10241 public String toString() { 10242 StringBuilder b = new StringBuilder(128); 10243 10244 b.append("Intent { "); 10245 toShortString(b, true, true, true, false); 10246 b.append(" }"); 10247 10248 return b.toString(); 10249 } 10250 10251 /** @hide */ 10252 @UnsupportedAppUsage toInsecureString()10253 public String toInsecureString() { 10254 StringBuilder b = new StringBuilder(128); 10255 10256 b.append("Intent { "); 10257 toShortString(b, false, true, true, false); 10258 b.append(" }"); 10259 10260 return b.toString(); 10261 } 10262 10263 /** @hide */ toInsecureStringWithClip()10264 public String toInsecureStringWithClip() { 10265 StringBuilder b = new StringBuilder(128); 10266 10267 b.append("Intent { "); 10268 toShortString(b, false, true, true, true); 10269 b.append(" }"); 10270 10271 return b.toString(); 10272 } 10273 10274 /** @hide */ toShortString(boolean secure, boolean comp, boolean extras, boolean clip)10275 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { 10276 StringBuilder b = new StringBuilder(128); 10277 toShortString(b, secure, comp, extras, clip); 10278 return b.toString(); 10279 } 10280 10281 /** @hide */ toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)10282 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, 10283 boolean clip) { 10284 boolean first = true; 10285 if (mAction != null) { 10286 b.append("act=").append(mAction); 10287 first = false; 10288 } 10289 if (mCategories != null) { 10290 if (!first) { 10291 b.append(' '); 10292 } 10293 first = false; 10294 b.append("cat=["); 10295 for (int i=0; i<mCategories.size(); i++) { 10296 if (i > 0) b.append(','); 10297 b.append(mCategories.valueAt(i)); 10298 } 10299 b.append("]"); 10300 } 10301 if (mData != null) { 10302 if (!first) { 10303 b.append(' '); 10304 } 10305 first = false; 10306 b.append("dat="); 10307 if (secure) { 10308 b.append(mData.toSafeString()); 10309 } else { 10310 b.append(mData); 10311 } 10312 } 10313 if (mType != null) { 10314 if (!first) { 10315 b.append(' '); 10316 } 10317 first = false; 10318 b.append("typ=").append(mType); 10319 } 10320 if (mIdentifier != null) { 10321 if (!first) { 10322 b.append(' '); 10323 } 10324 first = false; 10325 b.append("id=").append(mIdentifier); 10326 } 10327 if (mFlags != 0) { 10328 if (!first) { 10329 b.append(' '); 10330 } 10331 first = false; 10332 b.append("flg=0x").append(Integer.toHexString(mFlags)); 10333 } 10334 if (mPackage != null) { 10335 if (!first) { 10336 b.append(' '); 10337 } 10338 first = false; 10339 b.append("pkg=").append(mPackage); 10340 } 10341 if (comp && mComponent != null) { 10342 if (!first) { 10343 b.append(' '); 10344 } 10345 first = false; 10346 b.append("cmp=").append(mComponent.flattenToShortString()); 10347 } 10348 if (mSourceBounds != null) { 10349 if (!first) { 10350 b.append(' '); 10351 } 10352 first = false; 10353 b.append("bnds=").append(mSourceBounds.toShortString()); 10354 } 10355 if (mClipData != null) { 10356 if (!first) { 10357 b.append(' '); 10358 } 10359 b.append("clip={"); 10360 if (clip) { 10361 mClipData.toShortString(b); 10362 } else { 10363 if (mClipData.getDescription() != null) { 10364 first = !mClipData.getDescription().toShortStringTypesOnly(b); 10365 } else { 10366 first = true; 10367 } 10368 mClipData.toShortStringShortItems(b, first); 10369 } 10370 first = false; 10371 b.append('}'); 10372 } 10373 if (extras && mExtras != null) { 10374 if (!first) { 10375 b.append(' '); 10376 } 10377 first = false; 10378 b.append("(has extras)"); 10379 } 10380 if (mContentUserHint != UserHandle.USER_CURRENT) { 10381 if (!first) { 10382 b.append(' '); 10383 } 10384 first = false; 10385 b.append("u=").append(mContentUserHint); 10386 } 10387 if (mSelector != null) { 10388 b.append(" sel="); 10389 mSelector.toShortString(b, secure, comp, extras, clip); 10390 b.append("}"); 10391 } 10392 } 10393 10394 /** @hide */ writeToProto(ProtoOutputStream proto, long fieldId)10395 public void writeToProto(ProtoOutputStream proto, long fieldId) { 10396 // Same input parameters that toString() gives to toShortString(). 10397 writeToProto(proto, fieldId, true, true, true, false); 10398 } 10399 10400 /** @hide */ writeToProto(ProtoOutputStream proto)10401 public void writeToProto(ProtoOutputStream proto) { 10402 // Same input parameters that toString() gives to toShortString(). 10403 writeToProtoWithoutFieldId(proto, true, true, true, false); 10404 } 10405 10406 /** @hide */ writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)10407 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, 10408 boolean extras, boolean clip) { 10409 long token = proto.start(fieldId); 10410 writeToProtoWithoutFieldId(proto, secure, comp, extras, clip); 10411 proto.end(token); 10412 } 10413 writeToProtoWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)10414 private void writeToProtoWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, 10415 boolean extras, boolean clip) { 10416 if (mAction != null) { 10417 proto.write(IntentProto.ACTION, mAction); 10418 } 10419 if (mCategories != null) { 10420 for (String category : mCategories) { 10421 proto.write(IntentProto.CATEGORIES, category); 10422 } 10423 } 10424 if (mData != null) { 10425 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString()); 10426 } 10427 if (mType != null) { 10428 proto.write(IntentProto.TYPE, mType); 10429 } 10430 if (mIdentifier != null) { 10431 proto.write(IntentProto.IDENTIFIER, mIdentifier); 10432 } 10433 if (mFlags != 0) { 10434 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags)); 10435 } 10436 if (mPackage != null) { 10437 proto.write(IntentProto.PACKAGE, mPackage); 10438 } 10439 if (comp && mComponent != null) { 10440 mComponent.writeToProto(proto, IntentProto.COMPONENT); 10441 } 10442 if (mSourceBounds != null) { 10443 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString()); 10444 } 10445 if (mClipData != null) { 10446 StringBuilder b = new StringBuilder(); 10447 if (clip) { 10448 mClipData.toShortString(b); 10449 } else { 10450 mClipData.toShortStringShortItems(b, false); 10451 } 10452 proto.write(IntentProto.CLIP_DATA, b.toString()); 10453 } 10454 if (extras && mExtras != null) { 10455 proto.write(IntentProto.EXTRAS, mExtras.toShortString()); 10456 } 10457 if (mContentUserHint != 0) { 10458 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint); 10459 } 10460 if (mSelector != null) { 10461 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip)); 10462 } 10463 } 10464 10465 /** 10466 * Call {@link #toUri} with 0 flags. 10467 * @deprecated Use {@link #toUri} instead. 10468 */ 10469 @Deprecated toURI()10470 public String toURI() { 10471 return toUri(0); 10472 } 10473 10474 /** 10475 * Convert this Intent into a String holding a URI representation of it. 10476 * The returned URI string has been properly URI encoded, so it can be 10477 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the 10478 * Intent's data as the base URI, with an additional fragment describing 10479 * the action, categories, type, flags, package, component, and extras. 10480 * 10481 * <p>You can convert the returned string back to an Intent with 10482 * {@link #getIntent}. 10483 * 10484 * @param flags Additional operating flags. 10485 * 10486 * @return Returns a URI encoding URI string describing the entire contents 10487 * of the Intent. 10488 */ toUri(@riFlags int flags)10489 public String toUri(@UriFlags int flags) { 10490 StringBuilder uri = new StringBuilder(128); 10491 if ((flags&URI_ANDROID_APP_SCHEME) != 0) { 10492 if (mPackage == null) { 10493 throw new IllegalArgumentException( 10494 "Intent must include an explicit package name to build an android-app: " 10495 + this); 10496 } 10497 uri.append("android-app://"); 10498 uri.append(mPackage); 10499 String scheme = null; 10500 if (mData != null) { 10501 scheme = mData.getScheme(); 10502 if (scheme != null) { 10503 uri.append('/'); 10504 uri.append(scheme); 10505 String authority = mData.getEncodedAuthority(); 10506 if (authority != null) { 10507 uri.append('/'); 10508 uri.append(authority); 10509 String path = mData.getEncodedPath(); 10510 if (path != null) { 10511 uri.append(path); 10512 } 10513 String queryParams = mData.getEncodedQuery(); 10514 if (queryParams != null) { 10515 uri.append('?'); 10516 uri.append(queryParams); 10517 } 10518 String fragment = mData.getEncodedFragment(); 10519 if (fragment != null) { 10520 uri.append('#'); 10521 uri.append(fragment); 10522 } 10523 } 10524 } 10525 } 10526 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, 10527 mPackage, flags); 10528 return uri.toString(); 10529 } 10530 String scheme = null; 10531 if (mData != null) { 10532 String data = mData.toString(); 10533 if ((flags&URI_INTENT_SCHEME) != 0) { 10534 final int N = data.length(); 10535 for (int i=0; i<N; i++) { 10536 char c = data.charAt(i); 10537 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 10538 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') { 10539 continue; 10540 } 10541 if (c == ':' && i > 0) { 10542 // Valid scheme. 10543 scheme = data.substring(0, i); 10544 uri.append("intent:"); 10545 data = data.substring(i+1); 10546 break; 10547 } 10548 10549 // No scheme. 10550 break; 10551 } 10552 } 10553 uri.append(data); 10554 10555 } else if ((flags&URI_INTENT_SCHEME) != 0) { 10556 uri.append("intent:"); 10557 } 10558 10559 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); 10560 10561 return uri.toString(); 10562 } 10563 toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10564 private void toUriFragment(StringBuilder uri, String scheme, String defAction, 10565 String defPackage, int flags) { 10566 StringBuilder frag = new StringBuilder(128); 10567 10568 toUriInner(frag, scheme, defAction, defPackage, flags); 10569 if (mSelector != null) { 10570 frag.append("SEL;"); 10571 // Note that for now we are not going to try to handle the 10572 // data part; not clear how to represent this as a URI, and 10573 // not much utility in it. 10574 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, 10575 null, null, flags); 10576 } 10577 10578 if (frag.length() > 0) { 10579 uri.append("#Intent;"); 10580 uri.append(frag); 10581 uri.append("end"); 10582 } 10583 } 10584 toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10585 private void toUriInner(StringBuilder uri, String scheme, String defAction, 10586 String defPackage, int flags) { 10587 if (scheme != null) { 10588 uri.append("scheme=").append(scheme).append(';'); 10589 } 10590 if (mAction != null && !mAction.equals(defAction)) { 10591 uri.append("action=").append(Uri.encode(mAction)).append(';'); 10592 } 10593 if (mCategories != null) { 10594 for (int i=0; i<mCategories.size(); i++) { 10595 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';'); 10596 } 10597 } 10598 if (mType != null) { 10599 uri.append("type=").append(Uri.encode(mType, "/")).append(';'); 10600 } 10601 if (mIdentifier != null) { 10602 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';'); 10603 } 10604 if (mFlags != 0) { 10605 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); 10606 } 10607 if (mPackage != null && !mPackage.equals(defPackage)) { 10608 uri.append("package=").append(Uri.encode(mPackage)).append(';'); 10609 } 10610 if (mComponent != null) { 10611 uri.append("component=").append(Uri.encode( 10612 mComponent.flattenToShortString(), "/")).append(';'); 10613 } 10614 if (mSourceBounds != null) { 10615 uri.append("sourceBounds=") 10616 .append(Uri.encode(mSourceBounds.flattenToString())) 10617 .append(';'); 10618 } 10619 if (mExtras != null) { 10620 for (String key : mExtras.keySet()) { 10621 final Object value = mExtras.get(key); 10622 char entryType = 10623 value instanceof String ? 'S' : 10624 value instanceof Boolean ? 'B' : 10625 value instanceof Byte ? 'b' : 10626 value instanceof Character ? 'c' : 10627 value instanceof Double ? 'd' : 10628 value instanceof Float ? 'f' : 10629 value instanceof Integer ? 'i' : 10630 value instanceof Long ? 'l' : 10631 value instanceof Short ? 's' : 10632 '\0'; 10633 10634 if (entryType != '\0') { 10635 uri.append(entryType); 10636 uri.append('.'); 10637 uri.append(Uri.encode(key)); 10638 uri.append('='); 10639 uri.append(Uri.encode(value.toString())); 10640 uri.append(';'); 10641 } 10642 } 10643 } 10644 } 10645 describeContents()10646 public int describeContents() { 10647 return (mExtras != null) ? mExtras.describeContents() : 0; 10648 } 10649 writeToParcel(Parcel out, int flags)10650 public void writeToParcel(Parcel out, int flags) { 10651 out.writeString(mAction); 10652 Uri.writeToParcel(out, mData); 10653 out.writeString(mType); 10654 out.writeString(mIdentifier); 10655 out.writeInt(mFlags); 10656 out.writeString(mPackage); 10657 ComponentName.writeToParcel(mComponent, out); 10658 10659 if (mSourceBounds != null) { 10660 out.writeInt(1); 10661 mSourceBounds.writeToParcel(out, flags); 10662 } else { 10663 out.writeInt(0); 10664 } 10665 10666 if (mCategories != null) { 10667 final int N = mCategories.size(); 10668 out.writeInt(N); 10669 for (int i=0; i<N; i++) { 10670 out.writeString(mCategories.valueAt(i)); 10671 } 10672 } else { 10673 out.writeInt(0); 10674 } 10675 10676 if (mSelector != null) { 10677 out.writeInt(1); 10678 mSelector.writeToParcel(out, flags); 10679 } else { 10680 out.writeInt(0); 10681 } 10682 10683 if (mClipData != null) { 10684 out.writeInt(1); 10685 mClipData.writeToParcel(out, flags); 10686 } else { 10687 out.writeInt(0); 10688 } 10689 out.writeInt(mContentUserHint); 10690 out.writeBundle(mExtras); 10691 } 10692 10693 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR 10694 = new Parcelable.Creator<Intent>() { 10695 public Intent createFromParcel(Parcel in) { 10696 return new Intent(in); 10697 } 10698 public Intent[] newArray(int size) { 10699 return new Intent[size]; 10700 } 10701 }; 10702 10703 /** @hide */ Intent(Parcel in)10704 protected Intent(Parcel in) { 10705 readFromParcel(in); 10706 } 10707 readFromParcel(Parcel in)10708 public void readFromParcel(Parcel in) { 10709 setAction(in.readString()); 10710 mData = Uri.CREATOR.createFromParcel(in); 10711 mType = in.readString(); 10712 mIdentifier = in.readString(); 10713 mFlags = in.readInt(); 10714 mPackage = in.readString(); 10715 mComponent = ComponentName.readFromParcel(in); 10716 10717 if (in.readInt() != 0) { 10718 mSourceBounds = Rect.CREATOR.createFromParcel(in); 10719 } 10720 10721 int N = in.readInt(); 10722 if (N > 0) { 10723 mCategories = new ArraySet<String>(); 10724 int i; 10725 for (i=0; i<N; i++) { 10726 mCategories.add(in.readString().intern()); 10727 } 10728 } else { 10729 mCategories = null; 10730 } 10731 10732 if (in.readInt() != 0) { 10733 mSelector = new Intent(in); 10734 } 10735 10736 if (in.readInt() != 0) { 10737 mClipData = new ClipData(in); 10738 } 10739 mContentUserHint = in.readInt(); 10740 mExtras = in.readBundle(); 10741 } 10742 10743 /** 10744 * Parses the "intent" element (and its children) from XML and instantiates 10745 * an Intent object. The given XML parser should be located at the tag 10746 * where parsing should start (often named "intent"), from which the 10747 * basic action, data, type, and package and class name will be 10748 * retrieved. The function will then parse in to any child elements, 10749 * looking for <category android:name="xxx"> tags to add categories and 10750 * <extra android:name="xxx" android:value="yyy"> to attach extra data 10751 * to the intent. 10752 * 10753 * @param resources The Resources to use when inflating resources. 10754 * @param parser The XML parser pointing at an "intent" tag. 10755 * @param attrs The AttributeSet interface for retrieving extended 10756 * attribute data at the current <var>parser</var> location. 10757 * @return An Intent object matching the XML data. 10758 * @throws XmlPullParserException If there was an XML parsing error. 10759 * @throws IOException If there was an I/O error. 10760 */ parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)10761 public static @NonNull Intent parseIntent(@NonNull Resources resources, 10762 @NonNull XmlPullParser parser, AttributeSet attrs) 10763 throws XmlPullParserException, IOException { 10764 Intent intent = new Intent(); 10765 10766 TypedArray sa = resources.obtainAttributes(attrs, 10767 com.android.internal.R.styleable.Intent); 10768 10769 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); 10770 10771 String data = sa.getString(com.android.internal.R.styleable.Intent_data); 10772 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); 10773 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); 10774 10775 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier)); 10776 10777 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); 10778 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); 10779 if (packageName != null && className != null) { 10780 intent.setComponent(new ComponentName(packageName, className)); 10781 } 10782 10783 sa.recycle(); 10784 10785 int outerDepth = parser.getDepth(); 10786 int type; 10787 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 10788 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 10789 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 10790 continue; 10791 } 10792 10793 String nodeName = parser.getName(); 10794 if (nodeName.equals(TAG_CATEGORIES)) { 10795 sa = resources.obtainAttributes(attrs, 10796 com.android.internal.R.styleable.IntentCategory); 10797 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); 10798 sa.recycle(); 10799 10800 if (cat != null) { 10801 intent.addCategory(cat); 10802 } 10803 XmlUtils.skipCurrentTag(parser); 10804 10805 } else if (nodeName.equals(TAG_EXTRA)) { 10806 if (intent.mExtras == null) { 10807 intent.mExtras = new Bundle(); 10808 } 10809 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); 10810 XmlUtils.skipCurrentTag(parser); 10811 10812 } else { 10813 XmlUtils.skipCurrentTag(parser); 10814 } 10815 } 10816 10817 return intent; 10818 } 10819 10820 /** @hide */ saveToXml(XmlSerializer out)10821 public void saveToXml(XmlSerializer out) throws IOException { 10822 if (mAction != null) { 10823 out.attribute(null, ATTR_ACTION, mAction); 10824 } 10825 if (mData != null) { 10826 out.attribute(null, ATTR_DATA, mData.toString()); 10827 } 10828 if (mType != null) { 10829 out.attribute(null, ATTR_TYPE, mType); 10830 } 10831 if (mIdentifier != null) { 10832 out.attribute(null, ATTR_IDENTIFIER, mIdentifier); 10833 } 10834 if (mComponent != null) { 10835 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); 10836 } 10837 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); 10838 10839 if (mCategories != null) { 10840 out.startTag(null, TAG_CATEGORIES); 10841 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { 10842 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); 10843 } 10844 out.endTag(null, TAG_CATEGORIES); 10845 } 10846 } 10847 10848 /** @hide */ restoreFromXml(XmlPullParser in)10849 public static Intent restoreFromXml(XmlPullParser in) throws IOException, 10850 XmlPullParserException { 10851 Intent intent = new Intent(); 10852 final int outerDepth = in.getDepth(); 10853 10854 int attrCount = in.getAttributeCount(); 10855 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 10856 final String attrName = in.getAttributeName(attrNdx); 10857 final String attrValue = in.getAttributeValue(attrNdx); 10858 if (ATTR_ACTION.equals(attrName)) { 10859 intent.setAction(attrValue); 10860 } else if (ATTR_DATA.equals(attrName)) { 10861 intent.setData(Uri.parse(attrValue)); 10862 } else if (ATTR_TYPE.equals(attrName)) { 10863 intent.setType(attrValue); 10864 } else if (ATTR_IDENTIFIER.equals(attrName)) { 10865 intent.setIdentifier(attrValue); 10866 } else if (ATTR_COMPONENT.equals(attrName)) { 10867 intent.setComponent(ComponentName.unflattenFromString(attrValue)); 10868 } else if (ATTR_FLAGS.equals(attrName)) { 10869 intent.setFlags(Integer.parseInt(attrValue, 16)); 10870 } else { 10871 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName); 10872 } 10873 } 10874 10875 int event; 10876 String name; 10877 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && 10878 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { 10879 if (event == XmlPullParser.START_TAG) { 10880 name = in.getName(); 10881 if (TAG_CATEGORIES.equals(name)) { 10882 attrCount = in.getAttributeCount(); 10883 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 10884 intent.addCategory(in.getAttributeValue(attrNdx)); 10885 } 10886 } else { 10887 Log.w(TAG, "restoreFromXml: unknown name=" + name); 10888 XmlUtils.skipCurrentTag(in); 10889 } 10890 } 10891 } 10892 10893 return intent; 10894 } 10895 10896 /** 10897 * Normalize a MIME data type. 10898 * 10899 * <p>A normalized MIME type has white-space trimmed, 10900 * content-type parameters removed, and is lower-case. 10901 * This aligns the type with Android best practices for 10902 * intent filtering. 10903 * 10904 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". 10905 * "text/x-vCard" becomes "text/x-vcard". 10906 * 10907 * <p>All MIME types received from outside Android (such as user input, 10908 * or external sources like Bluetooth, NFC, or the Internet) should 10909 * be normalized before they are used to create an Intent. 10910 * 10911 * @param type MIME data type to normalize 10912 * @return normalized MIME data type, or null if the input was null 10913 * @see #setType 10914 * @see #setTypeAndNormalize 10915 */ normalizeMimeType(@ullable String type)10916 public static @Nullable String normalizeMimeType(@Nullable String type) { 10917 if (type == null) { 10918 return null; 10919 } 10920 10921 type = type.trim().toLowerCase(Locale.ROOT); 10922 10923 final int semicolonIndex = type.indexOf(';'); 10924 if (semicolonIndex != -1) { 10925 type = type.substring(0, semicolonIndex); 10926 } 10927 return type; 10928 } 10929 10930 /** 10931 * Prepare this {@link Intent} to leave an app process. 10932 * 10933 * @hide 10934 */ 10935 @UnsupportedAppUsage prepareToLeaveProcess(Context context)10936 public void prepareToLeaveProcess(Context context) { 10937 final boolean leavingPackage = (mComponent == null) 10938 || !Objects.equals(mComponent.getPackageName(), context.getPackageName()); 10939 prepareToLeaveProcess(leavingPackage); 10940 } 10941 10942 /** 10943 * Prepare this {@link Intent} to leave an app process. 10944 * 10945 * @hide 10946 */ prepareToLeaveProcess(boolean leavingPackage)10947 public void prepareToLeaveProcess(boolean leavingPackage) { 10948 setAllowFds(false); 10949 10950 if (mSelector != null) { 10951 mSelector.prepareToLeaveProcess(leavingPackage); 10952 } 10953 if (mClipData != null) { 10954 mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); 10955 } 10956 10957 if (mExtras != null && !mExtras.isParcelled()) { 10958 final Object intent = mExtras.get(Intent.EXTRA_INTENT); 10959 if (intent instanceof Intent) { 10960 ((Intent) intent).prepareToLeaveProcess(leavingPackage); 10961 } 10962 } 10963 10964 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() 10965 && leavingPackage) { 10966 switch (mAction) { 10967 case ACTION_MEDIA_REMOVED: 10968 case ACTION_MEDIA_UNMOUNTED: 10969 case ACTION_MEDIA_CHECKING: 10970 case ACTION_MEDIA_NOFS: 10971 case ACTION_MEDIA_MOUNTED: 10972 case ACTION_MEDIA_SHARED: 10973 case ACTION_MEDIA_UNSHARED: 10974 case ACTION_MEDIA_BAD_REMOVAL: 10975 case ACTION_MEDIA_UNMOUNTABLE: 10976 case ACTION_MEDIA_EJECT: 10977 case ACTION_MEDIA_SCANNER_STARTED: 10978 case ACTION_MEDIA_SCANNER_FINISHED: 10979 case ACTION_MEDIA_SCANNER_SCAN_FILE: 10980 case ACTION_PACKAGE_NEEDS_VERIFICATION: 10981 case ACTION_PACKAGE_VERIFIED: 10982 case ACTION_PACKAGE_ENABLE_ROLLBACK: 10983 // Ignore legacy actions 10984 break; 10985 default: 10986 mData.checkFileUriExposed("Intent.getData()"); 10987 } 10988 } 10989 10990 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() 10991 && leavingPackage) { 10992 switch (mAction) { 10993 case ACTION_PROVIDER_CHANGED: 10994 case QuickContact.ACTION_QUICK_CONTACT: 10995 // Ignore actions that don't need to grant 10996 break; 10997 default: 10998 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); 10999 } 11000 } 11001 11002 // Translate raw filesystem paths out of storage sandbox 11003 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null 11004 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) { 11005 final StorageManager sm = AppGlobals.getInitialApplication() 11006 .getSystemService(StorageManager.class); 11007 final File before = new File(mData.getPath()); 11008 final File after = sm.translateAppToSystem(before, 11009 android.os.Process.myPid(), android.os.Process.myUid()); 11010 if (!Objects.equals(before, after)) { 11011 Log.v(TAG, "Translated " + before + " to " + after); 11012 mData = Uri.fromFile(after); 11013 } 11014 } 11015 } 11016 11017 /** 11018 * @hide 11019 */ prepareToEnterProcess()11020 public void prepareToEnterProcess() { 11021 // We just entered destination process, so we should be able to read all 11022 // parcelables inside. 11023 setDefusable(true); 11024 11025 if (mSelector != null) { 11026 mSelector.prepareToEnterProcess(); 11027 } 11028 if (mClipData != null) { 11029 mClipData.prepareToEnterProcess(); 11030 } 11031 11032 if (mContentUserHint != UserHandle.USER_CURRENT) { 11033 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { 11034 fixUris(mContentUserHint); 11035 mContentUserHint = UserHandle.USER_CURRENT; 11036 } 11037 } 11038 } 11039 11040 /** @hide */ hasWebURI()11041 public boolean hasWebURI() { 11042 if (getData() == null) { 11043 return false; 11044 } 11045 final String scheme = getScheme(); 11046 if (TextUtils.isEmpty(scheme)) { 11047 return false; 11048 } 11049 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS); 11050 } 11051 11052 /** @hide */ isWebIntent()11053 public boolean isWebIntent() { 11054 return ACTION_VIEW.equals(mAction) 11055 && hasWebURI(); 11056 } 11057 11058 /** 11059 * @hide 11060 */ fixUris(int contentUserHint)11061 public void fixUris(int contentUserHint) { 11062 Uri data = getData(); 11063 if (data != null) { 11064 mData = maybeAddUserId(data, contentUserHint); 11065 } 11066 if (mClipData != null) { 11067 mClipData.fixUris(contentUserHint); 11068 } 11069 String action = getAction(); 11070 if (ACTION_SEND.equals(action)) { 11071 final Uri stream = getParcelableExtra(EXTRA_STREAM); 11072 if (stream != null) { 11073 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); 11074 } 11075 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 11076 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 11077 if (streams != null) { 11078 ArrayList<Uri> newStreams = new ArrayList<Uri>(); 11079 for (int i = 0; i < streams.size(); i++) { 11080 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); 11081 } 11082 putParcelableArrayListExtra(EXTRA_STREAM, newStreams); 11083 } 11084 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) 11085 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) 11086 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { 11087 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 11088 if (output != null) { 11089 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); 11090 } 11091 } 11092 } 11093 11094 /** 11095 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 11096 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 11097 * intents in {@link #ACTION_CHOOSER}. 11098 * 11099 * @return Whether any contents were migrated. 11100 * @hide 11101 */ migrateExtraStreamToClipData()11102 public boolean migrateExtraStreamToClipData() { 11103 // Refuse to touch if extras already parcelled 11104 if (mExtras != null && mExtras.isParcelled()) return false; 11105 11106 // Bail when someone already gave us ClipData 11107 if (getClipData() != null) return false; 11108 11109 final String action = getAction(); 11110 if (ACTION_CHOOSER.equals(action)) { 11111 // Inspect contained intents to see if we need to migrate extras. We 11112 // don't promote ClipData to the parent, since ChooserActivity will 11113 // already start the picked item as the caller, and we can't combine 11114 // the flags in a safe way. 11115 11116 boolean migrated = false; 11117 try { 11118 final Intent intent = getParcelableExtra(EXTRA_INTENT); 11119 if (intent != null) { 11120 migrated |= intent.migrateExtraStreamToClipData(); 11121 } 11122 } catch (ClassCastException e) { 11123 } 11124 try { 11125 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); 11126 if (intents != null) { 11127 for (int i = 0; i < intents.length; i++) { 11128 final Intent intent = (Intent) intents[i]; 11129 if (intent != null) { 11130 migrated |= intent.migrateExtraStreamToClipData(); 11131 } 11132 } 11133 } 11134 } catch (ClassCastException e) { 11135 } 11136 return migrated; 11137 11138 } else if (ACTION_SEND.equals(action)) { 11139 try { 11140 final Uri stream = getParcelableExtra(EXTRA_STREAM); 11141 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); 11142 final String htmlText = getStringExtra(EXTRA_HTML_TEXT); 11143 if (stream != null || text != null || htmlText != null) { 11144 final ClipData clipData = new ClipData( 11145 null, new String[] { getType() }, 11146 new ClipData.Item(text, htmlText, null, stream)); 11147 setClipData(clipData); 11148 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 11149 return true; 11150 } 11151 } catch (ClassCastException e) { 11152 } 11153 11154 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 11155 try { 11156 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 11157 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); 11158 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); 11159 int num = -1; 11160 if (streams != null) { 11161 num = streams.size(); 11162 } 11163 if (texts != null) { 11164 if (num >= 0 && num != texts.size()) { 11165 // Wha...! F- you. 11166 return false; 11167 } 11168 num = texts.size(); 11169 } 11170 if (htmlTexts != null) { 11171 if (num >= 0 && num != htmlTexts.size()) { 11172 // Wha...! F- you. 11173 return false; 11174 } 11175 num = htmlTexts.size(); 11176 } 11177 if (num > 0) { 11178 final ClipData clipData = new ClipData( 11179 null, new String[] { getType() }, 11180 makeClipItem(streams, texts, htmlTexts, 0)); 11181 11182 for (int i = 1; i < num; i++) { 11183 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); 11184 } 11185 11186 setClipData(clipData); 11187 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 11188 return true; 11189 } 11190 } catch (ClassCastException e) { 11191 } 11192 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) 11193 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) 11194 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { 11195 final Uri output; 11196 try { 11197 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 11198 } catch (ClassCastException e) { 11199 return false; 11200 } 11201 if (output != null) { 11202 setClipData(ClipData.newRawUri("", output)); 11203 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); 11204 return true; 11205 } 11206 } 11207 11208 return false; 11209 } 11210 11211 /** 11212 * Convert the dock state to a human readable format. 11213 * @hide 11214 */ dockStateToString(int dock)11215 public static String dockStateToString(int dock) { 11216 switch (dock) { 11217 case EXTRA_DOCK_STATE_HE_DESK: 11218 return "EXTRA_DOCK_STATE_HE_DESK"; 11219 case EXTRA_DOCK_STATE_LE_DESK: 11220 return "EXTRA_DOCK_STATE_LE_DESK"; 11221 case EXTRA_DOCK_STATE_CAR: 11222 return "EXTRA_DOCK_STATE_CAR"; 11223 case EXTRA_DOCK_STATE_DESK: 11224 return "EXTRA_DOCK_STATE_DESK"; 11225 case EXTRA_DOCK_STATE_UNDOCKED: 11226 return "EXTRA_DOCK_STATE_UNDOCKED"; 11227 default: 11228 return Integer.toString(dock); 11229 } 11230 } 11231 makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)11232 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, 11233 ArrayList<String> htmlTexts, int which) { 11234 Uri uri = streams != null ? streams.get(which) : null; 11235 CharSequence text = texts != null ? texts.get(which) : null; 11236 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; 11237 return new ClipData.Item(text, htmlText, null, uri); 11238 } 11239 11240 /** @hide */ isDocument()11241 public boolean isDocument() { 11242 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; 11243 } 11244 } 11245