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