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