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