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