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