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