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