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