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