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