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