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