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