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