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