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.SdkConstant; 27 import android.annotation.SdkConstant.SdkConstantType; 28 import android.annotation.SystemApi; 29 import android.content.pm.ActivityInfo; 30 import android.content.pm.ApplicationInfo; 31 import android.content.pm.ComponentInfo; 32 import android.content.pm.PackageManager; 33 import android.content.pm.ResolveInfo; 34 import android.content.res.Resources; 35 import android.content.res.TypedArray; 36 import android.graphics.Rect; 37 import android.net.Uri; 38 import android.os.Build; 39 import android.os.Bundle; 40 import android.os.IBinder; 41 import android.os.Parcel; 42 import android.os.Parcelable; 43 import android.os.PersistableBundle; 44 import android.os.Process; 45 import android.os.ResultReceiver; 46 import android.os.ShellCommand; 47 import android.os.StrictMode; 48 import android.os.UserHandle; 49 import android.provider.ContactsContract.QuickContact; 50 import android.provider.DocumentsContract; 51 import android.provider.DocumentsProvider; 52 import android.provider.MediaStore; 53 import android.provider.OpenableColumns; 54 import android.text.TextUtils; 55 import android.util.ArraySet; 56 import android.util.AttributeSet; 57 import android.util.Log; 58 import android.util.proto.ProtoOutputStream; 59 60 import com.android.internal.util.XmlUtils; 61 62 import org.xmlpull.v1.XmlPullParser; 63 import org.xmlpull.v1.XmlPullParserException; 64 import org.xmlpull.v1.XmlSerializer; 65 66 import java.io.IOException; 67 import java.io.PrintWriter; 68 import java.io.Serializable; 69 import java.lang.annotation.Retention; 70 import java.lang.annotation.RetentionPolicy; 71 import java.net.URISyntaxException; 72 import java.util.ArrayList; 73 import java.util.HashSet; 74 import java.util.List; 75 import java.util.Locale; 76 import java.util.Objects; 77 import java.util.Set; 78 79 /** 80 * An intent is an abstract description of an operation to be performed. It 81 * can be used with {@link Context#startActivity(Intent) startActivity} to 82 * launch an {@link android.app.Activity}, 83 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to 84 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, 85 * and {@link android.content.Context#startService} or 86 * {@link android.content.Context#bindService} to communicate with a 87 * background {@link android.app.Service}. 88 * 89 * <p>An Intent provides a facility for performing late runtime binding between the code in 90 * different applications. Its most significant use is in the launching of activities, where it 91 * can be thought of as the glue between activities. It is basically a passive data structure 92 * holding an abstract description of an action to be performed.</p> 93 * 94 * <div class="special reference"> 95 * <h3>Developer Guides</h3> 96 * <p>For information about how to create and resolve intents, read the 97 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> 98 * developer guide.</p> 99 * </div> 100 * 101 * <a name="IntentStructure"></a> 102 * <h3>Intent Structure</h3> 103 * <p>The primary pieces of information in an intent are:</p> 104 * 105 * <ul> 106 * <li> <p><b>action</b> -- The general action to be performed, such as 107 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, 108 * etc.</p> 109 * </li> 110 * <li> <p><b>data</b> -- The data to operate on, such as a person record 111 * in the contacts database, expressed as a {@link android.net.Uri}.</p> 112 * </li> 113 * </ul> 114 * 115 * 116 * <p>Some examples of action/data pairs are:</p> 117 * 118 * <ul> 119 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display 120 * information about the person whose identifier is "1".</p> 121 * </li> 122 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display 123 * the phone dialer with the person filled in.</p> 124 * </li> 125 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display 126 * the phone dialer with the given number filled in. Note how the 127 * VIEW action does what is considered the most reasonable thing for 128 * a particular URI.</p> 129 * </li> 130 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display 131 * the phone dialer with the given number filled in.</p> 132 * </li> 133 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit 134 * information about the person whose identifier is "1".</p> 135 * </li> 136 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display 137 * a list of people, which the user can browse through. This example is a 138 * typical top-level entry into the Contacts application, showing you the 139 * list of people. Selecting a particular person to view would result in a 140 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> } 141 * being used to start an activity to display that person.</p> 142 * </li> 143 * </ul> 144 * 145 * <p>In addition to these primary attributes, there are a number of secondary 146 * attributes that you can also include with an intent:</p> 147 * 148 * <ul> 149 * <li> <p><b>category</b> -- Gives additional information about the action 150 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should 151 * appear in the Launcher as a top-level application, while 152 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list 153 * of alternative actions the user can perform on a piece of data.</p> 154 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the 155 * intent data. Normally the type is inferred from the data itself. 156 * By setting this attribute, you disable that evaluation and force 157 * an explicit type.</p> 158 * <li> <p><b>component</b> -- Specifies an explicit name of a component 159 * class to use for the intent. Normally this is determined by looking 160 * at the other information in the intent (the action, data/type, and 161 * categories) and matching that with a component that can handle it. 162 * If this attribute is set then none of the evaluation is performed, 163 * and this component is used exactly as is. By specifying this attribute, 164 * all of the other Intent attributes become optional.</p> 165 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. 166 * This can be used to provide extended information to the component. 167 * For example, if we have a action to send an e-mail message, we could 168 * also include extra pieces of data here to supply a subject, body, 169 * etc.</p> 170 * </ul> 171 * 172 * <p>Here are some examples of other operations you can specify as intents 173 * using these additional parameters:</p> 174 * 175 * <ul> 176 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- 177 * Launch the home screen.</p> 178 * </li> 179 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 180 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI 181 * vnd.android.cursor.item/phone}</i></b> 182 * -- Display the list of people's phone numbers, allowing the user to 183 * browse through them and pick one and return it to the parent activity.</p> 184 * </li> 185 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 186 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> 187 * -- Display all pickers for data that can be opened with 188 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, 189 * allowing the user to pick one of them and then some data inside of it 190 * and returning the resulting URI to the caller. This can be used, 191 * for example, in an e-mail application to allow the user to pick some 192 * data to include as an attachment.</p> 193 * </li> 194 * </ul> 195 * 196 * <p>There are a variety of standard Intent action and category constants 197 * defined in the Intent class, but applications can also define their own. 198 * These strings use Java-style scoping, to ensure they are unique -- for 199 * example, the standard {@link #ACTION_VIEW} is called 200 * "android.intent.action.VIEW".</p> 201 * 202 * <p>Put together, the set of actions, data types, categories, and extra data 203 * defines a language for the system allowing for the expression of phrases 204 * such as "call john smith's cell". As applications are added to the system, 205 * they can extend this language by adding new actions, types, and categories, or 206 * they can modify the behavior of existing phrases by supplying their own 207 * activities that handle them.</p> 208 * 209 * <a name="IntentResolution"></a> 210 * <h3>Intent Resolution</h3> 211 * 212 * <p>There are two primary forms of intents you will use. 213 * 214 * <ul> 215 * <li> <p><b>Explicit Intents</b> have specified a component (via 216 * {@link #setComponent} or {@link #setClass}), which provides the exact 217 * class to be run. Often these will not include any other information, 218 * simply being a way for an application to launch various internal 219 * activities it has as the user interacts with the application. 220 * 221 * <li> <p><b>Implicit Intents</b> have not specified a component; 222 * instead, they must include enough information for the system to 223 * determine which of the available components is best to run for that 224 * intent. 225 * </ul> 226 * 227 * <p>When using implicit intents, given such an arbitrary intent we need to 228 * know what to do with it. This is handled by the process of <em>Intent 229 * resolution</em>, which maps an Intent to an {@link android.app.Activity}, 230 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or 231 * more activities/receivers) that can handle it.</p> 232 * 233 * <p>The intent resolution mechanism basically revolves around matching an 234 * Intent against all of the <intent-filter> descriptions in the 235 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} 236 * objects explicitly registered with {@link Context#registerReceiver}.) More 237 * details on this can be found in the documentation on the {@link 238 * IntentFilter} class.</p> 239 * 240 * <p>There are three pieces of information in the Intent that are used for 241 * resolution: the action, type, and category. Using this information, a query 242 * is done on the {@link PackageManager} for a component that can handle the 243 * intent. The appropriate component is determined based on the intent 244 * information supplied in the <code>AndroidManifest.xml</code> file as 245 * follows:</p> 246 * 247 * <ul> 248 * <li> <p>The <b>action</b>, if given, must be listed by the component as 249 * one it handles.</p> 250 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not 251 * already supplied in the Intent. Like the action, if a type is 252 * included in the intent (either explicitly or implicitly in its 253 * data), then this must be listed by the component as one it handles.</p> 254 * <li> For data that is not a <code>content:</code> URI and where no explicit 255 * type is included in the Intent, instead the <b>scheme</b> of the 256 * intent data (such as <code>http:</code> or <code>mailto:</code>) is 257 * considered. Again like the action, if we are matching a scheme it 258 * must be listed by the component as one it can handle. 259 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed 260 * by the activity as categories it handles. That is, if you include 261 * the categories {@link #CATEGORY_LAUNCHER} and 262 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components 263 * with an intent that lists <em>both</em> of those categories. 264 * Activities will very often need to support the 265 * {@link #CATEGORY_DEFAULT} so that they can be found by 266 * {@link Context#startActivity Context.startActivity()}.</p> 267 * </ul> 268 * 269 * <p>For example, consider the Note Pad sample application that 270 * allows a user to browse through a list of notes data and view details about 271 * individual items. Text in italics indicates places where you would replace a 272 * name with one specific to your own package.</p> 273 * 274 * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 275 * package="<i>com.android.notepad</i>"> 276 * <application android:icon="@drawable/app_notes" 277 * android:label="@string/app_name"> 278 * 279 * <provider class=".NotePadProvider" 280 * android:authorities="<i>com.google.provider.NotePad</i>" /> 281 * 282 * <activity class=".NotesList" android:label="@string/title_notes_list"> 283 * <intent-filter> 284 * <action android:name="android.intent.action.MAIN" /> 285 * <category android:name="android.intent.category.LAUNCHER" /> 286 * </intent-filter> 287 * <intent-filter> 288 * <action android:name="android.intent.action.VIEW" /> 289 * <action android:name="android.intent.action.EDIT" /> 290 * <action android:name="android.intent.action.PICK" /> 291 * <category android:name="android.intent.category.DEFAULT" /> 292 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 293 * </intent-filter> 294 * <intent-filter> 295 * <action android:name="android.intent.action.GET_CONTENT" /> 296 * <category android:name="android.intent.category.DEFAULT" /> 297 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 298 * </intent-filter> 299 * </activity> 300 * 301 * <activity class=".NoteEditor" android:label="@string/title_note"> 302 * <intent-filter android:label="@string/resolve_edit"> 303 * <action android:name="android.intent.action.VIEW" /> 304 * <action android:name="android.intent.action.EDIT" /> 305 * <category android:name="android.intent.category.DEFAULT" /> 306 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 307 * </intent-filter> 308 * 309 * <intent-filter> 310 * <action android:name="android.intent.action.INSERT" /> 311 * <category android:name="android.intent.category.DEFAULT" /> 312 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 313 * </intent-filter> 314 * 315 * </activity> 316 * 317 * <activity class=".TitleEditor" android:label="@string/title_edit_title" 318 * android:theme="@android:style/Theme.Dialog"> 319 * <intent-filter android:label="@string/resolve_title"> 320 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 321 * <category android:name="android.intent.category.DEFAULT" /> 322 * <category android:name="android.intent.category.ALTERNATIVE" /> 323 * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> 324 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 325 * </intent-filter> 326 * </activity> 327 * 328 * </application> 329 * </manifest></pre> 330 * 331 * <p>The first activity, 332 * <code>com.android.notepad.NotesList</code>, serves as our main 333 * entry into the app. It can do three things as described by its three intent 334 * templates: 335 * <ol> 336 * <li><pre> 337 * <intent-filter> 338 * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> 339 * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> 340 * </intent-filter></pre> 341 * <p>This provides a top-level entry into the NotePad application: the standard 342 * MAIN action is a main entry point (not requiring any other information in 343 * the Intent), and the LAUNCHER category says that this entry point should be 344 * listed in the application launcher.</p> 345 * <li><pre> 346 * <intent-filter> 347 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 348 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 349 * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> 350 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 351 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 352 * </intent-filter></pre> 353 * <p>This declares the things that the activity can do on a directory of 354 * notes. The type being supported is given with the <type> tag, where 355 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which 356 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can 357 * be retrieved which holds our note pad data (<code>vnd.google.note</code>). 358 * The activity allows the user to view or edit the directory of data (via 359 * the VIEW and EDIT actions), or to pick a particular note and return it 360 * to the caller (via the PICK action). Note also the DEFAULT category 361 * supplied here: this is <em>required</em> for the 362 * {@link Context#startActivity Context.startActivity} method to resolve your 363 * activity when its component name is not explicitly specified.</p> 364 * <li><pre> 365 * <intent-filter> 366 * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> 367 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 368 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 369 * </intent-filter></pre> 370 * <p>This filter describes the ability to return to the caller a note selected by 371 * the user without needing to know where it came from. The data type 372 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which 373 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can 374 * be retrieved which contains our note pad data (<code>vnd.google.note</code>). 375 * The GET_CONTENT action is similar to the PICK action, where the activity 376 * will return to its caller a piece of data selected by the user. Here, 377 * however, the caller specifies the type of data they desire instead of 378 * the type of data the user will be picking from.</p> 379 * </ol> 380 * 381 * <p>Given these capabilities, the following intents will resolve to the 382 * NotesList activity:</p> 383 * 384 * <ul> 385 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the 386 * activities that can be used as top-level entry points into an 387 * application.</p> 388 * <li> <p><b>{ action=android.app.action.MAIN, 389 * category=android.app.category.LAUNCHER }</b> is the actual intent 390 * used by the Launcher to populate its top-level list.</p> 391 * <li> <p><b>{ action=android.intent.action.VIEW 392 * data=content://com.google.provider.NotePad/notes }</b> 393 * displays a list of all the notes under 394 * "content://com.google.provider.NotePad/notes", which 395 * the user can browse through and see the details on.</p> 396 * <li> <p><b>{ action=android.app.action.PICK 397 * data=content://com.google.provider.NotePad/notes }</b> 398 * provides a list of the notes under 399 * "content://com.google.provider.NotePad/notes", from which 400 * the user can pick a note whose data URL is returned back to the caller.</p> 401 * <li> <p><b>{ action=android.app.action.GET_CONTENT 402 * type=vnd.android.cursor.item/vnd.google.note }</b> 403 * is similar to the pick action, but allows the caller to specify the 404 * kind of data they want back so that the system can find the appropriate 405 * activity to pick something of that data type.</p> 406 * </ul> 407 * 408 * <p>The second activity, 409 * <code>com.android.notepad.NoteEditor</code>, shows the user a single 410 * note entry and allows them to edit it. It can do two things as described 411 * by its two intent templates: 412 * <ol> 413 * <li><pre> 414 * <intent-filter android:label="@string/resolve_edit"> 415 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 416 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 417 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 418 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 419 * </intent-filter></pre> 420 * <p>The first, primary, purpose of this activity is to let the user interact 421 * with a single note, as decribed by the MIME type 422 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can 423 * either VIEW a note or allow the user to EDIT it. Again we support the 424 * DEFAULT category to allow the activity to be launched without explicitly 425 * specifying its component.</p> 426 * <li><pre> 427 * <intent-filter> 428 * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> 429 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 430 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 431 * </intent-filter></pre> 432 * <p>The secondary use of this activity is to insert a new note entry into 433 * an existing directory of notes. This is used when the user creates a new 434 * note: the INSERT action is executed on the directory of notes, causing 435 * this activity to run and have the user create the new note data which 436 * it then adds to the content provider.</p> 437 * </ol> 438 * 439 * <p>Given these capabilities, the following intents will resolve to the 440 * NoteEditor activity:</p> 441 * 442 * <ul> 443 * <li> <p><b>{ action=android.intent.action.VIEW 444 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 445 * shows the user the content of note <var>{ID}</var>.</p> 446 * <li> <p><b>{ action=android.app.action.EDIT 447 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 448 * allows the user to edit the content of note <var>{ID}</var>.</p> 449 * <li> <p><b>{ action=android.app.action.INSERT 450 * data=content://com.google.provider.NotePad/notes }</b> 451 * creates a new, empty note in the notes list at 452 * "content://com.google.provider.NotePad/notes" 453 * and allows the user to edit it. If they keep their changes, the URI 454 * of the newly created note is returned to the caller.</p> 455 * </ul> 456 * 457 * <p>The last activity, 458 * <code>com.android.notepad.TitleEditor</code>, allows the user to 459 * edit the title of a note. This could be implemented as a class that the 460 * application directly invokes (by explicitly setting its component in 461 * the Intent), but here we show a way you can publish alternative 462 * operations on existing data:</p> 463 * 464 * <pre> 465 * <intent-filter android:label="@string/resolve_title"> 466 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 467 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 468 * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> 469 * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> 470 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 471 * </intent-filter></pre> 472 * 473 * <p>In the single intent template here, we 474 * have created our own private action called 475 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to 476 * edit the title of a note. It must be invoked on a specific note 477 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous 478 * view and edit actions, but here displays and edits the title contained 479 * in the note data. 480 * 481 * <p>In addition to supporting the default category as usual, our title editor 482 * also supports two other standard categories: ALTERNATIVE and 483 * SELECTED_ALTERNATIVE. Implementing 484 * these categories allows others to find the special action it provides 485 * without directly knowing about it, through the 486 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or 487 * more often to build dynamic menu items with 488 * {@link android.view.Menu#addIntentOptions}. Note that in the intent 489 * template here was also supply an explicit name for the template 490 * (via <code>android:label="@string/resolve_title"</code>) to better control 491 * what the user sees when presented with this activity as an alternative 492 * action to the data they are viewing. 493 * 494 * <p>Given these capabilities, the following intent will resolve to the 495 * TitleEditor activity:</p> 496 * 497 * <ul> 498 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE 499 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 500 * displays and allows the user to edit the title associated 501 * with note <var>{ID}</var>.</p> 502 * </ul> 503 * 504 * <h3>Standard Activity Actions</h3> 505 * 506 * <p>These are the current standard actions that Intent defines for launching 507 * activities (usually through {@link Context#startActivity}. The most 508 * important, and by far most frequently used, are {@link #ACTION_MAIN} and 509 * {@link #ACTION_EDIT}. 510 * 511 * <ul> 512 * <li> {@link #ACTION_MAIN} 513 * <li> {@link #ACTION_VIEW} 514 * <li> {@link #ACTION_ATTACH_DATA} 515 * <li> {@link #ACTION_EDIT} 516 * <li> {@link #ACTION_PICK} 517 * <li> {@link #ACTION_CHOOSER} 518 * <li> {@link #ACTION_GET_CONTENT} 519 * <li> {@link #ACTION_DIAL} 520 * <li> {@link #ACTION_CALL} 521 * <li> {@link #ACTION_SEND} 522 * <li> {@link #ACTION_SENDTO} 523 * <li> {@link #ACTION_ANSWER} 524 * <li> {@link #ACTION_INSERT} 525 * <li> {@link #ACTION_DELETE} 526 * <li> {@link #ACTION_RUN} 527 * <li> {@link #ACTION_SYNC} 528 * <li> {@link #ACTION_PICK_ACTIVITY} 529 * <li> {@link #ACTION_SEARCH} 530 * <li> {@link #ACTION_WEB_SEARCH} 531 * <li> {@link #ACTION_FACTORY_TEST} 532 * </ul> 533 * 534 * <h3>Standard Broadcast Actions</h3> 535 * 536 * <p>These are the current standard actions that Intent defines for receiving 537 * broadcasts (usually through {@link Context#registerReceiver} or a 538 * <receiver> tag in a manifest). 539 * 540 * <ul> 541 * <li> {@link #ACTION_TIME_TICK} 542 * <li> {@link #ACTION_TIME_CHANGED} 543 * <li> {@link #ACTION_TIMEZONE_CHANGED} 544 * <li> {@link #ACTION_BOOT_COMPLETED} 545 * <li> {@link #ACTION_PACKAGE_ADDED} 546 * <li> {@link #ACTION_PACKAGE_CHANGED} 547 * <li> {@link #ACTION_PACKAGE_REMOVED} 548 * <li> {@link #ACTION_PACKAGE_RESTARTED} 549 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} 550 * <li> {@link #ACTION_PACKAGES_SUSPENDED} 551 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} 552 * <li> {@link #ACTION_UID_REMOVED} 553 * <li> {@link #ACTION_BATTERY_CHANGED} 554 * <li> {@link #ACTION_POWER_CONNECTED} 555 * <li> {@link #ACTION_POWER_DISCONNECTED} 556 * <li> {@link #ACTION_SHUTDOWN} 557 * </ul> 558 * 559 * <h3>Standard Categories</h3> 560 * 561 * <p>These are the current standard categories that can be used to further 562 * clarify an Intent via {@link #addCategory}. 563 * 564 * <ul> 565 * <li> {@link #CATEGORY_DEFAULT} 566 * <li> {@link #CATEGORY_BROWSABLE} 567 * <li> {@link #CATEGORY_TAB} 568 * <li> {@link #CATEGORY_ALTERNATIVE} 569 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} 570 * <li> {@link #CATEGORY_LAUNCHER} 571 * <li> {@link #CATEGORY_INFO} 572 * <li> {@link #CATEGORY_HOME} 573 * <li> {@link #CATEGORY_PREFERENCE} 574 * <li> {@link #CATEGORY_TEST} 575 * <li> {@link #CATEGORY_CAR_DOCK} 576 * <li> {@link #CATEGORY_DESK_DOCK} 577 * <li> {@link #CATEGORY_LE_DESK_DOCK} 578 * <li> {@link #CATEGORY_HE_DESK_DOCK} 579 * <li> {@link #CATEGORY_CAR_MODE} 580 * <li> {@link #CATEGORY_APP_MARKET} 581 * <li> {@link #CATEGORY_VR_HOME} 582 * </ul> 583 * 584 * <h3>Standard Extra Data</h3> 585 * 586 * <p>These are the current standard fields that can be used as extra data via 587 * {@link #putExtra}. 588 * 589 * <ul> 590 * <li> {@link #EXTRA_ALARM_COUNT} 591 * <li> {@link #EXTRA_BCC} 592 * <li> {@link #EXTRA_CC} 593 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} 594 * <li> {@link #EXTRA_DATA_REMOVED} 595 * <li> {@link #EXTRA_DOCK_STATE} 596 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} 597 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} 598 * <li> {@link #EXTRA_DOCK_STATE_CAR} 599 * <li> {@link #EXTRA_DOCK_STATE_DESK} 600 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} 601 * <li> {@link #EXTRA_DONT_KILL_APP} 602 * <li> {@link #EXTRA_EMAIL} 603 * <li> {@link #EXTRA_INITIAL_INTENTS} 604 * <li> {@link #EXTRA_INTENT} 605 * <li> {@link #EXTRA_KEY_EVENT} 606 * <li> {@link #EXTRA_ORIGINATING_URI} 607 * <li> {@link #EXTRA_PHONE_NUMBER} 608 * <li> {@link #EXTRA_REFERRER} 609 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} 610 * <li> {@link #EXTRA_REPLACING} 611 * <li> {@link #EXTRA_SHORTCUT_ICON} 612 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} 613 * <li> {@link #EXTRA_SHORTCUT_INTENT} 614 * <li> {@link #EXTRA_STREAM} 615 * <li> {@link #EXTRA_SHORTCUT_NAME} 616 * <li> {@link #EXTRA_SUBJECT} 617 * <li> {@link #EXTRA_TEMPLATE} 618 * <li> {@link #EXTRA_TEXT} 619 * <li> {@link #EXTRA_TITLE} 620 * <li> {@link #EXTRA_UID} 621 * </ul> 622 * 623 * <h3>Flags</h3> 624 * 625 * <p>These are the possible flags that can be used in the Intent via 626 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list 627 * of all possible flags. 628 */ 629 public class Intent implements Parcelable, Cloneable { 630 private static final String ATTR_ACTION = "action"; 631 private static final String TAG_CATEGORIES = "categories"; 632 private static final String ATTR_CATEGORY = "category"; 633 private static final String TAG_EXTRA = "extra"; 634 private static final String ATTR_TYPE = "type"; 635 private static final String ATTR_COMPONENT = "component"; 636 private static final String ATTR_DATA = "data"; 637 private static final String ATTR_FLAGS = "flags"; 638 639 // --------------------------------------------------------------------- 640 // --------------------------------------------------------------------- 641 // Standard intent activity actions (see action variable). 642 643 /** 644 * Activity Action: Start as a main entry point, does not expect to 645 * receive data. 646 * <p>Input: nothing 647 * <p>Output: nothing 648 */ 649 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 650 public static final String ACTION_MAIN = "android.intent.action.MAIN"; 651 652 /** 653 * Activity Action: Display the data to the user. This is the most common 654 * action performed on data -- it is the generic action you can use on 655 * a piece of data to get the most reasonable thing to occur. For example, 656 * when used on a contacts entry it will view the entry; when used on a 657 * mailto: URI it will bring up a compose window filled with the information 658 * supplied by the URI; when used with a tel: URI it will invoke the 659 * dialer. 660 * <p>Input: {@link #getData} is URI from which to retrieve data. 661 * <p>Output: nothing. 662 */ 663 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 664 public static final String ACTION_VIEW = "android.intent.action.VIEW"; 665 666 /** 667 * Extra that can be included on activity intents coming from the storage UI 668 * when it launches sub-activities to manage various types of storage. For example, 669 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show 670 * the images on the device, and in that case also include this extra to tell the 671 * app it is coming from the storage UI so should help the user manage storage of 672 * this type. 673 */ 674 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE"; 675 676 /** 677 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is 678 * performed on a piece of data. 679 */ 680 public static final String ACTION_DEFAULT = ACTION_VIEW; 681 682 /** 683 * Activity Action: Quick view the data. Launches a quick viewer for 684 * a URI or a list of URIs. 685 * <p>Activities handling this intent action should handle the vast majority of 686 * MIME types rather than only specific ones. 687 * <p>Quick viewers must render the quick view image locally, and must not send 688 * file content outside current device. 689 * <p>Input: {@link #getData} is a mandatory content URI of the item to 690 * preview. {@link #getClipData} contains an optional list of content URIs 691 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an 692 * optional index of the URI in the clip data to show first. 693 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features 694 * that can be shown in the quick view UI. 695 * <p>Output: nothing. 696 * @see #EXTRA_INDEX 697 * @see #EXTRA_QUICK_VIEW_FEATURES 698 */ 699 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 700 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; 701 702 /** 703 * Used to indicate that some piece of data should be attached to some other 704 * place. For example, image data could be attached to a contact. It is up 705 * to the recipient to decide where the data should be attached; the intent 706 * does not specify the ultimate destination. 707 * <p>Input: {@link #getData} is URI of data to be attached. 708 * <p>Output: nothing. 709 */ 710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 711 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; 712 713 /** 714 * Activity Action: Provide explicit editable access to the given data. 715 * <p>Input: {@link #getData} is URI of data to be edited. 716 * <p>Output: nothing. 717 */ 718 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 719 public static final String ACTION_EDIT = "android.intent.action.EDIT"; 720 721 /** 722 * Activity Action: Pick an existing item, or insert a new item, and then edit it. 723 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. 724 * The extras can contain type specific data to pass through to the editing/creating 725 * activity. 726 * <p>Output: The URI of the item that was picked. This must be a content: 727 * URI so that any receiver can access it. 728 */ 729 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 730 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; 731 732 /** 733 * Activity Action: Pick an item from the data, returning what was selected. 734 * <p>Input: {@link #getData} is URI containing a directory of data 735 * (vnd.android.cursor.dir/*) from which to pick an item. 736 * <p>Output: The URI of the item that was picked. 737 */ 738 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 739 public static final String ACTION_PICK = "android.intent.action.PICK"; 740 741 /** 742 * Activity Action: Creates a shortcut. 743 * <p>Input: Nothing.</p> 744 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> 745 * <p>For compatibility with older versions of android the intent may also contain three 746 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), 747 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE 748 * (value: ShortcutIconResource).</p> 749 * 750 * @see android.content.pm.ShortcutManager#createShortcutResultIntent 751 * @see #EXTRA_SHORTCUT_INTENT 752 * @see #EXTRA_SHORTCUT_NAME 753 * @see #EXTRA_SHORTCUT_ICON 754 * @see #EXTRA_SHORTCUT_ICON_RESOURCE 755 * @see android.content.Intent.ShortcutIconResource 756 */ 757 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 758 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; 759 760 /** 761 * The name of the extra used to define the Intent of a shortcut. 762 * 763 * @see #ACTION_CREATE_SHORTCUT 764 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 765 */ 766 @Deprecated 767 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; 768 /** 769 * The name of the extra used to define the name of a shortcut. 770 * 771 * @see #ACTION_CREATE_SHORTCUT 772 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 773 */ 774 @Deprecated 775 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; 776 /** 777 * The name of the extra used to define the icon, as a Bitmap, of a shortcut. 778 * 779 * @see #ACTION_CREATE_SHORTCUT 780 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 781 */ 782 @Deprecated 783 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; 784 /** 785 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. 786 * 787 * @see #ACTION_CREATE_SHORTCUT 788 * @see android.content.Intent.ShortcutIconResource 789 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 790 */ 791 @Deprecated 792 public static final String EXTRA_SHORTCUT_ICON_RESOURCE = 793 "android.intent.extra.shortcut.ICON_RESOURCE"; 794 795 /** 796 * An activity that provides a user interface for adjusting application preferences. 797 * Optional but recommended settings for all applications which have settings. 798 */ 799 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 800 public static final String ACTION_APPLICATION_PREFERENCES 801 = "android.intent.action.APPLICATION_PREFERENCES"; 802 803 /** 804 * Activity Action: Launch an activity showing the app information. 805 * For applications which install other applications (such as app stores), it is recommended 806 * to handle this action for providing the app information to the user. 807 * 808 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs 809 * to be displayed. 810 * <p>Output: Nothing. 811 */ 812 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 813 public static final String ACTION_SHOW_APP_INFO 814 = "android.intent.action.SHOW_APP_INFO"; 815 816 /** 817 * Represents a shortcut/live folder icon resource. 818 * 819 * @see Intent#ACTION_CREATE_SHORTCUT 820 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE 821 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER 822 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON 823 */ 824 public static class ShortcutIconResource implements Parcelable { 825 /** 826 * The package name of the application containing the icon. 827 */ 828 public String packageName; 829 830 /** 831 * The resource name of the icon, including package, name and type. 832 */ 833 public String resourceName; 834 835 /** 836 * Creates a new ShortcutIconResource for the specified context and resource 837 * identifier. 838 * 839 * @param context The context of the application. 840 * @param resourceId The resource identifier for the icon. 841 * @return A new ShortcutIconResource with the specified's context package name 842 * and icon resource identifier.`` 843 */ fromContext(Context context, @AnyRes int resourceId)844 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { 845 ShortcutIconResource icon = new ShortcutIconResource(); 846 icon.packageName = context.getPackageName(); 847 icon.resourceName = context.getResources().getResourceName(resourceId); 848 return icon; 849 } 850 851 /** 852 * Used to read a ShortcutIconResource from a Parcel. 853 */ 854 public static final Parcelable.Creator<ShortcutIconResource> CREATOR = 855 new Parcelable.Creator<ShortcutIconResource>() { 856 857 public ShortcutIconResource createFromParcel(Parcel source) { 858 ShortcutIconResource icon = new ShortcutIconResource(); 859 icon.packageName = source.readString(); 860 icon.resourceName = source.readString(); 861 return icon; 862 } 863 864 public ShortcutIconResource[] newArray(int size) { 865 return new ShortcutIconResource[size]; 866 } 867 }; 868 869 /** 870 * No special parcel contents. 871 */ describeContents()872 public int describeContents() { 873 return 0; 874 } 875 writeToParcel(Parcel dest, int flags)876 public void writeToParcel(Parcel dest, int flags) { 877 dest.writeString(packageName); 878 dest.writeString(resourceName); 879 } 880 881 @Override toString()882 public String toString() { 883 return resourceName; 884 } 885 } 886 887 /** 888 * Activity Action: Display an activity chooser, allowing the user to pick 889 * what they want to before proceeding. This can be used as an alternative 890 * to the standard activity picker that is displayed by the system when 891 * you try to start an activity with multiple possible matches, with these 892 * differences in behavior: 893 * <ul> 894 * <li>You can specify the title that will appear in the activity chooser. 895 * <li>The user does not have the option to make one of the matching 896 * activities a preferred activity, and all possible activities will 897 * always be shown even if one of them is currently marked as the 898 * preferred activity. 899 * </ul> 900 * <p> 901 * This action should be used when the user will naturally expect to 902 * select an activity in order to proceed. An example if when not to use 903 * it is when the user clicks on a "mailto:" link. They would naturally 904 * expect to go directly to their mail app, so startActivity() should be 905 * called directly: it will 906 * either launch the current preferred app, or put up a dialog allowing the 907 * user to pick an app to use and optionally marking that as preferred. 908 * <p> 909 * In contrast, if the user is selecting a menu item to send a picture 910 * they are viewing to someone else, there are many different things they 911 * may want to do at this point: send it through e-mail, upload it to a 912 * web service, etc. In this case the CHOOSER action should be used, to 913 * always present to the user a list of the things they can do, with a 914 * nice title given by the caller such as "Send this photo with:". 915 * <p> 916 * If you need to grant URI permissions through a chooser, you must specify 917 * the permissions to be granted on the ACTION_CHOOSER Intent 918 * <em>in addition</em> to the EXTRA_INTENT inside. This means using 919 * {@link #setClipData} to specify the URIs to be granted as well as 920 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 921 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. 922 * <p> 923 * As a convenience, an Intent of this form can be created with the 924 * {@link #createChooser} function. 925 * <p> 926 * Input: No data should be specified. get*Extra must have 927 * a {@link #EXTRA_INTENT} field containing the Intent being executed, 928 * and can optionally have a {@link #EXTRA_TITLE} field containing the 929 * title text to display in the chooser. 930 * <p> 931 * Output: Depends on the protocol of {@link #EXTRA_INTENT}. 932 */ 933 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 934 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; 935 936 /** 937 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 938 * 939 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 940 * target intent, also optionally supplying a title. If the target 941 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 942 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 943 * set in the returned chooser intent, with its ClipData set appropriately: 944 * either a direct reflection of {@link #getClipData()} if that is non-null, 945 * or a new ClipData built from {@link #getData()}. 946 * 947 * @param target The Intent that the user will be selecting an activity 948 * to perform. 949 * @param title Optional title that will be displayed in the chooser. 950 * @return Return a new Intent object that you can hand to 951 * {@link Context#startActivity(Intent) Context.startActivity()} and 952 * related methods. 953 */ createChooser(Intent target, CharSequence title)954 public static Intent createChooser(Intent target, CharSequence title) { 955 return createChooser(target, title, null); 956 } 957 958 /** 959 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 960 * 961 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 962 * target intent, also optionally supplying a title. If the target 963 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 964 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 965 * set in the returned chooser intent, with its ClipData set appropriately: 966 * either a direct reflection of {@link #getClipData()} if that is non-null, 967 * or a new ClipData built from {@link #getData()}.</p> 968 * 969 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback 970 * when the user makes a choice. This can be useful if the calling application wants 971 * to remember the last chosen target and surface it as a more prominent or one-touch 972 * affordance elsewhere in the UI for next time.</p> 973 * 974 * @param target The Intent that the user will be selecting an activity 975 * to perform. 976 * @param title Optional title that will be displayed in the chooser. 977 * @param sender Optional IntentSender to be called when a choice is made. 978 * @return Return a new Intent object that you can hand to 979 * {@link Context#startActivity(Intent) Context.startActivity()} and 980 * related methods. 981 */ createChooser(Intent target, CharSequence title, IntentSender sender)982 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) { 983 Intent intent = new Intent(ACTION_CHOOSER); 984 intent.putExtra(EXTRA_INTENT, target); 985 if (title != null) { 986 intent.putExtra(EXTRA_TITLE, title); 987 } 988 989 if (sender != null) { 990 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); 991 } 992 993 // Migrate any clip data and flags from target. 994 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION 995 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 996 | FLAG_GRANT_PREFIX_URI_PERMISSION); 997 if (permFlags != 0) { 998 ClipData targetClipData = target.getClipData(); 999 if (targetClipData == null && target.getData() != null) { 1000 ClipData.Item item = new ClipData.Item(target.getData()); 1001 String[] mimeTypes; 1002 if (target.getType() != null) { 1003 mimeTypes = new String[] { target.getType() }; 1004 } else { 1005 mimeTypes = new String[] { }; 1006 } 1007 targetClipData = new ClipData(null, mimeTypes, item); 1008 } 1009 if (targetClipData != null) { 1010 intent.setClipData(targetClipData); 1011 intent.addFlags(permFlags); 1012 } 1013 } 1014 1015 return intent; 1016 } 1017 1018 /** 1019 * Activity Action: Allow the user to select a particular kind of data and 1020 * return it. This is different than {@link #ACTION_PICK} in that here we 1021 * just say what kind of data is desired, not a URI of existing data from 1022 * which the user can pick. An ACTION_GET_CONTENT could allow the user to 1023 * create the data as it runs (for example taking a picture or recording a 1024 * sound), let them browse over the web and download the desired data, 1025 * etc. 1026 * <p> 1027 * There are two main ways to use this action: if you want a specific kind 1028 * of data, such as a person contact, you set the MIME type to the kind of 1029 * data you want and launch it with {@link Context#startActivity(Intent)}. 1030 * The system will then launch the best application to select that kind 1031 * of data for you. 1032 * <p> 1033 * You may also be interested in any of a set of types of content the user 1034 * can pick. For example, an e-mail application that wants to allow the 1035 * user to add an attachment to an e-mail message can use this action to 1036 * bring up a list of all of the types of content the user can attach. 1037 * <p> 1038 * In this case, you should wrap the GET_CONTENT intent with a chooser 1039 * (through {@link #createChooser}), which will give the proper interface 1040 * for the user to pick how to send your data and allow you to specify 1041 * a prompt indicating what they are doing. You will usually specify a 1042 * broad MIME type (such as image/* or {@literal *}/*), resulting in a 1043 * broad range of content types the user can select from. 1044 * <p> 1045 * When using such a broad GET_CONTENT action, it is often desirable to 1046 * only pick from data that can be represented as a stream. This is 1047 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. 1048 * <p> 1049 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that 1050 * the launched content chooser only returns results representing data that 1051 * is locally available on the device. For example, if this extra is set 1052 * to true then an image picker should not show any pictures that are available 1053 * from a remote server but not already on the local device (thus requiring 1054 * they be downloaded when opened). 1055 * <p> 1056 * If the caller can handle multiple returned items (the user performing 1057 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} 1058 * to indicate this. 1059 * <p> 1060 * Input: {@link #getType} is the desired MIME type to retrieve. Note 1061 * that no URI is supplied in the intent, as there are no constraints on 1062 * where the returned data originally comes from. You may also include the 1063 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be 1064 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content 1065 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to 1066 * allow the user to select multiple items. 1067 * <p> 1068 * Output: The URI of the item that was picked. This must be a content: 1069 * URI so that any receiver can access it. 1070 */ 1071 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1072 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; 1073 /** 1074 * Activity Action: Dial a number as specified by the data. This shows a 1075 * UI with the number being dialed, allowing the user to explicitly 1076 * initiate the call. 1077 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1078 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1079 * number. 1080 * <p>Output: nothing. 1081 */ 1082 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1083 public static final String ACTION_DIAL = "android.intent.action.DIAL"; 1084 /** 1085 * Activity Action: Perform a call to someone specified by the data. 1086 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1087 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1088 * number. 1089 * <p>Output: nothing. 1090 * 1091 * <p>Note: there will be restrictions on which applications can initiate a 1092 * call; most applications should use the {@link #ACTION_DIAL}. 1093 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency 1094 * numbers. Applications can <strong>dial</strong> emergency numbers using 1095 * {@link #ACTION_DIAL}, however. 1096 * 1097 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M} 1098 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE} 1099 * permission which is not granted, then attempting to use this action will 1100 * result in a {@link java.lang.SecurityException}. 1101 */ 1102 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1103 public static final String ACTION_CALL = "android.intent.action.CALL"; 1104 /** 1105 * Activity Action: Perform a call to an emergency number specified by the 1106 * data. 1107 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1108 * tel: URI of an explicit phone number. 1109 * <p>Output: nothing. 1110 * @hide 1111 */ 1112 @SystemApi 1113 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1114 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; 1115 /** 1116 * Activity action: Perform a call to any number (emergency or not) 1117 * specified by the data. 1118 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1119 * tel: URI of an explicit phone number. 1120 * <p>Output: nothing. 1121 * @hide 1122 */ 1123 @SystemApi 1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1125 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; 1126 1127 /** 1128 * Activity Action: Main entry point for carrier setup apps. 1129 * <p>Carrier apps that provide an implementation for this action may be invoked to configure 1130 * carrier service and typically require 1131 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to 1132 * fulfill their duties. 1133 */ 1134 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1135 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP"; 1136 /** 1137 * Activity Action: Send a message to someone specified by the data. 1138 * <p>Input: {@link #getData} is URI describing the target. 1139 * <p>Output: nothing. 1140 */ 1141 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1142 public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; 1143 /** 1144 * Activity Action: Deliver some data to someone else. Who the data is 1145 * being delivered to is not specified; it is up to the receiver of this 1146 * action to ask the user where the data should be sent. 1147 * <p> 1148 * When launching a SEND intent, you should usually wrap it in a chooser 1149 * (through {@link #createChooser}), which will give the proper interface 1150 * for the user to pick how to send your data and allow you to specify 1151 * a prompt indicating what they are doing. 1152 * <p> 1153 * Input: {@link #getType} is the MIME type of the data being sent. 1154 * get*Extra can have either a {@link #EXTRA_TEXT} 1155 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If 1156 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it 1157 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* 1158 * if the MIME type is unknown (this will only allow senders that can 1159 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can 1160 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve 1161 * your text with HTML formatting. 1162 * <p> 1163 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1164 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1165 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1166 * content: URIs and other advanced features of {@link ClipData}. If 1167 * using this approach, you still must supply the same data through the 1168 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1169 * for compatibility with old applications. If you don't set a ClipData, 1170 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1171 * <p> 1172 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1173 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1174 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1175 * be openable only as asset typed files using 1176 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1177 * <p> 1178 * Optional standard extras, which may be interpreted by some recipients as 1179 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1180 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1181 * <p> 1182 * Output: nothing. 1183 */ 1184 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1185 public static final String ACTION_SEND = "android.intent.action.SEND"; 1186 /** 1187 * Activity Action: Deliver multiple data to someone else. 1188 * <p> 1189 * Like {@link #ACTION_SEND}, except the data is multiple. 1190 * <p> 1191 * Input: {@link #getType} is the MIME type of the data being sent. 1192 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link 1193 * #EXTRA_STREAM} field, containing the data to be sent. If using 1194 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} 1195 * for clients to retrieve your text with HTML formatting. 1196 * <p> 1197 * Multiple types are supported, and receivers should handle mixed types 1198 * whenever possible. The right way for the receiver to check them is to 1199 * use the content resolver on each URI. The intent sender should try to 1200 * put the most concrete mime type in the intent type, but it can fall 1201 * back to {@literal <type>/*} or {@literal *}/* as needed. 1202 * <p> 1203 * e.g. if you are sending image/jpg and image/jpg, the intent's type can 1204 * be image/jpg, but if you are sending image/jpg and image/png, then the 1205 * intent's type should be image/*. 1206 * <p> 1207 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1208 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1209 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1210 * content: URIs and other advanced features of {@link ClipData}. If 1211 * using this approach, you still must supply the same data through the 1212 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1213 * for compatibility with old applications. If you don't set a ClipData, 1214 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1215 * <p> 1216 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1217 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1218 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1219 * be openable only as asset typed files using 1220 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1221 * <p> 1222 * Optional standard extras, which may be interpreted by some recipients as 1223 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1224 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1225 * <p> 1226 * Output: nothing. 1227 */ 1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1229 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; 1230 /** 1231 * Activity Action: Handle an incoming phone call. 1232 * <p>Input: nothing. 1233 * <p>Output: nothing. 1234 */ 1235 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1236 public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; 1237 /** 1238 * Activity Action: Insert an empty item into the given container. 1239 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1240 * in which to place the data. 1241 * <p>Output: URI of the new data that was created. 1242 */ 1243 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1244 public static final String ACTION_INSERT = "android.intent.action.INSERT"; 1245 /** 1246 * Activity Action: Create a new item in the given container, initializing it 1247 * from the current contents of the clipboard. 1248 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1249 * in which to place the data. 1250 * <p>Output: URI of the new data that was created. 1251 */ 1252 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1253 public static final String ACTION_PASTE = "android.intent.action.PASTE"; 1254 /** 1255 * Activity Action: Delete the given data from its container. 1256 * <p>Input: {@link #getData} is URI of data to be deleted. 1257 * <p>Output: nothing. 1258 */ 1259 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1260 public static final String ACTION_DELETE = "android.intent.action.DELETE"; 1261 /** 1262 * Activity Action: Run the data, whatever that means. 1263 * <p>Input: ? (Note: this is currently specific to the test harness.) 1264 * <p>Output: nothing. 1265 */ 1266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1267 public static final String ACTION_RUN = "android.intent.action.RUN"; 1268 /** 1269 * Activity Action: Perform a data synchronization. 1270 * <p>Input: ? 1271 * <p>Output: ? 1272 */ 1273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1274 public static final String ACTION_SYNC = "android.intent.action.SYNC"; 1275 /** 1276 * Activity Action: Pick an activity given an intent, returning the class 1277 * selected. 1278 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent 1279 * used with {@link PackageManager#queryIntentActivities} to determine the 1280 * set of activities from which to pick. 1281 * <p>Output: Class name of the activity that was selected. 1282 */ 1283 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1284 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; 1285 /** 1286 * Activity Action: Perform a search. 1287 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1288 * is the text to search for. If empty, simply 1289 * enter your search results Activity with the search UI activated. 1290 * <p>Output: nothing. 1291 */ 1292 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1293 public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; 1294 /** 1295 * Activity Action: Start the platform-defined tutorial 1296 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1297 * is the text to search for. If empty, simply 1298 * enter your search results Activity with the search UI activated. 1299 * <p>Output: nothing. 1300 */ 1301 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1302 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; 1303 /** 1304 * Activity Action: Perform a web search. 1305 * <p> 1306 * Input: {@link android.app.SearchManager#QUERY 1307 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is 1308 * a url starts with http or https, the site will be opened. If it is plain 1309 * text, Google search will be applied. 1310 * <p> 1311 * Output: nothing. 1312 */ 1313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1314 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; 1315 1316 /** 1317 * Activity Action: Perform assist action. 1318 * <p> 1319 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1320 * additional optional contextual information about where the user was when they 1321 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer 1322 * information. 1323 * Output: nothing. 1324 */ 1325 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1326 public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; 1327 1328 /** 1329 * Activity Action: Perform voice assist action. 1330 * <p> 1331 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1332 * additional optional contextual information about where the user was when they 1333 * requested the voice assist. 1334 * Output: nothing. 1335 * @hide 1336 */ 1337 @SystemApi 1338 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1339 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; 1340 1341 /** 1342 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground 1343 * application package at the time the assist was invoked. 1344 */ 1345 public static final String EXTRA_ASSIST_PACKAGE 1346 = "android.intent.extra.ASSIST_PACKAGE"; 1347 1348 /** 1349 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground 1350 * application package at the time the assist was invoked. 1351 */ 1352 public static final String EXTRA_ASSIST_UID 1353 = "android.intent.extra.ASSIST_UID"; 1354 1355 /** 1356 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual 1357 * information supplied by the current foreground app at the time of the assist request. 1358 * This is a {@link Bundle} of additional data. 1359 */ 1360 public static final String EXTRA_ASSIST_CONTEXT 1361 = "android.intent.extra.ASSIST_CONTEXT"; 1362 1363 /** 1364 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a 1365 * keyboard as the primary input device for assistance. 1366 */ 1367 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = 1368 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; 1369 1370 /** 1371 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id 1372 * that was used to invoke the assist. 1373 */ 1374 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = 1375 "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; 1376 1377 /** 1378 * Activity Action: List all available applications. 1379 * <p>Input: Nothing. 1380 * <p>Output: nothing. 1381 */ 1382 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1383 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; 1384 /** 1385 * Activity Action: Show settings for choosing wallpaper. 1386 * <p>Input: Nothing. 1387 * <p>Output: Nothing. 1388 */ 1389 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1390 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; 1391 1392 /** 1393 * Activity Action: Show activity for reporting a bug. 1394 * <p>Input: Nothing. 1395 * <p>Output: Nothing. 1396 */ 1397 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1398 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; 1399 1400 /** 1401 * Activity Action: Main entry point for factory tests. Only used when 1402 * the device is booting in factory test node. The implementing package 1403 * must be installed in the system image. 1404 * <p>Input: nothing 1405 * <p>Output: nothing 1406 */ 1407 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1408 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; 1409 1410 /** 1411 * Activity Action: The user pressed the "call" button to go to the dialer 1412 * or other appropriate UI for placing a call. 1413 * <p>Input: Nothing. 1414 * <p>Output: Nothing. 1415 */ 1416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1417 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; 1418 1419 /** 1420 * Activity Action: Start Voice Command. 1421 * <p>Input: Nothing. 1422 * <p>Output: Nothing. 1423 * <p class="note"> 1424 * In some cases, a matching Activity may not exist, so ensure you 1425 * safeguard against this. 1426 */ 1427 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1428 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; 1429 1430 /** 1431 * Activity Action: Start action associated with long pressing on the 1432 * search key. 1433 * <p>Input: Nothing. 1434 * <p>Output: Nothing. 1435 */ 1436 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1437 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; 1438 1439 /** 1440 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. 1441 * This intent is delivered to the package which installed the application, usually 1442 * Google Play. 1443 * <p>Input: No data is specified. The bug report is passed in using 1444 * an {@link #EXTRA_BUG_REPORT} field. 1445 * <p>Output: Nothing. 1446 * 1447 * @see #EXTRA_BUG_REPORT 1448 */ 1449 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1450 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; 1451 1452 /** 1453 * Activity Action: Show power usage information to the user. 1454 * <p>Input: Nothing. 1455 * <p>Output: Nothing. 1456 */ 1457 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1458 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; 1459 1460 /** 1461 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs 1462 * to run. 1463 * <p>Input: Nothing. 1464 * <p>Output: Nothing. 1465 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified 1466 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD} 1467 * @hide 1468 * @removed 1469 */ 1470 @Deprecated 1471 @SystemApi 1472 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = 1473 "android.intent.action.DEVICE_INITIALIZATION_WIZARD"; 1474 1475 /** 1476 * Activity Action: Setup wizard to launch after a platform update. This 1477 * activity should have a string meta-data field associated with it, 1478 * {@link #METADATA_SETUP_VERSION}, which defines the current version of 1479 * the platform for setup. The activity will be launched only if 1480 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the 1481 * same value. 1482 * <p>Input: Nothing. 1483 * <p>Output: Nothing. 1484 * @hide 1485 */ 1486 @SystemApi 1487 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1488 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; 1489 1490 /** 1491 * Activity Action: Start the Keyboard Shortcuts Helper screen. 1492 * <p>Input: Nothing. 1493 * <p>Output: Nothing. 1494 * @hide 1495 */ 1496 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1497 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = 1498 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; 1499 1500 /** 1501 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. 1502 * <p>Input: Nothing. 1503 * <p>Output: Nothing. 1504 * @hide 1505 */ 1506 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1507 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = 1508 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; 1509 1510 /** 1511 * Activity Action: Show settings for managing network data usage of a 1512 * specific application. Applications should define an activity that offers 1513 * options to control data usage. 1514 */ 1515 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1516 public static final String ACTION_MANAGE_NETWORK_USAGE = 1517 "android.intent.action.MANAGE_NETWORK_USAGE"; 1518 1519 /** 1520 * Activity Action: Launch application installer. 1521 * <p> 1522 * Input: The data must be a content: URI at which the application 1523 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, 1524 * you can also use "package:<package-name>" to install an application for the 1525 * current user that is already installed for another user. You can optionally supply 1526 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, 1527 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. 1528 * <p> 1529 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1530 * succeeded. 1531 * <p> 1532 * <strong>Note:</strong>If your app is targeting API level higher than 25 you 1533 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} 1534 * in order to launch the application installer. 1535 * </p> 1536 * 1537 * @see #EXTRA_INSTALLER_PACKAGE_NAME 1538 * @see #EXTRA_NOT_UNKNOWN_SOURCE 1539 * @see #EXTRA_RETURN_RESULT 1540 */ 1541 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1542 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; 1543 1544 /** 1545 * Activity Action: Activity to handle split installation failures. 1546 * <p>Splits may be installed dynamically. This happens when an Activity is launched, 1547 * but the split that contains the application isn't installed. When a split is 1548 * installed in this manner, the containing package usually doesn't know this is 1549 * happening. However, if an error occurs during installation, the containing 1550 * package can define a single activity handling this action to deal with such 1551 * failures. 1552 * <p>The activity handling this action must be in the base package. 1553 * <p> 1554 * Input: {@link #EXTRA_INTENT} the original intent that started split installation. 1555 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed. 1556 */ 1557 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1558 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE"; 1559 1560 /** 1561 * Activity Action: Launch instant application installer. 1562 * <p class="note"> 1563 * This is a protected intent that can only be sent by the system. 1564 * </p> 1565 * 1566 * @hide 1567 */ 1568 @SystemApi 1569 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1570 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE 1571 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE"; 1572 1573 /** 1574 * Service Action: Resolve instant application. 1575 * <p> 1576 * The system will have a persistent connection to this service. 1577 * This is a protected intent that can only be sent by the system. 1578 * </p> 1579 * 1580 * @hide 1581 */ 1582 @SystemApi 1583 @SdkConstant(SdkConstantType.SERVICE_ACTION) 1584 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE 1585 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; 1586 1587 /** 1588 * Activity Action: Launch instant app settings. 1589 * 1590 * <p class="note"> 1591 * This is a protected intent that can only be sent by the system. 1592 * </p> 1593 * 1594 * @hide 1595 */ 1596 @SystemApi 1597 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1598 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS 1599 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS"; 1600 1601 /** 1602 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1603 * package. Specifies the installer package name; this package will receive the 1604 * {@link #ACTION_APP_ERROR} intent. 1605 */ 1606 public static final String EXTRA_INSTALLER_PACKAGE_NAME 1607 = "android.intent.extra.INSTALLER_PACKAGE_NAME"; 1608 1609 /** 1610 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1611 * package. Specifies that the application being installed should not be 1612 * treated as coming from an unknown source, but as coming from the app 1613 * invoking the Intent. For this to work you must start the installer with 1614 * startActivityForResult(). 1615 */ 1616 public static final String EXTRA_NOT_UNKNOWN_SOURCE 1617 = "android.intent.extra.NOT_UNKNOWN_SOURCE"; 1618 1619 /** 1620 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and 1621 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent 1622 * data field originated from. 1623 */ 1624 public static final String EXTRA_ORIGINATING_URI 1625 = "android.intent.extra.ORIGINATING_URI"; 1626 1627 /** 1628 * This extra can be used with any Intent used to launch an activity, supplying information 1629 * about who is launching that activity. This field contains a {@link android.net.Uri} 1630 * object, typically an http: or https: URI of the web site that the referral came from; 1631 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify 1632 * a native application that it came from. 1633 * 1634 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} 1635 * instead of directly retrieving the extra. It is also valid for applications to 1636 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create 1637 * a string, not a Uri; the field here, if supplied, will always take precedence, 1638 * however.</p> 1639 * 1640 * @see #EXTRA_REFERRER_NAME 1641 */ 1642 public static final String EXTRA_REFERRER 1643 = "android.intent.extra.REFERRER"; 1644 1645 /** 1646 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather 1647 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can 1648 * not be created, in particular when Intent extras are supplied through the 1649 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} 1650 * schemes. 1651 * 1652 * @see #EXTRA_REFERRER 1653 */ 1654 public static final String EXTRA_REFERRER_NAME 1655 = "android.intent.extra.REFERRER_NAME"; 1656 1657 /** 1658 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and 1659 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install 1660 * Currently only a system app that hosts the provider authority "downloads" or holds the 1661 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this. 1662 * @hide 1663 */ 1664 @SystemApi 1665 public static final String EXTRA_ORIGINATING_UID 1666 = "android.intent.extra.ORIGINATING_UID"; 1667 1668 /** 1669 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1670 * package. Tells the installer UI to skip the confirmation with the user 1671 * if the .apk is replacing an existing one. 1672 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android 1673 * will no longer show an interstitial message about updating existing 1674 * applications so this is no longer needed. 1675 */ 1676 @Deprecated 1677 public static final String EXTRA_ALLOW_REPLACE 1678 = "android.intent.extra.ALLOW_REPLACE"; 1679 1680 /** 1681 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or 1682 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should 1683 * return to the application the result code of the install/uninstall. The returned result 1684 * code will be {@link android.app.Activity#RESULT_OK} on success or 1685 * {@link android.app.Activity#RESULT_FIRST_USER} on failure. 1686 */ 1687 public static final String EXTRA_RETURN_RESULT 1688 = "android.intent.extra.RETURN_RESULT"; 1689 1690 /** 1691 * Package manager install result code. @hide because result codes are not 1692 * yet ready to be exposed. 1693 */ 1694 public static final String EXTRA_INSTALL_RESULT 1695 = "android.intent.extra.INSTALL_RESULT"; 1696 1697 /** 1698 * Activity Action: Launch application uninstaller. 1699 * <p> 1700 * Input: The data must be a package: URI whose scheme specific part is 1701 * the package name of the current installed package to be uninstalled. 1702 * You can optionally supply {@link #EXTRA_RETURN_RESULT}. 1703 * <p> 1704 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1705 * succeeded. 1706 * <p> 1707 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} 1708 * since {@link Build.VERSION_CODES#P}. 1709 */ 1710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1711 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; 1712 1713 /** 1714 * Specify whether the package should be uninstalled for all users. 1715 * @hide because these should not be part of normal application flow. 1716 */ 1717 public static final String EXTRA_UNINSTALL_ALL_USERS 1718 = "android.intent.extra.UNINSTALL_ALL_USERS"; 1719 1720 /** 1721 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity 1722 * describing the last run version of the platform that was setup. 1723 * @hide 1724 */ 1725 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; 1726 1727 /** 1728 * Activity action: Launch UI to manage the permissions of an app. 1729 * <p> 1730 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions 1731 * will be managed by the launched UI. 1732 * </p> 1733 * <p> 1734 * Output: Nothing. 1735 * </p> 1736 * 1737 * @see #EXTRA_PACKAGE_NAME 1738 * 1739 * @hide 1740 */ 1741 @SystemApi 1742 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1743 public static final String ACTION_MANAGE_APP_PERMISSIONS = 1744 "android.intent.action.MANAGE_APP_PERMISSIONS"; 1745 1746 /** 1747 * Activity action: Launch UI to manage permissions. 1748 * <p> 1749 * Input: Nothing. 1750 * </p> 1751 * <p> 1752 * Output: Nothing. 1753 * </p> 1754 * 1755 * @hide 1756 */ 1757 @SystemApi 1758 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1759 public static final String ACTION_MANAGE_PERMISSIONS = 1760 "android.intent.action.MANAGE_PERMISSIONS"; 1761 1762 /** 1763 * Activity action: Launch UI to review permissions for an app. 1764 * The system uses this intent if permission review for apps not 1765 * supporting the new runtime permissions model is enabled. In 1766 * this mode a permission review is required before any of the 1767 * app components can run. 1768 * <p> 1769 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose 1770 * permissions will be reviewed (mandatory). 1771 * </p> 1772 * <p> 1773 * Input: {@link #EXTRA_INTENT} specifies a pending intent to 1774 * be fired after the permission review (optional). 1775 * </p> 1776 * <p> 1777 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to 1778 * be invoked after the permission review (optional). 1779 * </p> 1780 * <p> 1781 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent 1782 * passed via {@link #EXTRA_INTENT} needs a result (optional). 1783 * </p> 1784 * <p> 1785 * Output: Nothing. 1786 * </p> 1787 * 1788 * @see #EXTRA_PACKAGE_NAME 1789 * @see #EXTRA_INTENT 1790 * @see #EXTRA_REMOTE_CALLBACK 1791 * @see #EXTRA_RESULT_NEEDED 1792 * 1793 * @hide 1794 */ 1795 @SystemApi 1796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1797 public static final String ACTION_REVIEW_PERMISSIONS = 1798 "android.intent.action.REVIEW_PERMISSIONS"; 1799 1800 /** 1801 * Intent extra: A callback for reporting remote result as a bundle. 1802 * <p> 1803 * Type: IRemoteCallback 1804 * </p> 1805 * 1806 * @hide 1807 */ 1808 @SystemApi 1809 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; 1810 1811 /** 1812 * Intent extra: An app package name. 1813 * <p> 1814 * Type: String 1815 * </p> 1816 * 1817 */ 1818 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; 1819 1820 /** 1821 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an 1822 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}. 1823 * 1824 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the 1825 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}. 1826 * This is meant to enable the suspended app to better handle the state of being suspended. 1827 * 1828 * @see #ACTION_MY_PACKAGE_SUSPENDED 1829 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 1830 * @see PackageManager#isPackageSuspended() 1831 * @see PackageManager#getSuspendedPackageAppExtras() 1832 */ 1833 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS"; 1834 1835 /** 1836 * Intent extra: An app split name. 1837 * <p> 1838 * Type: String 1839 * </p> 1840 */ 1841 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; 1842 1843 /** 1844 * Intent extra: A {@link ComponentName} value. 1845 * <p> 1846 * Type: String 1847 * </p> 1848 */ 1849 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME"; 1850 1851 /** 1852 * Intent extra: An extra for specifying whether a result is needed. 1853 * <p> 1854 * Type: boolean 1855 * </p> 1856 * 1857 * @hide 1858 */ 1859 @SystemApi 1860 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; 1861 1862 /** 1863 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on 1864 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}. 1865 * 1866 * @see PackageManager#isPackageSuspended() 1867 * @see #ACTION_PACKAGES_SUSPENDED 1868 * 1869 * @hide 1870 */ 1871 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS"; 1872 1873 /** 1874 * Activity action: Launch UI to manage which apps have a given permission. 1875 * <p> 1876 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access 1877 * to which will be managed by the launched UI. 1878 * </p> 1879 * <p> 1880 * Output: Nothing. 1881 * </p> 1882 * 1883 * @see #EXTRA_PERMISSION_NAME 1884 * 1885 * @hide 1886 */ 1887 @SystemApi 1888 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1889 public static final String ACTION_MANAGE_PERMISSION_APPS = 1890 "android.intent.action.MANAGE_PERMISSION_APPS"; 1891 1892 /** 1893 * Intent extra: The name of a permission. 1894 * <p> 1895 * Type: String 1896 * </p> 1897 * 1898 * @hide 1899 */ 1900 @SystemApi 1901 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; 1902 1903 // --------------------------------------------------------------------- 1904 // --------------------------------------------------------------------- 1905 // Standard intent broadcast actions (see action variable). 1906 1907 /** 1908 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. 1909 * <p> 1910 * For historical reasons, the name of this broadcast action refers to the power 1911 * state of the screen but it is actually sent in response to changes in the 1912 * overall interactive state of the device. 1913 * </p><p> 1914 * This broadcast is sent when the device becomes non-interactive which may have 1915 * nothing to do with the screen turning off. To determine the 1916 * actual state of the screen, use {@link android.view.Display#getState}. 1917 * </p><p> 1918 * See {@link android.os.PowerManager#isInteractive} for details. 1919 * </p> 1920 * You <em>cannot</em> receive this through components declared in 1921 * manifests, only by explicitly registering for it with 1922 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 1923 * Context.registerReceiver()}. 1924 * 1925 * <p class="note">This is a protected intent that can only be sent 1926 * by the system. 1927 */ 1928 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1929 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; 1930 1931 /** 1932 * Broadcast Action: Sent when the device wakes up and becomes interactive. 1933 * <p> 1934 * For historical reasons, the name of this broadcast action refers to the power 1935 * state of the screen but it is actually sent in response to changes in the 1936 * overall interactive state of the device. 1937 * </p><p> 1938 * This broadcast is sent when the device becomes interactive which may have 1939 * nothing to do with the screen turning on. To determine the 1940 * actual state of the screen, use {@link android.view.Display#getState}. 1941 * </p><p> 1942 * See {@link android.os.PowerManager#isInteractive} for details. 1943 * </p> 1944 * You <em>cannot</em> receive this through components declared in 1945 * manifests, only by explicitly registering for it with 1946 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 1947 * Context.registerReceiver()}. 1948 * 1949 * <p class="note">This is a protected intent that can only be sent 1950 * by the system. 1951 */ 1952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1953 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; 1954 1955 /** 1956 * Broadcast Action: Sent after the system stops dreaming. 1957 * 1958 * <p class="note">This is a protected intent that can only be sent by the system. 1959 * It is only sent to registered receivers.</p> 1960 */ 1961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1962 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; 1963 1964 /** 1965 * Broadcast Action: Sent after the system starts dreaming. 1966 * 1967 * <p class="note">This is a protected intent that can only be sent by the system. 1968 * It is only sent to registered receivers.</p> 1969 */ 1970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1971 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; 1972 1973 /** 1974 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the 1975 * keyguard is gone). 1976 * 1977 * <p class="note">This is a protected intent that can only be sent 1978 * by the system. 1979 */ 1980 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1981 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; 1982 1983 /** 1984 * Broadcast Action: The current time has changed. Sent every 1985 * minute. You <em>cannot</em> receive this through components declared 1986 * in manifests, only by explicitly registering for it with 1987 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 1988 * Context.registerReceiver()}. 1989 * 1990 * <p class="note">This is a protected intent that can only be sent 1991 * by the system. 1992 */ 1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1994 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; 1995 /** 1996 * Broadcast Action: The time was set. 1997 */ 1998 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1999 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; 2000 /** 2001 * Broadcast Action: The date has changed. 2002 */ 2003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2004 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; 2005 /** 2006 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> 2007 * <ul> 2008 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li> 2009 * </ul> 2010 * 2011 * <p class="note">This is a protected intent that can only be sent 2012 * by the system. 2013 */ 2014 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2015 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; 2016 /** 2017 * Clear DNS Cache Action: This is broadcast when networks have changed and old 2018 * DNS entries should be tossed. 2019 * @hide 2020 */ 2021 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2022 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE"; 2023 /** 2024 * Alarm Changed Action: This is broadcast when the AlarmClock 2025 * application's alarm is set or unset. It is used by the 2026 * AlarmClock application and the StatusBar service. 2027 * @hide 2028 */ 2029 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2030 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; 2031 2032 /** 2033 * Broadcast Action: This is broadcast once, after the user has finished 2034 * booting, but while still in the "locked" state. It can be used to perform 2035 * application-specific initialization, such as installing alarms. You must 2036 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} 2037 * permission in order to receive this broadcast. 2038 * <p> 2039 * This broadcast is sent immediately at boot by all devices (regardless of 2040 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or 2041 * higher. Upon receipt of this broadcast, the user is still locked and only 2042 * device-protected storage can be accessed safely. If you want to access 2043 * credential-protected storage, you need to wait for the user to be 2044 * unlocked (typically by entering their lock pattern or PIN for the first 2045 * time), after which the {@link #ACTION_USER_UNLOCKED} and 2046 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. 2047 * <p> 2048 * To receive this broadcast, your receiver component must be marked as 2049 * being {@link ComponentInfo#directBootAware}. 2050 * <p class="note"> 2051 * This is a protected intent that can only be sent by the system. 2052 * 2053 * @see Context#createDeviceProtectedStorageContext() 2054 */ 2055 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2056 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; 2057 2058 /** 2059 * Broadcast Action: This is broadcast once, after the user has finished 2060 * booting. It can be used to perform application-specific initialization, 2061 * such as installing alarms. You must hold the 2062 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in 2063 * order to receive this broadcast. 2064 * <p> 2065 * This broadcast is sent at boot by all devices (both with and without 2066 * direct boot support). Upon receipt of this broadcast, the user is 2067 * unlocked and both device-protected and credential-protected storage can 2068 * accessed safely. 2069 * <p> 2070 * If you need to run while the user is still locked (before they've entered 2071 * their lock pattern or PIN for the first time), you can listen for the 2072 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. 2073 * <p class="note"> 2074 * This is a protected intent that can only be sent by the system. 2075 */ 2076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2077 @BroadcastBehavior(includeBackground = true) 2078 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; 2079 2080 /** 2081 * Broadcast Action: This is broadcast when a user action should request a 2082 * temporary system dialog to dismiss. Some examples of temporary system 2083 * dialogs are the notification window-shade and the recent tasks dialog. 2084 */ 2085 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2086 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; 2087 /** 2088 * Broadcast Action: Trigger the download and eventual installation 2089 * of a package. 2090 * <p>Input: {@link #getData} is the URI of the package file to download. 2091 * 2092 * <p class="note">This is a protected intent that can only be sent 2093 * by the system. 2094 * 2095 * @deprecated This constant has never been used. 2096 */ 2097 @Deprecated 2098 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2099 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; 2100 /** 2101 * Broadcast Action: A new application package has been installed on the 2102 * device. The data contains the name of the package. Note that the 2103 * newly installed package does <em>not</em> receive this broadcast. 2104 * <p>May include the following extras: 2105 * <ul> 2106 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2107 * <li> {@link #EXTRA_REPLACING} is set to true if this is following 2108 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. 2109 * </ul> 2110 * 2111 * <p class="note">This is a protected intent that can only be sent 2112 * by the system. 2113 */ 2114 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2115 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; 2116 /** 2117 * Broadcast Action: A new version of an application package has been 2118 * installed, replacing an existing version that was previously installed. 2119 * The data contains the name of the package. 2120 * <p>May include the following extras: 2121 * <ul> 2122 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2123 * </ul> 2124 * 2125 * <p class="note">This is a protected intent that can only be sent 2126 * by the system. 2127 */ 2128 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2129 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; 2130 /** 2131 * Broadcast Action: A new version of your application has been installed 2132 * over an existing one. This is only sent to the application that was 2133 * replaced. It does not contain any additional data; to receive it, just 2134 * use an intent filter for this action. 2135 * 2136 * <p class="note">This is a protected intent that can only be sent 2137 * by the system. 2138 */ 2139 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2140 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; 2141 /** 2142 * Broadcast Action: An existing application package has been removed from 2143 * the device. The data contains the name of the package. The package 2144 * that is being removed does <em>not</em> receive this Intent. 2145 * <ul> 2146 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2147 * to the package. 2148 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2149 * application -- data and code -- is being removed. 2150 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2151 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2152 * </ul> 2153 * 2154 * <p class="note">This is a protected intent that can only be sent 2155 * by the system. 2156 */ 2157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2158 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; 2159 /** 2160 * Broadcast Action: An existing application package has been completely 2161 * removed from the device. The data contains the name of the package. 2162 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when 2163 * {@link #EXTRA_DATA_REMOVED} is true and 2164 * {@link #EXTRA_REPLACING} is false of that broadcast. 2165 * 2166 * <ul> 2167 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2168 * to the package. 2169 * </ul> 2170 * 2171 * <p class="note">This is a protected intent that can only be sent 2172 * by the system. 2173 */ 2174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2175 public static final String ACTION_PACKAGE_FULLY_REMOVED 2176 = "android.intent.action.PACKAGE_FULLY_REMOVED"; 2177 /** 2178 * Broadcast Action: An existing application package has been changed (for 2179 * example, a component has been enabled or disabled). The data contains 2180 * the name of the package. 2181 * <ul> 2182 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2183 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name 2184 * of the changed components (or the package name itself). 2185 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the 2186 * default action of restarting the application. 2187 * </ul> 2188 * 2189 * <p class="note">This is a protected intent that can only be sent 2190 * by the system. 2191 */ 2192 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2193 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; 2194 /** 2195 * @hide 2196 * Broadcast Action: Ask system services if there is any reason to 2197 * restart the given package. The data contains the name of the 2198 * package. 2199 * <ul> 2200 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2201 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. 2202 * </ul> 2203 * 2204 * <p class="note">This is a protected intent that can only be sent 2205 * by the system. 2206 */ 2207 @SystemApi 2208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2209 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; 2210 /** 2211 * Broadcast Action: The user has restarted a package, and all of its 2212 * processes have been killed. All runtime state 2213 * associated with it (processes, alarms, notifications, etc) should 2214 * be removed. Note that the restarted package does <em>not</em> 2215 * receive this broadcast. 2216 * The data contains the name of the package. 2217 * <ul> 2218 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2219 * </ul> 2220 * 2221 * <p class="note">This is a protected intent that can only be sent 2222 * by the system. 2223 */ 2224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2225 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; 2226 /** 2227 * Broadcast Action: The user has cleared the data of a package. This should 2228 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of 2229 * its persistent data is erased and this broadcast sent. 2230 * Note that the cleared package does <em>not</em> 2231 * receive this broadcast. The data contains the name of the package. 2232 * <ul> 2233 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the 2234 * package whose data was cleared is an uninstalled instant app, then the UID 2235 * will be -1. The platform keeps some meta-data associated with instant apps 2236 * after they are uninstalled. 2237 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared 2238 * data was for an instant app. 2239 * </ul> 2240 * 2241 * <p class="note">This is a protected intent that can only be sent 2242 * by the system. 2243 */ 2244 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2245 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; 2246 /** 2247 * Broadcast Action: Packages have been suspended. 2248 * <p>Includes the following extras: 2249 * <ul> 2250 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended 2251 * </ul> 2252 * 2253 * <p class="note">This is a protected intent that can only be sent 2254 * by the system. It is only sent to registered receivers. 2255 */ 2256 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2257 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; 2258 /** 2259 * Broadcast Action: Packages have been unsuspended. 2260 * <p>Includes the following extras: 2261 * <ul> 2262 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended 2263 * </ul> 2264 * 2265 * <p class="note">This is a protected intent that can only be sent 2266 * by the system. It is only sent to registered receivers. 2267 */ 2268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2269 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; 2270 2271 /** 2272 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent 2273 * whenever a package is put into a suspended state or any of its app extras change while in the 2274 * suspended state. 2275 * <p> Optionally includes the following extras: 2276 * <ul> 2277 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain 2278 * useful information for the app being suspended. 2279 * </ul> 2280 * <p class="note">This is a protected intent that can only be sent 2281 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2282 * the manifest.</em> 2283 * 2284 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2285 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2286 * @see PackageManager#isPackageSuspended() 2287 * @see PackageManager#getSuspendedPackageAppExtras() 2288 */ 2289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2290 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED"; 2291 2292 /** 2293 * Activity Action: Started to show more details about why an application was suspended. 2294 * 2295 * <p>Whenever the system detects an activity launch for a suspended app, this action can 2296 * be used to show more details about the reason for suspension. 2297 * 2298 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity 2299 * handling this intent and protect it with 2300 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}. 2301 * 2302 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package. 2303 * 2304 * <p class="note">This is a protected intent that can only be sent 2305 * by the system. 2306 * 2307 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2308 * PersistableBundle, String) 2309 * @see PackageManager#isPackageSuspended() 2310 * @see #ACTION_PACKAGES_SUSPENDED 2311 * 2312 * @hide 2313 */ 2314 @SystemApi 2315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2316 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS = 2317 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS"; 2318 2319 /** 2320 * Broadcast Action: Sent to a package that has been unsuspended. 2321 * 2322 * <p class="note">This is a protected intent that can only be sent 2323 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2324 * the manifest.</em> 2325 * 2326 * @see #ACTION_MY_PACKAGE_SUSPENDED 2327 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2328 * @see PackageManager#isPackageSuspended() 2329 * @see PackageManager#getSuspendedPackageAppExtras() 2330 */ 2331 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2332 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED"; 2333 2334 /** 2335 * Broadcast Action: A user ID has been removed from the system. The user 2336 * ID number is stored in the extra data under {@link #EXTRA_UID}. 2337 * 2338 * <p class="note">This is a protected intent that can only be sent 2339 * by the system. 2340 */ 2341 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2342 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; 2343 2344 /** 2345 * Broadcast Action: Sent to the installer package of an application when 2346 * that application is first launched (that is the first time it is moved 2347 * out of the stopped state). The data contains the name of the package. 2348 * 2349 * <p class="note">This is a protected intent that can only be sent 2350 * by the system. 2351 */ 2352 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2353 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; 2354 2355 /** 2356 * Broadcast Action: Sent to the system package verifier when a package 2357 * needs to be verified. The data contains the package URI. 2358 * <p class="note"> 2359 * This is a protected intent that can only be sent by the system. 2360 * </p> 2361 */ 2362 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2363 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; 2364 2365 /** 2366 * Broadcast Action: Sent to the system package verifier when a package is 2367 * verified. The data contains the package URI. 2368 * <p class="note"> 2369 * This is a protected intent that can only be sent by the system. 2370 */ 2371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2372 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; 2373 2374 /** 2375 * Broadcast Action: Sent to the system intent filter verifier when an 2376 * intent filter needs to be verified. The data contains the filter data 2377 * hosts to be verified against. 2378 * <p class="note"> 2379 * This is a protected intent that can only be sent by the system. 2380 * </p> 2381 * 2382 * @hide 2383 */ 2384 @SystemApi 2385 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2386 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; 2387 2388 /** 2389 * Broadcast Action: Resources for a set of packages (which were 2390 * previously unavailable) are currently 2391 * available since the media on which they exist is available. 2392 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 2393 * list of packages whose availability changed. 2394 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 2395 * list of uids of packages whose availability changed. 2396 * Note that the 2397 * packages in this list do <em>not</em> receive this broadcast. 2398 * The specified set of packages are now available on the system. 2399 * <p>Includes the following extras: 2400 * <ul> 2401 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 2402 * whose resources(were previously unavailable) are currently available. 2403 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the 2404 * packages whose resources(were previously unavailable) 2405 * are currently available. 2406 * </ul> 2407 * 2408 * <p class="note">This is a protected intent that can only be sent 2409 * by the system. 2410 */ 2411 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2412 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = 2413 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; 2414 2415 /** 2416 * Broadcast Action: Resources for a set of packages are currently 2417 * unavailable since the media on which they exist is unavailable. 2418 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 2419 * list of packages whose availability changed. 2420 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 2421 * list of uids of packages whose availability changed. 2422 * The specified set of packages can no longer be 2423 * launched and are practically unavailable on the system. 2424 * <p>Inclues the following extras: 2425 * <ul> 2426 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 2427 * whose resources are no longer available. 2428 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages 2429 * whose resources are no longer available. 2430 * </ul> 2431 * 2432 * <p class="note">This is a protected intent that can only be sent 2433 * by the system. 2434 */ 2435 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2436 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = 2437 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; 2438 2439 /** 2440 * Broadcast Action: preferred activities have changed *explicitly*. 2441 * 2442 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. 2443 * when an app is installed or uninstalled, but in such cases this broadcast will *not* 2444 * be sent. 2445 * 2446 * {@link #EXTRA_USER_HANDLE} contains the user ID in question. 2447 * 2448 * @hide 2449 */ 2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2451 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = 2452 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; 2453 2454 2455 /** 2456 * Broadcast Action: The current system wallpaper has changed. See 2457 * {@link android.app.WallpaperManager} for retrieving the new wallpaper. 2458 * This should <em>only</em> be used to determine when the wallpaper 2459 * has changed to show the new wallpaper to the user. You should certainly 2460 * never, in response to this, change the wallpaper or other attributes of 2461 * it such as the suggested size. That would be crazy, right? You'd cause 2462 * all kinds of loops, especially if other apps are doing similar things, 2463 * right? Of course. So please don't do this. 2464 * 2465 * @deprecated Modern applications should use 2466 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER 2467 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper 2468 * shown behind their UI, rather than watching for this broadcast and 2469 * rendering the wallpaper on their own. 2470 */ 2471 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2472 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; 2473 /** 2474 * Broadcast Action: The current device {@link android.content.res.Configuration} 2475 * (orientation, locale, etc) has changed. When such a change happens, the 2476 * UIs (view hierarchy) will need to be rebuilt based on this new 2477 * information; for the most part, applications don't need to worry about 2478 * this, because the system will take care of stopping and restarting the 2479 * application to make sure it sees the new changes. Some system code that 2480 * can not be restarted will need to watch for this action and handle it 2481 * appropriately. 2482 * 2483 * <p class="note"> 2484 * You <em>cannot</em> receive this through components declared 2485 * in manifests, only by explicitly registering for it with 2486 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2487 * Context.registerReceiver()}. 2488 * 2489 * <p class="note">This is a protected intent that can only be sent 2490 * by the system. 2491 * 2492 * @see android.content.res.Configuration 2493 */ 2494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2495 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; 2496 2497 /** 2498 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed 2499 * such that the device may be eligible for the installation of additional configuration splits. 2500 * Configuration properties that can trigger this broadcast include locale and display density. 2501 * 2502 * <p class="note"> 2503 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through 2504 * components declared in manifests. However, the receiver <em>must</em> hold the 2505 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. 2506 * 2507 * <p class="note"> 2508 * This is a protected intent that can only be sent by the system. 2509 * 2510 * @hide 2511 */ 2512 @SystemApi 2513 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2514 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = 2515 "android.intent.action.SPLIT_CONFIGURATION_CHANGED"; 2516 /** 2517 * Broadcast Action: The current device's locale has changed. 2518 * 2519 * <p class="note">This is a protected intent that can only be sent 2520 * by the system. 2521 */ 2522 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2523 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; 2524 /** 2525 * Broadcast Action: This is a <em>sticky broadcast</em> containing the 2526 * charging state, level, and other information about the battery. 2527 * See {@link android.os.BatteryManager} for documentation on the 2528 * contents of the Intent. 2529 * 2530 * <p class="note"> 2531 * You <em>cannot</em> receive this through components declared 2532 * in manifests, only by explicitly registering for it with 2533 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2534 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, 2535 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, 2536 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related 2537 * broadcasts that are sent and can be received through manifest 2538 * receivers. 2539 * 2540 * <p class="note">This is a protected intent that can only be sent 2541 * by the system. 2542 */ 2543 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2544 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; 2545 2546 2547 /** 2548 * Broadcast Action: Sent when the current battery level changes. 2549 * 2550 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle} 2551 * instances representing individual battery level changes with associated 2552 * extras from {@link #ACTION_BATTERY_CHANGED}. 2553 * 2554 * <p class="note"> 2555 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission. 2556 * 2557 * @hide 2558 */ 2559 @SystemApi 2560 public static final String ACTION_BATTERY_LEVEL_CHANGED = 2561 "android.intent.action.BATTERY_LEVEL_CHANGED"; 2562 /** 2563 * Broadcast Action: Indicates low battery condition on the device. 2564 * This broadcast corresponds to the "Low battery warning" system dialog. 2565 * 2566 * <p class="note">This is a protected intent that can only be sent 2567 * by the system. 2568 */ 2569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2570 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; 2571 /** 2572 * Broadcast Action: Indicates the battery is now okay after being low. 2573 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has 2574 * gone back up to an okay state. 2575 * 2576 * <p class="note">This is a protected intent that can only be sent 2577 * by the system. 2578 */ 2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2580 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; 2581 /** 2582 * Broadcast Action: External power has been connected to the device. 2583 * This is intended for applications that wish to register specifically to this notification. 2584 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 2585 * stay active to receive this notification. This action can be used to implement actions 2586 * that wait until power is available to trigger. 2587 * 2588 * <p class="note">This is a protected intent that can only be sent 2589 * by the system. 2590 */ 2591 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2592 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; 2593 /** 2594 * Broadcast Action: External power has been removed from the device. 2595 * This is intended for applications that wish to register specifically to this notification. 2596 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 2597 * stay active to receive this notification. This action can be used to implement actions 2598 * that wait until power is available to trigger. 2599 * 2600 * <p class="note">This is a protected intent that can only be sent 2601 * by the system. 2602 */ 2603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2604 public static final String ACTION_POWER_DISCONNECTED = 2605 "android.intent.action.ACTION_POWER_DISCONNECTED"; 2606 /** 2607 * Broadcast Action: Device is shutting down. 2608 * This is broadcast when the device is being shut down (completely turned 2609 * off, not sleeping). Once the broadcast is complete, the final shutdown 2610 * will proceed and all unsaved data lost. Apps will not normally need 2611 * to handle this, since the foreground activity will be paused as well. 2612 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered 2613 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2614 * Context.registerReceiver}. 2615 * 2616 * <p class="note">This is a protected intent that can only be sent 2617 * by the system. 2618 * <p>May include the following extras: 2619 * <ul> 2620 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this 2621 * shutdown is only for userspace processes. If not set, assumed to be false. 2622 * </ul> 2623 */ 2624 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2625 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; 2626 /** 2627 * Activity Action: Start this activity to request system shutdown. 2628 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true 2629 * to request confirmation from the user before shutting down. The optional boolean 2630 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to 2631 * indicate that the shutdown is requested by the user. 2632 * 2633 * <p class="note">This is a protected intent that can only be sent 2634 * by the system. 2635 * 2636 * {@hide} 2637 */ 2638 public static final String ACTION_REQUEST_SHUTDOWN 2639 = "com.android.internal.intent.action.REQUEST_SHUTDOWN"; 2640 /** 2641 * Broadcast Action: A sticky broadcast that indicates low storage space 2642 * condition on the device 2643 * <p class="note"> 2644 * This is a protected intent that can only be sent by the system. 2645 * 2646 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 2647 * or above, this broadcast will no longer be delivered to any 2648 * {@link BroadcastReceiver} defined in your manifest. Instead, 2649 * apps are strongly encouraged to use the improved 2650 * {@link Context#getCacheDir()} behavior so the system can 2651 * automatically free up storage when needed. 2652 */ 2653 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2654 @Deprecated 2655 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; 2656 /** 2657 * Broadcast Action: Indicates low storage space condition on the device no 2658 * longer exists 2659 * <p class="note"> 2660 * This is a protected intent that can only be sent by the system. 2661 * 2662 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 2663 * or above, this broadcast will no longer be delivered to any 2664 * {@link BroadcastReceiver} defined in your manifest. Instead, 2665 * apps are strongly encouraged to use the improved 2666 * {@link Context#getCacheDir()} behavior so the system can 2667 * automatically free up storage when needed. 2668 */ 2669 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2670 @Deprecated 2671 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; 2672 /** 2673 * Broadcast Action: A sticky broadcast that indicates a storage space full 2674 * condition on the device. This is intended for activities that want to be 2675 * able to fill the data partition completely, leaving only enough free 2676 * space to prevent system-wide SQLite failures. 2677 * <p class="note"> 2678 * This is a protected intent that can only be sent by the system. 2679 * 2680 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 2681 * or above, this broadcast will no longer be delivered to any 2682 * {@link BroadcastReceiver} defined in your manifest. Instead, 2683 * apps are strongly encouraged to use the improved 2684 * {@link Context#getCacheDir()} behavior so the system can 2685 * automatically free up storage when needed. 2686 * @hide 2687 */ 2688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2689 @Deprecated 2690 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; 2691 /** 2692 * Broadcast Action: Indicates storage space full condition on the device no 2693 * longer exists. 2694 * <p class="note"> 2695 * This is a protected intent that can only be sent by the system. 2696 * 2697 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 2698 * or above, this broadcast will no longer be delivered to any 2699 * {@link BroadcastReceiver} defined in your manifest. Instead, 2700 * apps are strongly encouraged to use the improved 2701 * {@link Context#getCacheDir()} behavior so the system can 2702 * automatically free up storage when needed. 2703 * @hide 2704 */ 2705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2706 @Deprecated 2707 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; 2708 /** 2709 * Broadcast Action: Indicates low memory condition notification acknowledged by user 2710 * and package management should be started. 2711 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW 2712 * notification. 2713 */ 2714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2715 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; 2716 /** 2717 * Broadcast Action: The device has entered USB Mass Storage mode. 2718 * This is used mainly for the USB Settings panel. 2719 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 2720 * when the SD card file system is mounted or unmounted 2721 * @deprecated replaced by android.os.storage.StorageEventListener 2722 */ 2723 @Deprecated 2724 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2725 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; 2726 2727 /** 2728 * Broadcast Action: The device has exited USB Mass Storage mode. 2729 * This is used mainly for the USB Settings panel. 2730 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 2731 * when the SD card file system is mounted or unmounted 2732 * @deprecated replaced by android.os.storage.StorageEventListener 2733 */ 2734 @Deprecated 2735 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2736 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; 2737 2738 /** 2739 * Broadcast Action: External media has been removed. 2740 * The path to the mount point for the removed media is contained in the Intent.mData field. 2741 */ 2742 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2743 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; 2744 2745 /** 2746 * Broadcast Action: External media is present, but not mounted at its mount point. 2747 * The path to the mount point for the unmounted media is contained in the Intent.mData field. 2748 */ 2749 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2750 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; 2751 2752 /** 2753 * Broadcast Action: External media is present, and being disk-checked 2754 * The path to the mount point for the checking media is contained in the Intent.mData field. 2755 */ 2756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2757 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; 2758 2759 /** 2760 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) 2761 * The path to the mount point for the checking media is contained in the Intent.mData field. 2762 */ 2763 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2764 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; 2765 2766 /** 2767 * Broadcast Action: External media is present and mounted at its mount point. 2768 * The path to the mount point for the mounted media is contained in the Intent.mData field. 2769 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the 2770 * media was mounted read only. 2771 */ 2772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2773 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; 2774 2775 /** 2776 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. 2777 * The path to the mount point for the shared media is contained in the Intent.mData field. 2778 */ 2779 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2780 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; 2781 2782 /** 2783 * Broadcast Action: External media is no longer being shared via USB mass storage. 2784 * The path to the mount point for the previously shared media is contained in the Intent.mData field. 2785 * 2786 * @hide 2787 */ 2788 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; 2789 2790 /** 2791 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. 2792 * The path to the mount point for the removed media is contained in the Intent.mData field. 2793 */ 2794 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2795 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; 2796 2797 /** 2798 * Broadcast Action: External media is present but cannot be mounted. 2799 * The path to the mount point for the unmountable media is contained in the Intent.mData field. 2800 */ 2801 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2802 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; 2803 2804 /** 2805 * Broadcast Action: User has expressed the desire to remove the external storage media. 2806 * Applications should close all files they have open within the mount point when they receive this intent. 2807 * The path to the mount point for the media to be ejected is contained in the Intent.mData field. 2808 */ 2809 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2810 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; 2811 2812 /** 2813 * Broadcast Action: The media scanner has started scanning a directory. 2814 * The path to the directory being scanned is contained in the Intent.mData field. 2815 */ 2816 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2817 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; 2818 2819 /** 2820 * Broadcast Action: The media scanner has finished scanning a directory. 2821 * The path to the scanned directory is contained in the Intent.mData field. 2822 */ 2823 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2824 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; 2825 2826 /** 2827 * Broadcast Action: Request the media scanner to scan a file and add it to the media database. 2828 * The path to the file is contained in the Intent.mData field. 2829 */ 2830 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2831 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; 2832 2833 /** 2834 * Broadcast Action: The "Media Button" was pressed. Includes a single 2835 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 2836 * caused the broadcast. 2837 */ 2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2839 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; 2840 2841 /** 2842 * Broadcast Action: The "Camera Button" was pressed. Includes a single 2843 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 2844 * caused the broadcast. 2845 */ 2846 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2847 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; 2848 2849 // *** NOTE: @todo(*) The following really should go into a more domain-specific 2850 // location; they are not general-purpose actions. 2851 2852 /** 2853 * Broadcast Action: A GTalk connection has been established. 2854 */ 2855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2856 public static final String ACTION_GTALK_SERVICE_CONNECTED = 2857 "android.intent.action.GTALK_CONNECTED"; 2858 2859 /** 2860 * Broadcast Action: A GTalk connection has been disconnected. 2861 */ 2862 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2863 public static final String ACTION_GTALK_SERVICE_DISCONNECTED = 2864 "android.intent.action.GTALK_DISCONNECTED"; 2865 2866 /** 2867 * Broadcast Action: An input method has been changed. 2868 */ 2869 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2870 public static final String ACTION_INPUT_METHOD_CHANGED = 2871 "android.intent.action.INPUT_METHOD_CHANGED"; 2872 2873 /** 2874 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or 2875 * more radios have been turned off or on. The intent will have the following extra value:</p> 2876 * <ul> 2877 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, 2878 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been 2879 * turned off</li> 2880 * </ul> 2881 * 2882 * <p class="note">This is a protected intent that can only be sent by the system.</p> 2883 */ 2884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2885 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; 2886 2887 /** 2888 * Broadcast Action: Some content providers have parts of their namespace 2889 * where they publish new events or items that the user may be especially 2890 * interested in. For these things, they may broadcast this action when the 2891 * set of interesting items change. 2892 * 2893 * For example, GmailProvider sends this notification when the set of unread 2894 * mail in the inbox changes. 2895 * 2896 * <p>The data of the intent identifies which part of which provider 2897 * changed. When queried through the content resolver, the data URI will 2898 * return the data set in question. 2899 * 2900 * <p>The intent will have the following extra values: 2901 * <ul> 2902 * <li><em>count</em> - The number of items in the data set. This is the 2903 * same as the number of items in the cursor returned by querying the 2904 * data URI. </li> 2905 * </ul> 2906 * 2907 * This intent will be sent at boot (if the count is non-zero) and when the 2908 * data set changes. It is possible for the data set to change without the 2909 * count changing (for example, if a new unread message arrives in the same 2910 * sync operation in which a message is archived). The phone should still 2911 * ring/vibrate/etc as normal in this case. 2912 */ 2913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2914 public static final String ACTION_PROVIDER_CHANGED = 2915 "android.intent.action.PROVIDER_CHANGED"; 2916 2917 /** 2918 * Broadcast Action: Wired Headset plugged in or unplugged. 2919 * 2920 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value 2921 * and documentation. 2922 * <p>If the minimum SDK version of your application is 2923 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer 2924 * to the <code>AudioManager</code> constant in your receiver registration code instead. 2925 */ 2926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2927 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG; 2928 2929 /** 2930 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> 2931 * <ul> 2932 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> 2933 * </ul> 2934 * 2935 * <p class="note">This is a protected intent that can only be sent 2936 * by the system. 2937 * 2938 * @hide 2939 */ 2940 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2941 public static final String ACTION_ADVANCED_SETTINGS_CHANGED 2942 = "android.intent.action.ADVANCED_SETTINGS"; 2943 2944 /** 2945 * Broadcast Action: Sent after application restrictions are changed. 2946 * 2947 * <p class="note">This is a protected intent that can only be sent 2948 * by the system.</p> 2949 */ 2950 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2951 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = 2952 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; 2953 2954 /** 2955 * Broadcast Action: An outgoing call is about to be placed. 2956 * 2957 * <p>The Intent will have the following extra value:</p> 2958 * <ul> 2959 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - 2960 * the phone number originally intended to be dialed.</li> 2961 * </ul> 2962 * <p>Once the broadcast is finished, the resultData is used as the actual 2963 * number to call. If <code>null</code>, no call will be placed.</p> 2964 * <p>It is perfectly acceptable for multiple receivers to process the 2965 * outgoing call in turn: for example, a parental control application 2966 * might verify that the user is authorized to place the call at that 2967 * time, then a number-rewriting application might add an area code if 2968 * one was not specified.</p> 2969 * <p>For consistency, any receiver whose purpose is to prohibit phone 2970 * calls should have a priority of 0, to ensure it will see the final 2971 * phone number to be dialed. 2972 * Any receiver whose purpose is to rewrite phone numbers to be called 2973 * should have a positive priority. 2974 * Negative priorities are reserved for the system for this broadcast; 2975 * using them may cause problems.</p> 2976 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> 2977 * abort the broadcast.</p> 2978 * <p>Emergency calls cannot be intercepted using this mechanism, and 2979 * other calls cannot be modified to call emergency numbers using this 2980 * mechanism. 2981 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing 2982 * call to use their own service instead. Those apps should first prevent 2983 * the call from being placed by setting resultData to <code>null</code> 2984 * and then start their own app to make the call. 2985 * <p>You must hold the 2986 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} 2987 * permission to receive this Intent.</p> 2988 * 2989 * <p class="note">This is a protected intent that can only be sent 2990 * by the system. 2991 */ 2992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2993 public static final String ACTION_NEW_OUTGOING_CALL = 2994 "android.intent.action.NEW_OUTGOING_CALL"; 2995 2996 /** 2997 * Broadcast Action: Have the device reboot. This is only for use by 2998 * system code. 2999 * 3000 * <p class="note">This is a protected intent that can only be sent 3001 * by the system. 3002 */ 3003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3004 public static final String ACTION_REBOOT = 3005 "android.intent.action.REBOOT"; 3006 3007 /** 3008 * Broadcast Action: A sticky broadcast for changes in the physical 3009 * docking state of the device. 3010 * 3011 * <p>The intent will have the following extra values: 3012 * <ul> 3013 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock 3014 * state, indicating which dock the device is physically in.</li> 3015 * </ul> 3016 * <p>This is intended for monitoring the current physical dock state. 3017 * See {@link android.app.UiModeManager} for the normal API dealing with 3018 * dock mode changes. 3019 */ 3020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3021 public static final String ACTION_DOCK_EVENT = 3022 "android.intent.action.DOCK_EVENT"; 3023 3024 /** 3025 * Broadcast Action: A broadcast when idle maintenance can be started. 3026 * This means that the user is not interacting with the device and is 3027 * not expected to do so soon. Typical use of the idle maintenance is 3028 * to perform somehow expensive tasks that can be postponed at a moment 3029 * when they will not degrade user experience. 3030 * <p> 3031 * <p class="note">In order to keep the device responsive in case of an 3032 * unexpected user interaction, implementations of a maintenance task 3033 * should be interruptible. In such a scenario a broadcast with action 3034 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you 3035 * should not do the maintenance work in 3036 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a 3037 * maintenance service by {@link Context#startService(Intent)}. Also 3038 * you should hold a wake lock while your maintenance service is running 3039 * to prevent the device going to sleep. 3040 * </p> 3041 * <p> 3042 * <p class="note">This is a protected intent that can only be sent by 3043 * the system. 3044 * </p> 3045 * 3046 * @see #ACTION_IDLE_MAINTENANCE_END 3047 * 3048 * @hide 3049 */ 3050 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3051 public static final String ACTION_IDLE_MAINTENANCE_START = 3052 "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; 3053 3054 /** 3055 * Broadcast Action: A broadcast when idle maintenance should be stopped. 3056 * This means that the user was not interacting with the device as a result 3057 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} 3058 * was sent and now the user started interacting with the device. Typical 3059 * use of the idle maintenance is to perform somehow expensive tasks that 3060 * can be postponed at a moment when they will not degrade user experience. 3061 * <p> 3062 * <p class="note">In order to keep the device responsive in case of an 3063 * unexpected user interaction, implementations of a maintenance task 3064 * should be interruptible. Hence, on receiving a broadcast with this 3065 * action, the maintenance task should be interrupted as soon as possible. 3066 * In other words, you should not do the maintenance work in 3067 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the 3068 * maintenance service that was started on receiving of 3069 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake 3070 * lock you acquired when your maintenance service started. 3071 * </p> 3072 * <p class="note">This is a protected intent that can only be sent 3073 * by the system. 3074 * 3075 * @see #ACTION_IDLE_MAINTENANCE_START 3076 * 3077 * @hide 3078 */ 3079 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3080 public static final String ACTION_IDLE_MAINTENANCE_END = 3081 "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; 3082 3083 /** 3084 * Broadcast Action: a remote intent is to be broadcasted. 3085 * 3086 * A remote intent is used for remote RPC between devices. The remote intent 3087 * is serialized and sent from one device to another device. The receiving 3088 * device parses the remote intent and broadcasts it. Note that anyone can 3089 * broadcast a remote intent. However, if the intent receiver of the remote intent 3090 * does not trust intent broadcasts from arbitrary intent senders, it should require 3091 * the sender to hold certain permissions so only trusted sender's broadcast will be 3092 * let through. 3093 * @hide 3094 */ 3095 public static final String ACTION_REMOTE_INTENT = 3096 "com.google.android.c2dm.intent.RECEIVE"; 3097 3098 /** 3099 * Broadcast Action: This is broadcast once when the user is booting after a 3100 * system update. It can be used to perform cleanup or upgrades after a 3101 * system update. 3102 * <p> 3103 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} 3104 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's 3105 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only 3106 * sent to receivers in the system image. 3107 * 3108 * @hide 3109 */ 3110 @SystemApi 3111 public static final String ACTION_PRE_BOOT_COMPLETED = 3112 "android.intent.action.PRE_BOOT_COMPLETED"; 3113 3114 /** 3115 * Broadcast to a specific application to query any supported restrictions to impose 3116 * on restricted users. The broadcast intent contains an extra 3117 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted 3118 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or 3119 * String[] depending on the restriction type.<p/> 3120 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, 3121 * which is of type <code>ArrayList<RestrictionEntry></code>. It can also 3122 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. 3123 * The activity specified by that intent will be launched for a result which must contain 3124 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. 3125 * The keys and values of the returned restrictions will be persisted. 3126 * @see RestrictionEntry 3127 */ 3128 public static final String ACTION_GET_RESTRICTION_ENTRIES = 3129 "android.intent.action.GET_RESTRICTION_ENTRIES"; 3130 3131 /** 3132 * Sent the first time a user is starting, to allow system apps to 3133 * perform one time initialization. (This will not be seen by third 3134 * party applications because a newly initialized user does not have any 3135 * third party applications installed for it.) This is sent early in 3136 * starting the user, around the time the home app is started, before 3137 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground 3138 * broadcast, since it is part of a visible user interaction; be as quick 3139 * as possible when handling it. 3140 */ 3141 public static final String ACTION_USER_INITIALIZE = 3142 "android.intent.action.USER_INITIALIZE"; 3143 3144 /** 3145 * Sent when a user switch is happening, causing the process's user to be 3146 * brought to the foreground. This is only sent to receivers registered 3147 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3148 * Context.registerReceiver}. It is sent to the user that is going to the 3149 * foreground. This is sent as a foreground 3150 * broadcast, since it is part of a visible user interaction; be as quick 3151 * as possible when handling it. 3152 */ 3153 public static final String ACTION_USER_FOREGROUND = 3154 "android.intent.action.USER_FOREGROUND"; 3155 3156 /** 3157 * Sent when a user switch is happening, causing the process's user to be 3158 * sent to the background. This is only sent to receivers registered 3159 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3160 * Context.registerReceiver}. It is sent to the user that is going to the 3161 * background. This is sent as a foreground 3162 * broadcast, since it is part of a visible user interaction; be as quick 3163 * as possible when handling it. 3164 */ 3165 public static final String ACTION_USER_BACKGROUND = 3166 "android.intent.action.USER_BACKGROUND"; 3167 3168 /** 3169 * Broadcast sent to the system when a user is added. Carries an extra 3170 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to 3171 * all running users. You must hold 3172 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3173 * @hide 3174 */ 3175 public static final String ACTION_USER_ADDED = 3176 "android.intent.action.USER_ADDED"; 3177 3178 /** 3179 * Broadcast sent by the system when a user is started. Carries an extra 3180 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to 3181 * registered receivers, not manifest receivers. It is sent to the user 3182 * that has been started. This is sent as a foreground 3183 * broadcast, since it is part of a visible user interaction; be as quick 3184 * as possible when handling it. 3185 * @hide 3186 */ 3187 public static final String ACTION_USER_STARTED = 3188 "android.intent.action.USER_STARTED"; 3189 3190 /** 3191 * Broadcast sent when a user is in the process of starting. Carries an extra 3192 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only 3193 * sent to registered receivers, not manifest receivers. It is sent to all 3194 * users (including the one that is being started). You must hold 3195 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3196 * this broadcast. This is sent as a background broadcast, since 3197 * its result is not part of the primary UX flow; to safely keep track of 3198 * started/stopped state of a user you can use this in conjunction with 3199 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with 3200 * other user state broadcasts since those are foreground broadcasts so can 3201 * execute in a different order. 3202 * @hide 3203 */ 3204 public static final String ACTION_USER_STARTING = 3205 "android.intent.action.USER_STARTING"; 3206 3207 /** 3208 * Broadcast sent when a user is going to be stopped. Carries an extra 3209 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only 3210 * sent to registered receivers, not manifest receivers. It is sent to all 3211 * users (including the one that is being stopped). You must hold 3212 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3213 * this broadcast. The user will not stop until all receivers have 3214 * handled the broadcast. This is sent as a background broadcast, since 3215 * its result is not part of the primary UX flow; to safely keep track of 3216 * started/stopped state of a user you can use this in conjunction with 3217 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with 3218 * other user state broadcasts since those are foreground broadcasts so can 3219 * execute in a different order. 3220 * @hide 3221 */ 3222 public static final String ACTION_USER_STOPPING = 3223 "android.intent.action.USER_STOPPING"; 3224 3225 /** 3226 * Broadcast sent to the system when a user is stopped. Carries an extra 3227 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to 3228 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a 3229 * specific package. This is only sent to registered receivers, not manifest 3230 * receivers. It is sent to all running users <em>except</em> the one that 3231 * has just been stopped (which is no longer running). 3232 * @hide 3233 */ 3234 public static final String ACTION_USER_STOPPED = 3235 "android.intent.action.USER_STOPPED"; 3236 3237 /** 3238 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has 3239 * the userHandle of the user. It is sent to all running users except the 3240 * one that has been removed. The user will not be completely removed until all receivers have 3241 * handled the broadcast. You must hold 3242 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3243 * @hide 3244 */ 3245 @SystemApi 3246 public static final String ACTION_USER_REMOVED = 3247 "android.intent.action.USER_REMOVED"; 3248 3249 /** 3250 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has 3251 * the userHandle of the user to become the current one. This is only sent to 3252 * registered receivers, not manifest receivers. It is sent to all running users. 3253 * You must hold 3254 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3255 * @hide 3256 */ 3257 public static final String ACTION_USER_SWITCHED = 3258 "android.intent.action.USER_SWITCHED"; 3259 3260 /** 3261 * Broadcast Action: Sent when the credential-encrypted private storage has 3262 * become unlocked for the target user. This is only sent to registered 3263 * receivers, not manifest receivers. 3264 */ 3265 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3266 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; 3267 3268 /** 3269 * Broadcast sent to the system when a user's information changes. Carries an extra 3270 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. 3271 * This is only sent to registered receivers, not manifest receivers. It is sent to all users. 3272 * @hide 3273 */ 3274 public static final String ACTION_USER_INFO_CHANGED = 3275 "android.intent.action.USER_INFO_CHANGED"; 3276 3277 /** 3278 * Broadcast sent to the primary user when an associated managed profile is added (the profile 3279 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies 3280 * the UserHandle of the profile that was added. Only applications (for example Launchers) 3281 * that need to display merged content across both primary and managed profiles need to 3282 * worry about this broadcast. This is only sent to registered receivers, 3283 * not manifest receivers. 3284 */ 3285 public static final String ACTION_MANAGED_PROFILE_ADDED = 3286 "android.intent.action.MANAGED_PROFILE_ADDED"; 3287 3288 /** 3289 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an 3290 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. 3291 * Only applications (for example Launchers) that need to display merged content across both 3292 * primary and managed profiles need to worry about this broadcast. This is only sent to 3293 * registered receivers, not manifest receivers. 3294 */ 3295 public static final String ACTION_MANAGED_PROFILE_REMOVED = 3296 "android.intent.action.MANAGED_PROFILE_REMOVED"; 3297 3298 /** 3299 * Broadcast sent to the primary user when the credential-encrypted private storage for 3300 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that 3301 * specifies the UserHandle of the profile that was unlocked. Only applications (for example 3302 * Launchers) that need to display merged content across both primary and managed profiles 3303 * need to worry about this broadcast. This is only sent to registered receivers, 3304 * not manifest receivers. 3305 */ 3306 public static final String ACTION_MANAGED_PROFILE_UNLOCKED = 3307 "android.intent.action.MANAGED_PROFILE_UNLOCKED"; 3308 3309 /** 3310 * Broadcast sent to the primary user when an associated managed profile has become available. 3311 * Currently this includes when the user disables quiet mode for the profile. Carries an extra 3312 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, 3313 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state 3314 * of quiet mode. This is only sent to registered receivers, not manifest receivers. 3315 */ 3316 public static final String ACTION_MANAGED_PROFILE_AVAILABLE = 3317 "android.intent.action.MANAGED_PROFILE_AVAILABLE"; 3318 3319 /** 3320 * Broadcast sent to the primary user when an associated managed profile has become unavailable. 3321 * Currently this includes when the user enables quiet mode for the profile. Carries an extra 3322 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, 3323 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state 3324 * of quiet mode. This is only sent to registered receivers, not manifest receivers. 3325 */ 3326 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = 3327 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; 3328 3329 /** 3330 * Broadcast sent to the system user when the 'device locked' state changes for any user. 3331 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which 3332 * the device was locked or unlocked. 3333 * 3334 * This is only sent to registered receivers. 3335 * 3336 * @hide 3337 */ 3338 public static final String ACTION_DEVICE_LOCKED_CHANGED = 3339 "android.intent.action.DEVICE_LOCKED_CHANGED"; 3340 3341 /** 3342 * Sent when the user taps on the clock widget in the system's "quick settings" area. 3343 */ 3344 public static final String ACTION_QUICK_CLOCK = 3345 "android.intent.action.QUICK_CLOCK"; 3346 3347 /** 3348 * Activity Action: Shows the brightness setting dialog. 3349 * @hide 3350 */ 3351 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = 3352 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; 3353 3354 /** 3355 * Broadcast Action: A global button was pressed. Includes a single 3356 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3357 * caused the broadcast. 3358 * @hide 3359 */ 3360 @SystemApi 3361 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; 3362 3363 /** 3364 * Broadcast Action: Sent when media resource is granted. 3365 * <p> 3366 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource 3367 * granted. 3368 * </p> 3369 * <p class="note"> 3370 * This is a protected intent that can only be sent by the system. 3371 * </p> 3372 * <p class="note"> 3373 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. 3374 * </p> 3375 * 3376 * @hide 3377 */ 3378 public static final String ACTION_MEDIA_RESOURCE_GRANTED = 3379 "android.intent.action.MEDIA_RESOURCE_GRANTED"; 3380 3381 /** 3382 * Broadcast Action: An overlay package has changed. The data contains the 3383 * name of the overlay package which has changed. This is broadcast on all 3384 * changes to the OverlayInfo returned by {@link 3385 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The 3386 * most common change is a state change that will change whether the 3387 * overlay is enabled or not. 3388 * @hide 3389 */ 3390 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; 3391 3392 /** 3393 * Activity Action: Allow the user to select and return one or more existing 3394 * documents. When invoked, the system will display the various 3395 * {@link DocumentsProvider} instances installed on the device, letting the 3396 * user interactively navigate through them. These documents include local 3397 * media, such as photos and video, and documents provided by installed 3398 * cloud storage providers. 3399 * <p> 3400 * Each document is represented as a {@code content://} URI backed by a 3401 * {@link DocumentsProvider}, which can be opened as a stream with 3402 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 3403 * {@link android.provider.DocumentsContract.Document} metadata. 3404 * <p> 3405 * All selected documents are returned to the calling application with 3406 * persistable read and write permission grants. If you want to maintain 3407 * access to the documents across device reboots, you need to explicitly 3408 * take the persistable permissions using 3409 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. 3410 * <p> 3411 * Callers must indicate the acceptable document MIME types through 3412 * {@link #setType(String)}. For example, to select photos, use 3413 * {@code image/*}. If multiple disjoint MIME types are acceptable, define 3414 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to 3415 * {@literal *}/*. 3416 * <p> 3417 * If the caller can handle multiple returned items (the user performing 3418 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} 3419 * to indicate this. 3420 * <p> 3421 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 3422 * URIs that can be opened with 3423 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 3424 * <p> 3425 * Callers can set a document URI through 3426 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 3427 * location of documents navigator. System will do its best to launch the 3428 * navigator in the specified document if it's a folder, or the folder that 3429 * contains the specified document if not. 3430 * <p> 3431 * Output: The URI of the item that was picked, returned in 3432 * {@link #getData()}. This must be a {@code content://} URI so that any 3433 * receiver can access it. If multiple documents were selected, they are 3434 * returned in {@link #getClipData()}. 3435 * 3436 * @see DocumentsContract 3437 * @see #ACTION_OPEN_DOCUMENT_TREE 3438 * @see #ACTION_CREATE_DOCUMENT 3439 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 3440 */ 3441 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3442 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; 3443 3444 /** 3445 * Activity Action: Allow the user to create a new document. When invoked, 3446 * the system will display the various {@link DocumentsProvider} instances 3447 * installed on the device, letting the user navigate through them. The 3448 * returned document may be a newly created document with no content, or it 3449 * may be an existing document with the requested MIME type. 3450 * <p> 3451 * Each document is represented as a {@code content://} URI backed by a 3452 * {@link DocumentsProvider}, which can be opened as a stream with 3453 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 3454 * {@link android.provider.DocumentsContract.Document} metadata. 3455 * <p> 3456 * Callers must indicate the concrete MIME type of the document being 3457 * created by setting {@link #setType(String)}. This MIME type cannot be 3458 * changed after the document is created. 3459 * <p> 3460 * Callers can provide an initial display name through {@link #EXTRA_TITLE}, 3461 * but the user may change this value before creating the file. 3462 * <p> 3463 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 3464 * URIs that can be opened with 3465 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 3466 * <p> 3467 * Callers can set a document URI through 3468 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 3469 * location of documents navigator. System will do its best to launch the 3470 * navigator in the specified document if it's a folder, or the folder that 3471 * contains the specified document if not. 3472 * <p> 3473 * Output: The URI of the item that was created. This must be a 3474 * {@code content://} URI so that any receiver can access it. 3475 * 3476 * @see DocumentsContract 3477 * @see #ACTION_OPEN_DOCUMENT 3478 * @see #ACTION_OPEN_DOCUMENT_TREE 3479 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 3480 */ 3481 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3482 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; 3483 3484 /** 3485 * Activity Action: Allow the user to pick a directory subtree. When 3486 * invoked, the system will display the various {@link DocumentsProvider} 3487 * instances installed on the device, letting the user navigate through 3488 * them. Apps can fully manage documents within the returned directory. 3489 * <p> 3490 * To gain access to descendant (child, grandchild, etc) documents, use 3491 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and 3492 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} 3493 * with the returned URI. 3494 * <p> 3495 * Callers can set a document URI through 3496 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 3497 * location of documents navigator. System will do its best to launch the 3498 * navigator in the specified document if it's a folder, or the folder that 3499 * contains the specified document if not. 3500 * <p> 3501 * Output: The URI representing the selected directory tree. 3502 * 3503 * @see DocumentsContract 3504 */ 3505 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3506 public static final String 3507 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; 3508 3509 /** 3510 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or 3511 * exisiting sensor being disconnected. 3512 * 3513 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3514 * 3515 * {@hide} 3516 */ 3517 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3518 public static final String 3519 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; 3520 3521 /** 3522 * Deprecated - use ACTION_FACTORY_RESET instead. 3523 * @hide 3524 * @removed 3525 */ 3526 @Deprecated 3527 @SystemApi 3528 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; 3529 3530 /** 3531 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe) 3532 * is about to be performed. 3533 * @hide 3534 */ 3535 @SystemApi 3536 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3537 public static final String ACTION_MASTER_CLEAR_NOTIFICATION 3538 = "android.intent.action.MASTER_CLEAR_NOTIFICATION"; 3539 3540 /** 3541 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 3542 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 3543 * 3544 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. 3545 * 3546 * @hide 3547 */ 3548 @Deprecated 3549 public static final String EXTRA_FORCE_MASTER_CLEAR = 3550 "android.intent.extra.FORCE_MASTER_CLEAR"; 3551 3552 /** 3553 * A broadcast action to trigger a factory reset. 3554 * 3555 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The 3556 * reason for the factory reset should be specified as {@link #EXTRA_REASON}. 3557 * 3558 * <p>Not for use by third-party applications. 3559 * 3560 * @see #EXTRA_FORCE_FACTORY_RESET 3561 * 3562 * {@hide} 3563 */ 3564 @SystemApi 3565 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3566 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; 3567 3568 /** 3569 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 3570 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 3571 * 3572 * <p>Not for use by third-party applications. 3573 * 3574 * @hide 3575 */ 3576 @SystemApi 3577 public static final String EXTRA_FORCE_FACTORY_RESET = 3578 "android.intent.extra.FORCE_FACTORY_RESET"; 3579 3580 /** 3581 * Broadcast action: report that a settings element is being restored from backup. The intent 3582 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting, 3583 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE 3584 * is the value of that settings entry prior to the restore operation, and 3585 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been 3586 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three 3587 * values are represented as strings, the fourth one as int. 3588 * 3589 * <p>This broadcast is sent only for settings provider entries known to require special handling 3590 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within 3591 * the provider's backup agent implementation. 3592 * 3593 * @see #EXTRA_SETTING_NAME 3594 * @see #EXTRA_SETTING_PREVIOUS_VALUE 3595 * @see #EXTRA_SETTING_NEW_VALUE 3596 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT 3597 * {@hide} 3598 */ 3599 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; 3600 3601 /** {@hide} */ 3602 public static final String EXTRA_SETTING_NAME = "setting_name"; 3603 /** {@hide} */ 3604 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; 3605 /** {@hide} */ 3606 public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; 3607 /** {@hide} */ 3608 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int"; 3609 3610 /** 3611 * Activity Action: Process a piece of text. 3612 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. 3613 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> 3614 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> 3615 */ 3616 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3617 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; 3618 3619 /** 3620 * Broadcast Action: The sim card state has changed. 3621 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here 3622 * because TelephonyIntents is an internal class. 3623 * @hide 3624 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or 3625 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 3626 */ 3627 @Deprecated 3628 @SystemApi 3629 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3630 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED"; 3631 3632 /** 3633 * Broadcast Action: indicate that the phone service state has changed. 3634 * The intent will have the following extra values:</p> 3635 * <p> 3636 * @see #EXTRA_VOICE_REG_STATE 3637 * @see #EXTRA_DATA_REG_STATE 3638 * @see #EXTRA_VOICE_ROAMING_TYPE 3639 * @see #EXTRA_DATA_ROAMING_TYPE 3640 * @see #EXTRA_OPERATOR_ALPHA_LONG 3641 * @see #EXTRA_OPERATOR_ALPHA_SHORT 3642 * @see #EXTRA_OPERATOR_NUMERIC 3643 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG 3644 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT 3645 * @see #EXTRA_DATA_OPERATOR_NUMERIC 3646 * @see #EXTRA_MANUAL 3647 * @see #EXTRA_VOICE_RADIO_TECH 3648 * @see #EXTRA_DATA_RADIO_TECH 3649 * @see #EXTRA_CSS_INDICATOR 3650 * @see #EXTRA_NETWORK_ID 3651 * @see #EXTRA_SYSTEM_ID 3652 * @see #EXTRA_CDMA_ROAMING_INDICATOR 3653 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR 3654 * @see #EXTRA_EMERGENCY_ONLY 3655 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION 3656 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION 3657 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST 3658 * 3659 * <p class="note"> 3660 * Requires the READ_PHONE_STATE permission. 3661 * 3662 * <p class="note">This is a protected intent that can only be sent by the system. 3663 * @hide 3664 * @removed 3665 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper 3666 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and 3667 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState 3668 * for a given subscription id and field with a ContentObserver or using JobScheduler. 3669 */ 3670 @Deprecated 3671 @SystemApi 3672 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 3673 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE"; 3674 3675 /** 3676 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration 3677 * state. 3678 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 3679 * @see android.telephony.ServiceState#STATE_IN_SERVICE 3680 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 3681 * @see android.telephony.ServiceState#STATE_POWER_OFF 3682 * @hide 3683 * @removed 3684 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}. 3685 */ 3686 @Deprecated 3687 @SystemApi 3688 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState"; 3689 3690 /** 3691 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state. 3692 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 3693 * @see android.telephony.ServiceState#STATE_IN_SERVICE 3694 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 3695 * @see android.telephony.ServiceState#STATE_POWER_OFF 3696 * @hide 3697 * @removed 3698 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}. 3699 */ 3700 @Deprecated 3701 @SystemApi 3702 public static final String EXTRA_DATA_REG_STATE = "dataRegState"; 3703 3704 /** 3705 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming 3706 * type. 3707 * @hide 3708 * @removed 3709 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}. 3710 */ 3711 @Deprecated 3712 @SystemApi 3713 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType"; 3714 3715 /** 3716 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming 3717 * type. 3718 * @hide 3719 * @removed 3720 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}. 3721 */ 3722 @Deprecated 3723 @SystemApi 3724 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType"; 3725 3726 /** 3727 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 3728 * registered voice operator name in long alphanumeric format. 3729 * {@code null} if the operator name is not known or unregistered. 3730 * @hide 3731 * @removed 3732 * @deprecated Use 3733 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}. 3734 */ 3735 @Deprecated 3736 @SystemApi 3737 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long"; 3738 3739 /** 3740 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 3741 * registered voice operator name in short alphanumeric format. 3742 * {@code null} if the operator name is not known or unregistered. 3743 * @hide 3744 * @removed 3745 * @deprecated Use 3746 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}. 3747 */ 3748 @Deprecated 3749 @SystemApi 3750 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short"; 3751 3752 /** 3753 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 3754 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile 3755 * network. 3756 * @hide 3757 * @removed 3758 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}. 3759 */ 3760 @Deprecated 3761 @SystemApi 3762 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric"; 3763 3764 /** 3765 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 3766 * registered data operator name in long alphanumeric format. 3767 * {@code null} if the operator name is not known or unregistered. 3768 * @hide 3769 * @removed 3770 * @deprecated Use 3771 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}. 3772 */ 3773 @Deprecated 3774 @SystemApi 3775 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long"; 3776 3777 /** 3778 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 3779 * registered data operator name in short alphanumeric format. 3780 * {@code null} if the operator name is not known or unregistered. 3781 * @hide 3782 * @removed 3783 * @deprecated Use 3784 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}. 3785 */ 3786 @Deprecated 3787 @SystemApi 3788 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short"; 3789 3790 /** 3791 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 3792 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the 3793 * data operator. 3794 * @hide 3795 * @removed 3796 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}. 3797 */ 3798 @Deprecated 3799 @SystemApi 3800 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric"; 3801 3802 /** 3803 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current 3804 * network selection mode is manual. 3805 * Will be {@code true} if manual mode, {@code false} if automatic mode. 3806 * @hide 3807 * @removed 3808 * @deprecated Use 3809 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}. 3810 */ 3811 @Deprecated 3812 @SystemApi 3813 public static final String EXTRA_MANUAL = "manual"; 3814 3815 /** 3816 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice 3817 * radio technology. 3818 * @hide 3819 * @removed 3820 * @deprecated Use 3821 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}. 3822 */ 3823 @Deprecated 3824 @SystemApi 3825 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology"; 3826 3827 /** 3828 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data 3829 * radio technology. 3830 * @hide 3831 * @removed 3832 * @deprecated Use 3833 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}. 3834 */ 3835 @Deprecated 3836 @SystemApi 3837 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology"; 3838 3839 /** 3840 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service 3841 * support on CDMA network. 3842 * Will be {@code true} if support, {@code false} otherwise. 3843 * @hide 3844 * @removed 3845 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}. 3846 */ 3847 @Deprecated 3848 @SystemApi 3849 public static final String EXTRA_CSS_INDICATOR = "cssIndicator"; 3850 3851 /** 3852 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network 3853 * id. {@code Integer.MAX_VALUE} if unknown. 3854 * @hide 3855 * @removed 3856 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}. 3857 */ 3858 @Deprecated 3859 @SystemApi 3860 public static final String EXTRA_NETWORK_ID = "networkId"; 3861 3862 /** 3863 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id. 3864 * {@code Integer.MAX_VALUE} if unknown. 3865 * @hide 3866 * @removed 3867 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}. 3868 */ 3869 @Deprecated 3870 @SystemApi 3871 public static final String EXTRA_SYSTEM_ID = "systemId"; 3872 3873 /** 3874 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming 3875 * indicator if registered on a CDMA or EVDO system or {@code -1} if not. 3876 * @hide 3877 * @removed 3878 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}. 3879 */ 3880 @Deprecated 3881 @SystemApi 3882 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator"; 3883 3884 /** 3885 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming 3886 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not. 3887 * @hide 3888 * @removed 3889 * @deprecated Use 3890 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}. 3891 */ 3892 @Deprecated 3893 @SystemApi 3894 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator"; 3895 3896 /** 3897 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency 3898 * only mode. 3899 * {@code true} if in emergency only mode, {@code false} otherwise. 3900 * @hide 3901 * @removed 3902 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}. 3903 */ 3904 @Deprecated 3905 @SystemApi 3906 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly"; 3907 3908 /** 3909 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network 3910 * registration state is roaming. 3911 * {@code true} if registration indicates roaming, {@code false} otherwise 3912 * @hide 3913 * @removed 3914 * @deprecated Use 3915 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}. 3916 */ 3917 @Deprecated 3918 @SystemApi 3919 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION = 3920 "isDataRoamingFromRegistration"; 3921 3922 /** 3923 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier 3924 * aggregation is in use. 3925 * {@code true} if carrier aggregation is in use, {@code false} otherwise. 3926 * @hide 3927 * @removed 3928 * @deprecated Use 3929 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}. 3930 */ 3931 @Deprecated 3932 @SystemApi 3933 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation"; 3934 3935 /** 3936 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which 3937 * is reduced from the rsrp threshold while calculating signal strength level. 3938 * @hide 3939 * @removed 3940 */ 3941 @Deprecated 3942 @SystemApi 3943 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; 3944 3945 /** 3946 * The name of the extra used to define the text to be processed, as a 3947 * CharSequence. Note that this may be a styled CharSequence, so you must use 3948 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. 3949 */ 3950 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; 3951 /** 3952 * The name of the boolean extra used to define if the processed text will be used as read-only. 3953 */ 3954 public static final String EXTRA_PROCESS_TEXT_READONLY = 3955 "android.intent.extra.PROCESS_TEXT_READONLY"; 3956 3957 /** 3958 * Broadcast action: reports when a new thermal event has been reached. When the device 3959 * is reaching its maximum temperatue, the thermal level reported 3960 * {@hide} 3961 */ 3962 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3963 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; 3964 3965 /** {@hide} */ 3966 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; 3967 3968 /** 3969 * Thermal state when the device is normal. This state is sent in the 3970 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 3971 * {@hide} 3972 */ 3973 public static final int EXTRA_THERMAL_STATE_NORMAL = 0; 3974 3975 /** 3976 * Thermal state where the device is approaching its maximum threshold. This state is sent in 3977 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 3978 * {@hide} 3979 */ 3980 public static final int EXTRA_THERMAL_STATE_WARNING = 1; 3981 3982 /** 3983 * Thermal state where the device has reached its maximum threshold. This state is sent in the 3984 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 3985 * {@hide} 3986 */ 3987 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; 3988 3989 /** 3990 * Broadcast Action: Indicates the dock in idle state while device is docked. 3991 * 3992 * <p class="note">This is a protected intent that can only be sent 3993 * by the system. 3994 * 3995 * @hide 3996 */ 3997 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE"; 3998 3999 /** 4000 * Broadcast Action: Indicates the dock in active state while device is docked. 4001 * 4002 * <p class="note">This is a protected intent that can only be sent 4003 * by the system. 4004 * 4005 * @hide 4006 */ 4007 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE"; 4008 4009 4010 // --------------------------------------------------------------------- 4011 // --------------------------------------------------------------------- 4012 // Standard intent categories (see addCategory()). 4013 4014 /** 4015 * Set if the activity should be an option for the default action 4016 * (center press) to perform on a piece of data. Setting this will 4017 * hide from the user any activities without it set when performing an 4018 * action on some data. Note that this is normally -not- set in the 4019 * Intent when initiating an action -- it is for use in intent filters 4020 * specified in packages. 4021 */ 4022 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4023 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; 4024 /** 4025 * Activities that can be safely invoked from a browser must support this 4026 * category. For example, if the user is viewing a web page or an e-mail 4027 * and clicks on a link in the text, the Intent generated execute that 4028 * link will require the BROWSABLE category, so that only activities 4029 * supporting this category will be considered as possible actions. By 4030 * supporting this category, you are promising that there is nothing 4031 * damaging (without user intervention) that can happen by invoking any 4032 * matching Intent. 4033 */ 4034 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4035 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; 4036 /** 4037 * Categories for activities that can participate in voice interaction. 4038 * An activity that supports this category must be prepared to run with 4039 * no UI shown at all (though in some case it may have a UI shown), and 4040 * rely on {@link android.app.VoiceInteractor} to interact with the user. 4041 */ 4042 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4043 public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; 4044 /** 4045 * Set if the activity should be considered as an alternative action to 4046 * the data the user is currently viewing. See also 4047 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that 4048 * applies to the selection in a list of items. 4049 * 4050 * <p>Supporting this category means that you would like your activity to be 4051 * displayed in the set of alternative things the user can do, usually as 4052 * part of the current activity's options menu. You will usually want to 4053 * include a specific label in the <intent-filter> of this action 4054 * describing to the user what it does. 4055 * 4056 * <p>The action of IntentFilter with this category is important in that it 4057 * describes the specific action the target will perform. This generally 4058 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather 4059 * a specific name such as "com.android.camera.action.CROP. Only one 4060 * alternative of any particular action will be shown to the user, so using 4061 * a specific action like this makes sure that your alternative will be 4062 * displayed while also allowing other applications to provide their own 4063 * overrides of that particular action. 4064 */ 4065 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4066 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; 4067 /** 4068 * Set if the activity should be considered as an alternative selection 4069 * action to the data the user has currently selected. This is like 4070 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list 4071 * of items from which the user can select, giving them alternatives to the 4072 * default action that will be performed on it. 4073 */ 4074 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4075 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; 4076 /** 4077 * Intended to be used as a tab inside of a containing TabActivity. 4078 */ 4079 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4080 public static final String CATEGORY_TAB = "android.intent.category.TAB"; 4081 /** 4082 * Should be displayed in the top-level launcher. 4083 */ 4084 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4085 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; 4086 /** 4087 * Indicates an activity optimized for Leanback mode, and that should 4088 * be displayed in the Leanback launcher. 4089 */ 4090 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4091 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; 4092 /** 4093 * Indicates the preferred entry-point activity when an application is launched from a Car 4094 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a 4095 * fallback, or exclude the application entirely. 4096 * @hide 4097 */ 4098 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4099 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER"; 4100 /** 4101 * Indicates a Leanback settings activity to be displayed in the Leanback launcher. 4102 * @hide 4103 */ 4104 @SystemApi 4105 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; 4106 /** 4107 * Provides information about the package it is in; typically used if 4108 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide 4109 * a front-door to the user without having to be shown in the all apps list. 4110 */ 4111 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4112 public static final String CATEGORY_INFO = "android.intent.category.INFO"; 4113 /** 4114 * This is the home activity, that is the first activity that is displayed 4115 * when the device boots. 4116 */ 4117 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4118 public static final String CATEGORY_HOME = "android.intent.category.HOME"; 4119 /** 4120 * This is the home activity that is displayed when the device is finished setting up and ready 4121 * for use. 4122 * @hide 4123 */ 4124 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4125 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; 4126 /** 4127 * This is the setup wizard activity, that is the first activity that is displayed 4128 * when the user sets up the device for the first time. 4129 * @hide 4130 */ 4131 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4132 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; 4133 /** 4134 * This is the home activity, that is the activity that serves as the launcher app 4135 * from there the user can start other apps. Often components with lower/higher 4136 * priority intent filters handle the home intent, for example SetupWizard, to 4137 * setup the device and we need to be able to distinguish the home app from these 4138 * setup helpers. 4139 * @hide 4140 */ 4141 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4142 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP"; 4143 /** 4144 * This activity is a preference panel. 4145 */ 4146 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4147 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; 4148 /** 4149 * This activity is a development preference panel. 4150 */ 4151 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4152 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; 4153 /** 4154 * Capable of running inside a parent activity container. 4155 */ 4156 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4157 public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; 4158 /** 4159 * This activity allows the user to browse and download new applications. 4160 */ 4161 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4162 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; 4163 /** 4164 * This activity may be exercised by the monkey or other automated test tools. 4165 */ 4166 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4167 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; 4168 /** 4169 * To be used as a test (not part of the normal user experience). 4170 */ 4171 public static final String CATEGORY_TEST = "android.intent.category.TEST"; 4172 /** 4173 * To be used as a unit test (run through the Test Harness). 4174 */ 4175 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; 4176 /** 4177 * To be used as a sample code example (not part of the normal user 4178 * experience). 4179 */ 4180 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; 4181 4182 /** 4183 * Used to indicate that an intent only wants URIs that can be opened with 4184 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs 4185 * must support at least the columns defined in {@link OpenableColumns} when 4186 * queried. 4187 * 4188 * @see #ACTION_GET_CONTENT 4189 * @see #ACTION_OPEN_DOCUMENT 4190 * @see #ACTION_CREATE_DOCUMENT 4191 */ 4192 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4193 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; 4194 4195 /** 4196 * Used to indicate that an intent filter can accept files which are not necessarily 4197 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but 4198 * at least streamable via 4199 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} 4200 * using one of the stream types exposed via 4201 * {@link ContentResolver#getStreamTypes(Uri, String)}. 4202 * 4203 * @see #ACTION_SEND 4204 * @see #ACTION_SEND_MULTIPLE 4205 */ 4206 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4207 public static final String CATEGORY_TYPED_OPENABLE = 4208 "android.intent.category.TYPED_OPENABLE"; 4209 4210 /** 4211 * To be used as code under test for framework instrumentation tests. 4212 */ 4213 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = 4214 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; 4215 /** 4216 * An activity to run when device is inserted into a car dock. 4217 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4218 * information, see {@link android.app.UiModeManager}. 4219 */ 4220 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4221 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; 4222 /** 4223 * An activity to run when device is inserted into a car dock. 4224 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4225 * information, see {@link android.app.UiModeManager}. 4226 */ 4227 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4228 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; 4229 /** 4230 * An activity to run when device is inserted into a analog (low end) dock. 4231 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4232 * information, see {@link android.app.UiModeManager}. 4233 */ 4234 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4235 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; 4236 4237 /** 4238 * An activity to run when device is inserted into a digital (high end) dock. 4239 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4240 * information, see {@link android.app.UiModeManager}. 4241 */ 4242 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4243 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK"; 4244 4245 /** 4246 * Used to indicate that the activity can be used in a car environment. 4247 */ 4248 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4249 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; 4250 4251 /** 4252 * An activity to use for the launcher when the device is placed in a VR Headset viewer. 4253 * Used with {@link #ACTION_MAIN} to launch an activity. For more 4254 * information, see {@link android.app.UiModeManager}. 4255 */ 4256 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4257 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; 4258 // --------------------------------------------------------------------- 4259 // --------------------------------------------------------------------- 4260 // Application launch intent categories (see addCategory()). 4261 4262 /** 4263 * Used with {@link #ACTION_MAIN} to launch the browser application. 4264 * The activity should be able to browse the Internet. 4265 * <p>NOTE: This should not be used as the primary key of an Intent, 4266 * since it will not result in the app launching with the correct 4267 * action and category. Instead, use this with 4268 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4269 * Intent with this category in the selector.</p> 4270 */ 4271 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4272 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; 4273 4274 /** 4275 * Used with {@link #ACTION_MAIN} to launch the calculator application. 4276 * The activity should be able to perform standard arithmetic operations. 4277 * <p>NOTE: This should not be used as the primary key of an Intent, 4278 * since it will not result in the app launching with the correct 4279 * action and category. Instead, use this with 4280 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4281 * Intent with this category in the selector.</p> 4282 */ 4283 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4284 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; 4285 4286 /** 4287 * Used with {@link #ACTION_MAIN} to launch the calendar application. 4288 * The activity should be able to view and manipulate calendar entries. 4289 * <p>NOTE: This should not be used as the primary key of an Intent, 4290 * since it will not result in the app launching with the correct 4291 * action and category. Instead, use this with 4292 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4293 * Intent with this category in the selector.</p> 4294 */ 4295 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4296 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; 4297 4298 /** 4299 * Used with {@link #ACTION_MAIN} to launch the contacts application. 4300 * The activity should be able to view and manipulate address book entries. 4301 * <p>NOTE: This should not be used as the primary key of an Intent, 4302 * since it will not result in the app launching with the correct 4303 * action and category. Instead, use this with 4304 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4305 * Intent with this category in the selector.</p> 4306 */ 4307 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4308 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; 4309 4310 /** 4311 * Used with {@link #ACTION_MAIN} to launch the email application. 4312 * The activity should be able to send and receive email. 4313 * <p>NOTE: This should not be used as the primary key of an Intent, 4314 * since it will not result in the app launching with the correct 4315 * action and category. Instead, use this with 4316 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4317 * Intent with this category in the selector.</p> 4318 */ 4319 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4320 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; 4321 4322 /** 4323 * Used with {@link #ACTION_MAIN} to launch the gallery application. 4324 * The activity should be able to view and manipulate image and video files 4325 * stored on the device. 4326 * <p>NOTE: This should not be used as the primary key of an Intent, 4327 * since it will not result in the app launching with the correct 4328 * action and category. Instead, use this with 4329 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4330 * Intent with this category in the selector.</p> 4331 */ 4332 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4333 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; 4334 4335 /** 4336 * Used with {@link #ACTION_MAIN} to launch the maps application. 4337 * The activity should be able to show the user's current location and surroundings. 4338 * <p>NOTE: This should not be used as the primary key of an Intent, 4339 * since it will not result in the app launching with the correct 4340 * action and category. Instead, use this with 4341 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4342 * Intent with this category in the selector.</p> 4343 */ 4344 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4345 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; 4346 4347 /** 4348 * Used with {@link #ACTION_MAIN} to launch the messaging application. 4349 * The activity should be able to send and receive text messages. 4350 * <p>NOTE: This should not be used as the primary key of an Intent, 4351 * since it will not result in the app launching with the correct 4352 * action and category. Instead, use this with 4353 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4354 * Intent with this category in the selector.</p> 4355 */ 4356 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4357 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; 4358 4359 /** 4360 * Used with {@link #ACTION_MAIN} to launch the music application. 4361 * The activity should be able to play, browse, or manipulate music files 4362 * stored on the device. 4363 * <p>NOTE: This should not be used as the primary key of an Intent, 4364 * since it will not result in the app launching with the correct 4365 * action and category. Instead, use this with 4366 * {@link #makeMainSelectorActivity(String, String)} to generate a main 4367 * Intent with this category in the selector.</p> 4368 */ 4369 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 4370 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; 4371 4372 // --------------------------------------------------------------------- 4373 // --------------------------------------------------------------------- 4374 // Standard extra data keys. 4375 4376 /** 4377 * The initial data to place in a newly created record. Use with 4378 * {@link #ACTION_INSERT}. The data here is a Map containing the same 4379 * fields as would be given to the underlying ContentProvider.insert() 4380 * call. 4381 */ 4382 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; 4383 4384 /** 4385 * A constant CharSequence that is associated with the Intent, used with 4386 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that 4387 * this may be a styled CharSequence, so you must use 4388 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to 4389 * retrieve it. 4390 */ 4391 public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; 4392 4393 /** 4394 * A constant String that is associated with the Intent, used with 4395 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} 4396 * as HTML formatted text. Note that you <em>must</em> also supply 4397 * {@link #EXTRA_TEXT}. 4398 */ 4399 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; 4400 4401 /** 4402 * A content: URI holding a stream of data associated with the Intent, 4403 * used with {@link #ACTION_SEND} to supply the data being sent. 4404 */ 4405 public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; 4406 4407 /** 4408 * A String[] holding e-mail addresses that should be delivered to. 4409 */ 4410 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; 4411 4412 /** 4413 * A String[] holding e-mail addresses that should be carbon copied. 4414 */ 4415 public static final String EXTRA_CC = "android.intent.extra.CC"; 4416 4417 /** 4418 * A String[] holding e-mail addresses that should be blind carbon copied. 4419 */ 4420 public static final String EXTRA_BCC = "android.intent.extra.BCC"; 4421 4422 /** 4423 * A constant string holding the desired subject line of a message. 4424 */ 4425 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; 4426 4427 /** 4428 * An Intent describing the choices you would like shown with 4429 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. 4430 */ 4431 public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; 4432 4433 /** 4434 * An int representing the user id to be used. 4435 * 4436 * @hide 4437 */ 4438 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; 4439 4440 /** 4441 * An int representing the task id to be retrieved. This is used when a launch from recents is 4442 * intercepted by another action such as credentials confirmation to remember which task should 4443 * be resumed when complete. 4444 * 4445 * @hide 4446 */ 4447 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; 4448 4449 /** 4450 * An Intent[] describing additional, alternate choices you would like shown with 4451 * {@link #ACTION_CHOOSER}. 4452 * 4453 * <p>An app may be capable of providing several different payload types to complete a 4454 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos 4455 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer 4456 * several different supported sending mechanisms for sharing, such as the actual "image/*" 4457 * photo data or a hosted link where the photos can be viewed.</p> 4458 * 4459 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the 4460 * first/primary/preferred intent in the set. Additional intents specified in 4461 * this extra are ordered; by default intents that appear earlier in the array will be 4462 * preferred over intents that appear later in the array as matches for the same 4463 * target component. To alter this preference, a calling app may also supply 4464 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> 4465 */ 4466 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; 4467 4468 /** 4469 * A {@link ComponentName ComponentName[]} describing components that should be filtered out 4470 * and omitted from a list of components presented to the user. 4471 * 4472 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components 4473 * in this array if it otherwise would have shown them. Useful for omitting specific targets 4474 * from your own package or other apps from your organization if the idea of sending to those 4475 * targets would be redundant with other app functionality. Filtered components will not 4476 * be able to present targets from an associated <code>ChooserTargetService</code>.</p> 4477 */ 4478 public static final String EXTRA_EXCLUDE_COMPONENTS 4479 = "android.intent.extra.EXCLUDE_COMPONENTS"; 4480 4481 /** 4482 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} 4483 * describing additional high-priority deep-link targets for the chooser to present to the user. 4484 * 4485 * <p>Targets provided in this way will be presented inline with all other targets provided 4486 * by services from other apps. They will be prioritized before other service targets, but 4487 * after those targets provided by sources that the user has manually pinned to the front.</p> 4488 * 4489 * @see #ACTION_CHOOSER 4490 */ 4491 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; 4492 4493 /** 4494 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection 4495 * from the chooser activity presented by {@link #ACTION_CHOOSER}. 4496 * 4497 * <p>An app preparing an action for another app to complete may wish to allow the user to 4498 * disambiguate between several options for completing the action based on the chosen target 4499 * or otherwise refine the action before it is invoked. 4500 * </p> 4501 * 4502 * <p>When sent, this IntentSender may be filled in with the following extras:</p> 4503 * <ul> 4504 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> 4505 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's 4506 * chosen target beyond the first</li> 4507 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity 4508 * should fill in and send once the disambiguation is complete</li> 4509 * </ul> 4510 */ 4511 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER 4512 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; 4513 4514 /** 4515 * An {@code ArrayList} of {@code String} annotations describing content for 4516 * {@link #ACTION_CHOOSER}. 4517 * 4518 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a 4519 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> 4520 * 4521 * <p>Annotations should describe the major components or topics of the content. It is up to 4522 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be 4523 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to 4524 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon 4525 * character. Performance on customized annotations can suffer, if they are rarely used for 4526 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the 4527 * following annotations when applicable.</p> 4528 * <ul> 4529 * <li>"product" represents that the topic of the content is mainly about products, e.g., 4530 * health & beauty, and office supplies.</li> 4531 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g., 4532 * happy, and sad.</li> 4533 * <li>"person" represents that the topic of the content is mainly about persons, e.g., 4534 * face, finger, standing, and walking.</li> 4535 * <li>"child" represents that the topic of the content is mainly about children, e.g., 4536 * child, and baby.</li> 4537 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li> 4538 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li> 4539 * <li>"party" represents that the topic of the content is mainly about parties.</li> 4540 * <li>"animal" represent that the topic of the content is mainly about animals.</li> 4541 * <li>"plant" represents that the topic of the content is mainly about plants, e.g., 4542 * flowers.</li> 4543 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li> 4544 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g. 4545 * sunglasses, jewelry, handbags and clothing.</li> 4546 * <li>"material" represents that the topic of the content is mainly about materials, e.g., 4547 * paper, and silk.</li> 4548 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like 4549 * cars, and boats.</li> 4550 * <li>"document" represents that the topic of the content is mainly about documents, e.g. 4551 * posters.</li> 4552 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts 4553 * and designs of houses.</li> 4554 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g., 4555 * Christmas and Thanksgiving.</li> 4556 * </ul> 4557 */ 4558 public static final String EXTRA_CONTENT_ANNOTATIONS 4559 = "android.intent.extra.CONTENT_ANNOTATIONS"; 4560 4561 /** 4562 * A {@link ResultReceiver} used to return data back to the sender. 4563 * 4564 * <p>Used to complete an app-specific 4565 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> 4566 * 4567 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent 4568 * used to start a {@link #ACTION_CHOOSER} activity this extra will be 4569 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent 4570 * when the user selects a target component from the chooser. It is up to the recipient 4571 * to send a result to this ResultReceiver to signal that disambiguation is complete 4572 * and that the chooser should invoke the user's choice.</p> 4573 * 4574 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent 4575 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser 4576 * to match and fill in the final Intent or ChooserTarget before starting it. 4577 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from 4578 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to 4579 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> 4580 * 4581 * <p>The result code passed to the ResultReceiver should be 4582 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's 4583 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if 4584 * the chooser should finish without starting a target.</p> 4585 */ 4586 public static final String EXTRA_RESULT_RECEIVER 4587 = "android.intent.extra.RESULT_RECEIVER"; 4588 4589 /** 4590 * A CharSequence dialog title to provide to the user when used with a 4591 * {@link #ACTION_CHOOSER}. 4592 */ 4593 public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; 4594 4595 /** 4596 * A Parcelable[] of {@link Intent} or 4597 * {@link android.content.pm.LabeledIntent} objects as set with 4598 * {@link #putExtra(String, Parcelable[])} of additional activities to place 4599 * a the front of the list of choices, when shown to the user with a 4600 * {@link #ACTION_CHOOSER}. 4601 */ 4602 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; 4603 4604 /** 4605 * A {@link IntentSender} to start after ephemeral installation success. 4606 * @deprecated Use {@link #EXTRA_INSTANT_APP_SUCCESS). 4607 * @removed 4608 * @hide 4609 */ 4610 @Deprecated 4611 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS"; 4612 4613 /** 4614 * A {@link IntentSender} to start after instant app installation success. 4615 * @hide 4616 */ 4617 @SystemApi 4618 public static final String EXTRA_INSTANT_APP_SUCCESS = 4619 "android.intent.extra.INSTANT_APP_SUCCESS"; 4620 4621 /** 4622 * A {@link IntentSender} to start after ephemeral installation failure. 4623 * @deprecated Use {@link #EXTRA_INSTANT_APP_FAILURE). 4624 * @removed 4625 * @hide 4626 */ 4627 @Deprecated 4628 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE"; 4629 4630 /** 4631 * A {@link IntentSender} to start after instant app installation failure. 4632 * @hide 4633 */ 4634 @SystemApi 4635 public static final String EXTRA_INSTANT_APP_FAILURE = 4636 "android.intent.extra.INSTANT_APP_FAILURE"; 4637 4638 /** 4639 * The host name that triggered an ephemeral resolution. 4640 * @deprecated Use {@link #EXTRA_INSTANT_APP_HOSTNAME). 4641 * @removed 4642 * @hide 4643 */ 4644 @Deprecated 4645 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME"; 4646 4647 /** 4648 * The host name that triggered an instant app resolution. 4649 * @hide 4650 */ 4651 @SystemApi 4652 public static final String EXTRA_INSTANT_APP_HOSTNAME = 4653 "android.intent.extra.INSTANT_APP_HOSTNAME"; 4654 4655 /** 4656 * An opaque token to track ephemeral resolution. 4657 * @deprecated Use {@link #EXTRA_INSTANT_APP_TOKEN). 4658 * @removed 4659 * @hide 4660 */ 4661 @Deprecated 4662 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN"; 4663 4664 /** 4665 * An opaque token to track instant app resolution. 4666 * @hide 4667 */ 4668 @SystemApi 4669 public static final String EXTRA_INSTANT_APP_TOKEN = 4670 "android.intent.extra.INSTANT_APP_TOKEN"; 4671 4672 /** 4673 * The action that triggered an instant application resolution. 4674 * @hide 4675 */ 4676 @SystemApi 4677 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION"; 4678 4679 /** 4680 * An array of {@link Bundle}s containing details about resolved instant apps.. 4681 * @hide 4682 */ 4683 @SystemApi 4684 public static final String EXTRA_INSTANT_APP_BUNDLES = 4685 "android.intent.extra.INSTANT_APP_BUNDLES"; 4686 4687 /** 4688 * A {@link Bundle} of metadata that describes the instant application that needs to be 4689 * installed. This data is populated from the response to 4690 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered 4691 * instant application resolver. 4692 * @hide 4693 */ 4694 @SystemApi 4695 public static final String EXTRA_INSTANT_APP_EXTRAS = 4696 "android.intent.extra.INSTANT_APP_EXTRAS"; 4697 4698 /** 4699 * A boolean value indicating that the instant app resolver was unable to state with certainty 4700 * that it did or did not have an app for the sanitized {@link Intent} defined at 4701 * {@link #EXTRA_INTENT}. 4702 * @hide 4703 */ 4704 @SystemApi 4705 public static final String EXTRA_UNKNOWN_INSTANT_APP = 4706 "android.intent.extra.UNKNOWN_INSTANT_APP"; 4707 4708 /** 4709 * The version code of the app to install components from. 4710 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE). 4711 * @hide 4712 */ 4713 @Deprecated 4714 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; 4715 4716 /** 4717 * The version code of the app to install components from. 4718 * @hide 4719 */ 4720 @SystemApi 4721 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE"; 4722 4723 /** 4724 * The app that triggered the instant app installation. 4725 * @hide 4726 */ 4727 @SystemApi 4728 public static final String EXTRA_CALLING_PACKAGE 4729 = "android.intent.extra.CALLING_PACKAGE"; 4730 4731 /** 4732 * Optional calling app provided bundle containing additional launch information the 4733 * installer may use. 4734 * @hide 4735 */ 4736 @SystemApi 4737 public static final String EXTRA_VERIFICATION_BUNDLE 4738 = "android.intent.extra.VERIFICATION_BUNDLE"; 4739 4740 /** 4741 * A Bundle forming a mapping of potential target package names to different extras Bundles 4742 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with 4743 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not 4744 * be currently installed on the device. 4745 * 4746 * <p>An application may choose to provide alternate extras for the case where a user 4747 * selects an activity from a predetermined set of target packages. If the activity 4748 * the user selects from the chooser belongs to a package with its package name as 4749 * a key in this bundle, the corresponding extras for that package will be merged with 4750 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement 4751 * extra has the same key as an extra already present in the intent it will overwrite 4752 * the extra from the intent.</p> 4753 * 4754 * <p><em>Examples:</em> 4755 * <ul> 4756 * <li>An application may offer different {@link #EXTRA_TEXT} to an application 4757 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query 4758 * parameters for that target.</li> 4759 * <li>An application may offer additional metadata for known targets of a given intent 4760 * to pass along information only relevant to that target such as account or content 4761 * identifiers already known to that application.</li> 4762 * </ul></p> 4763 */ 4764 public static final String EXTRA_REPLACEMENT_EXTRAS = 4765 "android.intent.extra.REPLACEMENT_EXTRAS"; 4766 4767 /** 4768 * An {@link IntentSender} that will be notified if a user successfully chooses a target 4769 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender 4770 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the 4771 * {@link ComponentName} of the chosen component. 4772 * 4773 * <p>In some situations this callback may never come, for example if the user abandons 4774 * the chooser, switches to another task or any number of other reasons. Apps should not 4775 * be written assuming that this callback will always occur.</p> 4776 */ 4777 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = 4778 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; 4779 4780 /** 4781 * The {@link ComponentName} chosen by the user to complete an action. 4782 * 4783 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER 4784 */ 4785 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; 4786 4787 /** 4788 * A {@link android.view.KeyEvent} object containing the event that 4789 * triggered the creation of the Intent it is in. 4790 */ 4791 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; 4792 4793 /** 4794 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user 4795 * before shutting down. 4796 * 4797 * {@hide} 4798 */ 4799 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; 4800 4801 /** 4802 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is 4803 * requested by the user. 4804 * 4805 * {@hide} 4806 */ 4807 public static final String EXTRA_USER_REQUESTED_SHUTDOWN = 4808 "android.intent.extra.USER_REQUESTED_SHUTDOWN"; 4809 4810 /** 4811 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 4812 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action 4813 * of restarting the application. 4814 */ 4815 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; 4816 4817 /** 4818 * A String holding the phone number originally entered in 4819 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual 4820 * number to call in a {@link android.content.Intent#ACTION_CALL}. 4821 */ 4822 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; 4823 4824 /** 4825 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} 4826 * intents to supply the uid the package had been assigned. Also an optional 4827 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 4828 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same 4829 * purpose. 4830 */ 4831 public static final String EXTRA_UID = "android.intent.extra.UID"; 4832 4833 /** 4834 * @hide String array of package names. 4835 */ 4836 @SystemApi 4837 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; 4838 4839 /** 4840 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 4841 * intents to indicate whether this represents a full uninstall (removing 4842 * both the code and its data) or a partial uninstall (leaving its data, 4843 * implying that this is an update). 4844 */ 4845 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; 4846 4847 /** 4848 * @hide 4849 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 4850 * intents to indicate that at this point the package has been removed for 4851 * all users on the device. 4852 */ 4853 public static final String EXTRA_REMOVED_FOR_ALL_USERS 4854 = "android.intent.extra.REMOVED_FOR_ALL_USERS"; 4855 4856 /** 4857 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 4858 * intents to indicate that this is a replacement of the package, so this 4859 * broadcast will immediately be followed by an add broadcast for a 4860 * different version of the same package. 4861 */ 4862 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING"; 4863 4864 /** 4865 * Used as an int extra field in {@link android.app.AlarmManager} intents 4866 * to tell the application being invoked how many pending alarms are being 4867 * delievered with the intent. For one-shot alarms this will always be 1. 4868 * For recurring alarms, this might be greater than 1 if the device was 4869 * asleep or powered off at the time an earlier alarm would have been 4870 * delivered. 4871 */ 4872 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; 4873 4874 /** 4875 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} 4876 * intents to request the dock state. Possible values are 4877 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, 4878 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or 4879 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or 4880 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or 4881 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. 4882 */ 4883 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; 4884 4885 /** 4886 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 4887 * to represent that the phone is not in any dock. 4888 */ 4889 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; 4890 4891 /** 4892 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 4893 * to represent that the phone is in a desk dock. 4894 */ 4895 public static final int EXTRA_DOCK_STATE_DESK = 1; 4896 4897 /** 4898 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 4899 * to represent that the phone is in a car dock. 4900 */ 4901 public static final int EXTRA_DOCK_STATE_CAR = 2; 4902 4903 /** 4904 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 4905 * to represent that the phone is in a analog (low end) dock. 4906 */ 4907 public static final int EXTRA_DOCK_STATE_LE_DESK = 3; 4908 4909 /** 4910 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 4911 * to represent that the phone is in a digital (high end) dock. 4912 */ 4913 public static final int EXTRA_DOCK_STATE_HE_DESK = 4; 4914 4915 /** 4916 * Boolean that can be supplied as meta-data with a dock activity, to 4917 * indicate that the dock should take over the home key when it is active. 4918 */ 4919 public static final String METADATA_DOCK_HOME = "android.dock_home"; 4920 4921 /** 4922 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing 4923 * the bug report. 4924 */ 4925 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; 4926 4927 /** 4928 * Used in the extra field in the remote intent. It's astring token passed with the 4929 * remote intent. 4930 */ 4931 public static final String EXTRA_REMOTE_INTENT_TOKEN = 4932 "android.intent.extra.remote_intent_token"; 4933 4934 /** 4935 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field 4936 * will contain only the first name in the list. 4937 */ 4938 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = 4939 "android.intent.extra.changed_component_name"; 4940 4941 /** 4942 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, 4943 * and contains a string array of all of the components that have changed. If 4944 * the state of the overall package has changed, then it will contain an entry 4945 * with the package name itself. 4946 */ 4947 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = 4948 "android.intent.extra.changed_component_name_list"; 4949 4950 /** 4951 * This field is part of 4952 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 4953 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, 4954 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, 4955 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} 4956 * and contains a string array of all of the components that have changed. 4957 */ 4958 public static final String EXTRA_CHANGED_PACKAGE_LIST = 4959 "android.intent.extra.changed_package_list"; 4960 4961 /** 4962 * This field is part of 4963 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 4964 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 4965 * and contains an integer array of uids of all of the components 4966 * that have changed. 4967 */ 4968 public static final String EXTRA_CHANGED_UID_LIST = 4969 "android.intent.extra.changed_uid_list"; 4970 4971 /** 4972 * @hide 4973 * Magic extra system code can use when binding, to give a label for 4974 * who it is that has bound to a service. This is an integer giving 4975 * a framework string resource that can be displayed to the user. 4976 */ 4977 public static final String EXTRA_CLIENT_LABEL = 4978 "android.intent.extra.client_label"; 4979 4980 /** 4981 * @hide 4982 * Magic extra system code can use when binding, to give a PendingIntent object 4983 * that can be launched for the user to disable the system's use of this 4984 * service. 4985 */ 4986 public static final String EXTRA_CLIENT_INTENT = 4987 "android.intent.extra.client_intent"; 4988 4989 /** 4990 * Extra used to indicate that an intent should only return data that is on 4991 * the local device. This is a boolean extra; the default is false. If true, 4992 * an implementation should only allow the user to select data that is 4993 * already on the device, not requiring it be downloaded from a remote 4994 * service when opened. 4995 * 4996 * @see #ACTION_GET_CONTENT 4997 * @see #ACTION_OPEN_DOCUMENT 4998 * @see #ACTION_OPEN_DOCUMENT_TREE 4999 * @see #ACTION_CREATE_DOCUMENT 5000 */ 5001 public static final String EXTRA_LOCAL_ONLY = 5002 "android.intent.extra.LOCAL_ONLY"; 5003 5004 /** 5005 * Extra used to indicate that an intent can allow the user to select and 5006 * return multiple items. This is a boolean extra; the default is false. If 5007 * true, an implementation is allowed to present the user with a UI where 5008 * they can pick multiple items that are all returned to the caller. When 5009 * this happens, they should be returned as the {@link #getClipData()} part 5010 * of the result Intent. 5011 * 5012 * @see #ACTION_GET_CONTENT 5013 * @see #ACTION_OPEN_DOCUMENT 5014 */ 5015 public static final String EXTRA_ALLOW_MULTIPLE = 5016 "android.intent.extra.ALLOW_MULTIPLE"; 5017 5018 /** 5019 * The integer userHandle carried with broadcast intents related to addition, removal and 5020 * switching of users and managed profiles - {@link #ACTION_USER_ADDED}, 5021 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. 5022 * 5023 * @hide 5024 */ 5025 public static final String EXTRA_USER_HANDLE = 5026 "android.intent.extra.user_handle"; 5027 5028 /** 5029 * The UserHandle carried with broadcasts intents related to addition and removal of managed 5030 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}. 5031 */ 5032 public static final String EXTRA_USER = 5033 "android.intent.extra.USER"; 5034 5035 /** 5036 * Extra used in the response from a BroadcastReceiver that handles 5037 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is 5038 * <code>ArrayList<RestrictionEntry></code>. 5039 */ 5040 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; 5041 5042 /** 5043 * Extra sent in the intent to the BroadcastReceiver that handles 5044 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing 5045 * the restrictions as key/value pairs. 5046 */ 5047 public static final String EXTRA_RESTRICTIONS_BUNDLE = 5048 "android.intent.extra.restrictions_bundle"; 5049 5050 /** 5051 * Extra used in the response from a BroadcastReceiver that handles 5052 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. 5053 */ 5054 public static final String EXTRA_RESTRICTIONS_INTENT = 5055 "android.intent.extra.restrictions_intent"; 5056 5057 /** 5058 * Extra used to communicate a set of acceptable MIME types. The type of the 5059 * extra is {@code String[]}. Values may be a combination of concrete MIME 5060 * types (such as "image/png") and/or partial MIME types (such as 5061 * "audio/*"). 5062 * 5063 * @see #ACTION_GET_CONTENT 5064 * @see #ACTION_OPEN_DOCUMENT 5065 */ 5066 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; 5067 5068 /** 5069 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that 5070 * this shutdown is only for the user space of the system, not a complete shutdown. 5071 * When this is true, hardware devices can use this information to determine that 5072 * they shouldn't do a complete shutdown of their device since this is not a 5073 * complete shutdown down to the kernel, but only user space restarting. 5074 * The default if not supplied is false. 5075 */ 5076 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY 5077 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; 5078 5079 /** 5080 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the 5081 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, 5082 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and 5083 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative. 5084 * 5085 * @hide for internal use only. 5086 */ 5087 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = 5088 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; 5089 /** @hide */ 5090 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; 5091 /** @hide */ 5092 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; 5093 /** @hide */ 5094 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; 5095 5096 /** 5097 * Intent extra: the reason that the operation associated with this intent is being performed. 5098 * 5099 * <p>Type: String 5100 * @hide 5101 */ 5102 @SystemApi 5103 public static final String EXTRA_REASON = "android.intent.extra.REASON"; 5104 5105 /** 5106 * {@hide} 5107 * This extra will be send together with {@link #ACTION_FACTORY_RESET} 5108 */ 5109 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; 5110 5111 /** 5112 * {@hide} 5113 * This extra will be set to true when the user choose to wipe the data on eSIM during factory 5114 * reset for the device with eSIM. This extra will be sent together with 5115 * {@link #ACTION_FACTORY_RESET} 5116 */ 5117 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; 5118 5119 /** 5120 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM 5121 * activation request. 5122 * TODO: Add information about the structure and response data used with the pending intent. 5123 * @hide 5124 */ 5125 public static final String EXTRA_SIM_ACTIVATION_RESPONSE = 5126 "android.intent.extra.SIM_ACTIVATION_RESPONSE"; 5127 5128 /** 5129 * Optional index with semantics depending on the intent action. 5130 * 5131 * <p>The value must be an integer greater or equal to 0. 5132 * @see #ACTION_QUICK_VIEW 5133 */ 5134 public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; 5135 5136 /** 5137 * Tells the quick viewer to show additional UI actions suitable for the passed Uris, 5138 * such as opening in other apps, sharing, opening, editing, printing, deleting, 5139 * casting, etc. 5140 * 5141 * <p>The value is boolean. By default false. 5142 * @see #ACTION_QUICK_VIEW 5143 * @removed 5144 */ 5145 @Deprecated 5146 public static final String EXTRA_QUICK_VIEW_ADVANCED = 5147 "android.intent.extra.QUICK_VIEW_ADVANCED"; 5148 5149 /** 5150 * An optional extra of {@code String[]} indicating which quick view features should be made 5151 * available to the user in the quick view UI while handing a 5152 * {@link Intent#ACTION_QUICK_VIEW} intent. 5153 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer. 5154 * Quick viewer can implement features not listed below. 5155 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW}, 5156 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE}, 5157 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND}, 5158 * {@link QuickViewConstants#FEATURE_PRINT}. 5159 * <p> 5160 * Requirements: 5161 * <li>Quick viewer shouldn't show a feature if the feature is absent in 5162 * {@link #EXTRA_QUICK_VIEW_FEATURES}. 5163 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow 5164 * internal policies. 5165 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a 5166 * requirement that the feature be shown. Quick viewer may, according to its own policies, 5167 * disable or hide features. 5168 * 5169 * @see #ACTION_QUICK_VIEW 5170 */ 5171 public static final String EXTRA_QUICK_VIEW_FEATURES = 5172 "android.intent.extra.QUICK_VIEW_FEATURES"; 5173 5174 /** 5175 * Optional boolean extra indicating whether quiet mode has been switched on or off. 5176 * When a profile goes into quiet mode, all apps in the profile are killed and the 5177 * profile user is stopped. Widgets originating from the profile are masked, and app 5178 * launcher icons are grayed out. 5179 */ 5180 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; 5181 5182 /** 5183 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} 5184 * intents to specify the resource type granted. Possible values are 5185 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or 5186 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. 5187 * 5188 * @hide 5189 */ 5190 public static final String EXTRA_MEDIA_RESOURCE_TYPE = 5191 "android.intent.extra.MEDIA_RESOURCE_TYPE"; 5192 5193 /** 5194 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify 5195 * whether to show the chooser or not when there is only one application available 5196 * to choose from. 5197 * 5198 * @hide 5199 */ 5200 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = 5201 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; 5202 5203 /** 5204 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 5205 * to represent that a video codec is allowed to use. 5206 * 5207 * @hide 5208 */ 5209 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; 5210 5211 /** 5212 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 5213 * to represent that a audio codec is allowed to use. 5214 * 5215 * @hide 5216 */ 5217 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; 5218 5219 // --------------------------------------------------------------------- 5220 // --------------------------------------------------------------------- 5221 // Intent flags (see mFlags variable). 5222 5223 /** @hide */ 5224 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 5225 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, 5226 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) 5227 @Retention(RetentionPolicy.SOURCE) 5228 public @interface GrantUriMode {} 5229 5230 /** @hide */ 5231 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 5232 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) 5233 @Retention(RetentionPolicy.SOURCE) 5234 public @interface AccessUriMode {} 5235 5236 /** 5237 * Test if given mode flags specify an access mode, which must be at least 5238 * read and/or write. 5239 * 5240 * @hide 5241 */ isAccessUriMode(int modeFlags)5242 public static boolean isAccessUriMode(int modeFlags) { 5243 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION 5244 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; 5245 } 5246 5247 /** @hide */ 5248 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 5249 FLAG_GRANT_READ_URI_PERMISSION, 5250 FLAG_GRANT_WRITE_URI_PERMISSION, 5251 FLAG_FROM_BACKGROUND, 5252 FLAG_DEBUG_LOG_RESOLUTION, 5253 FLAG_EXCLUDE_STOPPED_PACKAGES, 5254 FLAG_INCLUDE_STOPPED_PACKAGES, 5255 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, 5256 FLAG_GRANT_PREFIX_URI_PERMISSION, 5257 FLAG_DEBUG_TRIAGED_MISSING, 5258 FLAG_IGNORE_EPHEMERAL, 5259 FLAG_ACTIVITY_MATCH_EXTERNAL, 5260 FLAG_ACTIVITY_NO_HISTORY, 5261 FLAG_ACTIVITY_SINGLE_TOP, 5262 FLAG_ACTIVITY_NEW_TASK, 5263 FLAG_ACTIVITY_MULTIPLE_TASK, 5264 FLAG_ACTIVITY_CLEAR_TOP, 5265 FLAG_ACTIVITY_FORWARD_RESULT, 5266 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 5267 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 5268 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 5269 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 5270 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 5271 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5272 FLAG_ACTIVITY_NEW_DOCUMENT, 5273 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5274 FLAG_ACTIVITY_NO_USER_ACTION, 5275 FLAG_ACTIVITY_REORDER_TO_FRONT, 5276 FLAG_ACTIVITY_NO_ANIMATION, 5277 FLAG_ACTIVITY_CLEAR_TASK, 5278 FLAG_ACTIVITY_TASK_ON_HOME, 5279 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 5280 FLAG_ACTIVITY_LAUNCH_ADJACENT, 5281 FLAG_RECEIVER_REGISTERED_ONLY, 5282 FLAG_RECEIVER_REPLACE_PENDING, 5283 FLAG_RECEIVER_FOREGROUND, 5284 FLAG_RECEIVER_NO_ABORT, 5285 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 5286 FLAG_RECEIVER_BOOT_UPGRADE, 5287 FLAG_RECEIVER_INCLUDE_BACKGROUND, 5288 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 5289 FLAG_RECEIVER_FROM_SHELL, 5290 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 5291 }) 5292 @Retention(RetentionPolicy.SOURCE) 5293 public @interface Flags {} 5294 5295 /** @hide */ 5296 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 5297 FLAG_FROM_BACKGROUND, 5298 FLAG_DEBUG_LOG_RESOLUTION, 5299 FLAG_EXCLUDE_STOPPED_PACKAGES, 5300 FLAG_INCLUDE_STOPPED_PACKAGES, 5301 FLAG_DEBUG_TRIAGED_MISSING, 5302 FLAG_IGNORE_EPHEMERAL, 5303 FLAG_ACTIVITY_MATCH_EXTERNAL, 5304 FLAG_ACTIVITY_NO_HISTORY, 5305 FLAG_ACTIVITY_SINGLE_TOP, 5306 FLAG_ACTIVITY_NEW_TASK, 5307 FLAG_ACTIVITY_MULTIPLE_TASK, 5308 FLAG_ACTIVITY_CLEAR_TOP, 5309 FLAG_ACTIVITY_FORWARD_RESULT, 5310 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 5311 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 5312 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 5313 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 5314 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 5315 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5316 FLAG_ACTIVITY_NEW_DOCUMENT, 5317 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 5318 FLAG_ACTIVITY_NO_USER_ACTION, 5319 FLAG_ACTIVITY_REORDER_TO_FRONT, 5320 FLAG_ACTIVITY_NO_ANIMATION, 5321 FLAG_ACTIVITY_CLEAR_TASK, 5322 FLAG_ACTIVITY_TASK_ON_HOME, 5323 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 5324 FLAG_ACTIVITY_LAUNCH_ADJACENT, 5325 FLAG_RECEIVER_REGISTERED_ONLY, 5326 FLAG_RECEIVER_REPLACE_PENDING, 5327 FLAG_RECEIVER_FOREGROUND, 5328 FLAG_RECEIVER_NO_ABORT, 5329 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 5330 FLAG_RECEIVER_BOOT_UPGRADE, 5331 FLAG_RECEIVER_INCLUDE_BACKGROUND, 5332 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 5333 FLAG_RECEIVER_FROM_SHELL, 5334 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 5335 }) 5336 @Retention(RetentionPolicy.SOURCE) 5337 public @interface MutableFlags {} 5338 5339 /** 5340 * If set, the recipient of this Intent will be granted permission to 5341 * perform read operations on the URI in the Intent's data and any URIs 5342 * specified in its ClipData. When applying to an Intent's ClipData, 5343 * all URIs as well as recursive traversals through data or other ClipData 5344 * in Intent items will be granted; only the grant flags of the top-level 5345 * Intent are used. 5346 */ 5347 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; 5348 /** 5349 * If set, the recipient of this Intent will be granted permission to 5350 * perform write operations on the URI in the Intent's data and any URIs 5351 * specified in its ClipData. When applying to an Intent's ClipData, 5352 * all URIs as well as recursive traversals through data or other ClipData 5353 * in Intent items will be granted; only the grant flags of the top-level 5354 * Intent are used. 5355 */ 5356 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; 5357 /** 5358 * Can be set by the caller to indicate that this Intent is coming from 5359 * a background operation, not from direct user interaction. 5360 */ 5361 public static final int FLAG_FROM_BACKGROUND = 0x00000004; 5362 /** 5363 * A flag you can enable for debugging: when set, log messages will be 5364 * printed during the resolution of this intent to show you what has 5365 * been found to create the final resolved list. 5366 */ 5367 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; 5368 /** 5369 * If set, this intent will not match any components in packages that 5370 * are currently stopped. If this is not set, then the default behavior 5371 * is to include such applications in the result. 5372 */ 5373 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; 5374 /** 5375 * If set, this intent will always match any components in packages that 5376 * are currently stopped. This is the default behavior when 5377 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these 5378 * flags are set, this one wins (it allows overriding of exclude for 5379 * places where the framework may automatically set the exclude flag). 5380 */ 5381 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; 5382 5383 /** 5384 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 5385 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be 5386 * persisted across device reboots until explicitly revoked with 5387 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the 5388 * grant for possible persisting; the receiving application must call 5389 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to 5390 * actually persist. 5391 * 5392 * @see ContentResolver#takePersistableUriPermission(Uri, int) 5393 * @see ContentResolver#releasePersistableUriPermission(Uri, int) 5394 * @see ContentResolver#getPersistedUriPermissions() 5395 * @see ContentResolver#getOutgoingPersistedUriPermissions() 5396 */ 5397 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; 5398 5399 /** 5400 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 5401 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant 5402 * applies to any URI that is a prefix match against the original granted 5403 * URI. (Without this flag, the URI must match exactly for access to be 5404 * granted.) Another URI is considered a prefix match only when scheme, 5405 * authority, and all path segments defined by the prefix are an exact 5406 * match. 5407 */ 5408 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; 5409 5410 /** 5411 * Internal flag used to indicate that a system component has done their 5412 * homework and verified that they correctly handle packages and components 5413 * that come and go over time. In particular: 5414 * <ul> 5415 * <li>Apps installed on external storage, which will appear to be 5416 * uninstalled while the the device is ejected. 5417 * <li>Apps with encryption unaware components, which will appear to not 5418 * exist while the device is locked. 5419 * </ul> 5420 * 5421 * @hide 5422 */ 5423 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100; 5424 5425 /** 5426 * Internal flag used to indicate ephemeral applications should not be 5427 * considered when resolving the intent. 5428 * 5429 * @hide 5430 */ 5431 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200; 5432 5433 /** 5434 * If set, the new activity is not kept in the history stack. As soon as 5435 * the user navigates away from it, the activity is finished. This may also 5436 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory 5437 * noHistory} attribute. 5438 * 5439 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} 5440 * is never invoked when the current activity starts a new activity which 5441 * sets a result and finishes. 5442 */ 5443 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; 5444 /** 5445 * If set, the activity will not be launched if it is already running 5446 * at the top of the history stack. 5447 */ 5448 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; 5449 /** 5450 * If set, this activity will become the start of a new task on this 5451 * history stack. A task (from the activity that started it to the 5452 * next task activity) defines an atomic group of activities that the 5453 * user can move to. Tasks can be moved to the foreground and background; 5454 * all of the activities inside of a particular task always remain in 5455 * the same order. See 5456 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 5457 * Stack</a> for more information about tasks. 5458 * 5459 * <p>This flag is generally used by activities that want 5460 * to present a "launcher" style behavior: they give the user a list of 5461 * separate things that can be done, which otherwise run completely 5462 * independently of the activity launching them. 5463 * 5464 * <p>When using this flag, if a task is already running for the activity 5465 * you are now starting, then a new activity will not be started; instead, 5466 * the current task will simply be brought to the front of the screen with 5467 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag 5468 * to disable this behavior. 5469 * 5470 * <p>This flag can not be used when the caller is requesting a result from 5471 * the activity being launched. 5472 */ 5473 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; 5474 /** 5475 * This flag is used to create a new task and launch an activity into it. 5476 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} 5477 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would 5478 * search through existing tasks for ones matching this Intent. Only if no such 5479 * task is found would a new task be created. When paired with 5480 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip 5481 * the search for a matching task and unconditionally start a new task. 5482 * 5483 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this 5484 * flag unless you are implementing your own 5485 * top-level application launcher.</strong> Used in conjunction with 5486 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the 5487 * behavior of bringing an existing task to the foreground. When set, 5488 * a new task is <em>always</em> started to host the Activity for the 5489 * Intent, regardless of whether there is already an existing task running 5490 * the same thing. 5491 * 5492 * <p><strong>Because the default system does not include graphical task management, 5493 * you should not use this flag unless you provide some way for a user to 5494 * return back to the tasks you have launched.</strong> 5495 * 5496 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for 5497 * creating new document tasks. 5498 * 5499 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or 5500 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. 5501 * 5502 * <p>See 5503 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 5504 * Stack</a> for more information about tasks. 5505 * 5506 * @see #FLAG_ACTIVITY_NEW_DOCUMENT 5507 * @see #FLAG_ACTIVITY_NEW_TASK 5508 */ 5509 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; 5510 /** 5511 * If set, and the activity being launched is already running in the 5512 * current task, then instead of launching a new instance of that activity, 5513 * all of the other activities on top of it will be closed and this Intent 5514 * will be delivered to the (now on top) old activity as a new Intent. 5515 * 5516 * <p>For example, consider a task consisting of the activities: A, B, C, D. 5517 * If D calls startActivity() with an Intent that resolves to the component 5518 * of activity B, then C and D will be finished and B receive the given 5519 * Intent, resulting in the stack now being: A, B. 5520 * 5521 * <p>The currently running instance of activity B in the above example will 5522 * either receive the new intent you are starting here in its 5523 * onNewIntent() method, or be itself finished and restarted with the 5524 * new intent. If it has declared its launch mode to be "multiple" (the 5525 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in 5526 * the same intent, then it will be finished and re-created; for all other 5527 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this 5528 * Intent will be delivered to the current instance's onNewIntent(). 5529 * 5530 * <p>This launch mode can also be used to good effect in conjunction with 5531 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity 5532 * of a task, it will bring any currently running instance of that task 5533 * to the foreground, and then clear it to its root state. This is 5534 * especially useful, for example, when launching an activity from the 5535 * notification manager. 5536 * 5537 * <p>See 5538 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 5539 * Stack</a> for more information about tasks. 5540 */ 5541 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; 5542 /** 5543 * If set and this intent is being used to launch a new activity from an 5544 * existing one, then the reply target of the existing activity will be 5545 * transfered to the new activity. This way the new activity can call 5546 * {@link android.app.Activity#setResult} and have that result sent back to 5547 * the reply target of the original activity. 5548 */ 5549 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; 5550 /** 5551 * If set and this intent is being used to launch a new activity from an 5552 * existing one, the current activity will not be counted as the top 5553 * activity for deciding whether the new intent should be delivered to 5554 * the top instead of starting a new one. The previous activity will 5555 * be used as the top, with the assumption being that the current activity 5556 * will finish itself immediately. 5557 */ 5558 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; 5559 /** 5560 * If set, the new activity is not kept in the list of recently launched 5561 * activities. 5562 */ 5563 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; 5564 /** 5565 * This flag is not normally set by application code, but set for you by 5566 * the system as described in the 5567 * {@link android.R.styleable#AndroidManifestActivity_launchMode 5568 * launchMode} documentation for the singleTask mode. 5569 */ 5570 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; 5571 /** 5572 * If set, and this activity is either being started in a new task or 5573 * bringing to the top an existing task, then it will be launched as 5574 * the front door of the task. This will result in the application of 5575 * any affinities needed to have that task in the proper state (either 5576 * moving activities to or from it), or simply resetting that task to 5577 * its initial state if needed. 5578 */ 5579 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; 5580 /** 5581 * This flag is not normally set by application code, but set for you by 5582 * the system if this activity is being launched from history 5583 * (longpress home key). 5584 */ 5585 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; 5586 /** 5587 * @deprecated As of API 21 this performs identically to 5588 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. 5589 */ 5590 @Deprecated 5591 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; 5592 /** 5593 * This flag is used to open a document into a new task rooted at the activity launched 5594 * by this Intent. Through the use of this flag, or its equivalent attribute, 5595 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity 5596 * containing different documents will appear in the recent tasks list. 5597 * 5598 * <p>The use of the activity attribute form of this, 5599 * {@link android.R.attr#documentLaunchMode}, is 5600 * preferred over the Intent flag described here. The attribute form allows the 5601 * Activity to specify multiple document behavior for all launchers of the Activity 5602 * whereas using this flag requires each Intent that launches the Activity to specify it. 5603 * 5604 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for 5605 * it is kept after the activity is finished is different than the use of 5606 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if 5607 * this flag is being used to create a new recents entry, then by default that entry 5608 * will be removed once the activity is finished. You can modify this behavior with 5609 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. 5610 * 5611 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link 5612 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the 5613 * equivalent of the Activity manifest specifying {@link 5614 * android.R.attr#documentLaunchMode}="intoExisting". When used with 5615 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying 5616 * {@link android.R.attr#documentLaunchMode}="always". 5617 * 5618 * Refer to {@link android.R.attr#documentLaunchMode} for more information. 5619 * 5620 * @see android.R.attr#documentLaunchMode 5621 * @see #FLAG_ACTIVITY_MULTIPLE_TASK 5622 */ 5623 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; 5624 /** 5625 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} 5626 * callback from occurring on the current frontmost activity before it is 5627 * paused as the newly-started activity is brought to the front. 5628 * 5629 * <p>Typically, an activity can rely on that callback to indicate that an 5630 * explicit user action has caused their activity to be moved out of the 5631 * foreground. The callback marks an appropriate point in the activity's 5632 * lifecycle for it to dismiss any notifications that it intends to display 5633 * "until the user has seen them," such as a blinking LED. 5634 * 5635 * <p>If an activity is ever started via any non-user-driven events such as 5636 * phone-call receipt or an alarm handler, this flag should be passed to {@link 5637 * Context#startActivity Context.startActivity}, ensuring that the pausing 5638 * activity does not think the user has acknowledged its notification. 5639 */ 5640 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; 5641 /** 5642 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 5643 * this flag will cause the launched activity to be brought to the front of its 5644 * task's history stack if it is already running. 5645 * 5646 * <p>For example, consider a task consisting of four activities: A, B, C, D. 5647 * If D calls startActivity() with an Intent that resolves to the component 5648 * of activity B, then B will be brought to the front of the history stack, 5649 * with this resulting order: A, C, D, B. 5650 * 5651 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also 5652 * specified. 5653 */ 5654 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; 5655 /** 5656 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 5657 * this flag will prevent the system from applying an activity transition 5658 * animation to go to the next activity state. This doesn't mean an 5659 * animation will never run -- if another activity change happens that doesn't 5660 * specify this flag before the activity started here is displayed, then 5661 * that transition will be used. This flag can be put to good use 5662 * when you are going to do a series of activity operations but the 5663 * animation seen by the user shouldn't be driven by the first activity 5664 * change but rather a later one. 5665 */ 5666 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; 5667 /** 5668 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 5669 * this flag will cause any existing task that would be associated with the 5670 * activity to be cleared before the activity is started. That is, the activity 5671 * becomes the new root of an otherwise empty task, and any old activities 5672 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 5673 */ 5674 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; 5675 /** 5676 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 5677 * this flag will cause a newly launching task to be placed on top of the current 5678 * home activity task (if there is one). That is, pressing back from the task 5679 * will always return the user to home even if that was not the last activity they 5680 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 5681 */ 5682 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; 5683 /** 5684 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will 5685 * have its entry in recent tasks removed when the user closes it (with back 5686 * or however else it may finish()). If you would like to instead allow the 5687 * document to be kept in recents so that it can be re-launched, you can use 5688 * this flag. When set and the task's activity is finished, the recents 5689 * entry will remain in the interface for the user to re-launch it, like a 5690 * recents entry for a top-level application. 5691 * <p> 5692 * The receiving activity can override this request with 5693 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling 5694 * {@link android.app.Activity#finishAndRemoveTask() 5695 * Activity.finishAndRemoveTask()}. 5696 */ 5697 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; 5698 5699 /** 5700 * This flag is only used in split-screen multi-window mode. The new activity will be displayed 5701 * adjacent to the one launching it. This can only be used in conjunction with 5702 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is 5703 * required if you want a new instance of an existing activity to be created. 5704 */ 5705 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; 5706 5707 5708 /** 5709 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 5710 * this flag will attempt to launch an instant app if no full app on the device can already 5711 * handle the intent. 5712 * <p> 5713 * When attempting to resolve instant apps externally, the following {@link Intent} properties 5714 * are supported: 5715 * <ul> 5716 * <li>{@link Intent#setAction(String)}</li> 5717 * <li>{@link Intent#addCategory(String)}</li> 5718 * <li>{@link Intent#setData(Uri)}</li> 5719 * <li>{@link Intent#setType(String)}</li> 5720 * <li>{@link Intent#setPackage(String)}</li> 5721 * <li>{@link Intent#addFlags(int)}</li> 5722 * </ul> 5723 * <p> 5724 * In the case that no instant app can be found, the installer will be launched to notify the 5725 * user that the intent could not be resolved. On devices that do not support instant apps, 5726 * the flag will be ignored. 5727 */ 5728 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800; 5729 5730 /** 5731 * If set, when sending a broadcast only registered receivers will be 5732 * called -- no BroadcastReceiver components will be launched. 5733 */ 5734 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 5735 /** 5736 * If set, when sending a broadcast the new broadcast will replace 5737 * any existing pending broadcast that matches it. Matching is defined 5738 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning 5739 * true for the intents of the two broadcasts. When a match is found, 5740 * the new broadcast (and receivers associated with it) will replace the 5741 * existing one in the pending broadcast list, remaining at the same 5742 * position in the list. 5743 * 5744 * <p>This flag is most typically used with sticky broadcasts, which 5745 * only care about delivering the most recent values of the broadcast 5746 * to their receivers. 5747 */ 5748 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; 5749 /** 5750 * If set, when sending a broadcast the recipient is allowed to run at 5751 * foreground priority, with a shorter timeout interval. During normal 5752 * broadcasts the receivers are not automatically hoisted out of the 5753 * background priority class. 5754 */ 5755 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; 5756 /** 5757 * If this is an ordered broadcast, don't allow receivers to abort the broadcast. 5758 * They can still propagate results through to later receivers, but they can not prevent 5759 * later receivers from seeing the broadcast. 5760 */ 5761 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; 5762 /** 5763 * If set, when sending a broadcast <i>before boot has completed</i> only 5764 * registered receivers will be called -- no BroadcastReceiver components 5765 * will be launched. Sticky intent state will be recorded properly even 5766 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} 5767 * is specified in the broadcast intent, this flag is unnecessary. 5768 * 5769 * <p>This flag is only for use by system sevices as a convenience to 5770 * avoid having to implement a more complex mechanism around detection 5771 * of boot completion. 5772 * 5773 * @hide 5774 */ 5775 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; 5776 /** 5777 * Set when this broadcast is for a boot upgrade, a special mode that 5778 * allows the broadcast to be sent before the system is ready and launches 5779 * the app process with no providers running in it. 5780 * @hide 5781 */ 5782 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; 5783 /** 5784 * If set, the broadcast will always go to manifest receivers in background (cached 5785 * or not running) apps, regardless of whether that would be done by default. By 5786 * default they will only receive broadcasts if the broadcast has specified an 5787 * explicit component or package name. 5788 * 5789 * NOTE: dumpstate uses this flag numerically, so when its value is changed 5790 * the broadcast code there must also be changed to match. 5791 * 5792 * @hide 5793 */ 5794 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; 5795 /** 5796 * If set, the broadcast will never go to manifest receivers in background (cached 5797 * or not running) apps, regardless of whether that would be done by default. By 5798 * default they will receive broadcasts if the broadcast has specified an 5799 * explicit component or package name. 5800 * @hide 5801 */ 5802 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; 5803 /** 5804 * If set, this broadcast is being sent from the shell. 5805 * @hide 5806 */ 5807 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; 5808 5809 /** 5810 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps 5811 * will not receive broadcasts. 5812 * 5813 * <em>This flag has no effect when used by an Instant App.</em> 5814 */ 5815 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000; 5816 5817 /** 5818 * @hide Flags that can't be changed with PendingIntent. 5819 */ 5820 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION 5821 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 5822 | FLAG_GRANT_PREFIX_URI_PERMISSION; 5823 5824 // --------------------------------------------------------------------- 5825 // --------------------------------------------------------------------- 5826 // toUri() and parseUri() options. 5827 5828 /** @hide */ 5829 @IntDef(flag = true, prefix = { "URI_" }, value = { 5830 URI_ALLOW_UNSAFE, 5831 URI_ANDROID_APP_SCHEME, 5832 URI_INTENT_SCHEME, 5833 }) 5834 @Retention(RetentionPolicy.SOURCE) 5835 public @interface UriFlags {} 5836 5837 /** 5838 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 5839 * always has the "intent:" scheme. This syntax can be used when you want 5840 * to later disambiguate between URIs that are intended to describe an 5841 * Intent vs. all others that should be treated as raw URIs. When used 5842 * with {@link #parseUri}, any other scheme will result in a generic 5843 * VIEW action for that raw URI. 5844 */ 5845 public static final int URI_INTENT_SCHEME = 1<<0; 5846 5847 /** 5848 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 5849 * always has the "android-app:" scheme. This is a variation of 5850 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an 5851 * http/https URI being delivered to a specific package name. The format 5852 * is: 5853 * 5854 * <pre class="prettyprint"> 5855 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> 5856 * 5857 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, 5858 * you must also include a scheme; including a path also requires both a host and a scheme. 5859 * The final #Intent; fragment can be used without a scheme, host, or path. 5860 * Note that this can not be 5861 * used with intents that have a {@link #setSelector}, since the base intent 5862 * will always have an explicit package name.</p> 5863 * 5864 * <p>Some examples of how this scheme maps to Intent objects:</p> 5865 * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> 5866 * <colgroup align="left" /> 5867 * <colgroup align="left" /> 5868 * <thead> 5869 * <tr><th>URI</th> <th>Intent</th></tr> 5870 * </thead> 5871 * 5872 * <tbody> 5873 * <tr><td><code>android-app://com.example.app</code></td> 5874 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 5875 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> 5876 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 5877 * </table></td> 5878 * </tr> 5879 * <tr><td><code>android-app://com.example.app/http/example.com</code></td> 5880 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 5881 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 5882 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> 5883 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 5884 * </table></td> 5885 * </tr> 5886 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> 5887 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 5888 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 5889 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 5890 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 5891 * </table></td> 5892 * </tr> 5893 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> 5894 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 5895 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 5896 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 5897 * </table></td> 5898 * </tr> 5899 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> 5900 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 5901 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 5902 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 5903 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 5904 * </table></td> 5905 * </tr> 5906 * <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> 5907 * <td><table border="" style="margin:0" > 5908 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 5909 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 5910 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> 5911 * </table></td> 5912 * </tr> 5913 * </tbody> 5914 * </table> 5915 */ 5916 public static final int URI_ANDROID_APP_SCHEME = 1<<1; 5917 5918 /** 5919 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing 5920 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, 5921 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, 5922 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the 5923 * generated Intent can not cause unexpected data access to happen. 5924 * 5925 * <p>If you do not trust the source of the URI being parsed, you should still do further 5926 * processing to protect yourself from it. In particular, when using it to start an 5927 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities 5928 * that can handle it.</p> 5929 */ 5930 public static final int URI_ALLOW_UNSAFE = 1<<2; 5931 5932 // --------------------------------------------------------------------- 5933 5934 private String mAction; 5935 private Uri mData; 5936 private String mType; 5937 private String mPackage; 5938 private ComponentName mComponent; 5939 private int mFlags; 5940 private ArraySet<String> mCategories; 5941 private Bundle mExtras; 5942 private Rect mSourceBounds; 5943 private Intent mSelector; 5944 private ClipData mClipData; 5945 private int mContentUserHint = UserHandle.USER_CURRENT; 5946 /** Token to track instant app launches. Local only; do not copy cross-process. */ 5947 private String mLaunchToken; 5948 5949 // --------------------------------------------------------------------- 5950 5951 private static final int COPY_MODE_ALL = 0; 5952 private static final int COPY_MODE_FILTER = 1; 5953 private static final int COPY_MODE_HISTORY = 2; 5954 5955 /** @hide */ 5956 @IntDef(prefix = { "COPY_MODE_" }, value = { 5957 COPY_MODE_ALL, 5958 COPY_MODE_FILTER, 5959 COPY_MODE_HISTORY 5960 }) 5961 @Retention(RetentionPolicy.SOURCE) 5962 public @interface CopyMode {} 5963 5964 /** 5965 * Create an empty intent. 5966 */ Intent()5967 public Intent() { 5968 } 5969 5970 /** 5971 * Copy constructor. 5972 */ Intent(Intent o)5973 public Intent(Intent o) { 5974 this(o, COPY_MODE_ALL); 5975 } 5976 Intent(Intent o, @CopyMode int copyMode)5977 private Intent(Intent o, @CopyMode int copyMode) { 5978 this.mAction = o.mAction; 5979 this.mData = o.mData; 5980 this.mType = o.mType; 5981 this.mPackage = o.mPackage; 5982 this.mComponent = o.mComponent; 5983 5984 if (o.mCategories != null) { 5985 this.mCategories = new ArraySet<>(o.mCategories); 5986 } 5987 5988 if (copyMode != COPY_MODE_FILTER) { 5989 this.mFlags = o.mFlags; 5990 this.mContentUserHint = o.mContentUserHint; 5991 this.mLaunchToken = o.mLaunchToken; 5992 if (o.mSourceBounds != null) { 5993 this.mSourceBounds = new Rect(o.mSourceBounds); 5994 } 5995 if (o.mSelector != null) { 5996 this.mSelector = new Intent(o.mSelector); 5997 } 5998 5999 if (copyMode != COPY_MODE_HISTORY) { 6000 if (o.mExtras != null) { 6001 this.mExtras = new Bundle(o.mExtras); 6002 } 6003 if (o.mClipData != null) { 6004 this.mClipData = new ClipData(o.mClipData); 6005 } 6006 } else { 6007 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) { 6008 this.mExtras = Bundle.STRIPPED; 6009 } 6010 6011 // Also set "stripped" clip data when we ever log mClipData in the (broadcast) 6012 // history. 6013 } 6014 } 6015 } 6016 6017 @Override clone()6018 public Object clone() { 6019 return new Intent(this); 6020 } 6021 6022 /** 6023 * Make a clone of only the parts of the Intent that are relevant for 6024 * filter matching: the action, data, type, component, and categories. 6025 */ cloneFilter()6026 public @NonNull Intent cloneFilter() { 6027 return new Intent(this, COPY_MODE_FILTER); 6028 } 6029 6030 /** 6031 * Create an intent with a given action. All other fields (data, type, 6032 * class) are null. Note that the action <em>must</em> be in a 6033 * namespace because Intents are used globally in the system -- for 6034 * example the system VIEW action is android.intent.action.VIEW; an 6035 * application's custom action would be something like 6036 * com.google.app.myapp.CUSTOM_ACTION. 6037 * 6038 * @param action The Intent action, such as ACTION_VIEW. 6039 */ Intent(String action)6040 public Intent(String action) { 6041 setAction(action); 6042 } 6043 6044 /** 6045 * Create an intent with a given action and for a given data url. Note 6046 * that the action <em>must</em> be in a namespace because Intents are 6047 * used globally in the system -- for example the system VIEW action is 6048 * android.intent.action.VIEW; an application's custom action would be 6049 * something like com.google.app.myapp.CUSTOM_ACTION. 6050 * 6051 * <p><em>Note: scheme and host name matching in the Android framework is 6052 * case-sensitive, unlike the formal RFC. As a result, 6053 * you should always ensure that you write your Uri with these elements 6054 * using lower case letters, and normalize any Uris you receive from 6055 * outside of Android to ensure the scheme and host is lower case.</em></p> 6056 * 6057 * @param action The Intent action, such as ACTION_VIEW. 6058 * @param uri The Intent data URI. 6059 */ Intent(String action, Uri uri)6060 public Intent(String action, Uri uri) { 6061 setAction(action); 6062 mData = uri; 6063 } 6064 6065 /** 6066 * Create an intent for a specific component. All other fields (action, data, 6067 * type, class) are null, though they can be modified later with explicit 6068 * calls. This provides a convenient way to create an intent that is 6069 * intended to execute a hard-coded class name, rather than relying on the 6070 * system to find an appropriate class for you; see {@link #setComponent} 6071 * for more information on the repercussions of this. 6072 * 6073 * @param packageContext A Context of the application package implementing 6074 * this class. 6075 * @param cls The component class that is to be used for the intent. 6076 * 6077 * @see #setClass 6078 * @see #setComponent 6079 * @see #Intent(String, android.net.Uri , Context, Class) 6080 */ Intent(Context packageContext, Class<?> cls)6081 public Intent(Context packageContext, Class<?> cls) { 6082 mComponent = new ComponentName(packageContext, cls); 6083 } 6084 6085 /** 6086 * Create an intent for a specific component with a specified action and data. 6087 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to 6088 * construct the Intent and then calling {@link #setClass} to set its 6089 * class. 6090 * 6091 * <p><em>Note: scheme and host name matching in the Android framework is 6092 * case-sensitive, unlike the formal RFC. As a result, 6093 * you should always ensure that you write your Uri with these elements 6094 * using lower case letters, and normalize any Uris you receive from 6095 * outside of Android to ensure the scheme and host is lower case.</em></p> 6096 * 6097 * @param action The Intent action, such as ACTION_VIEW. 6098 * @param uri The Intent data URI. 6099 * @param packageContext A Context of the application package implementing 6100 * this class. 6101 * @param cls The component class that is to be used for the intent. 6102 * 6103 * @see #Intent(String, android.net.Uri) 6104 * @see #Intent(Context, Class) 6105 * @see #setClass 6106 * @see #setComponent 6107 */ Intent(String action, Uri uri, Context packageContext, Class<?> cls)6108 public Intent(String action, Uri uri, 6109 Context packageContext, Class<?> cls) { 6110 setAction(action); 6111 mData = uri; 6112 mComponent = new ComponentName(packageContext, cls); 6113 } 6114 6115 /** 6116 * Create an intent to launch the main (root) activity of a task. This 6117 * is the Intent that is started when the application's is launched from 6118 * Home. For anything else that wants to launch an application in the 6119 * same way, it is important that they use an Intent structured the same 6120 * way, and can use this function to ensure this is the case. 6121 * 6122 * <p>The returned Intent has the given Activity component as its explicit 6123 * component, {@link #ACTION_MAIN} as its action, and includes the 6124 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 6125 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 6126 * to do that through {@link #addFlags(int)} on the returned Intent. 6127 * 6128 * @param mainActivity The main activity component that this Intent will 6129 * launch. 6130 * @return Returns a newly created Intent that can be used to launch the 6131 * activity as a main application entry. 6132 * 6133 * @see #setClass 6134 * @see #setComponent 6135 */ makeMainActivity(ComponentName mainActivity)6136 public static Intent makeMainActivity(ComponentName mainActivity) { 6137 Intent intent = new Intent(ACTION_MAIN); 6138 intent.setComponent(mainActivity); 6139 intent.addCategory(CATEGORY_LAUNCHER); 6140 return intent; 6141 } 6142 6143 /** 6144 * Make an Intent for the main activity of an application, without 6145 * specifying a specific activity to run but giving a selector to find 6146 * the activity. This results in a final Intent that is structured 6147 * the same as when the application is launched from 6148 * Home. For anything else that wants to launch an application in the 6149 * same way, it is important that they use an Intent structured the same 6150 * way, and can use this function to ensure this is the case. 6151 * 6152 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the 6153 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 6154 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 6155 * to do that through {@link #addFlags(int)} on the returned Intent. 6156 * 6157 * @param selectorAction The action name of the Intent's selector. 6158 * @param selectorCategory The name of a category to add to the Intent's 6159 * selector. 6160 * @return Returns a newly created Intent that can be used to launch the 6161 * activity as a main application entry. 6162 * 6163 * @see #setSelector(Intent) 6164 */ makeMainSelectorActivity(String selectorAction, String selectorCategory)6165 public static Intent makeMainSelectorActivity(String selectorAction, 6166 String selectorCategory) { 6167 Intent intent = new Intent(ACTION_MAIN); 6168 intent.addCategory(CATEGORY_LAUNCHER); 6169 Intent selector = new Intent(); 6170 selector.setAction(selectorAction); 6171 selector.addCategory(selectorCategory); 6172 intent.setSelector(selector); 6173 return intent; 6174 } 6175 6176 /** 6177 * Make an Intent that can be used to re-launch an application's task 6178 * in its base state. This is like {@link #makeMainActivity(ComponentName)}, 6179 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and 6180 * {@link #FLAG_ACTIVITY_CLEAR_TASK}. 6181 * 6182 * @param mainActivity The activity component that is the root of the 6183 * task; this is the activity that has been published in the application's 6184 * manifest as the main launcher icon. 6185 * 6186 * @return Returns a newly created Intent that can be used to relaunch the 6187 * activity's task in its root state. 6188 */ makeRestartActivityTask(ComponentName mainActivity)6189 public static Intent makeRestartActivityTask(ComponentName mainActivity) { 6190 Intent intent = makeMainActivity(mainActivity); 6191 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 6192 | Intent.FLAG_ACTIVITY_CLEAR_TASK); 6193 return intent; 6194 } 6195 6196 /** 6197 * Call {@link #parseUri} with 0 flags. 6198 * @deprecated Use {@link #parseUri} instead. 6199 */ 6200 @Deprecated getIntent(String uri)6201 public static Intent getIntent(String uri) throws URISyntaxException { 6202 return parseUri(uri, 0); 6203 } 6204 6205 /** 6206 * Create an intent from a URI. This URI may encode the action, 6207 * category, and other intent fields, if it was returned by 6208 * {@link #toUri}. If the Intent was not generate by toUri(), its data 6209 * will be the entire URI and its action will be ACTION_VIEW. 6210 * 6211 * <p>The URI given here must not be relative -- that is, it must include 6212 * the scheme and full path. 6213 * 6214 * @param uri The URI to turn into an Intent. 6215 * @param flags Additional processing flags. 6216 * 6217 * @return Intent The newly created Intent object. 6218 * 6219 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax 6220 * it bad (as parsed by the Uri class) or the Intent data within the 6221 * URI is invalid. 6222 * 6223 * @see #toUri 6224 */ parseUri(String uri, @UriFlags int flags)6225 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException { 6226 int i = 0; 6227 try { 6228 final boolean androidApp = uri.startsWith("android-app:"); 6229 6230 // Validate intent scheme if requested. 6231 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { 6232 if (!uri.startsWith("intent:") && !androidApp) { 6233 Intent intent = new Intent(ACTION_VIEW); 6234 try { 6235 intent.setData(Uri.parse(uri)); 6236 } catch (IllegalArgumentException e) { 6237 throw new URISyntaxException(uri, e.getMessage()); 6238 } 6239 return intent; 6240 } 6241 } 6242 6243 i = uri.lastIndexOf("#"); 6244 // simple case 6245 if (i == -1) { 6246 if (!androidApp) { 6247 return new Intent(ACTION_VIEW, Uri.parse(uri)); 6248 } 6249 6250 // old format Intent URI 6251 } else if (!uri.startsWith("#Intent;", i)) { 6252 if (!androidApp) { 6253 return getIntentOld(uri, flags); 6254 } else { 6255 i = -1; 6256 } 6257 } 6258 6259 // new format 6260 Intent intent = new Intent(ACTION_VIEW); 6261 Intent baseIntent = intent; 6262 boolean explicitAction = false; 6263 boolean inSelector = false; 6264 6265 // fetch data part, if present 6266 String scheme = null; 6267 String data; 6268 if (i >= 0) { 6269 data = uri.substring(0, i); 6270 i += 8; // length of "#Intent;" 6271 } else { 6272 data = uri; 6273 } 6274 6275 // loop over contents of Intent, all name=value; 6276 while (i >= 0 && !uri.startsWith("end", i)) { 6277 int eq = uri.indexOf('=', i); 6278 if (eq < 0) eq = i-1; 6279 int semi = uri.indexOf(';', i); 6280 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : ""; 6281 6282 // action 6283 if (uri.startsWith("action=", i)) { 6284 intent.setAction(value); 6285 if (!inSelector) { 6286 explicitAction = true; 6287 } 6288 } 6289 6290 // categories 6291 else if (uri.startsWith("category=", i)) { 6292 intent.addCategory(value); 6293 } 6294 6295 // type 6296 else if (uri.startsWith("type=", i)) { 6297 intent.mType = value; 6298 } 6299 6300 // launch flags 6301 else if (uri.startsWith("launchFlags=", i)) { 6302 intent.mFlags = Integer.decode(value).intValue(); 6303 if ((flags& URI_ALLOW_UNSAFE) == 0) { 6304 intent.mFlags &= ~IMMUTABLE_FLAGS; 6305 } 6306 } 6307 6308 // package 6309 else if (uri.startsWith("package=", i)) { 6310 intent.mPackage = value; 6311 } 6312 6313 // component 6314 else if (uri.startsWith("component=", i)) { 6315 intent.mComponent = ComponentName.unflattenFromString(value); 6316 } 6317 6318 // scheme 6319 else if (uri.startsWith("scheme=", i)) { 6320 if (inSelector) { 6321 intent.mData = Uri.parse(value + ":"); 6322 } else { 6323 scheme = value; 6324 } 6325 } 6326 6327 // source bounds 6328 else if (uri.startsWith("sourceBounds=", i)) { 6329 intent.mSourceBounds = Rect.unflattenFromString(value); 6330 } 6331 6332 // selector 6333 else if (semi == (i+3) && uri.startsWith("SEL", i)) { 6334 intent = new Intent(); 6335 inSelector = true; 6336 } 6337 6338 // extra 6339 else { 6340 String key = Uri.decode(uri.substring(i + 2, eq)); 6341 // create Bundle if it doesn't already exist 6342 if (intent.mExtras == null) intent.mExtras = new Bundle(); 6343 Bundle b = intent.mExtras; 6344 // add EXTRA 6345 if (uri.startsWith("S.", i)) b.putString(key, value); 6346 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); 6347 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); 6348 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); 6349 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); 6350 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); 6351 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); 6352 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); 6353 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); 6354 else throw new URISyntaxException(uri, "unknown EXTRA type", i); 6355 } 6356 6357 // move to the next item 6358 i = semi + 1; 6359 } 6360 6361 if (inSelector) { 6362 // The Intent had a selector; fix it up. 6363 if (baseIntent.mPackage == null) { 6364 baseIntent.setSelector(intent); 6365 } 6366 intent = baseIntent; 6367 } 6368 6369 if (data != null) { 6370 if (data.startsWith("intent:")) { 6371 data = data.substring(7); 6372 if (scheme != null) { 6373 data = scheme + ':' + data; 6374 } 6375 } else if (data.startsWith("android-app:")) { 6376 if (data.charAt(12) == '/' && data.charAt(13) == '/') { 6377 // Correctly formed android-app, first part is package name. 6378 int end = data.indexOf('/', 14); 6379 if (end < 0) { 6380 // All we have is a package name. 6381 intent.mPackage = data.substring(14); 6382 if (!explicitAction) { 6383 intent.setAction(ACTION_MAIN); 6384 } 6385 data = ""; 6386 } else { 6387 // Target the Intent at the given package name always. 6388 String authority = null; 6389 intent.mPackage = data.substring(14, end); 6390 int newEnd; 6391 if ((end+1) < data.length()) { 6392 if ((newEnd=data.indexOf('/', end+1)) >= 0) { 6393 // Found a scheme, remember it. 6394 scheme = data.substring(end+1, newEnd); 6395 end = newEnd; 6396 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { 6397 // Found a authority, remember it. 6398 authority = data.substring(end+1, newEnd); 6399 end = newEnd; 6400 } 6401 } else { 6402 // All we have is a scheme. 6403 scheme = data.substring(end+1); 6404 } 6405 } 6406 if (scheme == null) { 6407 // If there was no scheme, then this just targets the package. 6408 if (!explicitAction) { 6409 intent.setAction(ACTION_MAIN); 6410 } 6411 data = ""; 6412 } else if (authority == null) { 6413 data = scheme + ":"; 6414 } else { 6415 data = scheme + "://" + authority + data.substring(end); 6416 } 6417 } 6418 } else { 6419 data = ""; 6420 } 6421 } 6422 6423 if (data.length() > 0) { 6424 try { 6425 intent.mData = Uri.parse(data); 6426 } catch (IllegalArgumentException e) { 6427 throw new URISyntaxException(uri, e.getMessage()); 6428 } 6429 } 6430 } 6431 6432 return intent; 6433 6434 } catch (IndexOutOfBoundsException e) { 6435 throw new URISyntaxException(uri, "illegal Intent URI format", i); 6436 } 6437 } 6438 6439 public static Intent getIntentOld(String uri) throws URISyntaxException { 6440 return getIntentOld(uri, 0); 6441 } 6442 6443 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException { 6444 Intent intent; 6445 6446 int i = uri.lastIndexOf('#'); 6447 if (i >= 0) { 6448 String action = null; 6449 final int intentFragmentStart = i; 6450 boolean isIntentFragment = false; 6451 6452 i++; 6453 6454 if (uri.regionMatches(i, "action(", 0, 7)) { 6455 isIntentFragment = true; 6456 i += 7; 6457 int j = uri.indexOf(')', i); 6458 action = uri.substring(i, j); 6459 i = j + 1; 6460 } 6461 6462 intent = new Intent(action); 6463 6464 if (uri.regionMatches(i, "categories(", 0, 11)) { 6465 isIntentFragment = true; 6466 i += 11; 6467 int j = uri.indexOf(')', i); 6468 while (i < j) { 6469 int sep = uri.indexOf('!', i); 6470 if (sep < 0 || sep > j) sep = j; 6471 if (i < sep) { 6472 intent.addCategory(uri.substring(i, sep)); 6473 } 6474 i = sep + 1; 6475 } 6476 i = j + 1; 6477 } 6478 6479 if (uri.regionMatches(i, "type(", 0, 5)) { 6480 isIntentFragment = true; 6481 i += 5; 6482 int j = uri.indexOf(')', i); 6483 intent.mType = uri.substring(i, j); 6484 i = j + 1; 6485 } 6486 6487 if (uri.regionMatches(i, "launchFlags(", 0, 12)) { 6488 isIntentFragment = true; 6489 i += 12; 6490 int j = uri.indexOf(')', i); 6491 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); 6492 if ((flags& URI_ALLOW_UNSAFE) == 0) { 6493 intent.mFlags &= ~IMMUTABLE_FLAGS; 6494 } 6495 i = j + 1; 6496 } 6497 6498 if (uri.regionMatches(i, "component(", 0, 10)) { 6499 isIntentFragment = true; 6500 i += 10; 6501 int j = uri.indexOf(')', i); 6502 int sep = uri.indexOf('!', i); 6503 if (sep >= 0 && sep < j) { 6504 String pkg = uri.substring(i, sep); 6505 String cls = uri.substring(sep + 1, j); 6506 intent.mComponent = new ComponentName(pkg, cls); 6507 } 6508 i = j + 1; 6509 } 6510 6511 if (uri.regionMatches(i, "extras(", 0, 7)) { 6512 isIntentFragment = true; 6513 i += 7; 6514 6515 final int closeParen = uri.indexOf(')', i); 6516 if (closeParen == -1) throw new URISyntaxException(uri, 6517 "EXTRA missing trailing ')'", i); 6518 6519 while (i < closeParen) { 6520 // fetch the key value 6521 int j = uri.indexOf('=', i); 6522 if (j <= i + 1 || i >= closeParen) { 6523 throw new URISyntaxException(uri, "EXTRA missing '='", i); 6524 } 6525 char type = uri.charAt(i); 6526 i++; 6527 String key = uri.substring(i, j); 6528 i = j + 1; 6529 6530 // get type-value 6531 j = uri.indexOf('!', i); 6532 if (j == -1 || j >= closeParen) j = closeParen; 6533 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); 6534 String value = uri.substring(i, j); 6535 i = j; 6536 6537 // create Bundle if it doesn't already exist 6538 if (intent.mExtras == null) intent.mExtras = new Bundle(); 6539 6540 // add item to bundle 6541 try { 6542 switch (type) { 6543 case 'S': 6544 intent.mExtras.putString(key, Uri.decode(value)); 6545 break; 6546 case 'B': 6547 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); 6548 break; 6549 case 'b': 6550 intent.mExtras.putByte(key, Byte.parseByte(value)); 6551 break; 6552 case 'c': 6553 intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); 6554 break; 6555 case 'd': 6556 intent.mExtras.putDouble(key, Double.parseDouble(value)); 6557 break; 6558 case 'f': 6559 intent.mExtras.putFloat(key, Float.parseFloat(value)); 6560 break; 6561 case 'i': 6562 intent.mExtras.putInt(key, Integer.parseInt(value)); 6563 break; 6564 case 'l': 6565 intent.mExtras.putLong(key, Long.parseLong(value)); 6566 break; 6567 case 's': 6568 intent.mExtras.putShort(key, Short.parseShort(value)); 6569 break; 6570 default: 6571 throw new URISyntaxException(uri, "EXTRA has unknown type", i); 6572 } 6573 } catch (NumberFormatException e) { 6574 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); 6575 } 6576 6577 char ch = uri.charAt(i); 6578 if (ch == ')') break; 6579 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); 6580 i++; 6581 } 6582 } 6583 6584 if (isIntentFragment) { 6585 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); 6586 } else { 6587 intent.mData = Uri.parse(uri); 6588 } 6589 6590 if (intent.mAction == null) { 6591 // By default, if no action is specified, then use VIEW. 6592 intent.mAction = ACTION_VIEW; 6593 } 6594 6595 } else { 6596 intent = new Intent(ACTION_VIEW, Uri.parse(uri)); 6597 } 6598 6599 return intent; 6600 } 6601 6602 /** @hide */ 6603 public interface CommandOptionHandler { 6604 boolean handleOption(String opt, ShellCommand cmd); 6605 } 6606 6607 /** @hide */ parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)6608 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) 6609 throws URISyntaxException { 6610 Intent intent = new Intent(); 6611 Intent baseIntent = intent; 6612 boolean hasIntentInfo = false; 6613 6614 Uri data = null; 6615 String type = null; 6616 6617 String opt; 6618 while ((opt=cmd.getNextOption()) != null) { 6619 switch (opt) { 6620 case "-a": 6621 intent.setAction(cmd.getNextArgRequired()); 6622 if (intent == baseIntent) { 6623 hasIntentInfo = true; 6624 } 6625 break; 6626 case "-d": 6627 data = Uri.parse(cmd.getNextArgRequired()); 6628 if (intent == baseIntent) { 6629 hasIntentInfo = true; 6630 } 6631 break; 6632 case "-t": 6633 type = cmd.getNextArgRequired(); 6634 if (intent == baseIntent) { 6635 hasIntentInfo = true; 6636 } 6637 break; 6638 case "-c": 6639 intent.addCategory(cmd.getNextArgRequired()); 6640 if (intent == baseIntent) { 6641 hasIntentInfo = true; 6642 } 6643 break; 6644 case "-e": 6645 case "--es": { 6646 String key = cmd.getNextArgRequired(); 6647 String value = cmd.getNextArgRequired(); 6648 intent.putExtra(key, value); 6649 } 6650 break; 6651 case "--esn": { 6652 String key = cmd.getNextArgRequired(); 6653 intent.putExtra(key, (String) null); 6654 } 6655 break; 6656 case "--ei": { 6657 String key = cmd.getNextArgRequired(); 6658 String value = cmd.getNextArgRequired(); 6659 intent.putExtra(key, Integer.decode(value)); 6660 } 6661 break; 6662 case "--eu": { 6663 String key = cmd.getNextArgRequired(); 6664 String value = cmd.getNextArgRequired(); 6665 intent.putExtra(key, Uri.parse(value)); 6666 } 6667 break; 6668 case "--ecn": { 6669 String key = cmd.getNextArgRequired(); 6670 String value = cmd.getNextArgRequired(); 6671 ComponentName cn = ComponentName.unflattenFromString(value); 6672 if (cn == null) 6673 throw new IllegalArgumentException("Bad component name: " + value); 6674 intent.putExtra(key, cn); 6675 } 6676 break; 6677 case "--eia": { 6678 String key = cmd.getNextArgRequired(); 6679 String value = cmd.getNextArgRequired(); 6680 String[] strings = value.split(","); 6681 int[] list = new int[strings.length]; 6682 for (int i = 0; i < strings.length; i++) { 6683 list[i] = Integer.decode(strings[i]); 6684 } 6685 intent.putExtra(key, list); 6686 } 6687 break; 6688 case "--eial": { 6689 String key = cmd.getNextArgRequired(); 6690 String value = cmd.getNextArgRequired(); 6691 String[] strings = value.split(","); 6692 ArrayList<Integer> list = new ArrayList<>(strings.length); 6693 for (int i = 0; i < strings.length; i++) { 6694 list.add(Integer.decode(strings[i])); 6695 } 6696 intent.putExtra(key, list); 6697 } 6698 break; 6699 case "--el": { 6700 String key = cmd.getNextArgRequired(); 6701 String value = cmd.getNextArgRequired(); 6702 intent.putExtra(key, Long.valueOf(value)); 6703 } 6704 break; 6705 case "--ela": { 6706 String key = cmd.getNextArgRequired(); 6707 String value = cmd.getNextArgRequired(); 6708 String[] strings = value.split(","); 6709 long[] list = new long[strings.length]; 6710 for (int i = 0; i < strings.length; i++) { 6711 list[i] = Long.valueOf(strings[i]); 6712 } 6713 intent.putExtra(key, list); 6714 hasIntentInfo = true; 6715 } 6716 break; 6717 case "--elal": { 6718 String key = cmd.getNextArgRequired(); 6719 String value = cmd.getNextArgRequired(); 6720 String[] strings = value.split(","); 6721 ArrayList<Long> list = new ArrayList<>(strings.length); 6722 for (int i = 0; i < strings.length; i++) { 6723 list.add(Long.valueOf(strings[i])); 6724 } 6725 intent.putExtra(key, list); 6726 hasIntentInfo = true; 6727 } 6728 break; 6729 case "--ef": { 6730 String key = cmd.getNextArgRequired(); 6731 String value = cmd.getNextArgRequired(); 6732 intent.putExtra(key, Float.valueOf(value)); 6733 hasIntentInfo = true; 6734 } 6735 break; 6736 case "--efa": { 6737 String key = cmd.getNextArgRequired(); 6738 String value = cmd.getNextArgRequired(); 6739 String[] strings = value.split(","); 6740 float[] list = new float[strings.length]; 6741 for (int i = 0; i < strings.length; i++) { 6742 list[i] = Float.valueOf(strings[i]); 6743 } 6744 intent.putExtra(key, list); 6745 hasIntentInfo = true; 6746 } 6747 break; 6748 case "--efal": { 6749 String key = cmd.getNextArgRequired(); 6750 String value = cmd.getNextArgRequired(); 6751 String[] strings = value.split(","); 6752 ArrayList<Float> list = new ArrayList<>(strings.length); 6753 for (int i = 0; i < strings.length; i++) { 6754 list.add(Float.valueOf(strings[i])); 6755 } 6756 intent.putExtra(key, list); 6757 hasIntentInfo = true; 6758 } 6759 break; 6760 case "--esa": { 6761 String key = cmd.getNextArgRequired(); 6762 String value = cmd.getNextArgRequired(); 6763 // Split on commas unless they are preceeded by an escape. 6764 // The escape character must be escaped for the string and 6765 // again for the regex, thus four escape characters become one. 6766 String[] strings = value.split("(?<!\\\\),"); 6767 intent.putExtra(key, strings); 6768 hasIntentInfo = true; 6769 } 6770 break; 6771 case "--esal": { 6772 String key = cmd.getNextArgRequired(); 6773 String value = cmd.getNextArgRequired(); 6774 // Split on commas unless they are preceeded by an escape. 6775 // The escape character must be escaped for the string and 6776 // again for the regex, thus four escape characters become one. 6777 String[] strings = value.split("(?<!\\\\),"); 6778 ArrayList<String> list = new ArrayList<>(strings.length); 6779 for (int i = 0; i < strings.length; i++) { 6780 list.add(strings[i]); 6781 } 6782 intent.putExtra(key, list); 6783 hasIntentInfo = true; 6784 } 6785 break; 6786 case "--ez": { 6787 String key = cmd.getNextArgRequired(); 6788 String value = cmd.getNextArgRequired().toLowerCase(); 6789 // Boolean.valueOf() results in false for anything that is not "true", which is 6790 // error-prone in shell commands 6791 boolean arg; 6792 if ("true".equals(value) || "t".equals(value)) { 6793 arg = true; 6794 } else if ("false".equals(value) || "f".equals(value)) { 6795 arg = false; 6796 } else { 6797 try { 6798 arg = Integer.decode(value) != 0; 6799 } catch (NumberFormatException ex) { 6800 throw new IllegalArgumentException("Invalid boolean value: " + value); 6801 } 6802 } 6803 6804 intent.putExtra(key, arg); 6805 } 6806 break; 6807 case "-n": { 6808 String str = cmd.getNextArgRequired(); 6809 ComponentName cn = ComponentName.unflattenFromString(str); 6810 if (cn == null) 6811 throw new IllegalArgumentException("Bad component name: " + str); 6812 intent.setComponent(cn); 6813 if (intent == baseIntent) { 6814 hasIntentInfo = true; 6815 } 6816 } 6817 break; 6818 case "-p": { 6819 String str = cmd.getNextArgRequired(); 6820 intent.setPackage(str); 6821 if (intent == baseIntent) { 6822 hasIntentInfo = true; 6823 } 6824 } 6825 break; 6826 case "-f": 6827 String str = cmd.getNextArgRequired(); 6828 intent.setFlags(Integer.decode(str).intValue()); 6829 break; 6830 case "--grant-read-uri-permission": 6831 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 6832 break; 6833 case "--grant-write-uri-permission": 6834 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 6835 break; 6836 case "--grant-persistable-uri-permission": 6837 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); 6838 break; 6839 case "--grant-prefix-uri-permission": 6840 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); 6841 break; 6842 case "--exclude-stopped-packages": 6843 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); 6844 break; 6845 case "--include-stopped-packages": 6846 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); 6847 break; 6848 case "--debug-log-resolution": 6849 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); 6850 break; 6851 case "--activity-brought-to-front": 6852 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); 6853 break; 6854 case "--activity-clear-top": 6855 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 6856 break; 6857 case "--activity-clear-when-task-reset": 6858 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 6859 break; 6860 case "--activity-exclude-from-recents": 6861 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 6862 break; 6863 case "--activity-launched-from-history": 6864 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); 6865 break; 6866 case "--activity-multiple-task": 6867 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 6868 break; 6869 case "--activity-no-animation": 6870 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 6871 break; 6872 case "--activity-no-history": 6873 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 6874 break; 6875 case "--activity-no-user-action": 6876 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); 6877 break; 6878 case "--activity-previous-is-top": 6879 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); 6880 break; 6881 case "--activity-reorder-to-front": 6882 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 6883 break; 6884 case "--activity-reset-task-if-needed": 6885 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 6886 break; 6887 case "--activity-single-top": 6888 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 6889 break; 6890 case "--activity-clear-task": 6891 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 6892 break; 6893 case "--activity-task-on-home": 6894 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); 6895 break; 6896 case "--activity-match-external": 6897 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL); 6898 break; 6899 case "--receiver-registered-only": 6900 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); 6901 break; 6902 case "--receiver-replace-pending": 6903 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); 6904 break; 6905 case "--receiver-foreground": 6906 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 6907 break; 6908 case "--receiver-no-abort": 6909 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); 6910 break; 6911 case "--receiver-include-background": 6912 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 6913 break; 6914 case "--selector": 6915 intent.setDataAndType(data, type); 6916 intent = new Intent(); 6917 break; 6918 default: 6919 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { 6920 // Okay, caller handled this option. 6921 } else { 6922 throw new IllegalArgumentException("Unknown option: " + opt); 6923 } 6924 break; 6925 } 6926 } 6927 intent.setDataAndType(data, type); 6928 6929 final boolean hasSelector = intent != baseIntent; 6930 if (hasSelector) { 6931 // A selector was specified; fix up. 6932 baseIntent.setSelector(intent); 6933 intent = baseIntent; 6934 } 6935 6936 String arg = cmd.getNextArg(); 6937 baseIntent = null; 6938 if (arg == null) { 6939 if (hasSelector) { 6940 // If a selector has been specified, and no arguments 6941 // have been supplied for the main Intent, then we can 6942 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't 6943 // need to have a component name specified yet, the 6944 // selector will take care of that. 6945 baseIntent = new Intent(Intent.ACTION_MAIN); 6946 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 6947 } 6948 } else if (arg.indexOf(':') >= 0) { 6949 // The argument is a URI. Fully parse it, and use that result 6950 // to fill in any data not specified so far. 6951 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME 6952 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); 6953 } else if (arg.indexOf('/') >= 0) { 6954 // The argument is a component name. Build an Intent to launch 6955 // it. 6956 baseIntent = new Intent(Intent.ACTION_MAIN); 6957 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 6958 baseIntent.setComponent(ComponentName.unflattenFromString(arg)); 6959 } else { 6960 // Assume the argument is a package name. 6961 baseIntent = new Intent(Intent.ACTION_MAIN); 6962 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 6963 baseIntent.setPackage(arg); 6964 } 6965 if (baseIntent != null) { 6966 Bundle extras = intent.getExtras(); 6967 intent.replaceExtras((Bundle)null); 6968 Bundle uriExtras = baseIntent.getExtras(); 6969 baseIntent.replaceExtras((Bundle)null); 6970 if (intent.getAction() != null && baseIntent.getCategories() != null) { 6971 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); 6972 for (String c : cats) { 6973 baseIntent.removeCategory(c); 6974 } 6975 } 6976 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); 6977 if (extras == null) { 6978 extras = uriExtras; 6979 } else if (uriExtras != null) { 6980 uriExtras.putAll(extras); 6981 extras = uriExtras; 6982 } 6983 intent.replaceExtras(extras); 6984 hasIntentInfo = true; 6985 } 6986 6987 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); 6988 return intent; 6989 } 6990 6991 /** @hide */ printIntentArgsHelp(PrintWriter pw, String prefix)6992 public static void printIntentArgsHelp(PrintWriter pw, String prefix) { 6993 final String[] lines = new String[] { 6994 "<INTENT> specifications include these flags and arguments:", 6995 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]", 6996 " [-c <CATEGORY> [-c <CATEGORY>] ...]", 6997 " [-n <COMPONENT_NAME>]", 6998 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", 6999 " [--esn <EXTRA_KEY> ...]", 7000 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", 7001 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", 7002 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", 7003 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", 7004 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", 7005 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", 7006 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 7007 " (mutiple extras passed as Integer[])", 7008 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 7009 " (mutiple extras passed as List<Integer>)", 7010 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 7011 " (mutiple extras passed as Long[])", 7012 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 7013 " (mutiple extras passed as List<Long>)", 7014 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 7015 " (mutiple extras passed as Float[])", 7016 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 7017 " (mutiple extras passed as List<Float>)", 7018 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 7019 " (mutiple extras passed as String[]; to embed a comma into a string,", 7020 " escape it using \"\\,\")", 7021 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 7022 " (mutiple extras passed as List<String>; to embed a comma into a string,", 7023 " escape it using \"\\,\")", 7024 " [-f <FLAG>]", 7025 " [--grant-read-uri-permission] [--grant-write-uri-permission]", 7026 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", 7027 " [--debug-log-resolution] [--exclude-stopped-packages]", 7028 " [--include-stopped-packages]", 7029 " [--activity-brought-to-front] [--activity-clear-top]", 7030 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", 7031 " [--activity-launched-from-history] [--activity-multiple-task]", 7032 " [--activity-no-animation] [--activity-no-history]", 7033 " [--activity-no-user-action] [--activity-previous-is-top]", 7034 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", 7035 " [--activity-single-top] [--activity-clear-task]", 7036 " [--activity-task-on-home] [--activity-match-external]", 7037 " [--receiver-registered-only] [--receiver-replace-pending]", 7038 " [--receiver-foreground] [--receiver-no-abort]", 7039 " [--receiver-include-background]", 7040 " [--selector]", 7041 " [<URI> | <PACKAGE> | <COMPONENT>]" 7042 }; 7043 for (String line : lines) { 7044 pw.print(prefix); 7045 pw.println(line); 7046 } 7047 } 7048 7049 /** 7050 * Retrieve the general action to be performed, such as 7051 * {@link #ACTION_VIEW}. The action describes the general way the rest of 7052 * the information in the intent should be interpreted -- most importantly, 7053 * what to do with the data returned by {@link #getData}. 7054 * 7055 * @return The action of this intent or null if none is specified. 7056 * 7057 * @see #setAction 7058 */ getAction()7059 public @Nullable String getAction() { 7060 return mAction; 7061 } 7062 7063 /** 7064 * Retrieve data this intent is operating on. This URI specifies the name 7065 * of the data; often it uses the content: scheme, specifying data in a 7066 * content provider. Other schemes may be handled by specific activities, 7067 * such as http: by the web browser. 7068 * 7069 * @return The URI of the data this intent is targeting or null. 7070 * 7071 * @see #getScheme 7072 * @see #setData 7073 */ getData()7074 public @Nullable Uri getData() { 7075 return mData; 7076 } 7077 7078 /** 7079 * The same as {@link #getData()}, but returns the URI as an encoded 7080 * String. 7081 */ getDataString()7082 public @Nullable String getDataString() { 7083 return mData != null ? mData.toString() : null; 7084 } 7085 7086 /** 7087 * Return the scheme portion of the intent's data. If the data is null or 7088 * does not include a scheme, null is returned. Otherwise, the scheme 7089 * prefix without the final ':' is returned, i.e. "http". 7090 * 7091 * <p>This is the same as calling getData().getScheme() (and checking for 7092 * null data). 7093 * 7094 * @return The scheme of this intent. 7095 * 7096 * @see #getData 7097 */ getScheme()7098 public @Nullable String getScheme() { 7099 return mData != null ? mData.getScheme() : null; 7100 } 7101 7102 /** 7103 * Retrieve any explicit MIME type included in the intent. This is usually 7104 * null, as the type is determined by the intent data. 7105 * 7106 * @return If a type was manually set, it is returned; else null is 7107 * returned. 7108 * 7109 * @see #resolveType(ContentResolver) 7110 * @see #setType 7111 */ getType()7112 public @Nullable String getType() { 7113 return mType; 7114 } 7115 7116 /** 7117 * Return the MIME data type of this intent. If the type field is 7118 * explicitly set, that is simply returned. Otherwise, if the data is set, 7119 * the type of that data is returned. If neither fields are set, a null is 7120 * returned. 7121 * 7122 * @return The MIME type of this intent. 7123 * 7124 * @see #getType 7125 * @see #resolveType(ContentResolver) 7126 */ resolveType(@onNull Context context)7127 public @Nullable String resolveType(@NonNull Context context) { 7128 return resolveType(context.getContentResolver()); 7129 } 7130 7131 /** 7132 * Return the MIME data type of this intent. If the type field is 7133 * explicitly set, that is simply returned. Otherwise, if the data is set, 7134 * the type of that data is returned. If neither fields are set, a null is 7135 * returned. 7136 * 7137 * @param resolver A ContentResolver that can be used to determine the MIME 7138 * type of the intent's data. 7139 * 7140 * @return The MIME type of this intent. 7141 * 7142 * @see #getType 7143 * @see #resolveType(Context) 7144 */ resolveType(@onNull ContentResolver resolver)7145 public @Nullable String resolveType(@NonNull ContentResolver resolver) { 7146 if (mType != null) { 7147 return mType; 7148 } 7149 if (mData != null) { 7150 if ("content".equals(mData.getScheme())) { 7151 return resolver.getType(mData); 7152 } 7153 } 7154 return null; 7155 } 7156 7157 /** 7158 * Return the MIME data type of this intent, only if it will be needed for 7159 * intent resolution. This is not generally useful for application code; 7160 * it is used by the frameworks for communicating with back-end system 7161 * services. 7162 * 7163 * @param resolver A ContentResolver that can be used to determine the MIME 7164 * type of the intent's data. 7165 * 7166 * @return The MIME type of this intent, or null if it is unknown or not 7167 * needed. 7168 */ resolveTypeIfNeeded(@onNull ContentResolver resolver)7169 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) { 7170 if (mComponent != null) { 7171 return mType; 7172 } 7173 return resolveType(resolver); 7174 } 7175 7176 /** 7177 * Check if a category exists in the intent. 7178 * 7179 * @param category The category to check. 7180 * 7181 * @return boolean True if the intent contains the category, else false. 7182 * 7183 * @see #getCategories 7184 * @see #addCategory 7185 */ hasCategory(String category)7186 public boolean hasCategory(String category) { 7187 return mCategories != null && mCategories.contains(category); 7188 } 7189 7190 /** 7191 * Return the set of all categories in the intent. If there are no categories, 7192 * returns NULL. 7193 * 7194 * @return The set of categories you can examine. Do not modify! 7195 * 7196 * @see #hasCategory 7197 * @see #addCategory 7198 */ getCategories()7199 public Set<String> getCategories() { 7200 return mCategories; 7201 } 7202 7203 /** 7204 * Return the specific selector associated with this Intent. If there is 7205 * none, returns null. See {@link #setSelector} for more information. 7206 * 7207 * @see #setSelector 7208 */ getSelector()7209 public @Nullable Intent getSelector() { 7210 return mSelector; 7211 } 7212 7213 /** 7214 * Return the {@link ClipData} associated with this Intent. If there is 7215 * none, returns null. See {@link #setClipData} for more information. 7216 * 7217 * @see #setClipData 7218 */ getClipData()7219 public @Nullable ClipData getClipData() { 7220 return mClipData; 7221 } 7222 7223 /** @hide */ getContentUserHint()7224 public int getContentUserHint() { 7225 return mContentUserHint; 7226 } 7227 7228 /** @hide */ getLaunchToken()7229 public String getLaunchToken() { 7230 return mLaunchToken; 7231 } 7232 7233 /** @hide */ setLaunchToken(String launchToken)7234 public void setLaunchToken(String launchToken) { 7235 mLaunchToken = launchToken; 7236 } 7237 7238 /** 7239 * Sets the ClassLoader that will be used when unmarshalling 7240 * any Parcelable values from the extras of this Intent. 7241 * 7242 * @param loader a ClassLoader, or null to use the default loader 7243 * at the time of unmarshalling. 7244 */ setExtrasClassLoader(@ullable ClassLoader loader)7245 public void setExtrasClassLoader(@Nullable ClassLoader loader) { 7246 if (mExtras != null) { 7247 mExtras.setClassLoader(loader); 7248 } 7249 } 7250 7251 /** 7252 * Returns true if an extra value is associated with the given name. 7253 * @param name the extra's name 7254 * @return true if the given extra is present. 7255 */ hasExtra(String name)7256 public boolean hasExtra(String name) { 7257 return mExtras != null && mExtras.containsKey(name); 7258 } 7259 7260 /** 7261 * Returns true if the Intent's extras contain a parcelled file descriptor. 7262 * @return true if the Intent contains a parcelled file descriptor. 7263 */ hasFileDescriptors()7264 public boolean hasFileDescriptors() { 7265 return mExtras != null && mExtras.hasFileDescriptors(); 7266 } 7267 7268 /** {@hide} */ setAllowFds(boolean allowFds)7269 public void setAllowFds(boolean allowFds) { 7270 if (mExtras != null) { 7271 mExtras.setAllowFds(allowFds); 7272 } 7273 } 7274 7275 /** {@hide} */ setDefusable(boolean defusable)7276 public void setDefusable(boolean defusable) { 7277 if (mExtras != null) { 7278 mExtras.setDefusable(defusable); 7279 } 7280 } 7281 7282 /** 7283 * Retrieve extended data from the intent. 7284 * 7285 * @param name The name of the desired item. 7286 * 7287 * @return the value of an item previously added with putExtra(), 7288 * or null if none was found. 7289 * 7290 * @deprecated 7291 * @hide 7292 */ 7293 @Deprecated getExtra(String name)7294 public Object getExtra(String name) { 7295 return getExtra(name, null); 7296 } 7297 7298 /** 7299 * Retrieve extended data from the intent. 7300 * 7301 * @param name The name of the desired item. 7302 * @param defaultValue the value to be returned if no value of the desired 7303 * type is stored with the given name. 7304 * 7305 * @return the value of an item previously added with putExtra(), 7306 * or the default value if none was found. 7307 * 7308 * @see #putExtra(String, boolean) 7309 */ getBooleanExtra(String name, boolean defaultValue)7310 public boolean getBooleanExtra(String name, boolean defaultValue) { 7311 return mExtras == null ? defaultValue : 7312 mExtras.getBoolean(name, defaultValue); 7313 } 7314 7315 /** 7316 * Retrieve extended data from the intent. 7317 * 7318 * @param name The name of the desired item. 7319 * @param defaultValue the value to be returned if no value of the desired 7320 * type is stored with the given name. 7321 * 7322 * @return the value of an item previously added with putExtra(), 7323 * or the default value if none was found. 7324 * 7325 * @see #putExtra(String, byte) 7326 */ getByteExtra(String name, byte defaultValue)7327 public byte getByteExtra(String name, byte defaultValue) { 7328 return mExtras == null ? defaultValue : 7329 mExtras.getByte(name, defaultValue); 7330 } 7331 7332 /** 7333 * Retrieve extended data from the intent. 7334 * 7335 * @param name The name of the desired item. 7336 * @param defaultValue the value to be returned if no value of the desired 7337 * type is stored with the given name. 7338 * 7339 * @return the value of an item previously added with putExtra(), 7340 * or the default value if none was found. 7341 * 7342 * @see #putExtra(String, short) 7343 */ getShortExtra(String name, short defaultValue)7344 public short getShortExtra(String name, short defaultValue) { 7345 return mExtras == null ? defaultValue : 7346 mExtras.getShort(name, defaultValue); 7347 } 7348 7349 /** 7350 * Retrieve extended data from the intent. 7351 * 7352 * @param name The name of the desired item. 7353 * @param defaultValue the value to be returned if no value of the desired 7354 * type is stored with the given name. 7355 * 7356 * @return the value of an item previously added with putExtra(), 7357 * or the default value if none was found. 7358 * 7359 * @see #putExtra(String, char) 7360 */ getCharExtra(String name, char defaultValue)7361 public char getCharExtra(String name, char defaultValue) { 7362 return mExtras == null ? defaultValue : 7363 mExtras.getChar(name, defaultValue); 7364 } 7365 7366 /** 7367 * Retrieve extended data from the intent. 7368 * 7369 * @param name The name of the desired item. 7370 * @param defaultValue the value to be returned if no value of the desired 7371 * type is stored with the given name. 7372 * 7373 * @return the value of an item previously added with putExtra(), 7374 * or the default value if none was found. 7375 * 7376 * @see #putExtra(String, int) 7377 */ getIntExtra(String name, int defaultValue)7378 public int getIntExtra(String name, int defaultValue) { 7379 return mExtras == null ? defaultValue : 7380 mExtras.getInt(name, defaultValue); 7381 } 7382 7383 /** 7384 * Retrieve extended data from the intent. 7385 * 7386 * @param name The name of the desired item. 7387 * @param defaultValue the value to be returned if no value of the desired 7388 * type is stored with the given name. 7389 * 7390 * @return the value of an item previously added with putExtra(), 7391 * or the default value if none was found. 7392 * 7393 * @see #putExtra(String, long) 7394 */ getLongExtra(String name, long defaultValue)7395 public long getLongExtra(String name, long defaultValue) { 7396 return mExtras == null ? defaultValue : 7397 mExtras.getLong(name, defaultValue); 7398 } 7399 7400 /** 7401 * Retrieve extended data from the intent. 7402 * 7403 * @param name The name of the desired item. 7404 * @param defaultValue the value to be returned if no value of the desired 7405 * type is stored with the given name. 7406 * 7407 * @return the value of an item previously added with putExtra(), 7408 * or the default value if no such item is present 7409 * 7410 * @see #putExtra(String, float) 7411 */ getFloatExtra(String name, float defaultValue)7412 public float getFloatExtra(String name, float defaultValue) { 7413 return mExtras == null ? defaultValue : 7414 mExtras.getFloat(name, defaultValue); 7415 } 7416 7417 /** 7418 * Retrieve extended data from the intent. 7419 * 7420 * @param name The name of the desired item. 7421 * @param defaultValue the value to be returned if no value of the desired 7422 * type is stored with the given name. 7423 * 7424 * @return the value of an item previously added with putExtra(), 7425 * or the default value if none was found. 7426 * 7427 * @see #putExtra(String, double) 7428 */ getDoubleExtra(String name, double defaultValue)7429 public double getDoubleExtra(String name, double defaultValue) { 7430 return mExtras == null ? defaultValue : 7431 mExtras.getDouble(name, defaultValue); 7432 } 7433 7434 /** 7435 * Retrieve extended data from the intent. 7436 * 7437 * @param name The name of the desired item. 7438 * 7439 * @return the value of an item previously added with putExtra(), 7440 * or null if no String value was found. 7441 * 7442 * @see #putExtra(String, String) 7443 */ getStringExtra(String name)7444 public String getStringExtra(String name) { 7445 return mExtras == null ? null : mExtras.getString(name); 7446 } 7447 7448 /** 7449 * Retrieve extended data from the intent. 7450 * 7451 * @param name The name of the desired item. 7452 * 7453 * @return the value of an item previously added with putExtra(), 7454 * or null if no CharSequence value was found. 7455 * 7456 * @see #putExtra(String, CharSequence) 7457 */ getCharSequenceExtra(String name)7458 public CharSequence getCharSequenceExtra(String name) { 7459 return mExtras == null ? null : mExtras.getCharSequence(name); 7460 } 7461 7462 /** 7463 * Retrieve extended data from the intent. 7464 * 7465 * @param name The name of the desired item. 7466 * 7467 * @return the value of an item previously added with putExtra(), 7468 * or null if no Parcelable value was found. 7469 * 7470 * @see #putExtra(String, Parcelable) 7471 */ getParcelableExtra(String name)7472 public <T extends Parcelable> T getParcelableExtra(String name) { 7473 return mExtras == null ? null : mExtras.<T>getParcelable(name); 7474 } 7475 7476 /** 7477 * Retrieve extended data from the intent. 7478 * 7479 * @param name The name of the desired item. 7480 * 7481 * @return the value of an item previously added with putExtra(), 7482 * or null if no Parcelable[] value was found. 7483 * 7484 * @see #putExtra(String, Parcelable[]) 7485 */ getParcelableArrayExtra(String name)7486 public Parcelable[] getParcelableArrayExtra(String name) { 7487 return mExtras == null ? null : mExtras.getParcelableArray(name); 7488 } 7489 7490 /** 7491 * Retrieve extended data from the intent. 7492 * 7493 * @param name The name of the desired item. 7494 * 7495 * @return the value of an item previously added with 7496 * putParcelableArrayListExtra(), or null if no 7497 * ArrayList<Parcelable> value was found. 7498 * 7499 * @see #putParcelableArrayListExtra(String, ArrayList) 7500 */ getParcelableArrayListExtra(String name)7501 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { 7502 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); 7503 } 7504 7505 /** 7506 * Retrieve extended data from the intent. 7507 * 7508 * @param name The name of the desired item. 7509 * 7510 * @return the value of an item previously added with putExtra(), 7511 * or null if no Serializable value was found. 7512 * 7513 * @see #putExtra(String, Serializable) 7514 */ getSerializableExtra(String name)7515 public Serializable getSerializableExtra(String name) { 7516 return mExtras == null ? null : mExtras.getSerializable(name); 7517 } 7518 7519 /** 7520 * Retrieve extended data from the intent. 7521 * 7522 * @param name The name of the desired item. 7523 * 7524 * @return the value of an item previously added with 7525 * putIntegerArrayListExtra(), or null if no 7526 * ArrayList<Integer> value was found. 7527 * 7528 * @see #putIntegerArrayListExtra(String, ArrayList) 7529 */ getIntegerArrayListExtra(String name)7530 public ArrayList<Integer> getIntegerArrayListExtra(String name) { 7531 return mExtras == null ? null : mExtras.getIntegerArrayList(name); 7532 } 7533 7534 /** 7535 * Retrieve extended data from the intent. 7536 * 7537 * @param name The name of the desired item. 7538 * 7539 * @return the value of an item previously added with 7540 * putStringArrayListExtra(), or null if no 7541 * ArrayList<String> value was found. 7542 * 7543 * @see #putStringArrayListExtra(String, ArrayList) 7544 */ getStringArrayListExtra(String name)7545 public ArrayList<String> getStringArrayListExtra(String name) { 7546 return mExtras == null ? null : mExtras.getStringArrayList(name); 7547 } 7548 7549 /** 7550 * Retrieve extended data from the intent. 7551 * 7552 * @param name The name of the desired item. 7553 * 7554 * @return the value of an item previously added with 7555 * putCharSequenceArrayListExtra, or null if no 7556 * ArrayList<CharSequence> value was found. 7557 * 7558 * @see #putCharSequenceArrayListExtra(String, ArrayList) 7559 */ getCharSequenceArrayListExtra(String name)7560 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { 7561 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); 7562 } 7563 7564 /** 7565 * Retrieve extended data from the intent. 7566 * 7567 * @param name The name of the desired item. 7568 * 7569 * @return the value of an item previously added with putExtra(), 7570 * or null if no boolean array value was found. 7571 * 7572 * @see #putExtra(String, boolean[]) 7573 */ getBooleanArrayExtra(String name)7574 public boolean[] getBooleanArrayExtra(String name) { 7575 return mExtras == null ? null : mExtras.getBooleanArray(name); 7576 } 7577 7578 /** 7579 * Retrieve extended data from the intent. 7580 * 7581 * @param name The name of the desired item. 7582 * 7583 * @return the value of an item previously added with putExtra(), 7584 * or null if no byte array value was found. 7585 * 7586 * @see #putExtra(String, byte[]) 7587 */ getByteArrayExtra(String name)7588 public byte[] getByteArrayExtra(String name) { 7589 return mExtras == null ? null : mExtras.getByteArray(name); 7590 } 7591 7592 /** 7593 * Retrieve extended data from the intent. 7594 * 7595 * @param name The name of the desired item. 7596 * 7597 * @return the value of an item previously added with putExtra(), 7598 * or null if no short array value was found. 7599 * 7600 * @see #putExtra(String, short[]) 7601 */ getShortArrayExtra(String name)7602 public short[] getShortArrayExtra(String name) { 7603 return mExtras == null ? null : mExtras.getShortArray(name); 7604 } 7605 7606 /** 7607 * Retrieve extended data from the intent. 7608 * 7609 * @param name The name of the desired item. 7610 * 7611 * @return the value of an item previously added with putExtra(), 7612 * or null if no char array value was found. 7613 * 7614 * @see #putExtra(String, char[]) 7615 */ getCharArrayExtra(String name)7616 public char[] getCharArrayExtra(String name) { 7617 return mExtras == null ? null : mExtras.getCharArray(name); 7618 } 7619 7620 /** 7621 * Retrieve extended data from the intent. 7622 * 7623 * @param name The name of the desired item. 7624 * 7625 * @return the value of an item previously added with putExtra(), 7626 * or null if no int array value was found. 7627 * 7628 * @see #putExtra(String, int[]) 7629 */ getIntArrayExtra(String name)7630 public int[] getIntArrayExtra(String name) { 7631 return mExtras == null ? null : mExtras.getIntArray(name); 7632 } 7633 7634 /** 7635 * Retrieve extended data from the intent. 7636 * 7637 * @param name The name of the desired item. 7638 * 7639 * @return the value of an item previously added with putExtra(), 7640 * or null if no long array value was found. 7641 * 7642 * @see #putExtra(String, long[]) 7643 */ getLongArrayExtra(String name)7644 public long[] getLongArrayExtra(String name) { 7645 return mExtras == null ? null : mExtras.getLongArray(name); 7646 } 7647 7648 /** 7649 * Retrieve extended data from the intent. 7650 * 7651 * @param name The name of the desired item. 7652 * 7653 * @return the value of an item previously added with putExtra(), 7654 * or null if no float array value was found. 7655 * 7656 * @see #putExtra(String, float[]) 7657 */ getFloatArrayExtra(String name)7658 public float[] getFloatArrayExtra(String name) { 7659 return mExtras == null ? null : mExtras.getFloatArray(name); 7660 } 7661 7662 /** 7663 * Retrieve extended data from the intent. 7664 * 7665 * @param name The name of the desired item. 7666 * 7667 * @return the value of an item previously added with putExtra(), 7668 * or null if no double array value was found. 7669 * 7670 * @see #putExtra(String, double[]) 7671 */ getDoubleArrayExtra(String name)7672 public double[] getDoubleArrayExtra(String name) { 7673 return mExtras == null ? null : mExtras.getDoubleArray(name); 7674 } 7675 7676 /** 7677 * Retrieve extended data from the intent. 7678 * 7679 * @param name The name of the desired item. 7680 * 7681 * @return the value of an item previously added with putExtra(), 7682 * or null if no String array value was found. 7683 * 7684 * @see #putExtra(String, String[]) 7685 */ getStringArrayExtra(String name)7686 public String[] getStringArrayExtra(String name) { 7687 return mExtras == null ? null : mExtras.getStringArray(name); 7688 } 7689 7690 /** 7691 * Retrieve extended data from the intent. 7692 * 7693 * @param name The name of the desired item. 7694 * 7695 * @return the value of an item previously added with putExtra(), 7696 * or null if no CharSequence array value was found. 7697 * 7698 * @see #putExtra(String, CharSequence[]) 7699 */ getCharSequenceArrayExtra(String name)7700 public CharSequence[] getCharSequenceArrayExtra(String name) { 7701 return mExtras == null ? null : mExtras.getCharSequenceArray(name); 7702 } 7703 7704 /** 7705 * Retrieve extended data from the intent. 7706 * 7707 * @param name The name of the desired item. 7708 * 7709 * @return the value of an item previously added with putExtra(), 7710 * or null if no Bundle value was found. 7711 * 7712 * @see #putExtra(String, Bundle) 7713 */ getBundleExtra(String name)7714 public Bundle getBundleExtra(String name) { 7715 return mExtras == null ? null : mExtras.getBundle(name); 7716 } 7717 7718 /** 7719 * Retrieve extended data from the intent. 7720 * 7721 * @param name The name of the desired item. 7722 * 7723 * @return the value of an item previously added with putExtra(), 7724 * or null if no IBinder value was found. 7725 * 7726 * @see #putExtra(String, IBinder) 7727 * 7728 * @deprecated 7729 * @hide 7730 */ 7731 @Deprecated getIBinderExtra(String name)7732 public IBinder getIBinderExtra(String name) { 7733 return mExtras == null ? null : mExtras.getIBinder(name); 7734 } 7735 7736 /** 7737 * Retrieve extended data from the intent. 7738 * 7739 * @param name The name of the desired item. 7740 * @param defaultValue The default value to return in case no item is 7741 * associated with the key 'name' 7742 * 7743 * @return the value of an item previously added with putExtra(), 7744 * or defaultValue if none was found. 7745 * 7746 * @see #putExtra 7747 * 7748 * @deprecated 7749 * @hide 7750 */ 7751 @Deprecated getExtra(String name, Object defaultValue)7752 public Object getExtra(String name, Object defaultValue) { 7753 Object result = defaultValue; 7754 if (mExtras != null) { 7755 Object result2 = mExtras.get(name); 7756 if (result2 != null) { 7757 result = result2; 7758 } 7759 } 7760 7761 return result; 7762 } 7763 7764 /** 7765 * Retrieves a map of extended data from the intent. 7766 * 7767 * @return the map of all extras previously added with putExtra(), 7768 * or null if none have been added. 7769 */ getExtras()7770 public @Nullable Bundle getExtras() { 7771 return (mExtras != null) 7772 ? new Bundle(mExtras) 7773 : null; 7774 } 7775 7776 /** 7777 * Filter extras to only basic types. 7778 * @hide 7779 */ removeUnsafeExtras()7780 public void removeUnsafeExtras() { 7781 if (mExtras != null) { 7782 mExtras = mExtras.filterValues(); 7783 } 7784 } 7785 7786 /** 7787 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or 7788 * return itself as-is. 7789 * @hide 7790 */ canStripForHistory()7791 public boolean canStripForHistory() { 7792 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null); 7793 } 7794 7795 /** 7796 * Call it when the system needs to keep an intent for logging purposes to remove fields 7797 * that are not needed for logging. 7798 * @hide 7799 */ maybeStripForHistory()7800 public Intent maybeStripForHistory() { 7801 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras? 7802 7803 if (!canStripForHistory()) { 7804 return this; 7805 } 7806 return new Intent(this, COPY_MODE_HISTORY); 7807 } 7808 7809 /** 7810 * Retrieve any special flags associated with this intent. You will 7811 * normally just set them with {@link #setFlags} and let the system 7812 * take the appropriate action with them. 7813 * 7814 * @return The currently set flags. 7815 * @see #setFlags 7816 * @see #addFlags 7817 * @see #removeFlags 7818 */ getFlags()7819 public @Flags int getFlags() { 7820 return mFlags; 7821 } 7822 7823 /** @hide */ isExcludingStopped()7824 public boolean isExcludingStopped() { 7825 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) 7826 == FLAG_EXCLUDE_STOPPED_PACKAGES; 7827 } 7828 7829 /** 7830 * Retrieve the application package name this Intent is limited to. When 7831 * resolving an Intent, if non-null this limits the resolution to only 7832 * components in the given application package. 7833 * 7834 * @return The name of the application package for the Intent. 7835 * 7836 * @see #resolveActivity 7837 * @see #setPackage 7838 */ getPackage()7839 public @Nullable String getPackage() { 7840 return mPackage; 7841 } 7842 7843 /** 7844 * Retrieve the concrete component associated with the intent. When receiving 7845 * an intent, this is the component that was found to best handle it (that is, 7846 * yourself) and will always be non-null; in all other cases it will be 7847 * null unless explicitly set. 7848 * 7849 * @return The name of the application component to handle the intent. 7850 * 7851 * @see #resolveActivity 7852 * @see #setComponent 7853 */ getComponent()7854 public @Nullable ComponentName getComponent() { 7855 return mComponent; 7856 } 7857 7858 /** 7859 * Get the bounds of the sender of this intent, in screen coordinates. This can be 7860 * used as a hint to the receiver for animations and the like. Null means that there 7861 * is no source bounds. 7862 */ getSourceBounds()7863 public @Nullable Rect getSourceBounds() { 7864 return mSourceBounds; 7865 } 7866 7867 /** 7868 * Return the Activity component that should be used to handle this intent. 7869 * The appropriate component is determined based on the information in the 7870 * intent, evaluated as follows: 7871 * 7872 * <p>If {@link #getComponent} returns an explicit class, that is returned 7873 * without any further consideration. 7874 * 7875 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent 7876 * category to be considered. 7877 * 7878 * <p>If {@link #getAction} is non-NULL, the activity must handle this 7879 * action. 7880 * 7881 * <p>If {@link #resolveType} returns non-NULL, the activity must handle 7882 * this type. 7883 * 7884 * <p>If {@link #addCategory} has added any categories, the activity must 7885 * handle ALL of the categories specified. 7886 * 7887 * <p>If {@link #getPackage} is non-NULL, only activity components in 7888 * that application package will be considered. 7889 * 7890 * <p>If there are no activities that satisfy all of these conditions, a 7891 * null string is returned. 7892 * 7893 * <p>If multiple activities are found to satisfy the intent, the one with 7894 * the highest priority will be used. If there are multiple activities 7895 * with the same priority, the system will either pick the best activity 7896 * based on user preference, or resolve to a system class that will allow 7897 * the user to pick an activity and forward from there. 7898 * 7899 * <p>This method is implemented simply by calling 7900 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter 7901 * true.</p> 7902 * <p> This API is called for you as part of starting an activity from an 7903 * intent. You do not normally need to call it yourself.</p> 7904 * 7905 * @param pm The package manager with which to resolve the Intent. 7906 * 7907 * @return Name of the component implementing an activity that can 7908 * display the intent. 7909 * 7910 * @see #setComponent 7911 * @see #getComponent 7912 * @see #resolveActivityInfo 7913 */ resolveActivity(@onNull PackageManager pm)7914 public ComponentName resolveActivity(@NonNull PackageManager pm) { 7915 if (mComponent != null) { 7916 return mComponent; 7917 } 7918 7919 ResolveInfo info = pm.resolveActivity( 7920 this, PackageManager.MATCH_DEFAULT_ONLY); 7921 if (info != null) { 7922 return new ComponentName( 7923 info.activityInfo.applicationInfo.packageName, 7924 info.activityInfo.name); 7925 } 7926 7927 return null; 7928 } 7929 7930 /** 7931 * Resolve the Intent into an {@link ActivityInfo} 7932 * describing the activity that should execute the intent. Resolution 7933 * follows the same rules as described for {@link #resolveActivity}, but 7934 * you get back the completely information about the resolved activity 7935 * instead of just its class name. 7936 * 7937 * @param pm The package manager with which to resolve the Intent. 7938 * @param flags Addition information to retrieve as per 7939 * {@link PackageManager#getActivityInfo(ComponentName, int) 7940 * PackageManager.getActivityInfo()}. 7941 * 7942 * @return PackageManager.ActivityInfo 7943 * 7944 * @see #resolveActivity 7945 */ resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)7946 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm, 7947 @PackageManager.ComponentInfoFlags int flags) { 7948 ActivityInfo ai = null; 7949 if (mComponent != null) { 7950 try { 7951 ai = pm.getActivityInfo(mComponent, flags); 7952 } catch (PackageManager.NameNotFoundException e) { 7953 // ignore 7954 } 7955 } else { 7956 ResolveInfo info = pm.resolveActivity( 7957 this, PackageManager.MATCH_DEFAULT_ONLY | flags); 7958 if (info != null) { 7959 ai = info.activityInfo; 7960 } 7961 } 7962 7963 return ai; 7964 } 7965 7966 /** 7967 * Special function for use by the system to resolve service 7968 * intents to system apps. Throws an exception if there are 7969 * multiple potential matches to the Intent. Returns null if 7970 * there are no matches. 7971 * @hide 7972 */ resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)7973 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm, 7974 @PackageManager.ComponentInfoFlags int flags) { 7975 if (mComponent != null) { 7976 return mComponent; 7977 } 7978 7979 List<ResolveInfo> results = pm.queryIntentServices(this, flags); 7980 if (results == null) { 7981 return null; 7982 } 7983 ComponentName comp = null; 7984 for (int i=0; i<results.size(); i++) { 7985 ResolveInfo ri = results.get(i); 7986 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { 7987 continue; 7988 } 7989 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, 7990 ri.serviceInfo.name); 7991 if (comp != null) { 7992 throw new IllegalStateException("Multiple system services handle " + this 7993 + ": " + comp + ", " + foundComp); 7994 } 7995 comp = foundComp; 7996 } 7997 return comp; 7998 } 7999 8000 /** 8001 * Set the general action to be performed. 8002 * 8003 * @param action An action name, such as ACTION_VIEW. Application-specific 8004 * actions should be prefixed with the vendor's package name. 8005 * 8006 * @return Returns the same Intent object, for chaining multiple calls 8007 * into a single statement. 8008 * 8009 * @see #getAction 8010 */ setAction(@ullable String action)8011 public @NonNull Intent setAction(@Nullable String action) { 8012 mAction = action != null ? action.intern() : null; 8013 return this; 8014 } 8015 8016 /** 8017 * Set the data this intent is operating on. This method automatically 8018 * clears any type that was previously set by {@link #setType} or 8019 * {@link #setTypeAndNormalize}. 8020 * 8021 * <p><em>Note: scheme matching in the Android framework is 8022 * case-sensitive, unlike the formal RFC. As a result, 8023 * you should always write your Uri with a lower case scheme, 8024 * or use {@link Uri#normalizeScheme} or 8025 * {@link #setDataAndNormalize} 8026 * to ensure that the scheme is converted to lower case.</em> 8027 * 8028 * @param data The Uri of the data this intent is now targeting. 8029 * 8030 * @return Returns the same Intent object, for chaining multiple calls 8031 * into a single statement. 8032 * 8033 * @see #getData 8034 * @see #setDataAndNormalize 8035 * @see android.net.Uri#normalizeScheme() 8036 */ setData(@ullable Uri data)8037 public @NonNull Intent setData(@Nullable Uri data) { 8038 mData = data; 8039 mType = null; 8040 return this; 8041 } 8042 8043 /** 8044 * Normalize and set the data this intent is operating on. 8045 * 8046 * <p>This method automatically clears any type that was 8047 * previously set (for example, by {@link #setType}). 8048 * 8049 * <p>The data Uri is normalized using 8050 * {@link android.net.Uri#normalizeScheme} before it is set, 8051 * so really this is just a convenience method for 8052 * <pre> 8053 * setData(data.normalize()) 8054 * </pre> 8055 * 8056 * @param data The Uri of the data this intent is now targeting. 8057 * 8058 * @return Returns the same Intent object, for chaining multiple calls 8059 * into a single statement. 8060 * 8061 * @see #getData 8062 * @see #setType 8063 * @see android.net.Uri#normalizeScheme 8064 */ setDataAndNormalize(@onNull Uri data)8065 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) { 8066 return setData(data.normalizeScheme()); 8067 } 8068 8069 /** 8070 * Set an explicit MIME data type. 8071 * 8072 * <p>This is used to create intents that only specify a type and not data, 8073 * for example to indicate the type of data to return. 8074 * 8075 * <p>This method automatically clears any data that was 8076 * previously set (for example by {@link #setData}). 8077 * 8078 * <p><em>Note: MIME type matching in the Android framework is 8079 * case-sensitive, unlike formal RFC MIME types. As a result, 8080 * you should always write your MIME types with lower case letters, 8081 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} 8082 * to ensure that it is converted to lower case.</em> 8083 * 8084 * @param type The MIME type of the data being handled by this intent. 8085 * 8086 * @return Returns the same Intent object, for chaining multiple calls 8087 * into a single statement. 8088 * 8089 * @see #getType 8090 * @see #setTypeAndNormalize 8091 * @see #setDataAndType 8092 * @see #normalizeMimeType 8093 */ setType(@ullable String type)8094 public @NonNull Intent setType(@Nullable String type) { 8095 mData = null; 8096 mType = type; 8097 return this; 8098 } 8099 8100 /** 8101 * Normalize and set an explicit MIME data type. 8102 * 8103 * <p>This is used to create intents that only specify a type and not data, 8104 * for example to indicate the type of data to return. 8105 * 8106 * <p>This method automatically clears any data that was 8107 * previously set (for example by {@link #setData}). 8108 * 8109 * <p>The MIME type is normalized using 8110 * {@link #normalizeMimeType} before it is set, 8111 * so really this is just a convenience method for 8112 * <pre> 8113 * setType(Intent.normalizeMimeType(type)) 8114 * </pre> 8115 * 8116 * @param type The MIME type of the data being handled by this intent. 8117 * 8118 * @return Returns the same Intent object, for chaining multiple calls 8119 * into a single statement. 8120 * 8121 * @see #getType 8122 * @see #setData 8123 * @see #normalizeMimeType 8124 */ setTypeAndNormalize(@ullable String type)8125 public @NonNull Intent setTypeAndNormalize(@Nullable String type) { 8126 return setType(normalizeMimeType(type)); 8127 } 8128 8129 /** 8130 * (Usually optional) Set the data for the intent along with an explicit 8131 * MIME data type. This method should very rarely be used -- it allows you 8132 * to override the MIME type that would ordinarily be inferred from the 8133 * data with your own type given here. 8134 * 8135 * <p><em>Note: MIME type and Uri scheme matching in the 8136 * Android framework is case-sensitive, unlike the formal RFC definitions. 8137 * As a result, you should always write these elements with lower case letters, 8138 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or 8139 * {@link #setDataAndTypeAndNormalize} 8140 * to ensure that they are converted to lower case.</em> 8141 * 8142 * @param data The Uri of the data this intent is now targeting. 8143 * @param type The MIME type of the data being handled by this intent. 8144 * 8145 * @return Returns the same Intent object, for chaining multiple calls 8146 * into a single statement. 8147 * 8148 * @see #setType 8149 * @see #setData 8150 * @see #normalizeMimeType 8151 * @see android.net.Uri#normalizeScheme 8152 * @see #setDataAndTypeAndNormalize 8153 */ setDataAndType(@ullable Uri data, @Nullable String type)8154 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) { 8155 mData = data; 8156 mType = type; 8157 return this; 8158 } 8159 8160 /** 8161 * (Usually optional) Normalize and set both the data Uri and an explicit 8162 * MIME data type. This method should very rarely be used -- it allows you 8163 * to override the MIME type that would ordinarily be inferred from the 8164 * data with your own type given here. 8165 * 8166 * <p>The data Uri and the MIME type are normalize using 8167 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} 8168 * before they are set, so really this is just a convenience method for 8169 * <pre> 8170 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) 8171 * </pre> 8172 * 8173 * @param data The Uri of the data this intent is now targeting. 8174 * @param type The MIME type of the data being handled by this intent. 8175 * 8176 * @return Returns the same Intent object, for chaining multiple calls 8177 * into a single statement. 8178 * 8179 * @see #setType 8180 * @see #setData 8181 * @see #setDataAndType 8182 * @see #normalizeMimeType 8183 * @see android.net.Uri#normalizeScheme 8184 */ setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)8185 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) { 8186 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); 8187 } 8188 8189 /** 8190 * Add a new category to the intent. Categories provide additional detail 8191 * about the action the intent performs. When resolving an intent, only 8192 * activities that provide <em>all</em> of the requested categories will be 8193 * used. 8194 * 8195 * @param category The desired category. This can be either one of the 8196 * predefined Intent categories, or a custom category in your own 8197 * namespace. 8198 * 8199 * @return Returns the same Intent object, for chaining multiple calls 8200 * into a single statement. 8201 * 8202 * @see #hasCategory 8203 * @see #removeCategory 8204 */ addCategory(String category)8205 public @NonNull Intent addCategory(String category) { 8206 if (mCategories == null) { 8207 mCategories = new ArraySet<String>(); 8208 } 8209 mCategories.add(category.intern()); 8210 return this; 8211 } 8212 8213 /** 8214 * Remove a category from an intent. 8215 * 8216 * @param category The category to remove. 8217 * 8218 * @see #addCategory 8219 */ removeCategory(String category)8220 public void removeCategory(String category) { 8221 if (mCategories != null) { 8222 mCategories.remove(category); 8223 if (mCategories.size() == 0) { 8224 mCategories = null; 8225 } 8226 } 8227 } 8228 8229 /** 8230 * Set a selector for this Intent. This is a modification to the kinds of 8231 * things the Intent will match. If the selector is set, it will be used 8232 * when trying to find entities that can handle the Intent, instead of the 8233 * main contents of the Intent. This allows you build an Intent containing 8234 * a generic protocol while targeting it more specifically. 8235 * 8236 * <p>An example of where this may be used is with things like 8237 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an 8238 * Intent that will launch the Browser application. However, the correct 8239 * main entry point of an application is actually {@link #ACTION_MAIN} 8240 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} 8241 * used to specify the actual Activity to launch. If you launch the browser 8242 * with something different, undesired behavior may happen if the user has 8243 * previously or later launches it the normal way, since they do not match. 8244 * Instead, you can build an Intent with the MAIN action (but no ComponentName 8245 * yet specified) and set a selector with {@link #ACTION_MAIN} and 8246 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. 8247 * 8248 * <p>Setting a selector does not impact the behavior of 8249 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the 8250 * desired behavior of a selector -- it does not impact the base meaning 8251 * of the Intent, just what kinds of things will be matched against it 8252 * when determining who can handle it.</p> 8253 * 8254 * <p>You can not use both a selector and {@link #setPackage(String)} on 8255 * the same base Intent.</p> 8256 * 8257 * @param selector The desired selector Intent; set to null to not use 8258 * a special selector. 8259 */ setSelector(@ullable Intent selector)8260 public void setSelector(@Nullable Intent selector) { 8261 if (selector == this) { 8262 throw new IllegalArgumentException( 8263 "Intent being set as a selector of itself"); 8264 } 8265 if (selector != null && mPackage != null) { 8266 throw new IllegalArgumentException( 8267 "Can't set selector when package name is already set"); 8268 } 8269 mSelector = selector; 8270 } 8271 8272 /** 8273 * Set a {@link ClipData} associated with this Intent. This replaces any 8274 * previously set ClipData. 8275 * 8276 * <p>The ClipData in an intent is not used for Intent matching or other 8277 * such operations. Semantically it is like extras, used to transmit 8278 * additional data with the Intent. The main feature of using this over 8279 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} 8280 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI 8281 * items included in the clip data. This is useful, in particular, if 8282 * you want to transmit an Intent containing multiple <code>content:</code> 8283 * URIs for which the recipient may not have global permission to access the 8284 * content provider. 8285 * 8286 * <p>If the ClipData contains items that are themselves Intents, any 8287 * grant flags in those Intents will be ignored. Only the top-level flags 8288 * of the main Intent are respected, and will be applied to all Uri or 8289 * Intent items in the clip (or sub-items of the clip). 8290 * 8291 * <p>The MIME type, label, and icon in the ClipData object are not 8292 * directly used by Intent. Applications should generally rely on the 8293 * MIME type of the Intent itself, not what it may find in the ClipData. 8294 * A common practice is to construct a ClipData for use with an Intent 8295 * with a MIME type of "*/*". 8296 * 8297 * @param clip The new clip to set. May be null to clear the current clip. 8298 */ setClipData(@ullable ClipData clip)8299 public void setClipData(@Nullable ClipData clip) { 8300 mClipData = clip; 8301 } 8302 8303 /** 8304 * This is NOT a secure mechanism to identify the user who sent the intent. 8305 * When the intent is sent to a different user, it is used to fix uris by adding the userId 8306 * who sent the intent. 8307 * @hide 8308 */ prepareToLeaveUser(int userId)8309 public void prepareToLeaveUser(int userId) { 8310 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. 8311 // We want mContentUserHint to refer to the original user, so don't do anything. 8312 if (mContentUserHint == UserHandle.USER_CURRENT) { 8313 mContentUserHint = userId; 8314 } 8315 } 8316 8317 /** 8318 * Add extended data to the intent. The name must include a package 8319 * prefix, for example the app com.android.contacts would use names 8320 * like "com.android.contacts.ShowAll". 8321 * 8322 * @param name The name of the extra data, with package prefix. 8323 * @param value The boolean data value. 8324 * 8325 * @return Returns the same Intent object, for chaining multiple calls 8326 * into a single statement. 8327 * 8328 * @see #putExtras 8329 * @see #removeExtra 8330 * @see #getBooleanExtra(String, boolean) 8331 */ putExtra(String name, boolean value)8332 public @NonNull Intent putExtra(String name, boolean value) { 8333 if (mExtras == null) { 8334 mExtras = new Bundle(); 8335 } 8336 mExtras.putBoolean(name, value); 8337 return this; 8338 } 8339 8340 /** 8341 * Add extended data to the intent. The name must include a package 8342 * prefix, for example the app com.android.contacts would use names 8343 * like "com.android.contacts.ShowAll". 8344 * 8345 * @param name The name of the extra data, with package prefix. 8346 * @param value The byte data value. 8347 * 8348 * @return Returns the same Intent object, for chaining multiple calls 8349 * into a single statement. 8350 * 8351 * @see #putExtras 8352 * @see #removeExtra 8353 * @see #getByteExtra(String, byte) 8354 */ putExtra(String name, byte value)8355 public @NonNull Intent putExtra(String name, byte value) { 8356 if (mExtras == null) { 8357 mExtras = new Bundle(); 8358 } 8359 mExtras.putByte(name, value); 8360 return this; 8361 } 8362 8363 /** 8364 * Add extended data to the intent. The name must include a package 8365 * prefix, for example the app com.android.contacts would use names 8366 * like "com.android.contacts.ShowAll". 8367 * 8368 * @param name The name of the extra data, with package prefix. 8369 * @param value The char data value. 8370 * 8371 * @return Returns the same Intent object, for chaining multiple calls 8372 * into a single statement. 8373 * 8374 * @see #putExtras 8375 * @see #removeExtra 8376 * @see #getCharExtra(String, char) 8377 */ putExtra(String name, char value)8378 public @NonNull Intent putExtra(String name, char value) { 8379 if (mExtras == null) { 8380 mExtras = new Bundle(); 8381 } 8382 mExtras.putChar(name, value); 8383 return this; 8384 } 8385 8386 /** 8387 * Add extended data to the intent. The name must include a package 8388 * prefix, for example the app com.android.contacts would use names 8389 * like "com.android.contacts.ShowAll". 8390 * 8391 * @param name The name of the extra data, with package prefix. 8392 * @param value The short data value. 8393 * 8394 * @return Returns the same Intent object, for chaining multiple calls 8395 * into a single statement. 8396 * 8397 * @see #putExtras 8398 * @see #removeExtra 8399 * @see #getShortExtra(String, short) 8400 */ putExtra(String name, short value)8401 public @NonNull Intent putExtra(String name, short value) { 8402 if (mExtras == null) { 8403 mExtras = new Bundle(); 8404 } 8405 mExtras.putShort(name, value); 8406 return this; 8407 } 8408 8409 /** 8410 * Add extended data to the intent. The name must include a package 8411 * prefix, for example the app com.android.contacts would use names 8412 * like "com.android.contacts.ShowAll". 8413 * 8414 * @param name The name of the extra data, with package prefix. 8415 * @param value The integer data value. 8416 * 8417 * @return Returns the same Intent object, for chaining multiple calls 8418 * into a single statement. 8419 * 8420 * @see #putExtras 8421 * @see #removeExtra 8422 * @see #getIntExtra(String, int) 8423 */ putExtra(String name, int value)8424 public @NonNull Intent putExtra(String name, int value) { 8425 if (mExtras == null) { 8426 mExtras = new Bundle(); 8427 } 8428 mExtras.putInt(name, value); 8429 return this; 8430 } 8431 8432 /** 8433 * Add extended data to the intent. The name must include a package 8434 * prefix, for example the app com.android.contacts would use names 8435 * like "com.android.contacts.ShowAll". 8436 * 8437 * @param name The name of the extra data, with package prefix. 8438 * @param value The long data value. 8439 * 8440 * @return Returns the same Intent object, for chaining multiple calls 8441 * into a single statement. 8442 * 8443 * @see #putExtras 8444 * @see #removeExtra 8445 * @see #getLongExtra(String, long) 8446 */ putExtra(String name, long value)8447 public @NonNull Intent putExtra(String name, long value) { 8448 if (mExtras == null) { 8449 mExtras = new Bundle(); 8450 } 8451 mExtras.putLong(name, value); 8452 return this; 8453 } 8454 8455 /** 8456 * Add extended data to the intent. The name must include a package 8457 * prefix, for example the app com.android.contacts would use names 8458 * like "com.android.contacts.ShowAll". 8459 * 8460 * @param name The name of the extra data, with package prefix. 8461 * @param value The float data value. 8462 * 8463 * @return Returns the same Intent object, for chaining multiple calls 8464 * into a single statement. 8465 * 8466 * @see #putExtras 8467 * @see #removeExtra 8468 * @see #getFloatExtra(String, float) 8469 */ putExtra(String name, float value)8470 public @NonNull Intent putExtra(String name, float value) { 8471 if (mExtras == null) { 8472 mExtras = new Bundle(); 8473 } 8474 mExtras.putFloat(name, value); 8475 return this; 8476 } 8477 8478 /** 8479 * Add extended data to the intent. The name must include a package 8480 * prefix, for example the app com.android.contacts would use names 8481 * like "com.android.contacts.ShowAll". 8482 * 8483 * @param name The name of the extra data, with package prefix. 8484 * @param value The double data value. 8485 * 8486 * @return Returns the same Intent object, for chaining multiple calls 8487 * into a single statement. 8488 * 8489 * @see #putExtras 8490 * @see #removeExtra 8491 * @see #getDoubleExtra(String, double) 8492 */ putExtra(String name, double value)8493 public @NonNull Intent putExtra(String name, double value) { 8494 if (mExtras == null) { 8495 mExtras = new Bundle(); 8496 } 8497 mExtras.putDouble(name, value); 8498 return this; 8499 } 8500 8501 /** 8502 * Add extended data to the intent. The name must include a package 8503 * prefix, for example the app com.android.contacts would use names 8504 * like "com.android.contacts.ShowAll". 8505 * 8506 * @param name The name of the extra data, with package prefix. 8507 * @param value The String data value. 8508 * 8509 * @return Returns the same Intent object, for chaining multiple calls 8510 * into a single statement. 8511 * 8512 * @see #putExtras 8513 * @see #removeExtra 8514 * @see #getStringExtra(String) 8515 */ putExtra(String name, String value)8516 public @NonNull Intent putExtra(String name, String value) { 8517 if (mExtras == null) { 8518 mExtras = new Bundle(); 8519 } 8520 mExtras.putString(name, value); 8521 return this; 8522 } 8523 8524 /** 8525 * Add extended data to the intent. The name must include a package 8526 * prefix, for example the app com.android.contacts would use names 8527 * like "com.android.contacts.ShowAll". 8528 * 8529 * @param name The name of the extra data, with package prefix. 8530 * @param value The CharSequence data value. 8531 * 8532 * @return Returns the same Intent object, for chaining multiple calls 8533 * into a single statement. 8534 * 8535 * @see #putExtras 8536 * @see #removeExtra 8537 * @see #getCharSequenceExtra(String) 8538 */ putExtra(String name, CharSequence value)8539 public @NonNull Intent putExtra(String name, CharSequence value) { 8540 if (mExtras == null) { 8541 mExtras = new Bundle(); 8542 } 8543 mExtras.putCharSequence(name, value); 8544 return this; 8545 } 8546 8547 /** 8548 * Add extended data to the intent. The name must include a package 8549 * prefix, for example the app com.android.contacts would use names 8550 * like "com.android.contacts.ShowAll". 8551 * 8552 * @param name The name of the extra data, with package prefix. 8553 * @param value The Parcelable data value. 8554 * 8555 * @return Returns the same Intent object, for chaining multiple calls 8556 * into a single statement. 8557 * 8558 * @see #putExtras 8559 * @see #removeExtra 8560 * @see #getParcelableExtra(String) 8561 */ putExtra(String name, Parcelable value)8562 public @NonNull Intent putExtra(String name, Parcelable value) { 8563 if (mExtras == null) { 8564 mExtras = new Bundle(); 8565 } 8566 mExtras.putParcelable(name, value); 8567 return this; 8568 } 8569 8570 /** 8571 * Add extended data to the intent. The name must include a package 8572 * prefix, for example the app com.android.contacts would use names 8573 * like "com.android.contacts.ShowAll". 8574 * 8575 * @param name The name of the extra data, with package prefix. 8576 * @param value The Parcelable[] data value. 8577 * 8578 * @return Returns the same Intent object, for chaining multiple calls 8579 * into a single statement. 8580 * 8581 * @see #putExtras 8582 * @see #removeExtra 8583 * @see #getParcelableArrayExtra(String) 8584 */ putExtra(String name, Parcelable[] value)8585 public @NonNull Intent putExtra(String name, Parcelable[] value) { 8586 if (mExtras == null) { 8587 mExtras = new Bundle(); 8588 } 8589 mExtras.putParcelableArray(name, value); 8590 return this; 8591 } 8592 8593 /** 8594 * Add extended data to the intent. The name must include a package 8595 * prefix, for example the app com.android.contacts would use names 8596 * like "com.android.contacts.ShowAll". 8597 * 8598 * @param name The name of the extra data, with package prefix. 8599 * @param value The ArrayList<Parcelable> data value. 8600 * 8601 * @return Returns the same Intent object, for chaining multiple calls 8602 * into a single statement. 8603 * 8604 * @see #putExtras 8605 * @see #removeExtra 8606 * @see #getParcelableArrayListExtra(String) 8607 */ putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value)8608 public @NonNull Intent putParcelableArrayListExtra(String name, 8609 ArrayList<? extends Parcelable> value) { 8610 if (mExtras == null) { 8611 mExtras = new Bundle(); 8612 } 8613 mExtras.putParcelableArrayList(name, value); 8614 return this; 8615 } 8616 8617 /** 8618 * Add extended data to the intent. The name must include a package 8619 * prefix, for example the app com.android.contacts would use names 8620 * like "com.android.contacts.ShowAll". 8621 * 8622 * @param name The name of the extra data, with package prefix. 8623 * @param value The ArrayList<Integer> data value. 8624 * 8625 * @return Returns the same Intent object, for chaining multiple calls 8626 * into a single statement. 8627 * 8628 * @see #putExtras 8629 * @see #removeExtra 8630 * @see #getIntegerArrayListExtra(String) 8631 */ putIntegerArrayListExtra(String name, ArrayList<Integer> value)8632 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) { 8633 if (mExtras == null) { 8634 mExtras = new Bundle(); 8635 } 8636 mExtras.putIntegerArrayList(name, value); 8637 return this; 8638 } 8639 8640 /** 8641 * Add extended data to the intent. The name must include a package 8642 * prefix, for example the app com.android.contacts would use names 8643 * like "com.android.contacts.ShowAll". 8644 * 8645 * @param name The name of the extra data, with package prefix. 8646 * @param value The ArrayList<String> data value. 8647 * 8648 * @return Returns the same Intent object, for chaining multiple calls 8649 * into a single statement. 8650 * 8651 * @see #putExtras 8652 * @see #removeExtra 8653 * @see #getStringArrayListExtra(String) 8654 */ putStringArrayListExtra(String name, ArrayList<String> value)8655 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) { 8656 if (mExtras == null) { 8657 mExtras = new Bundle(); 8658 } 8659 mExtras.putStringArrayList(name, value); 8660 return this; 8661 } 8662 8663 /** 8664 * Add extended data to the intent. The name must include a package 8665 * prefix, for example the app com.android.contacts would use names 8666 * like "com.android.contacts.ShowAll". 8667 * 8668 * @param name The name of the extra data, with package prefix. 8669 * @param value The ArrayList<CharSequence> data value. 8670 * 8671 * @return Returns the same Intent object, for chaining multiple calls 8672 * into a single statement. 8673 * 8674 * @see #putExtras 8675 * @see #removeExtra 8676 * @see #getCharSequenceArrayListExtra(String) 8677 */ putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value)8678 public @NonNull Intent putCharSequenceArrayListExtra(String name, 8679 ArrayList<CharSequence> value) { 8680 if (mExtras == null) { 8681 mExtras = new Bundle(); 8682 } 8683 mExtras.putCharSequenceArrayList(name, value); 8684 return this; 8685 } 8686 8687 /** 8688 * Add extended data to the intent. The name must include a package 8689 * prefix, for example the app com.android.contacts would use names 8690 * like "com.android.contacts.ShowAll". 8691 * 8692 * @param name The name of the extra data, with package prefix. 8693 * @param value The Serializable data value. 8694 * 8695 * @return Returns the same Intent object, for chaining multiple calls 8696 * into a single statement. 8697 * 8698 * @see #putExtras 8699 * @see #removeExtra 8700 * @see #getSerializableExtra(String) 8701 */ putExtra(String name, Serializable value)8702 public @NonNull Intent putExtra(String name, Serializable value) { 8703 if (mExtras == null) { 8704 mExtras = new Bundle(); 8705 } 8706 mExtras.putSerializable(name, value); 8707 return this; 8708 } 8709 8710 /** 8711 * Add extended data to the intent. The name must include a package 8712 * prefix, for example the app com.android.contacts would use names 8713 * like "com.android.contacts.ShowAll". 8714 * 8715 * @param name The name of the extra data, with package prefix. 8716 * @param value The boolean array data value. 8717 * 8718 * @return Returns the same Intent object, for chaining multiple calls 8719 * into a single statement. 8720 * 8721 * @see #putExtras 8722 * @see #removeExtra 8723 * @see #getBooleanArrayExtra(String) 8724 */ putExtra(String name, boolean[] value)8725 public @NonNull Intent putExtra(String name, boolean[] value) { 8726 if (mExtras == null) { 8727 mExtras = new Bundle(); 8728 } 8729 mExtras.putBooleanArray(name, value); 8730 return this; 8731 } 8732 8733 /** 8734 * Add extended data to the intent. The name must include a package 8735 * prefix, for example the app com.android.contacts would use names 8736 * like "com.android.contacts.ShowAll". 8737 * 8738 * @param name The name of the extra data, with package prefix. 8739 * @param value The byte array data value. 8740 * 8741 * @return Returns the same Intent object, for chaining multiple calls 8742 * into a single statement. 8743 * 8744 * @see #putExtras 8745 * @see #removeExtra 8746 * @see #getByteArrayExtra(String) 8747 */ putExtra(String name, byte[] value)8748 public @NonNull Intent putExtra(String name, byte[] value) { 8749 if (mExtras == null) { 8750 mExtras = new Bundle(); 8751 } 8752 mExtras.putByteArray(name, value); 8753 return this; 8754 } 8755 8756 /** 8757 * Add extended data to the intent. The name must include a package 8758 * prefix, for example the app com.android.contacts would use names 8759 * like "com.android.contacts.ShowAll". 8760 * 8761 * @param name The name of the extra data, with package prefix. 8762 * @param value The short array data value. 8763 * 8764 * @return Returns the same Intent object, for chaining multiple calls 8765 * into a single statement. 8766 * 8767 * @see #putExtras 8768 * @see #removeExtra 8769 * @see #getShortArrayExtra(String) 8770 */ putExtra(String name, short[] value)8771 public @NonNull Intent putExtra(String name, short[] value) { 8772 if (mExtras == null) { 8773 mExtras = new Bundle(); 8774 } 8775 mExtras.putShortArray(name, value); 8776 return this; 8777 } 8778 8779 /** 8780 * Add extended data to the intent. The name must include a package 8781 * prefix, for example the app com.android.contacts would use names 8782 * like "com.android.contacts.ShowAll". 8783 * 8784 * @param name The name of the extra data, with package prefix. 8785 * @param value The char array data value. 8786 * 8787 * @return Returns the same Intent object, for chaining multiple calls 8788 * into a single statement. 8789 * 8790 * @see #putExtras 8791 * @see #removeExtra 8792 * @see #getCharArrayExtra(String) 8793 */ putExtra(String name, char[] value)8794 public @NonNull Intent putExtra(String name, char[] value) { 8795 if (mExtras == null) { 8796 mExtras = new Bundle(); 8797 } 8798 mExtras.putCharArray(name, value); 8799 return this; 8800 } 8801 8802 /** 8803 * Add extended data to the intent. The name must include a package 8804 * prefix, for example the app com.android.contacts would use names 8805 * like "com.android.contacts.ShowAll". 8806 * 8807 * @param name The name of the extra data, with package prefix. 8808 * @param value The int array data value. 8809 * 8810 * @return Returns the same Intent object, for chaining multiple calls 8811 * into a single statement. 8812 * 8813 * @see #putExtras 8814 * @see #removeExtra 8815 * @see #getIntArrayExtra(String) 8816 */ putExtra(String name, int[] value)8817 public @NonNull Intent putExtra(String name, int[] value) { 8818 if (mExtras == null) { 8819 mExtras = new Bundle(); 8820 } 8821 mExtras.putIntArray(name, value); 8822 return this; 8823 } 8824 8825 /** 8826 * Add extended data to the intent. The name must include a package 8827 * prefix, for example the app com.android.contacts would use names 8828 * like "com.android.contacts.ShowAll". 8829 * 8830 * @param name The name of the extra data, with package prefix. 8831 * @param value The byte array data value. 8832 * 8833 * @return Returns the same Intent object, for chaining multiple calls 8834 * into a single statement. 8835 * 8836 * @see #putExtras 8837 * @see #removeExtra 8838 * @see #getLongArrayExtra(String) 8839 */ putExtra(String name, long[] value)8840 public @NonNull Intent putExtra(String name, long[] value) { 8841 if (mExtras == null) { 8842 mExtras = new Bundle(); 8843 } 8844 mExtras.putLongArray(name, value); 8845 return this; 8846 } 8847 8848 /** 8849 * Add extended data to the intent. The name must include a package 8850 * prefix, for example the app com.android.contacts would use names 8851 * like "com.android.contacts.ShowAll". 8852 * 8853 * @param name The name of the extra data, with package prefix. 8854 * @param value The float array data value. 8855 * 8856 * @return Returns the same Intent object, for chaining multiple calls 8857 * into a single statement. 8858 * 8859 * @see #putExtras 8860 * @see #removeExtra 8861 * @see #getFloatArrayExtra(String) 8862 */ putExtra(String name, float[] value)8863 public @NonNull Intent putExtra(String name, float[] value) { 8864 if (mExtras == null) { 8865 mExtras = new Bundle(); 8866 } 8867 mExtras.putFloatArray(name, value); 8868 return this; 8869 } 8870 8871 /** 8872 * Add extended data to the intent. The name must include a package 8873 * prefix, for example the app com.android.contacts would use names 8874 * like "com.android.contacts.ShowAll". 8875 * 8876 * @param name The name of the extra data, with package prefix. 8877 * @param value The double array data value. 8878 * 8879 * @return Returns the same Intent object, for chaining multiple calls 8880 * into a single statement. 8881 * 8882 * @see #putExtras 8883 * @see #removeExtra 8884 * @see #getDoubleArrayExtra(String) 8885 */ putExtra(String name, double[] value)8886 public @NonNull Intent putExtra(String name, double[] value) { 8887 if (mExtras == null) { 8888 mExtras = new Bundle(); 8889 } 8890 mExtras.putDoubleArray(name, value); 8891 return this; 8892 } 8893 8894 /** 8895 * Add extended data to the intent. The name must include a package 8896 * prefix, for example the app com.android.contacts would use names 8897 * like "com.android.contacts.ShowAll". 8898 * 8899 * @param name The name of the extra data, with package prefix. 8900 * @param value The String array data value. 8901 * 8902 * @return Returns the same Intent object, for chaining multiple calls 8903 * into a single statement. 8904 * 8905 * @see #putExtras 8906 * @see #removeExtra 8907 * @see #getStringArrayExtra(String) 8908 */ putExtra(String name, String[] value)8909 public @NonNull Intent putExtra(String name, String[] value) { 8910 if (mExtras == null) { 8911 mExtras = new Bundle(); 8912 } 8913 mExtras.putStringArray(name, value); 8914 return this; 8915 } 8916 8917 /** 8918 * Add extended data to the intent. The name must include a package 8919 * prefix, for example the app com.android.contacts would use names 8920 * like "com.android.contacts.ShowAll". 8921 * 8922 * @param name The name of the extra data, with package prefix. 8923 * @param value The CharSequence array data value. 8924 * 8925 * @return Returns the same Intent object, for chaining multiple calls 8926 * into a single statement. 8927 * 8928 * @see #putExtras 8929 * @see #removeExtra 8930 * @see #getCharSequenceArrayExtra(String) 8931 */ putExtra(String name, CharSequence[] value)8932 public @NonNull Intent putExtra(String name, CharSequence[] value) { 8933 if (mExtras == null) { 8934 mExtras = new Bundle(); 8935 } 8936 mExtras.putCharSequenceArray(name, value); 8937 return this; 8938 } 8939 8940 /** 8941 * Add extended data to the intent. The name must include a package 8942 * prefix, for example the app com.android.contacts would use names 8943 * like "com.android.contacts.ShowAll". 8944 * 8945 * @param name The name of the extra data, with package prefix. 8946 * @param value The Bundle data value. 8947 * 8948 * @return Returns the same Intent object, for chaining multiple calls 8949 * into a single statement. 8950 * 8951 * @see #putExtras 8952 * @see #removeExtra 8953 * @see #getBundleExtra(String) 8954 */ putExtra(String name, Bundle value)8955 public @NonNull Intent putExtra(String name, Bundle value) { 8956 if (mExtras == null) { 8957 mExtras = new Bundle(); 8958 } 8959 mExtras.putBundle(name, value); 8960 return this; 8961 } 8962 8963 /** 8964 * Add extended data to the intent. The name must include a package 8965 * prefix, for example the app com.android.contacts would use names 8966 * like "com.android.contacts.ShowAll". 8967 * 8968 * @param name The name of the extra data, with package prefix. 8969 * @param value The IBinder data value. 8970 * 8971 * @return Returns the same Intent object, for chaining multiple calls 8972 * into a single statement. 8973 * 8974 * @see #putExtras 8975 * @see #removeExtra 8976 * @see #getIBinderExtra(String) 8977 * 8978 * @deprecated 8979 * @hide 8980 */ 8981 @Deprecated putExtra(String name, IBinder value)8982 public @NonNull Intent putExtra(String name, IBinder value) { 8983 if (mExtras == null) { 8984 mExtras = new Bundle(); 8985 } 8986 mExtras.putIBinder(name, value); 8987 return this; 8988 } 8989 8990 /** 8991 * Copy all extras in 'src' in to this intent. 8992 * 8993 * @param src Contains the extras to copy. 8994 * 8995 * @see #putExtra 8996 */ putExtras(@onNull Intent src)8997 public @NonNull Intent putExtras(@NonNull Intent src) { 8998 if (src.mExtras != null) { 8999 if (mExtras == null) { 9000 mExtras = new Bundle(src.mExtras); 9001 } else { 9002 mExtras.putAll(src.mExtras); 9003 } 9004 } 9005 return this; 9006 } 9007 9008 /** 9009 * Add a set of extended data to the intent. The keys must include a package 9010 * prefix, for example the app com.android.contacts would use names 9011 * like "com.android.contacts.ShowAll". 9012 * 9013 * @param extras The Bundle of extras to add to this intent. 9014 * 9015 * @see #putExtra 9016 * @see #removeExtra 9017 */ putExtras(@onNull Bundle extras)9018 public @NonNull Intent putExtras(@NonNull Bundle extras) { 9019 if (mExtras == null) { 9020 mExtras = new Bundle(); 9021 } 9022 mExtras.putAll(extras); 9023 return this; 9024 } 9025 9026 /** 9027 * Completely replace the extras in the Intent with the extras in the 9028 * given Intent. 9029 * 9030 * @param src The exact extras contained in this Intent are copied 9031 * into the target intent, replacing any that were previously there. 9032 */ replaceExtras(@onNull Intent src)9033 public @NonNull Intent replaceExtras(@NonNull Intent src) { 9034 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; 9035 return this; 9036 } 9037 9038 /** 9039 * Completely replace the extras in the Intent with the given Bundle of 9040 * extras. 9041 * 9042 * @param extras The new set of extras in the Intent, or null to erase 9043 * all extras. 9044 */ replaceExtras(@onNull Bundle extras)9045 public @NonNull Intent replaceExtras(@NonNull Bundle extras) { 9046 mExtras = extras != null ? new Bundle(extras) : null; 9047 return this; 9048 } 9049 9050 /** 9051 * Remove extended data from the intent. 9052 * 9053 * @see #putExtra 9054 */ removeExtra(String name)9055 public void removeExtra(String name) { 9056 if (mExtras != null) { 9057 mExtras.remove(name); 9058 if (mExtras.size() == 0) { 9059 mExtras = null; 9060 } 9061 } 9062 } 9063 9064 /** 9065 * Set special flags controlling how this intent is handled. Most values 9066 * here depend on the type of component being executed by the Intent, 9067 * specifically the FLAG_ACTIVITY_* flags are all for use with 9068 * {@link Context#startActivity Context.startActivity()} and the 9069 * FLAG_RECEIVER_* flags are all for use with 9070 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. 9071 * 9072 * <p>See the 9073 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 9074 * Stack</a> documentation for important information on how some of these options impact 9075 * the behavior of your application. 9076 * 9077 * @param flags The desired flags. 9078 * @return Returns the same Intent object, for chaining multiple calls 9079 * into a single statement. 9080 * @see #getFlags 9081 * @see #addFlags 9082 * @see #removeFlags 9083 */ setFlags(@lags int flags)9084 public @NonNull Intent setFlags(@Flags int flags) { 9085 mFlags = flags; 9086 return this; 9087 } 9088 9089 /** 9090 * Add additional flags to the intent (or with existing flags value). 9091 * 9092 * @param flags The new flags to set. 9093 * @return Returns the same Intent object, for chaining multiple calls into 9094 * a single statement. 9095 * @see #setFlags 9096 * @see #getFlags 9097 * @see #removeFlags 9098 */ addFlags(@lags int flags)9099 public @NonNull Intent addFlags(@Flags int flags) { 9100 mFlags |= flags; 9101 return this; 9102 } 9103 9104 /** 9105 * Remove these flags from the intent. 9106 * 9107 * @param flags The flags to remove. 9108 * @see #setFlags 9109 * @see #getFlags 9110 * @see #addFlags 9111 */ removeFlags(@lags int flags)9112 public void removeFlags(@Flags int flags) { 9113 mFlags &= ~flags; 9114 } 9115 9116 /** 9117 * (Usually optional) Set an explicit application package name that limits 9118 * the components this Intent will resolve to. If left to the default 9119 * value of null, all components in all applications will considered. 9120 * If non-null, the Intent can only match the components in the given 9121 * application package. 9122 * 9123 * @param packageName The name of the application package to handle the 9124 * intent, or null to allow any application package. 9125 * 9126 * @return Returns the same Intent object, for chaining multiple calls 9127 * into a single statement. 9128 * 9129 * @see #getPackage 9130 * @see #resolveActivity 9131 */ setPackage(@ullable String packageName)9132 public @NonNull Intent setPackage(@Nullable String packageName) { 9133 if (packageName != null && mSelector != null) { 9134 throw new IllegalArgumentException( 9135 "Can't set package name when selector is already set"); 9136 } 9137 mPackage = packageName; 9138 return this; 9139 } 9140 9141 /** 9142 * (Usually optional) Explicitly set the component to handle the intent. 9143 * If left with the default value of null, the system will determine the 9144 * appropriate class to use based on the other fields (action, data, 9145 * type, categories) in the Intent. If this class is defined, the 9146 * specified class will always be used regardless of the other fields. You 9147 * should only set this value when you know you absolutely want a specific 9148 * class to be used; otherwise it is better to let the system find the 9149 * appropriate class so that you will respect the installed applications 9150 * and user preferences. 9151 * 9152 * @param component The name of the application component to handle the 9153 * intent, or null to let the system find one for you. 9154 * 9155 * @return Returns the same Intent object, for chaining multiple calls 9156 * into a single statement. 9157 * 9158 * @see #setClass 9159 * @see #setClassName(Context, String) 9160 * @see #setClassName(String, String) 9161 * @see #getComponent 9162 * @see #resolveActivity 9163 */ setComponent(@ullable ComponentName component)9164 public @NonNull Intent setComponent(@Nullable ComponentName component) { 9165 mComponent = component; 9166 return this; 9167 } 9168 9169 /** 9170 * Convenience for calling {@link #setComponent} with an 9171 * explicit class name. 9172 * 9173 * @param packageContext A Context of the application package implementing 9174 * this class. 9175 * @param className The name of a class inside of the application package 9176 * that will be used as the component for this Intent. 9177 * 9178 * @return Returns the same Intent object, for chaining multiple calls 9179 * into a single statement. 9180 * 9181 * @see #setComponent 9182 * @see #setClass 9183 */ setClassName(@onNull Context packageContext, @NonNull String className)9184 public @NonNull Intent setClassName(@NonNull Context packageContext, 9185 @NonNull String className) { 9186 mComponent = new ComponentName(packageContext, className); 9187 return this; 9188 } 9189 9190 /** 9191 * Convenience for calling {@link #setComponent} with an 9192 * explicit application package name and class name. 9193 * 9194 * @param packageName The name of the package implementing the desired 9195 * component. 9196 * @param className The name of a class inside of the application package 9197 * that will be used as the component for this Intent. 9198 * 9199 * @return Returns the same Intent object, for chaining multiple calls 9200 * into a single statement. 9201 * 9202 * @see #setComponent 9203 * @see #setClass 9204 */ setClassName(@onNull String packageName, @NonNull String className)9205 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) { 9206 mComponent = new ComponentName(packageName, className); 9207 return this; 9208 } 9209 9210 /** 9211 * Convenience for calling {@link #setComponent(ComponentName)} with the 9212 * name returned by a {@link Class} object. 9213 * 9214 * @param packageContext A Context of the application package implementing 9215 * this class. 9216 * @param cls The class name to set, equivalent to 9217 * <code>setClassName(context, cls.getName())</code>. 9218 * 9219 * @return Returns the same Intent object, for chaining multiple calls 9220 * into a single statement. 9221 * 9222 * @see #setComponent 9223 */ setClass(@onNull Context packageContext, @NonNull Class<?> cls)9224 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) { 9225 mComponent = new ComponentName(packageContext, cls); 9226 return this; 9227 } 9228 9229 /** 9230 * Set the bounds of the sender of this intent, in screen coordinates. This can be 9231 * used as a hint to the receiver for animations and the like. Null means that there 9232 * is no source bounds. 9233 */ setSourceBounds(@ullable Rect r)9234 public void setSourceBounds(@Nullable Rect r) { 9235 if (r != null) { 9236 mSourceBounds = new Rect(r); 9237 } else { 9238 mSourceBounds = null; 9239 } 9240 } 9241 9242 /** @hide */ 9243 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = { 9244 FILL_IN_ACTION, 9245 FILL_IN_DATA, 9246 FILL_IN_CATEGORIES, 9247 FILL_IN_COMPONENT, 9248 FILL_IN_PACKAGE, 9249 FILL_IN_SOURCE_BOUNDS, 9250 FILL_IN_SELECTOR, 9251 FILL_IN_CLIP_DATA 9252 }) 9253 @Retention(RetentionPolicy.SOURCE) 9254 public @interface FillInFlags {} 9255 9256 /** 9257 * Use with {@link #fillIn} to allow the current action value to be 9258 * overwritten, even if it is already set. 9259 */ 9260 public static final int FILL_IN_ACTION = 1<<0; 9261 9262 /** 9263 * Use with {@link #fillIn} to allow the current data or type value 9264 * overwritten, even if it is already set. 9265 */ 9266 public static final int FILL_IN_DATA = 1<<1; 9267 9268 /** 9269 * Use with {@link #fillIn} to allow the current categories to be 9270 * overwritten, even if they are already set. 9271 */ 9272 public static final int FILL_IN_CATEGORIES = 1<<2; 9273 9274 /** 9275 * Use with {@link #fillIn} to allow the current component value to be 9276 * overwritten, even if it is already set. 9277 */ 9278 public static final int FILL_IN_COMPONENT = 1<<3; 9279 9280 /** 9281 * Use with {@link #fillIn} to allow the current package value to be 9282 * overwritten, even if it is already set. 9283 */ 9284 public static final int FILL_IN_PACKAGE = 1<<4; 9285 9286 /** 9287 * Use with {@link #fillIn} to allow the current bounds rectangle to be 9288 * overwritten, even if it is already set. 9289 */ 9290 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; 9291 9292 /** 9293 * Use with {@link #fillIn} to allow the current selector to be 9294 * overwritten, even if it is already set. 9295 */ 9296 public static final int FILL_IN_SELECTOR = 1<<6; 9297 9298 /** 9299 * Use with {@link #fillIn} to allow the current ClipData to be 9300 * overwritten, even if it is already set. 9301 */ 9302 public static final int FILL_IN_CLIP_DATA = 1<<7; 9303 9304 /** 9305 * Copy the contents of <var>other</var> in to this object, but only 9306 * where fields are not defined by this object. For purposes of a field 9307 * being defined, the following pieces of data in the Intent are 9308 * considered to be separate fields: 9309 * 9310 * <ul> 9311 * <li> action, as set by {@link #setAction}. 9312 * <li> data Uri and MIME type, as set by {@link #setData(Uri)}, 9313 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. 9314 * <li> categories, as set by {@link #addCategory}. 9315 * <li> package, as set by {@link #setPackage}. 9316 * <li> component, as set by {@link #setComponent(ComponentName)} or 9317 * related methods. 9318 * <li> source bounds, as set by {@link #setSourceBounds}. 9319 * <li> selector, as set by {@link #setSelector(Intent)}. 9320 * <li> clip data, as set by {@link #setClipData(ClipData)}. 9321 * <li> each top-level name in the associated extras. 9322 * </ul> 9323 * 9324 * <p>In addition, you can use the {@link #FILL_IN_ACTION}, 9325 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 9326 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 9327 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override 9328 * the restriction where the corresponding field will not be replaced if 9329 * it is already set. 9330 * 9331 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} 9332 * is explicitly specified. The selector will only be copied if 9333 * {@link #FILL_IN_SELECTOR} is explicitly specified. 9334 * 9335 * <p>For example, consider Intent A with {data="foo", categories="bar"} 9336 * and Intent B with {action="gotit", data-type="some/thing", 9337 * categories="one","two"}. 9338 * 9339 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now 9340 * containing: {action="gotit", data-type="some/thing", 9341 * categories="bar"}. 9342 * 9343 * @param other Another Intent whose values are to be used to fill in 9344 * the current one. 9345 * @param flags Options to control which fields can be filled in. 9346 * 9347 * @return Returns a bit mask of {@link #FILL_IN_ACTION}, 9348 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 9349 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 9350 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were 9351 * changed. 9352 */ 9353 @FillInFlags fillIn(@onNull Intent other, @FillInFlags int flags)9354 public int fillIn(@NonNull Intent other, @FillInFlags int flags) { 9355 int changes = 0; 9356 boolean mayHaveCopiedUris = false; 9357 if (other.mAction != null 9358 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { 9359 mAction = other.mAction; 9360 changes |= FILL_IN_ACTION; 9361 } 9362 if ((other.mData != null || other.mType != null) 9363 && ((mData == null && mType == null) 9364 || (flags&FILL_IN_DATA) != 0)) { 9365 mData = other.mData; 9366 mType = other.mType; 9367 changes |= FILL_IN_DATA; 9368 mayHaveCopiedUris = true; 9369 } 9370 if (other.mCategories != null 9371 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { 9372 if (other.mCategories != null) { 9373 mCategories = new ArraySet<String>(other.mCategories); 9374 } 9375 changes |= FILL_IN_CATEGORIES; 9376 } 9377 if (other.mPackage != null 9378 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { 9379 // Only do this if mSelector is not set. 9380 if (mSelector == null) { 9381 mPackage = other.mPackage; 9382 changes |= FILL_IN_PACKAGE; 9383 } 9384 } 9385 // Selector is special: it can only be set if explicitly allowed, 9386 // for the same reason as the component name. 9387 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { 9388 if (mPackage == null) { 9389 mSelector = new Intent(other.mSelector); 9390 mPackage = null; 9391 changes |= FILL_IN_SELECTOR; 9392 } 9393 } 9394 if (other.mClipData != null 9395 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { 9396 mClipData = other.mClipData; 9397 changes |= FILL_IN_CLIP_DATA; 9398 mayHaveCopiedUris = true; 9399 } 9400 // Component is special: it can -only- be set if explicitly allowed, 9401 // since otherwise the sender could force the intent somewhere the 9402 // originator didn't intend. 9403 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { 9404 mComponent = other.mComponent; 9405 changes |= FILL_IN_COMPONENT; 9406 } 9407 mFlags |= other.mFlags; 9408 if (other.mSourceBounds != null 9409 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { 9410 mSourceBounds = new Rect(other.mSourceBounds); 9411 changes |= FILL_IN_SOURCE_BOUNDS; 9412 } 9413 if (mExtras == null) { 9414 if (other.mExtras != null) { 9415 mExtras = new Bundle(other.mExtras); 9416 mayHaveCopiedUris = true; 9417 } 9418 } else if (other.mExtras != null) { 9419 try { 9420 Bundle newb = new Bundle(other.mExtras); 9421 newb.putAll(mExtras); 9422 mExtras = newb; 9423 mayHaveCopiedUris = true; 9424 } catch (RuntimeException e) { 9425 // Modifying the extras can cause us to unparcel the contents 9426 // of the bundle, and if we do this in the system process that 9427 // may fail. We really should handle this (i.e., the Bundle 9428 // impl shouldn't be on top of a plain map), but for now just 9429 // ignore it and keep the original contents. :( 9430 Log.w("Intent", "Failure filling in extras", e); 9431 } 9432 } 9433 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT 9434 && other.mContentUserHint != UserHandle.USER_CURRENT) { 9435 mContentUserHint = other.mContentUserHint; 9436 } 9437 return changes; 9438 } 9439 9440 /** 9441 * Wrapper class holding an Intent and implementing comparisons on it for 9442 * the purpose of filtering. The class implements its 9443 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as 9444 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and 9445 * {@link android.content.Intent#filterHashCode()} filterHashCode()} 9446 * on the wrapped Intent. 9447 */ 9448 public static final class FilterComparison { 9449 private final Intent mIntent; 9450 private final int mHashCode; 9451 FilterComparison(Intent intent)9452 public FilterComparison(Intent intent) { 9453 mIntent = intent; 9454 mHashCode = intent.filterHashCode(); 9455 } 9456 9457 /** 9458 * Return the Intent that this FilterComparison represents. 9459 * @return Returns the Intent held by the FilterComparison. Do 9460 * not modify! 9461 */ getIntent()9462 public Intent getIntent() { 9463 return mIntent; 9464 } 9465 9466 @Override equals(Object obj)9467 public boolean equals(Object obj) { 9468 if (obj instanceof FilterComparison) { 9469 Intent other = ((FilterComparison)obj).mIntent; 9470 return mIntent.filterEquals(other); 9471 } 9472 return false; 9473 } 9474 9475 @Override hashCode()9476 public int hashCode() { 9477 return mHashCode; 9478 } 9479 } 9480 9481 /** 9482 * Determine if two intents are the same for the purposes of intent 9483 * resolution (filtering). That is, if their action, data, type, 9484 * class, and categories are the same. This does <em>not</em> compare 9485 * any extra data included in the intents. 9486 * 9487 * @param other The other Intent to compare against. 9488 * 9489 * @return Returns true if action, data, type, class, and categories 9490 * are the same. 9491 */ filterEquals(Intent other)9492 public boolean filterEquals(Intent other) { 9493 if (other == null) { 9494 return false; 9495 } 9496 if (!Objects.equals(this.mAction, other.mAction)) return false; 9497 if (!Objects.equals(this.mData, other.mData)) return false; 9498 if (!Objects.equals(this.mType, other.mType)) return false; 9499 if (!Objects.equals(this.mPackage, other.mPackage)) return false; 9500 if (!Objects.equals(this.mComponent, other.mComponent)) return false; 9501 if (!Objects.equals(this.mCategories, other.mCategories)) return false; 9502 9503 return true; 9504 } 9505 9506 /** 9507 * Generate hash code that matches semantics of filterEquals(). 9508 * 9509 * @return Returns the hash value of the action, data, type, class, and 9510 * categories. 9511 * 9512 * @see #filterEquals 9513 */ filterHashCode()9514 public int filterHashCode() { 9515 int code = 0; 9516 if (mAction != null) { 9517 code += mAction.hashCode(); 9518 } 9519 if (mData != null) { 9520 code += mData.hashCode(); 9521 } 9522 if (mType != null) { 9523 code += mType.hashCode(); 9524 } 9525 if (mPackage != null) { 9526 code += mPackage.hashCode(); 9527 } 9528 if (mComponent != null) { 9529 code += mComponent.hashCode(); 9530 } 9531 if (mCategories != null) { 9532 code += mCategories.hashCode(); 9533 } 9534 return code; 9535 } 9536 9537 @Override toString()9538 public String toString() { 9539 StringBuilder b = new StringBuilder(128); 9540 9541 b.append("Intent { "); 9542 toShortString(b, true, true, true, false); 9543 b.append(" }"); 9544 9545 return b.toString(); 9546 } 9547 9548 /** @hide */ toInsecureString()9549 public String toInsecureString() { 9550 StringBuilder b = new StringBuilder(128); 9551 9552 b.append("Intent { "); 9553 toShortString(b, false, true, true, false); 9554 b.append(" }"); 9555 9556 return b.toString(); 9557 } 9558 9559 /** @hide */ toInsecureStringWithClip()9560 public String toInsecureStringWithClip() { 9561 StringBuilder b = new StringBuilder(128); 9562 9563 b.append("Intent { "); 9564 toShortString(b, false, true, true, true); 9565 b.append(" }"); 9566 9567 return b.toString(); 9568 } 9569 9570 /** @hide */ toShortString(boolean secure, boolean comp, boolean extras, boolean clip)9571 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { 9572 StringBuilder b = new StringBuilder(128); 9573 toShortString(b, secure, comp, extras, clip); 9574 return b.toString(); 9575 } 9576 9577 /** @hide */ toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)9578 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, 9579 boolean clip) { 9580 boolean first = true; 9581 if (mAction != null) { 9582 b.append("act=").append(mAction); 9583 first = false; 9584 } 9585 if (mCategories != null) { 9586 if (!first) { 9587 b.append(' '); 9588 } 9589 first = false; 9590 b.append("cat=["); 9591 for (int i=0; i<mCategories.size(); i++) { 9592 if (i > 0) b.append(','); 9593 b.append(mCategories.valueAt(i)); 9594 } 9595 b.append("]"); 9596 } 9597 if (mData != null) { 9598 if (!first) { 9599 b.append(' '); 9600 } 9601 first = false; 9602 b.append("dat="); 9603 if (secure) { 9604 b.append(mData.toSafeString()); 9605 } else { 9606 b.append(mData); 9607 } 9608 } 9609 if (mType != null) { 9610 if (!first) { 9611 b.append(' '); 9612 } 9613 first = false; 9614 b.append("typ=").append(mType); 9615 } 9616 if (mFlags != 0) { 9617 if (!first) { 9618 b.append(' '); 9619 } 9620 first = false; 9621 b.append("flg=0x").append(Integer.toHexString(mFlags)); 9622 } 9623 if (mPackage != null) { 9624 if (!first) { 9625 b.append(' '); 9626 } 9627 first = false; 9628 b.append("pkg=").append(mPackage); 9629 } 9630 if (comp && mComponent != null) { 9631 if (!first) { 9632 b.append(' '); 9633 } 9634 first = false; 9635 b.append("cmp=").append(mComponent.flattenToShortString()); 9636 } 9637 if (mSourceBounds != null) { 9638 if (!first) { 9639 b.append(' '); 9640 } 9641 first = false; 9642 b.append("bnds=").append(mSourceBounds.toShortString()); 9643 } 9644 if (mClipData != null) { 9645 if (!first) { 9646 b.append(' '); 9647 } 9648 b.append("clip={"); 9649 if (clip) { 9650 mClipData.toShortString(b); 9651 } else { 9652 if (mClipData.getDescription() != null) { 9653 first = !mClipData.getDescription().toShortStringTypesOnly(b); 9654 } else { 9655 first = true; 9656 } 9657 mClipData.toShortStringShortItems(b, first); 9658 } 9659 first = false; 9660 b.append('}'); 9661 } 9662 if (extras && mExtras != null) { 9663 if (!first) { 9664 b.append(' '); 9665 } 9666 first = false; 9667 b.append("(has extras)"); 9668 } 9669 if (mContentUserHint != UserHandle.USER_CURRENT) { 9670 if (!first) { 9671 b.append(' '); 9672 } 9673 first = false; 9674 b.append("u=").append(mContentUserHint); 9675 } 9676 if (mSelector != null) { 9677 b.append(" sel="); 9678 mSelector.toShortString(b, secure, comp, extras, clip); 9679 b.append("}"); 9680 } 9681 } 9682 9683 /** @hide */ writeToProto(ProtoOutputStream proto, long fieldId)9684 public void writeToProto(ProtoOutputStream proto, long fieldId) { 9685 // Same input parameters that toString() gives to toShortString(). 9686 writeToProto(proto, fieldId, true, true, true, false); 9687 } 9688 9689 /** @hide */ writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)9690 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, 9691 boolean extras, boolean clip) { 9692 long token = proto.start(fieldId); 9693 if (mAction != null) { 9694 proto.write(IntentProto.ACTION, mAction); 9695 } 9696 if (mCategories != null) { 9697 for (String category : mCategories) { 9698 proto.write(IntentProto.CATEGORIES, category); 9699 } 9700 } 9701 if (mData != null) { 9702 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString()); 9703 } 9704 if (mType != null) { 9705 proto.write(IntentProto.TYPE, mType); 9706 } 9707 if (mFlags != 0) { 9708 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags)); 9709 } 9710 if (mPackage != null) { 9711 proto.write(IntentProto.PACKAGE, mPackage); 9712 } 9713 if (comp && mComponent != null) { 9714 mComponent.writeToProto(proto, IntentProto.COMPONENT); 9715 } 9716 if (mSourceBounds != null) { 9717 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString()); 9718 } 9719 if (mClipData != null) { 9720 StringBuilder b = new StringBuilder(); 9721 if (clip) { 9722 mClipData.toShortString(b); 9723 } else { 9724 mClipData.toShortStringShortItems(b, false); 9725 } 9726 proto.write(IntentProto.CLIP_DATA, b.toString()); 9727 } 9728 if (extras && mExtras != null) { 9729 proto.write(IntentProto.EXTRAS, mExtras.toShortString()); 9730 } 9731 if (mContentUserHint != 0) { 9732 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint); 9733 } 9734 if (mSelector != null) { 9735 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip)); 9736 } 9737 proto.end(token); 9738 } 9739 9740 /** 9741 * Call {@link #toUri} with 0 flags. 9742 * @deprecated Use {@link #toUri} instead. 9743 */ 9744 @Deprecated toURI()9745 public String toURI() { 9746 return toUri(0); 9747 } 9748 9749 /** 9750 * Convert this Intent into a String holding a URI representation of it. 9751 * The returned URI string has been properly URI encoded, so it can be 9752 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the 9753 * Intent's data as the base URI, with an additional fragment describing 9754 * the action, categories, type, flags, package, component, and extras. 9755 * 9756 * <p>You can convert the returned string back to an Intent with 9757 * {@link #getIntent}. 9758 * 9759 * @param flags Additional operating flags. 9760 * 9761 * @return Returns a URI encoding URI string describing the entire contents 9762 * of the Intent. 9763 */ toUri(@riFlags int flags)9764 public String toUri(@UriFlags int flags) { 9765 StringBuilder uri = new StringBuilder(128); 9766 if ((flags&URI_ANDROID_APP_SCHEME) != 0) { 9767 if (mPackage == null) { 9768 throw new IllegalArgumentException( 9769 "Intent must include an explicit package name to build an android-app: " 9770 + this); 9771 } 9772 uri.append("android-app://"); 9773 uri.append(mPackage); 9774 String scheme = null; 9775 if (mData != null) { 9776 scheme = mData.getScheme(); 9777 if (scheme != null) { 9778 uri.append('/'); 9779 uri.append(scheme); 9780 String authority = mData.getEncodedAuthority(); 9781 if (authority != null) { 9782 uri.append('/'); 9783 uri.append(authority); 9784 String path = mData.getEncodedPath(); 9785 if (path != null) { 9786 uri.append(path); 9787 } 9788 String queryParams = mData.getEncodedQuery(); 9789 if (queryParams != null) { 9790 uri.append('?'); 9791 uri.append(queryParams); 9792 } 9793 String fragment = mData.getEncodedFragment(); 9794 if (fragment != null) { 9795 uri.append('#'); 9796 uri.append(fragment); 9797 } 9798 } 9799 } 9800 } 9801 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, 9802 mPackage, flags); 9803 return uri.toString(); 9804 } 9805 String scheme = null; 9806 if (mData != null) { 9807 String data = mData.toString(); 9808 if ((flags&URI_INTENT_SCHEME) != 0) { 9809 final int N = data.length(); 9810 for (int i=0; i<N; i++) { 9811 char c = data.charAt(i); 9812 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 9813 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') { 9814 continue; 9815 } 9816 if (c == ':' && i > 0) { 9817 // Valid scheme. 9818 scheme = data.substring(0, i); 9819 uri.append("intent:"); 9820 data = data.substring(i+1); 9821 break; 9822 } 9823 9824 // No scheme. 9825 break; 9826 } 9827 } 9828 uri.append(data); 9829 9830 } else if ((flags&URI_INTENT_SCHEME) != 0) { 9831 uri.append("intent:"); 9832 } 9833 9834 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); 9835 9836 return uri.toString(); 9837 } 9838 toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)9839 private void toUriFragment(StringBuilder uri, String scheme, String defAction, 9840 String defPackage, int flags) { 9841 StringBuilder frag = new StringBuilder(128); 9842 9843 toUriInner(frag, scheme, defAction, defPackage, flags); 9844 if (mSelector != null) { 9845 frag.append("SEL;"); 9846 // Note that for now we are not going to try to handle the 9847 // data part; not clear how to represent this as a URI, and 9848 // not much utility in it. 9849 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, 9850 null, null, flags); 9851 } 9852 9853 if (frag.length() > 0) { 9854 uri.append("#Intent;"); 9855 uri.append(frag); 9856 uri.append("end"); 9857 } 9858 } 9859 toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)9860 private void toUriInner(StringBuilder uri, String scheme, String defAction, 9861 String defPackage, int flags) { 9862 if (scheme != null) { 9863 uri.append("scheme=").append(scheme).append(';'); 9864 } 9865 if (mAction != null && !mAction.equals(defAction)) { 9866 uri.append("action=").append(Uri.encode(mAction)).append(';'); 9867 } 9868 if (mCategories != null) { 9869 for (int i=0; i<mCategories.size(); i++) { 9870 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';'); 9871 } 9872 } 9873 if (mType != null) { 9874 uri.append("type=").append(Uri.encode(mType, "/")).append(';'); 9875 } 9876 if (mFlags != 0) { 9877 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); 9878 } 9879 if (mPackage != null && !mPackage.equals(defPackage)) { 9880 uri.append("package=").append(Uri.encode(mPackage)).append(';'); 9881 } 9882 if (mComponent != null) { 9883 uri.append("component=").append(Uri.encode( 9884 mComponent.flattenToShortString(), "/")).append(';'); 9885 } 9886 if (mSourceBounds != null) { 9887 uri.append("sourceBounds=") 9888 .append(Uri.encode(mSourceBounds.flattenToString())) 9889 .append(';'); 9890 } 9891 if (mExtras != null) { 9892 for (String key : mExtras.keySet()) { 9893 final Object value = mExtras.get(key); 9894 char entryType = 9895 value instanceof String ? 'S' : 9896 value instanceof Boolean ? 'B' : 9897 value instanceof Byte ? 'b' : 9898 value instanceof Character ? 'c' : 9899 value instanceof Double ? 'd' : 9900 value instanceof Float ? 'f' : 9901 value instanceof Integer ? 'i' : 9902 value instanceof Long ? 'l' : 9903 value instanceof Short ? 's' : 9904 '\0'; 9905 9906 if (entryType != '\0') { 9907 uri.append(entryType); 9908 uri.append('.'); 9909 uri.append(Uri.encode(key)); 9910 uri.append('='); 9911 uri.append(Uri.encode(value.toString())); 9912 uri.append(';'); 9913 } 9914 } 9915 } 9916 } 9917 describeContents()9918 public int describeContents() { 9919 return (mExtras != null) ? mExtras.describeContents() : 0; 9920 } 9921 writeToParcel(Parcel out, int flags)9922 public void writeToParcel(Parcel out, int flags) { 9923 out.writeString(mAction); 9924 Uri.writeToParcel(out, mData); 9925 out.writeString(mType); 9926 out.writeInt(mFlags); 9927 out.writeString(mPackage); 9928 ComponentName.writeToParcel(mComponent, out); 9929 9930 if (mSourceBounds != null) { 9931 out.writeInt(1); 9932 mSourceBounds.writeToParcel(out, flags); 9933 } else { 9934 out.writeInt(0); 9935 } 9936 9937 if (mCategories != null) { 9938 final int N = mCategories.size(); 9939 out.writeInt(N); 9940 for (int i=0; i<N; i++) { 9941 out.writeString(mCategories.valueAt(i)); 9942 } 9943 } else { 9944 out.writeInt(0); 9945 } 9946 9947 if (mSelector != null) { 9948 out.writeInt(1); 9949 mSelector.writeToParcel(out, flags); 9950 } else { 9951 out.writeInt(0); 9952 } 9953 9954 if (mClipData != null) { 9955 out.writeInt(1); 9956 mClipData.writeToParcel(out, flags); 9957 } else { 9958 out.writeInt(0); 9959 } 9960 out.writeInt(mContentUserHint); 9961 out.writeBundle(mExtras); 9962 } 9963 9964 public static final Parcelable.Creator<Intent> CREATOR 9965 = new Parcelable.Creator<Intent>() { 9966 public Intent createFromParcel(Parcel in) { 9967 return new Intent(in); 9968 } 9969 public Intent[] newArray(int size) { 9970 return new Intent[size]; 9971 } 9972 }; 9973 9974 /** @hide */ Intent(Parcel in)9975 protected Intent(Parcel in) { 9976 readFromParcel(in); 9977 } 9978 readFromParcel(Parcel in)9979 public void readFromParcel(Parcel in) { 9980 setAction(in.readString()); 9981 mData = Uri.CREATOR.createFromParcel(in); 9982 mType = in.readString(); 9983 mFlags = in.readInt(); 9984 mPackage = in.readString(); 9985 mComponent = ComponentName.readFromParcel(in); 9986 9987 if (in.readInt() != 0) { 9988 mSourceBounds = Rect.CREATOR.createFromParcel(in); 9989 } 9990 9991 int N = in.readInt(); 9992 if (N > 0) { 9993 mCategories = new ArraySet<String>(); 9994 int i; 9995 for (i=0; i<N; i++) { 9996 mCategories.add(in.readString().intern()); 9997 } 9998 } else { 9999 mCategories = null; 10000 } 10001 10002 if (in.readInt() != 0) { 10003 mSelector = new Intent(in); 10004 } 10005 10006 if (in.readInt() != 0) { 10007 mClipData = new ClipData(in); 10008 } 10009 mContentUserHint = in.readInt(); 10010 mExtras = in.readBundle(); 10011 } 10012 10013 /** 10014 * Parses the "intent" element (and its children) from XML and instantiates 10015 * an Intent object. The given XML parser should be located at the tag 10016 * where parsing should start (often named "intent"), from which the 10017 * basic action, data, type, and package and class name will be 10018 * retrieved. The function will then parse in to any child elements, 10019 * looking for <category android:name="xxx"> tags to add categories and 10020 * <extra android:name="xxx" android:value="yyy"> to attach extra data 10021 * to the intent. 10022 * 10023 * @param resources The Resources to use when inflating resources. 10024 * @param parser The XML parser pointing at an "intent" tag. 10025 * @param attrs The AttributeSet interface for retrieving extended 10026 * attribute data at the current <var>parser</var> location. 10027 * @return An Intent object matching the XML data. 10028 * @throws XmlPullParserException If there was an XML parsing error. 10029 * @throws IOException If there was an I/O error. 10030 */ parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)10031 public static @NonNull Intent parseIntent(@NonNull Resources resources, 10032 @NonNull XmlPullParser parser, AttributeSet attrs) 10033 throws XmlPullParserException, IOException { 10034 Intent intent = new Intent(); 10035 10036 TypedArray sa = resources.obtainAttributes(attrs, 10037 com.android.internal.R.styleable.Intent); 10038 10039 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); 10040 10041 String data = sa.getString(com.android.internal.R.styleable.Intent_data); 10042 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); 10043 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); 10044 10045 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); 10046 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); 10047 if (packageName != null && className != null) { 10048 intent.setComponent(new ComponentName(packageName, className)); 10049 } 10050 10051 sa.recycle(); 10052 10053 int outerDepth = parser.getDepth(); 10054 int type; 10055 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 10056 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 10057 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 10058 continue; 10059 } 10060 10061 String nodeName = parser.getName(); 10062 if (nodeName.equals(TAG_CATEGORIES)) { 10063 sa = resources.obtainAttributes(attrs, 10064 com.android.internal.R.styleable.IntentCategory); 10065 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); 10066 sa.recycle(); 10067 10068 if (cat != null) { 10069 intent.addCategory(cat); 10070 } 10071 XmlUtils.skipCurrentTag(parser); 10072 10073 } else if (nodeName.equals(TAG_EXTRA)) { 10074 if (intent.mExtras == null) { 10075 intent.mExtras = new Bundle(); 10076 } 10077 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); 10078 XmlUtils.skipCurrentTag(parser); 10079 10080 } else { 10081 XmlUtils.skipCurrentTag(parser); 10082 } 10083 } 10084 10085 return intent; 10086 } 10087 10088 /** @hide */ saveToXml(XmlSerializer out)10089 public void saveToXml(XmlSerializer out) throws IOException { 10090 if (mAction != null) { 10091 out.attribute(null, ATTR_ACTION, mAction); 10092 } 10093 if (mData != null) { 10094 out.attribute(null, ATTR_DATA, mData.toString()); 10095 } 10096 if (mType != null) { 10097 out.attribute(null, ATTR_TYPE, mType); 10098 } 10099 if (mComponent != null) { 10100 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); 10101 } 10102 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); 10103 10104 if (mCategories != null) { 10105 out.startTag(null, TAG_CATEGORIES); 10106 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { 10107 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); 10108 } 10109 out.endTag(null, TAG_CATEGORIES); 10110 } 10111 } 10112 10113 /** @hide */ restoreFromXml(XmlPullParser in)10114 public static Intent restoreFromXml(XmlPullParser in) throws IOException, 10115 XmlPullParserException { 10116 Intent intent = new Intent(); 10117 final int outerDepth = in.getDepth(); 10118 10119 int attrCount = in.getAttributeCount(); 10120 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 10121 final String attrName = in.getAttributeName(attrNdx); 10122 final String attrValue = in.getAttributeValue(attrNdx); 10123 if (ATTR_ACTION.equals(attrName)) { 10124 intent.setAction(attrValue); 10125 } else if (ATTR_DATA.equals(attrName)) { 10126 intent.setData(Uri.parse(attrValue)); 10127 } else if (ATTR_TYPE.equals(attrName)) { 10128 intent.setType(attrValue); 10129 } else if (ATTR_COMPONENT.equals(attrName)) { 10130 intent.setComponent(ComponentName.unflattenFromString(attrValue)); 10131 } else if (ATTR_FLAGS.equals(attrName)) { 10132 intent.setFlags(Integer.parseInt(attrValue, 16)); 10133 } else { 10134 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName); 10135 } 10136 } 10137 10138 int event; 10139 String name; 10140 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && 10141 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { 10142 if (event == XmlPullParser.START_TAG) { 10143 name = in.getName(); 10144 if (TAG_CATEGORIES.equals(name)) { 10145 attrCount = in.getAttributeCount(); 10146 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 10147 intent.addCategory(in.getAttributeValue(attrNdx)); 10148 } 10149 } else { 10150 Log.w("Intent", "restoreFromXml: unknown name=" + name); 10151 XmlUtils.skipCurrentTag(in); 10152 } 10153 } 10154 } 10155 10156 return intent; 10157 } 10158 10159 /** 10160 * Normalize a MIME data type. 10161 * 10162 * <p>A normalized MIME type has white-space trimmed, 10163 * content-type parameters removed, and is lower-case. 10164 * This aligns the type with Android best practices for 10165 * intent filtering. 10166 * 10167 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". 10168 * "text/x-vCard" becomes "text/x-vcard". 10169 * 10170 * <p>All MIME types received from outside Android (such as user input, 10171 * or external sources like Bluetooth, NFC, or the Internet) should 10172 * be normalized before they are used to create an Intent. 10173 * 10174 * @param type MIME data type to normalize 10175 * @return normalized MIME data type, or null if the input was null 10176 * @see #setType 10177 * @see #setTypeAndNormalize 10178 */ normalizeMimeType(@ullable String type)10179 public static @Nullable String normalizeMimeType(@Nullable String type) { 10180 if (type == null) { 10181 return null; 10182 } 10183 10184 type = type.trim().toLowerCase(Locale.ROOT); 10185 10186 final int semicolonIndex = type.indexOf(';'); 10187 if (semicolonIndex != -1) { 10188 type = type.substring(0, semicolonIndex); 10189 } 10190 return type; 10191 } 10192 10193 /** 10194 * Prepare this {@link Intent} to leave an app process. 10195 * 10196 * @hide 10197 */ prepareToLeaveProcess(Context context)10198 public void prepareToLeaveProcess(Context context) { 10199 final boolean leavingPackage = (mComponent == null) 10200 || !Objects.equals(mComponent.getPackageName(), context.getPackageName()); 10201 prepareToLeaveProcess(leavingPackage); 10202 } 10203 10204 /** 10205 * Prepare this {@link Intent} to leave an app process. 10206 * 10207 * @hide 10208 */ prepareToLeaveProcess(boolean leavingPackage)10209 public void prepareToLeaveProcess(boolean leavingPackage) { 10210 setAllowFds(false); 10211 10212 if (mSelector != null) { 10213 mSelector.prepareToLeaveProcess(leavingPackage); 10214 } 10215 if (mClipData != null) { 10216 mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); 10217 } 10218 10219 if (mExtras != null && !mExtras.isParcelled()) { 10220 final Object intent = mExtras.get(Intent.EXTRA_INTENT); 10221 if (intent instanceof Intent) { 10222 ((Intent) intent).prepareToLeaveProcess(leavingPackage); 10223 } 10224 } 10225 10226 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() 10227 && leavingPackage) { 10228 switch (mAction) { 10229 case ACTION_MEDIA_REMOVED: 10230 case ACTION_MEDIA_UNMOUNTED: 10231 case ACTION_MEDIA_CHECKING: 10232 case ACTION_MEDIA_NOFS: 10233 case ACTION_MEDIA_MOUNTED: 10234 case ACTION_MEDIA_SHARED: 10235 case ACTION_MEDIA_UNSHARED: 10236 case ACTION_MEDIA_BAD_REMOVAL: 10237 case ACTION_MEDIA_UNMOUNTABLE: 10238 case ACTION_MEDIA_EJECT: 10239 case ACTION_MEDIA_SCANNER_STARTED: 10240 case ACTION_MEDIA_SCANNER_FINISHED: 10241 case ACTION_MEDIA_SCANNER_SCAN_FILE: 10242 case ACTION_PACKAGE_NEEDS_VERIFICATION: 10243 case ACTION_PACKAGE_VERIFIED: 10244 // Ignore legacy actions 10245 break; 10246 default: 10247 mData.checkFileUriExposed("Intent.getData()"); 10248 } 10249 } 10250 10251 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() 10252 && leavingPackage) { 10253 switch (mAction) { 10254 case ACTION_PROVIDER_CHANGED: 10255 case QuickContact.ACTION_QUICK_CONTACT: 10256 // Ignore actions that don't need to grant 10257 break; 10258 default: 10259 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); 10260 } 10261 } 10262 } 10263 10264 /** 10265 * @hide 10266 */ prepareToEnterProcess()10267 public void prepareToEnterProcess() { 10268 // We just entered destination process, so we should be able to read all 10269 // parcelables inside. 10270 setDefusable(true); 10271 10272 if (mSelector != null) { 10273 mSelector.prepareToEnterProcess(); 10274 } 10275 if (mClipData != null) { 10276 mClipData.prepareToEnterProcess(); 10277 } 10278 10279 if (mContentUserHint != UserHandle.USER_CURRENT) { 10280 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { 10281 fixUris(mContentUserHint); 10282 mContentUserHint = UserHandle.USER_CURRENT; 10283 } 10284 } 10285 } 10286 10287 /** @hide */ hasWebURI()10288 public boolean hasWebURI() { 10289 if (getData() == null) { 10290 return false; 10291 } 10292 final String scheme = getScheme(); 10293 if (TextUtils.isEmpty(scheme)) { 10294 return false; 10295 } 10296 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS); 10297 } 10298 10299 /** @hide */ isWebIntent()10300 public boolean isWebIntent() { 10301 return ACTION_VIEW.equals(mAction) 10302 && hasWebURI(); 10303 } 10304 10305 /** 10306 * @hide 10307 */ fixUris(int contentUserHint)10308 public void fixUris(int contentUserHint) { 10309 Uri data = getData(); 10310 if (data != null) { 10311 mData = maybeAddUserId(data, contentUserHint); 10312 } 10313 if (mClipData != null) { 10314 mClipData.fixUris(contentUserHint); 10315 } 10316 String action = getAction(); 10317 if (ACTION_SEND.equals(action)) { 10318 final Uri stream = getParcelableExtra(EXTRA_STREAM); 10319 if (stream != null) { 10320 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); 10321 } 10322 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 10323 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 10324 if (streams != null) { 10325 ArrayList<Uri> newStreams = new ArrayList<Uri>(); 10326 for (int i = 0; i < streams.size(); i++) { 10327 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); 10328 } 10329 putParcelableArrayListExtra(EXTRA_STREAM, newStreams); 10330 } 10331 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) 10332 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) 10333 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { 10334 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 10335 if (output != null) { 10336 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); 10337 } 10338 } 10339 } 10340 10341 /** 10342 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 10343 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 10344 * intents in {@link #ACTION_CHOOSER}. 10345 * 10346 * @return Whether any contents were migrated. 10347 * @hide 10348 */ migrateExtraStreamToClipData()10349 public boolean migrateExtraStreamToClipData() { 10350 // Refuse to touch if extras already parcelled 10351 if (mExtras != null && mExtras.isParcelled()) return false; 10352 10353 // Bail when someone already gave us ClipData 10354 if (getClipData() != null) return false; 10355 10356 final String action = getAction(); 10357 if (ACTION_CHOOSER.equals(action)) { 10358 // Inspect contained intents to see if we need to migrate extras. We 10359 // don't promote ClipData to the parent, since ChooserActivity will 10360 // already start the picked item as the caller, and we can't combine 10361 // the flags in a safe way. 10362 10363 boolean migrated = false; 10364 try { 10365 final Intent intent = getParcelableExtra(EXTRA_INTENT); 10366 if (intent != null) { 10367 migrated |= intent.migrateExtraStreamToClipData(); 10368 } 10369 } catch (ClassCastException e) { 10370 } 10371 try { 10372 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); 10373 if (intents != null) { 10374 for (int i = 0; i < intents.length; i++) { 10375 final Intent intent = (Intent) intents[i]; 10376 if (intent != null) { 10377 migrated |= intent.migrateExtraStreamToClipData(); 10378 } 10379 } 10380 } 10381 } catch (ClassCastException e) { 10382 } 10383 return migrated; 10384 10385 } else if (ACTION_SEND.equals(action)) { 10386 try { 10387 final Uri stream = getParcelableExtra(EXTRA_STREAM); 10388 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); 10389 final String htmlText = getStringExtra(EXTRA_HTML_TEXT); 10390 if (stream != null || text != null || htmlText != null) { 10391 final ClipData clipData = new ClipData( 10392 null, new String[] { getType() }, 10393 new ClipData.Item(text, htmlText, null, stream)); 10394 setClipData(clipData); 10395 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 10396 return true; 10397 } 10398 } catch (ClassCastException e) { 10399 } 10400 10401 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 10402 try { 10403 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 10404 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); 10405 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); 10406 int num = -1; 10407 if (streams != null) { 10408 num = streams.size(); 10409 } 10410 if (texts != null) { 10411 if (num >= 0 && num != texts.size()) { 10412 // Wha...! F- you. 10413 return false; 10414 } 10415 num = texts.size(); 10416 } 10417 if (htmlTexts != null) { 10418 if (num >= 0 && num != htmlTexts.size()) { 10419 // Wha...! F- you. 10420 return false; 10421 } 10422 num = htmlTexts.size(); 10423 } 10424 if (num > 0) { 10425 final ClipData clipData = new ClipData( 10426 null, new String[] { getType() }, 10427 makeClipItem(streams, texts, htmlTexts, 0)); 10428 10429 for (int i = 1; i < num; i++) { 10430 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); 10431 } 10432 10433 setClipData(clipData); 10434 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 10435 return true; 10436 } 10437 } catch (ClassCastException e) { 10438 } 10439 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) 10440 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) 10441 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { 10442 final Uri output; 10443 try { 10444 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 10445 } catch (ClassCastException e) { 10446 return false; 10447 } 10448 if (output != null) { 10449 setClipData(ClipData.newRawUri("", output)); 10450 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); 10451 return true; 10452 } 10453 } 10454 10455 return false; 10456 } 10457 10458 /** 10459 * Convert the dock state to a human readable format. 10460 * @hide 10461 */ dockStateToString(int dock)10462 public static String dockStateToString(int dock) { 10463 switch (dock) { 10464 case EXTRA_DOCK_STATE_HE_DESK: 10465 return "EXTRA_DOCK_STATE_HE_DESK"; 10466 case EXTRA_DOCK_STATE_LE_DESK: 10467 return "EXTRA_DOCK_STATE_LE_DESK"; 10468 case EXTRA_DOCK_STATE_CAR: 10469 return "EXTRA_DOCK_STATE_CAR"; 10470 case EXTRA_DOCK_STATE_DESK: 10471 return "EXTRA_DOCK_STATE_DESK"; 10472 case EXTRA_DOCK_STATE_UNDOCKED: 10473 return "EXTRA_DOCK_STATE_UNDOCKED"; 10474 default: 10475 return Integer.toString(dock); 10476 } 10477 } 10478 makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)10479 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, 10480 ArrayList<String> htmlTexts, int which) { 10481 Uri uri = streams != null ? streams.get(which) : null; 10482 CharSequence text = texts != null ? texts.get(which) : null; 10483 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; 10484 return new ClipData.Item(text, htmlText, null, uri); 10485 } 10486 10487 /** @hide */ isDocument()10488 public boolean isDocument() { 10489 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; 10490 } 10491 } 10492