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