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