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