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