Intent.java revision 23fdaf6fb62a9b5154b2508916a21c678462c5d0
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 org.xmlpull.v1.XmlPullParser; 20import org.xmlpull.v1.XmlPullParserException; 21 22import android.annotation.SdkConstant; 23import android.annotation.SdkConstant.SdkConstantType; 24import android.content.pm.ActivityInfo; 25import android.content.pm.PackageManager; 26import android.content.pm.ResolveInfo; 27import android.content.res.Resources; 28import android.content.res.TypedArray; 29import android.graphics.Rect; 30import android.net.Uri; 31import android.os.Bundle; 32import android.os.IBinder; 33import android.os.Parcel; 34import android.os.Parcelable; 35import android.util.AttributeSet; 36import android.util.Log; 37 38import com.android.internal.util.XmlUtils; 39 40import java.io.IOException; 41import java.io.Serializable; 42import java.net.URISyntaxException; 43import java.util.ArrayList; 44import java.util.HashSet; 45import java.util.Iterator; 46import java.util.Set; 47 48/** 49 * An intent is an abstract description of an operation to be performed. It 50 * can be used with {@link Context#startActivity(Intent) startActivity} to 51 * launch an {@link android.app.Activity}, 52 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to 53 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, 54 * and {@link android.content.Context#startService} or 55 * {@link android.content.Context#bindService} to communicate with a 56 * background {@link android.app.Service}. 57 * 58 * <p>An Intent provides a facility for performing late runtime binding between 59 * the code in different applications. Its most significant use is in the 60 * launching of activities, where it can be thought of as the glue between 61 * activities. It is 62 * basically a passive data structure holding an abstract description of an 63 * action to be performed. The primary pieces of information in an intent 64 * are:</p> 65 * 66 * <ul> 67 * <li> <p><b>action</b> -- The general action to be performed, such as 68 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, 69 * etc.</p> 70 * </li> 71 * <li> <p><b>data</b> -- The data to operate on, such as a person record 72 * in the contacts database, expressed as a {@link android.net.Uri}.</p> 73 * </li> 74 * </ul> 75 * 76 * 77 * <p>Some examples of action/data pairs are:</p> 78 * 79 * <ul> 80 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display 81 * information about the person whose identifier is "1".</p> 82 * </li> 83 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display 84 * the phone dialer with the person filled in.</p> 85 * </li> 86 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display 87 * the phone dialer with the given number filled in. Note how the 88 * VIEW action does what what is considered the most reasonable thing for 89 * a particular URI.</p> 90 * </li> 91 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display 92 * the phone dialer with the given number filled in.</p> 93 * </li> 94 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit 95 * information about the person whose identifier is "1".</p> 96 * </li> 97 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display 98 * a list of people, which the user can browse through. This example is a 99 * typical top-level entry into the Contacts application, showing you the 100 * list of people. Selecting a particular person to view would result in a 101 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> } 102 * being used to start an activity to display that person.</p> 103 * </li> 104 * </ul> 105 * 106 * <p>In addition to these primary attributes, there are a number of secondary 107 * attributes that you can also include with an intent:</p> 108 * 109 * <ul> 110 * <li> <p><b>category</b> -- Gives additional information about the action 111 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should 112 * appear in the Launcher as a top-level application, while 113 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list 114 * of alternative actions the user can perform on a piece of data.</p> 115 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the 116 * intent data. Normally the type is inferred from the data itself. 117 * By setting this attribute, you disable that evaluation and force 118 * an explicit type.</p> 119 * <li> <p><b>component</b> -- Specifies an explicit name of a component 120 * class to use for the intent. Normally this is determined by looking 121 * at the other information in the intent (the action, data/type, and 122 * categories) and matching that with a component that can handle it. 123 * If this attribute is set then none of the evaluation is performed, 124 * and this component is used exactly as is. By specifying this attribute, 125 * all of the other Intent attributes become optional.</p> 126 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. 127 * This can be used to provide extended information to the component. 128 * For example, if we have a action to send an e-mail message, we could 129 * also include extra pieces of data here to supply a subject, body, 130 * etc.</p> 131 * </ul> 132 * 133 * <p>Here are some examples of other operations you can specify as intents 134 * using these additional parameters:</p> 135 * 136 * <ul> 137 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- 138 * Launch the home screen.</p> 139 * </li> 140 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 141 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI 142 * vnd.android.cursor.item/phone}</i></b> 143 * -- Display the list of people's phone numbers, allowing the user to 144 * browse through them and pick one and return it to the parent activity.</p> 145 * </li> 146 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 147 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> 148 * -- Display all pickers for data that can be opened with 149 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, 150 * allowing the user to pick one of them and then some data inside of it 151 * and returning the resulting URI to the caller. This can be used, 152 * for example, in an e-mail application to allow the user to pick some 153 * data to include as an attachment.</p> 154 * </li> 155 * </ul> 156 * 157 * <p>There are a variety of standard Intent action and category constants 158 * defined in the Intent class, but applications can also define their own. 159 * These strings use java style scoping, to ensure they are unique -- for 160 * example, the standard {@link #ACTION_VIEW} is called 161 * "android.intent.action.VIEW".</p> 162 * 163 * <p>Put together, the set of actions, data types, categories, and extra data 164 * defines a language for the system allowing for the expression of phrases 165 * such as "call john smith's cell". As applications are added to the system, 166 * they can extend this language by adding new actions, types, and categories, or 167 * they can modify the behavior of existing phrases by supplying their own 168 * activities that handle them.</p> 169 * 170 * <a name="IntentResolution"></a> 171 * <h3>Intent Resolution</h3> 172 * 173 * <p>There are two primary forms of intents you will use. 174 * 175 * <ul> 176 * <li> <p><b>Explicit Intents</b> have specified a component (via 177 * {@link #setComponent} or {@link #setClass}), which provides the exact 178 * class to be run. Often these will not include any other information, 179 * simply being a way for an application to launch various internal 180 * activities it has as the user interacts with the application. 181 * 182 * <li> <p><b>Implicit Intents</b> have not specified a component; 183 * instead, they must include enough information for the system to 184 * determine which of the available components is best to run for that 185 * intent. 186 * </ul> 187 * 188 * <p>When using implicit intents, given such an arbitrary intent we need to 189 * know what to do with it. This is handled by the process of <em>Intent 190 * resolution</em>, which maps an Intent to an {@link android.app.Activity}, 191 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or 192 * more activities/receivers) that can handle it.</p> 193 * 194 * <p>The intent resolution mechanism basically revolves around matching an 195 * Intent against all of the <intent-filter> descriptions in the 196 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} 197 * objects explicitly registered with {@link Context#registerReceiver}.) More 198 * details on this can be found in the documentation on the {@link 199 * IntentFilter} class.</p> 200 * 201 * <p>There are three pieces of information in the Intent that are used for 202 * resolution: the action, type, and category. Using this information, a query 203 * is done on the {@link PackageManager} for a component that can handle the 204 * intent. The appropriate component is determined based on the intent 205 * information supplied in the <code>AndroidManifest.xml</code> file as 206 * follows:</p> 207 * 208 * <ul> 209 * <li> <p>The <b>action</b>, if given, must be listed by the component as 210 * one it handles.</p> 211 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not 212 * already supplied in the Intent. Like the action, if a type is 213 * included in the intent (either explicitly or implicitly in its 214 * data), then this must be listed by the component as one it handles.</p> 215 * <li> For data that is not a <code>content:</code> URI and where no explicit 216 * type is included in the Intent, instead the <b>scheme</b> of the 217 * intent data (such as <code>http:</code> or <code>mailto:</code>) is 218 * considered. Again like the action, if we are matching a scheme it 219 * must be listed by the component as one it can handle. 220 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed 221 * by the activity as categories it handles. That is, if you include 222 * the categories {@link #CATEGORY_LAUNCHER} and 223 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components 224 * with an intent that lists <em>both</em> of those categories. 225 * Activities will very often need to support the 226 * {@link #CATEGORY_DEFAULT} so that they can be found by 227 * {@link Context#startActivity Context.startActivity()}.</p> 228 * </ul> 229 * 230 * <p>For example, consider the Note Pad sample application that 231 * allows user to browse through a list of notes data and view details about 232 * individual items. Text in italics indicate places were you would replace a 233 * name with one specific to your own package.</p> 234 * 235 * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 236 * package="<i>com.android.notepad</i>"> 237 * <application android:icon="@drawable/app_notes" 238 * android:label="@string/app_name"> 239 * 240 * <provider class=".NotePadProvider" 241 * android:authorities="<i>com.google.provider.NotePad</i>" /> 242 * 243 * <activity class=".NotesList" android:label="@string/title_notes_list"> 244 * <intent-filter> 245 * <action android:name="android.intent.action.MAIN" /> 246 * <category android:name="android.intent.category.LAUNCHER" /> 247 * </intent-filter> 248 * <intent-filter> 249 * <action android:name="android.intent.action.VIEW" /> 250 * <action android:name="android.intent.action.EDIT" /> 251 * <action android:name="android.intent.action.PICK" /> 252 * <category android:name="android.intent.category.DEFAULT" /> 253 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 254 * </intent-filter> 255 * <intent-filter> 256 * <action android:name="android.intent.action.GET_CONTENT" /> 257 * <category android:name="android.intent.category.DEFAULT" /> 258 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 259 * </intent-filter> 260 * </activity> 261 * 262 * <activity class=".NoteEditor" android:label="@string/title_note"> 263 * <intent-filter android:label="@string/resolve_edit"> 264 * <action android:name="android.intent.action.VIEW" /> 265 * <action android:name="android.intent.action.EDIT" /> 266 * <category android:name="android.intent.category.DEFAULT" /> 267 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 268 * </intent-filter> 269 * 270 * <intent-filter> 271 * <action android:name="android.intent.action.INSERT" /> 272 * <category android:name="android.intent.category.DEFAULT" /> 273 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 274 * </intent-filter> 275 * 276 * </activity> 277 * 278 * <activity class=".TitleEditor" android:label="@string/title_edit_title" 279 * android:theme="@android:style/Theme.Dialog"> 280 * <intent-filter android:label="@string/resolve_title"> 281 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 282 * <category android:name="android.intent.category.DEFAULT" /> 283 * <category android:name="android.intent.category.ALTERNATIVE" /> 284 * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> 285 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 286 * </intent-filter> 287 * </activity> 288 * 289 * </application> 290 * </manifest></pre> 291 * 292 * <p>The first activity, 293 * <code>com.android.notepad.NotesList</code>, serves as our main 294 * entry into the app. It can do three things as described by its three intent 295 * templates: 296 * <ol> 297 * <li><pre> 298 * <intent-filter> 299 * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> 300 * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> 301 * </intent-filter></pre> 302 * <p>This provides a top-level entry into the NotePad application: the standard 303 * MAIN action is a main entry point (not requiring any other information in 304 * the Intent), and the LAUNCHER category says that this entry point should be 305 * listed in the application launcher.</p> 306 * <li><pre> 307 * <intent-filter> 308 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 309 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 310 * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> 311 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 312 * <data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 313 * </intent-filter></pre> 314 * <p>This declares the things that the activity can do on a directory of 315 * notes. The type being supported is given with the <type> tag, where 316 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which 317 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can 318 * be retrieved which holds our note pad data (<code>vnd.google.note</code>). 319 * The activity allows the user to view or edit the directory of data (via 320 * the VIEW and EDIT actions), or to pick a particular note and return it 321 * to the caller (via the PICK action). Note also the DEFAULT category 322 * supplied here: this is <em>required</em> for the 323 * {@link Context#startActivity Context.startActivity} method to resolve your 324 * activity when its component name is not explicitly specified.</p> 325 * <li><pre> 326 * <intent-filter> 327 * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> 328 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 329 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 330 * </intent-filter></pre> 331 * <p>This filter describes the ability return to the caller a note selected by 332 * the user without needing to know where it came from. The data type 333 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which 334 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can 335 * be retrieved which contains our note pad data (<code>vnd.google.note</code>). 336 * The GET_CONTENT action is similar to the PICK action, where the activity 337 * will return to its caller a piece of data selected by the user. Here, 338 * however, the caller specifies the type of data they desire instead of 339 * the type of data the user will be picking from.</p> 340 * </ol> 341 * 342 * <p>Given these capabilities, the following intents will resolve to the 343 * NotesList activity:</p> 344 * 345 * <ul> 346 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the 347 * activities that can be used as top-level entry points into an 348 * application.</p> 349 * <li> <p><b>{ action=android.app.action.MAIN, 350 * category=android.app.category.LAUNCHER }</b> is the actual intent 351 * used by the Launcher to populate its top-level list.</p> 352 * <li> <p><b>{ action=android.intent.action.VIEW 353 * data=content://com.google.provider.NotePad/notes }</b> 354 * displays a list of all the notes under 355 * "content://com.google.provider.NotePad/notes", which 356 * the user can browse through and see the details on.</p> 357 * <li> <p><b>{ action=android.app.action.PICK 358 * data=content://com.google.provider.NotePad/notes }</b> 359 * provides a list of the notes under 360 * "content://com.google.provider.NotePad/notes", from which 361 * the user can pick a note whose data URL is returned back to the caller.</p> 362 * <li> <p><b>{ action=android.app.action.GET_CONTENT 363 * type=vnd.android.cursor.item/vnd.google.note }</b> 364 * is similar to the pick action, but allows the caller to specify the 365 * kind of data they want back so that the system can find the appropriate 366 * activity to pick something of that data type.</p> 367 * </ul> 368 * 369 * <p>The second activity, 370 * <code>com.android.notepad.NoteEditor</code>, shows the user a single 371 * note entry and allows them to edit it. It can do two things as described 372 * by its two intent templates: 373 * <ol> 374 * <li><pre> 375 * <intent-filter android:label="@string/resolve_edit"> 376 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 377 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 378 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 379 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 380 * </intent-filter></pre> 381 * <p>The first, primary, purpose of this activity is to let the user interact 382 * with a single note, as decribed by the MIME type 383 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can 384 * either VIEW a note or allow the user to EDIT it. Again we support the 385 * DEFAULT category to allow the activity to be launched without explicitly 386 * specifying its component.</p> 387 * <li><pre> 388 * <intent-filter> 389 * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> 390 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 391 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 392 * </intent-filter></pre> 393 * <p>The secondary use of this activity is to insert a new note entry into 394 * an existing directory of notes. This is used when the user creates a new 395 * note: the INSERT action is executed on the directory of notes, causing 396 * this activity to run and have the user create the new note data which 397 * it then adds to the content provider.</p> 398 * </ol> 399 * 400 * <p>Given these capabilities, the following intents will resolve to the 401 * NoteEditor activity:</p> 402 * 403 * <ul> 404 * <li> <p><b>{ action=android.intent.action.VIEW 405 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 406 * shows the user the content of note <var>{ID}</var>.</p> 407 * <li> <p><b>{ action=android.app.action.EDIT 408 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 409 * allows the user to edit the content of note <var>{ID}</var>.</p> 410 * <li> <p><b>{ action=android.app.action.INSERT 411 * data=content://com.google.provider.NotePad/notes }</b> 412 * creates a new, empty note in the notes list at 413 * "content://com.google.provider.NotePad/notes" 414 * and allows the user to edit it. If they keep their changes, the URI 415 * of the newly created note is returned to the caller.</p> 416 * </ul> 417 * 418 * <p>The last activity, 419 * <code>com.android.notepad.TitleEditor</code>, allows the user to 420 * edit the title of a note. This could be implemented as a class that the 421 * application directly invokes (by explicitly setting its component in 422 * the Intent), but here we show a way you can publish alternative 423 * operations on existing data:</p> 424 * 425 * <pre> 426 * <intent-filter android:label="@string/resolve_title"> 427 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 428 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 429 * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> 430 * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> 431 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 432 * </intent-filter></pre> 433 * 434 * <p>In the single intent template here, we 435 * have created our own private action called 436 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to 437 * edit the title of a note. It must be invoked on a specific note 438 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous 439 * view and edit actions, but here displays and edits the title contained 440 * in the note data. 441 * 442 * <p>In addition to supporting the default category as usual, our title editor 443 * also supports two other standard categories: ALTERNATIVE and 444 * SELECTED_ALTERNATIVE. Implementing 445 * these categories allows others to find the special action it provides 446 * without directly knowing about it, through the 447 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or 448 * more often to build dynamic menu items with 449 * {@link android.view.Menu#addIntentOptions}. Note that in the intent 450 * template here was also supply an explicit name for the template 451 * (via <code>android:label="@string/resolve_title"</code>) to better control 452 * what the user sees when presented with this activity as an alternative 453 * action to the data they are viewing. 454 * 455 * <p>Given these capabilities, the following intent will resolve to the 456 * TitleEditor activity:</p> 457 * 458 * <ul> 459 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE 460 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 461 * displays and allows the user to edit the title associated 462 * with note <var>{ID}</var>.</p> 463 * </ul> 464 * 465 * <h3>Standard Activity Actions</h3> 466 * 467 * <p>These are the current standard actions that Intent defines for launching 468 * activities (usually through {@link Context#startActivity}. The most 469 * important, and by far most frequently used, are {@link #ACTION_MAIN} and 470 * {@link #ACTION_EDIT}. 471 * 472 * <ul> 473 * <li> {@link #ACTION_MAIN} 474 * <li> {@link #ACTION_VIEW} 475 * <li> {@link #ACTION_ATTACH_DATA} 476 * <li> {@link #ACTION_EDIT} 477 * <li> {@link #ACTION_PICK} 478 * <li> {@link #ACTION_CHOOSER} 479 * <li> {@link #ACTION_GET_CONTENT} 480 * <li> {@link #ACTION_DIAL} 481 * <li> {@link #ACTION_CALL} 482 * <li> {@link #ACTION_SEND} 483 * <li> {@link #ACTION_SENDTO} 484 * <li> {@link #ACTION_ANSWER} 485 * <li> {@link #ACTION_INSERT} 486 * <li> {@link #ACTION_DELETE} 487 * <li> {@link #ACTION_RUN} 488 * <li> {@link #ACTION_SYNC} 489 * <li> {@link #ACTION_PICK_ACTIVITY} 490 * <li> {@link #ACTION_SEARCH} 491 * <li> {@link #ACTION_WEB_SEARCH} 492 * <li> {@link #ACTION_FACTORY_TEST} 493 * </ul> 494 * 495 * <h3>Standard Broadcast Actions</h3> 496 * 497 * <p>These are the current standard actions that Intent defines for receiving 498 * broadcasts (usually through {@link Context#registerReceiver} or a 499 * <receiver> tag in a manifest). 500 * 501 * <ul> 502 * <li> {@link #ACTION_TIME_TICK} 503 * <li> {@link #ACTION_TIME_CHANGED} 504 * <li> {@link #ACTION_TIMEZONE_CHANGED} 505 * <li> {@link #ACTION_BOOT_COMPLETED} 506 * <li> {@link #ACTION_PACKAGE_ADDED} 507 * <li> {@link #ACTION_PACKAGE_CHANGED} 508 * <li> {@link #ACTION_PACKAGE_REMOVED} 509 * <li> {@link #ACTION_PACKAGE_RESTARTED} 510 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} 511 * <li> {@link #ACTION_UID_REMOVED} 512 * <li> {@link #ACTION_BATTERY_CHANGED} 513 * <li> {@link #ACTION_POWER_CONNECTED} 514 * <li> {@link #ACTION_POWER_DISCONNECTED} 515 * <li> {@link #ACTION_SHUTDOWN} 516 * </ul> 517 * 518 * <h3>Standard Categories</h3> 519 * 520 * <p>These are the current standard categories that can be used to further 521 * clarify an Intent via {@link #addCategory}. 522 * 523 * <ul> 524 * <li> {@link #CATEGORY_DEFAULT} 525 * <li> {@link #CATEGORY_BROWSABLE} 526 * <li> {@link #CATEGORY_TAB} 527 * <li> {@link #CATEGORY_ALTERNATIVE} 528 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} 529 * <li> {@link #CATEGORY_LAUNCHER} 530 * <li> {@link #CATEGORY_INFO} 531 * <li> {@link #CATEGORY_HOME} 532 * <li> {@link #CATEGORY_PREFERENCE} 533 * <li> {@link #CATEGORY_TEST} 534 * <li> {@link #CATEGORY_CAR_DOCK} 535 * <li> {@link #CATEGORY_DESK_DOCK} 536 * <li> {@link #CATEGORY_CAR_MODE} 537 * </ul> 538 * 539 * <h3>Standard Extra Data</h3> 540 * 541 * <p>These are the current standard fields that can be used as extra data via 542 * {@link #putExtra}. 543 * 544 * <ul> 545 * <li> {@link #EXTRA_ALARM_COUNT} 546 * <li> {@link #EXTRA_BCC} 547 * <li> {@link #EXTRA_CC} 548 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} 549 * <li> {@link #EXTRA_DATA_REMOVED} 550 * <li> {@link #EXTRA_DOCK_STATE} 551 * <li> {@link #EXTRA_DOCK_STATE_CAR} 552 * <li> {@link #EXTRA_DOCK_STATE_DESK} 553 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} 554 * <li> {@link #EXTRA_DONT_KILL_APP} 555 * <li> {@link #EXTRA_EMAIL} 556 * <li> {@link #EXTRA_INITIAL_INTENTS} 557 * <li> {@link #EXTRA_INTENT} 558 * <li> {@link #EXTRA_KEY_EVENT} 559 * <li> {@link #EXTRA_PHONE_NUMBER} 560 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} 561 * <li> {@link #EXTRA_REPLACING} 562 * <li> {@link #EXTRA_SHORTCUT_ICON} 563 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} 564 * <li> {@link #EXTRA_SHORTCUT_INTENT} 565 * <li> {@link #EXTRA_STREAM} 566 * <li> {@link #EXTRA_SHORTCUT_NAME} 567 * <li> {@link #EXTRA_SUBJECT} 568 * <li> {@link #EXTRA_TEMPLATE} 569 * <li> {@link #EXTRA_TEXT} 570 * <li> {@link #EXTRA_TITLE} 571 * <li> {@link #EXTRA_UID} 572 * </ul> 573 * 574 * <h3>Flags</h3> 575 * 576 * <p>These are the possible flags that can be used in the Intent via 577 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list 578 * of all possible flags. 579 */ 580public class Intent implements Parcelable, Cloneable { 581 // --------------------------------------------------------------------- 582 // --------------------------------------------------------------------- 583 // Standard intent activity actions (see action variable). 584 585 /** 586 * Activity Action: Start as a main entry point, does not expect to 587 * receive data. 588 * <p>Input: nothing 589 * <p>Output: nothing 590 */ 591 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 592 public static final String ACTION_MAIN = "android.intent.action.MAIN"; 593 594 /** 595 * Activity Action: Display the data to the user. This is the most common 596 * action performed on data -- it is the generic action you can use on 597 * a piece of data to get the most reasonable thing to occur. For example, 598 * when used on a contacts entry it will view the entry; when used on a 599 * mailto: URI it will bring up a compose window filled with the information 600 * supplied by the URI; when used with a tel: URI it will invoke the 601 * dialer. 602 * <p>Input: {@link #getData} is URI from which to retrieve data. 603 * <p>Output: nothing. 604 */ 605 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 606 public static final String ACTION_VIEW = "android.intent.action.VIEW"; 607 608 /** 609 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is 610 * performed on a piece of data. 611 */ 612 public static final String ACTION_DEFAULT = ACTION_VIEW; 613 614 /** 615 * Used to indicate that some piece of data should be attached to some other 616 * place. For example, image data could be attached to a contact. It is up 617 * to the recipient to decide where the data should be attached; the intent 618 * does not specify the ultimate destination. 619 * <p>Input: {@link #getData} is URI of data to be attached. 620 * <p>Output: nothing. 621 */ 622 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 623 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; 624 625 /** 626 * Activity Action: Provide explicit editable access to the given data. 627 * <p>Input: {@link #getData} is URI of data to be edited. 628 * <p>Output: nothing. 629 */ 630 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 631 public static final String ACTION_EDIT = "android.intent.action.EDIT"; 632 633 /** 634 * Activity Action: Pick an existing item, or insert a new item, and then edit it. 635 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. 636 * The extras can contain type specific data to pass through to the editing/creating 637 * activity. 638 * <p>Output: The URI of the item that was picked. This must be a content: 639 * URI so that any receiver can access it. 640 */ 641 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 642 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; 643 644 /** 645 * Activity Action: Pick an item from the data, returning what was selected. 646 * <p>Input: {@link #getData} is URI containing a directory of data 647 * (vnd.android.cursor.dir/*) from which to pick an item. 648 * <p>Output: The URI of the item that was picked. 649 */ 650 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 651 public static final String ACTION_PICK = "android.intent.action.PICK"; 652 653 /** 654 * Activity Action: Creates a shortcut. 655 * <p>Input: Nothing.</p> 656 * <p>Output: An Intent representing the shortcut. The intent must contain three 657 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), 658 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE 659 * (value: ShortcutIconResource).</p> 660 * 661 * @see #EXTRA_SHORTCUT_INTENT 662 * @see #EXTRA_SHORTCUT_NAME 663 * @see #EXTRA_SHORTCUT_ICON 664 * @see #EXTRA_SHORTCUT_ICON_RESOURCE 665 * @see android.content.Intent.ShortcutIconResource 666 */ 667 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 668 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; 669 670 /** 671 * The name of the extra used to define the Intent of a shortcut. 672 * 673 * @see #ACTION_CREATE_SHORTCUT 674 */ 675 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; 676 /** 677 * The name of the extra used to define the name of a shortcut. 678 * 679 * @see #ACTION_CREATE_SHORTCUT 680 */ 681 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; 682 /** 683 * The name of the extra used to define the icon, as a Bitmap, of a shortcut. 684 * 685 * @see #ACTION_CREATE_SHORTCUT 686 */ 687 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; 688 /** 689 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. 690 * 691 * @see #ACTION_CREATE_SHORTCUT 692 * @see android.content.Intent.ShortcutIconResource 693 */ 694 public static final String EXTRA_SHORTCUT_ICON_RESOURCE = 695 "android.intent.extra.shortcut.ICON_RESOURCE"; 696 697 /** 698 * Represents a shortcut/live folder icon resource. 699 * 700 * @see Intent#ACTION_CREATE_SHORTCUT 701 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE 702 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER 703 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON 704 */ 705 public static class ShortcutIconResource implements Parcelable { 706 /** 707 * The package name of the application containing the icon. 708 */ 709 public String packageName; 710 711 /** 712 * The resource name of the icon, including package, name and type. 713 */ 714 public String resourceName; 715 716 /** 717 * Creates a new ShortcutIconResource for the specified context and resource 718 * identifier. 719 * 720 * @param context The context of the application. 721 * @param resourceId The resource idenfitier for the icon. 722 * @return A new ShortcutIconResource with the specified's context package name 723 * and icon resource idenfitier. 724 */ 725 public static ShortcutIconResource fromContext(Context context, int resourceId) { 726 ShortcutIconResource icon = new ShortcutIconResource(); 727 icon.packageName = context.getPackageName(); 728 icon.resourceName = context.getResources().getResourceName(resourceId); 729 return icon; 730 } 731 732 /** 733 * Used to read a ShortcutIconResource from a Parcel. 734 */ 735 public static final Parcelable.Creator<ShortcutIconResource> CREATOR = 736 new Parcelable.Creator<ShortcutIconResource>() { 737 738 public ShortcutIconResource createFromParcel(Parcel source) { 739 ShortcutIconResource icon = new ShortcutIconResource(); 740 icon.packageName = source.readString(); 741 icon.resourceName = source.readString(); 742 return icon; 743 } 744 745 public ShortcutIconResource[] newArray(int size) { 746 return new ShortcutIconResource[size]; 747 } 748 }; 749 750 /** 751 * No special parcel contents. 752 */ 753 public int describeContents() { 754 return 0; 755 } 756 757 public void writeToParcel(Parcel dest, int flags) { 758 dest.writeString(packageName); 759 dest.writeString(resourceName); 760 } 761 762 @Override 763 public String toString() { 764 return resourceName; 765 } 766 } 767 768 /** 769 * Activity Action: Display an activity chooser, allowing the user to pick 770 * what they want to before proceeding. This can be used as an alternative 771 * to the standard activity picker that is displayed by the system when 772 * you try to start an activity with multiple possible matches, with these 773 * differences in behavior: 774 * <ul> 775 * <li>You can specify the title that will appear in the activity chooser. 776 * <li>The user does not have the option to make one of the matching 777 * activities a preferred activity, and all possible activities will 778 * always be shown even if one of them is currently marked as the 779 * preferred activity. 780 * </ul> 781 * <p> 782 * This action should be used when the user will naturally expect to 783 * select an activity in order to proceed. An example if when not to use 784 * it is when the user clicks on a "mailto:" link. They would naturally 785 * expect to go directly to their mail app, so startActivity() should be 786 * called directly: it will 787 * either launch the current preferred app, or put up a dialog allowing the 788 * user to pick an app to use and optionally marking that as preferred. 789 * <p> 790 * In contrast, if the user is selecting a menu item to send a picture 791 * they are viewing to someone else, there are many different things they 792 * may want to do at this point: send it through e-mail, upload it to a 793 * web service, etc. In this case the CHOOSER action should be used, to 794 * always present to the user a list of the things they can do, with a 795 * nice title given by the caller such as "Send this photo with:". 796 * <p> 797 * As a convenience, an Intent of this form can be created with the 798 * {@link #createChooser} function. 799 * <p>Input: No data should be specified. get*Extra must have 800 * a {@link #EXTRA_INTENT} field containing the Intent being executed, 801 * and can optionally have a {@link #EXTRA_TITLE} field containing the 802 * title text to display in the chooser. 803 * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}. 804 */ 805 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 806 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; 807 808 /** 809 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 810 * 811 * @param target The Intent that the user will be selecting an activity 812 * to perform. 813 * @param title Optional title that will be displayed in the chooser. 814 * @return Return a new Intent object that you can hand to 815 * {@link Context#startActivity(Intent) Context.startActivity()} and 816 * related methods. 817 */ 818 public static Intent createChooser(Intent target, CharSequence title) { 819 Intent intent = new Intent(ACTION_CHOOSER); 820 intent.putExtra(EXTRA_INTENT, target); 821 if (title != null) { 822 intent.putExtra(EXTRA_TITLE, title); 823 } 824 return intent; 825 } 826 /** 827 * Activity Action: Allow the user to select a particular kind of data and 828 * return it. This is different than {@link #ACTION_PICK} in that here we 829 * just say what kind of data is desired, not a URI of existing data from 830 * which the user can pick. A ACTION_GET_CONTENT could allow the user to 831 * create the data as it runs (for example taking a picture or recording a 832 * sound), let them browser over the web and download the desired data, 833 * etc. 834 * <p> 835 * There are two main ways to use this action: if you want an specific kind 836 * of data, such as a person contact, you set the MIME type to the kind of 837 * data you want and launch it with {@link Context#startActivity(Intent)}. 838 * The system will then launch the best application to select that kind 839 * of data for you. 840 * <p> 841 * You may also be interested in any of a set of types of content the user 842 * can pick. For example, an e-mail application that wants to allow the 843 * user to add an attachment to an e-mail message can use this action to 844 * bring up a list of all of the types of content the user can attach. 845 * <p> 846 * In this case, you should wrap the GET_CONTENT intent with a chooser 847 * (through {@link #createChooser}), which will give the proper interface 848 * for the user to pick how to send your data and allow you to specify 849 * a prompt indicating what they are doing. You will usually specify a 850 * broad MIME type (such as image/* or {@literal *}/*), resulting in a 851 * broad range of content types the user can select from. 852 * <p> 853 * When using such a broad GET_CONTENT action, it is often desireable to 854 * only pick from data that can be represented as a stream. This is 855 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. 856 * <p> 857 * Input: {@link #getType} is the desired MIME type to retrieve. Note 858 * that no URI is supplied in the intent, as there are no constraints on 859 * where the returned data originally comes from. You may also include the 860 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be 861 * opened as a stream. 862 * <p> 863 * Output: The URI of the item that was picked. This must be a content: 864 * URI so that any receiver can access it. 865 */ 866 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 867 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; 868 /** 869 * Activity Action: Dial a number as specified by the data. This shows a 870 * UI with the number being dialed, allowing the user to explicitly 871 * initiate the call. 872 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 873 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 874 * number. 875 * <p>Output: nothing. 876 */ 877 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 878 public static final String ACTION_DIAL = "android.intent.action.DIAL"; 879 /** 880 * Activity Action: Perform a call to someone specified by the data. 881 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 882 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 883 * number. 884 * <p>Output: nothing. 885 * 886 * <p>Note: there will be restrictions on which applications can initiate a 887 * call; most applications should use the {@link #ACTION_DIAL}. 888 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency 889 * numbers. Applications can <strong>dial</strong> emergency numbers using 890 * {@link #ACTION_DIAL}, however. 891 */ 892 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 893 public static final String ACTION_CALL = "android.intent.action.CALL"; 894 /** 895 * Activity Action: Perform a call to an emergency number specified by the 896 * data. 897 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 898 * tel: URI of an explicit phone number. 899 * <p>Output: nothing. 900 * @hide 901 */ 902 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; 903 /** 904 * Activity action: Perform a call to any number (emergency or not) 905 * specified by the data. 906 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 907 * tel: URI of an explicit phone number. 908 * <p>Output: nothing. 909 * @hide 910 */ 911 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; 912 /** 913 * Activity Action: Send a message to someone specified by the data. 914 * <p>Input: {@link #getData} is URI describing the target. 915 * <p>Output: nothing. 916 */ 917 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 918 public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; 919 /** 920 * Activity Action: Deliver some data to someone else. Who the data is 921 * being delivered to is not specified; it is up to the receiver of this 922 * action to ask the user where the data should be sent. 923 * <p> 924 * When launching a SEND intent, you should usually wrap it in a chooser 925 * (through {@link #createChooser}), which will give the proper interface 926 * for the user to pick how to send your data and allow you to specify 927 * a prompt indicating what they are doing. 928 * <p> 929 * Input: {@link #getType} is the MIME type of the data being sent. 930 * get*Extra can have either a {@link #EXTRA_TEXT} 931 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If 932 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it 933 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* 934 * if the MIME type is unknown (this will only allow senders that can 935 * handle generic data streams). 936 * <p> 937 * Optional standard extras, which may be interpreted by some recipients as 938 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 939 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 940 * <p> 941 * Output: nothing. 942 */ 943 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 944 public static final String ACTION_SEND = "android.intent.action.SEND"; 945 /** 946 * Activity Action: Deliver multiple data to someone else. 947 * <p> 948 * Like ACTION_SEND, except the data is multiple. 949 * <p> 950 * Input: {@link #getType} is the MIME type of the data being sent. 951 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link 952 * #EXTRA_STREAM} field, containing the data to be sent. 953 * <p> 954 * Multiple types are supported, and receivers should handle mixed types 955 * whenever possible. The right way for the receiver to check them is to 956 * use the content resolver on each URI. The intent sender should try to 957 * put the most concrete mime type in the intent type, but it can fall 958 * back to {@literal <type>/*} or {@literal *}/* as needed. 959 * <p> 960 * e.g. if you are sending image/jpg and image/jpg, the intent's type can 961 * be image/jpg, but if you are sending image/jpg and image/png, then the 962 * intent's type should be image/*. 963 * <p> 964 * Optional standard extras, which may be interpreted by some recipients as 965 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 966 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 967 * <p> 968 * Output: nothing. 969 */ 970 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 971 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; 972 /** 973 * Activity Action: Handle an incoming phone call. 974 * <p>Input: nothing. 975 * <p>Output: nothing. 976 */ 977 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 978 public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; 979 /** 980 * Activity Action: Insert an empty item into the given container. 981 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 982 * in which to place the data. 983 * <p>Output: URI of the new data that was created. 984 */ 985 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 986 public static final String ACTION_INSERT = "android.intent.action.INSERT"; 987 /** 988 * Activity Action: Create a new item in the given container, initializing it 989 * from the current contents of the clipboard. 990 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 991 * in which to place the data. 992 * <p>Output: URI of the new data that was created. 993 */ 994 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 995 public static final String ACTION_PASTE = "android.intent.action.PASTE"; 996 /** 997 * Activity Action: Delete the given data from its container. 998 * <p>Input: {@link #getData} is URI of data to be deleted. 999 * <p>Output: nothing. 1000 */ 1001 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1002 public static final String ACTION_DELETE = "android.intent.action.DELETE"; 1003 /** 1004 * Activity Action: Run the data, whatever that means. 1005 * <p>Input: ? (Note: this is currently specific to the test harness.) 1006 * <p>Output: nothing. 1007 */ 1008 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1009 public static final String ACTION_RUN = "android.intent.action.RUN"; 1010 /** 1011 * Activity Action: Perform a data synchronization. 1012 * <p>Input: ? 1013 * <p>Output: ? 1014 */ 1015 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1016 public static final String ACTION_SYNC = "android.intent.action.SYNC"; 1017 /** 1018 * Activity Action: Pick an activity given an intent, returning the class 1019 * selected. 1020 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent 1021 * used with {@link PackageManager#queryIntentActivities} to determine the 1022 * set of activities from which to pick. 1023 * <p>Output: Class name of the activity that was selected. 1024 */ 1025 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1026 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; 1027 /** 1028 * Activity Action: Perform a search. 1029 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1030 * is the text to search for. If empty, simply 1031 * enter your search results Activity with the search UI activated. 1032 * <p>Output: nothing. 1033 */ 1034 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1035 public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; 1036 /** 1037 * Activity Action: Start the platform-defined tutorial 1038 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1039 * is the text to search for. If empty, simply 1040 * enter your search results Activity with the search UI activated. 1041 * <p>Output: nothing. 1042 */ 1043 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1044 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; 1045 /** 1046 * Activity Action: Perform a web search. 1047 * <p> 1048 * Input: {@link android.app.SearchManager#QUERY 1049 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is 1050 * a url starts with http or https, the site will be opened. If it is plain 1051 * text, Google search will be applied. 1052 * <p> 1053 * Output: nothing. 1054 */ 1055 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1056 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; 1057 /** 1058 * Activity Action: List all available applications 1059 * <p>Input: Nothing. 1060 * <p>Output: nothing. 1061 */ 1062 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1063 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; 1064 /** 1065 * Activity Action: Show settings for choosing wallpaper 1066 * <p>Input: Nothing. 1067 * <p>Output: Nothing. 1068 */ 1069 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1070 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; 1071 1072 /** 1073 * Activity Action: Show activity for reporting a bug. 1074 * <p>Input: Nothing. 1075 * <p>Output: Nothing. 1076 */ 1077 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1078 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; 1079 1080 /** 1081 * Activity Action: Main entry point for factory tests. Only used when 1082 * the device is booting in factory test node. The implementing package 1083 * must be installed in the system image. 1084 * <p>Input: nothing 1085 * <p>Output: nothing 1086 */ 1087 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; 1088 1089 /** 1090 * Activity Action: The user pressed the "call" button to go to the dialer 1091 * or other appropriate UI for placing a call. 1092 * <p>Input: Nothing. 1093 * <p>Output: Nothing. 1094 */ 1095 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1096 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; 1097 1098 /** 1099 * Activity Action: Start Voice Command. 1100 * <p>Input: Nothing. 1101 * <p>Output: Nothing. 1102 */ 1103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1104 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; 1105 1106 /** 1107 * Activity Action: Start action associated with long pressing on the 1108 * search key. 1109 * <p>Input: Nothing. 1110 * <p>Output: Nothing. 1111 */ 1112 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1113 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; 1114 1115 /** 1116 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. 1117 * This intent is delivered to the package which installed the application, usually 1118 * the Market. 1119 * <p>Input: No data is specified. The bug report is passed in using 1120 * an {@link #EXTRA_BUG_REPORT} field. 1121 * <p>Output: Nothing. 1122 * @hide 1123 */ 1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1125 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; 1126 1127 /** 1128 * Activity Action: Show power usage information to the user. 1129 * <p>Input: Nothing. 1130 * <p>Output: Nothing. 1131 */ 1132 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1133 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; 1134 1135 /** 1136 * Activity Action: Setup wizard to launch after a platform update. This 1137 * activity should have a string meta-data field associated with it, 1138 * {@link #METADATA_SETUP_VERSION}, which defines the current version of 1139 * the platform for setup. The activity will be launched only if 1140 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the 1141 * same value. 1142 * <p>Input: Nothing. 1143 * <p>Output: Nothing. 1144 * @hide 1145 */ 1146 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1147 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; 1148 1149 /** 1150 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity 1151 * describing the last run version of the platform that was setup. 1152 * @hide 1153 */ 1154 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; 1155 1156 // --------------------------------------------------------------------- 1157 // --------------------------------------------------------------------- 1158 // Standard intent broadcast actions (see action variable). 1159 1160 /** 1161 * Broadcast Action: Sent after the screen turns off. 1162 * 1163 * <p class="note">This is a protected intent that can only be sent 1164 * by the system. 1165 */ 1166 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1167 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; 1168 /** 1169 * Broadcast Action: Sent after the screen turns on. 1170 * 1171 * <p class="note">This is a protected intent that can only be sent 1172 * by the system. 1173 */ 1174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1175 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; 1176 1177 /** 1178 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the 1179 * keyguard is gone). 1180 * 1181 * <p class="note">This is a protected intent that can only be sent 1182 * by the system. 1183 */ 1184 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1185 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; 1186 1187 /** 1188 * Broadcast Action: The current time has changed. Sent every 1189 * minute. You can <em>not</em> receive this through components declared 1190 * in manifests, only by exlicitly registering for it with 1191 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 1192 * Context.registerReceiver()}. 1193 * 1194 * <p class="note">This is a protected intent that can only be sent 1195 * by the system. 1196 */ 1197 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1198 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; 1199 /** 1200 * Broadcast Action: The time was set. 1201 */ 1202 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1203 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; 1204 /** 1205 * Broadcast Action: The date has changed. 1206 */ 1207 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1208 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; 1209 /** 1210 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> 1211 * <ul> 1212 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li> 1213 * </ul> 1214 * 1215 * <p class="note">This is a protected intent that can only be sent 1216 * by the system. 1217 */ 1218 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1219 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; 1220 /** 1221 * Alarm Changed Action: This is broadcast when the AlarmClock 1222 * application's alarm is set or unset. It is used by the 1223 * AlarmClock application and the StatusBar service. 1224 * @hide 1225 */ 1226 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1227 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; 1228 /** 1229 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has 1230 * been failing for a long time. It is used by the SyncManager and the StatusBar service. 1231 * @hide 1232 */ 1233 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1234 public static final String ACTION_SYNC_STATE_CHANGED 1235 = "android.intent.action.SYNC_STATE_CHANGED"; 1236 /** 1237 * Broadcast Action: This is broadcast once, after the system has finished 1238 * booting. It can be used to perform application-specific initialization, 1239 * such as installing alarms. You must hold the 1240 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission 1241 * in order to receive this broadcast. 1242 * 1243 * <p class="note">This is a protected intent that can only be sent 1244 * by the system. 1245 */ 1246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1247 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; 1248 /** 1249 * Broadcast Action: This is broadcast when a user action should request a 1250 * temporary system dialog to dismiss. Some examples of temporary system 1251 * dialogs are the notification window-shade and the recent tasks dialog. 1252 */ 1253 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; 1254 /** 1255 * Broadcast Action: Trigger the download and eventual installation 1256 * of a package. 1257 * <p>Input: {@link #getData} is the URI of the package file to download. 1258 * 1259 * <p class="note">This is a protected intent that can only be sent 1260 * by the system. 1261 */ 1262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1263 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; 1264 /** 1265 * Broadcast Action: A new application package has been installed on the 1266 * device. The data contains the name of the package. Note that the 1267 * newly installed package does <em>not</em> receive this broadcast. 1268 * <p>My include the following extras: 1269 * <ul> 1270 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 1271 * <li> {@link #EXTRA_REPLACING} is set to true if this is following 1272 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. 1273 * </ul> 1274 * 1275 * <p class="note">This is a protected intent that can only be sent 1276 * by the system. 1277 */ 1278 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1279 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; 1280 /** 1281 * Broadcast Action: A new version of an application package has been 1282 * installed, replacing an existing version that was previously installed. 1283 * The data contains the name of the package. 1284 * <p>My include the following extras: 1285 * <ul> 1286 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 1287 * </ul> 1288 * 1289 * <p class="note">This is a protected intent that can only be sent 1290 * by the system. 1291 */ 1292 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1293 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; 1294 /** 1295 * Broadcast Action: An existing application package has been removed from 1296 * the device. The data contains the name of the package. The package 1297 * that is being installed does <em>not</em> receive this Intent. 1298 * <ul> 1299 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 1300 * to the package. 1301 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 1302 * application -- data and code -- is being removed. 1303 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 1304 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 1305 * </ul> 1306 * 1307 * <p class="note">This is a protected intent that can only be sent 1308 * by the system. 1309 */ 1310 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1311 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; 1312 /** 1313 * Broadcast Action: An existing application package has been changed (e.g. 1314 * a component has been enabled or disabled). The data contains the name of 1315 * the package. 1316 * <ul> 1317 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 1318 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name 1319 * of the changed components. 1320 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the 1321 * default action of restarting the application. 1322 * </ul> 1323 * 1324 * <p class="note">This is a protected intent that can only be sent 1325 * by the system. 1326 */ 1327 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1328 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; 1329 /** 1330 * @hide 1331 * Broadcast Action: Ask system services if there is any reason to 1332 * restart the given package. The data contains the name of the 1333 * package. 1334 * <ul> 1335 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 1336 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. 1337 * </ul> 1338 * 1339 * <p class="note">This is a protected intent that can only be sent 1340 * by the system. 1341 */ 1342 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1343 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; 1344 /** 1345 * Broadcast Action: The user has restarted a package, and all of its 1346 * processes have been killed. All runtime state 1347 * associated with it (processes, alarms, notifications, etc) should 1348 * be removed. Note that the restarted package does <em>not</em> 1349 * receive this broadcast. 1350 * The data contains the name of the package. 1351 * <ul> 1352 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 1353 * </ul> 1354 * 1355 * <p class="note">This is a protected intent that can only be sent 1356 * by the system. 1357 */ 1358 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1359 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; 1360 /** 1361 * Broadcast Action: The user has cleared the data of a package. This should 1362 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of 1363 * its persistent data is erased and this broadcast sent. 1364 * Note that the cleared package does <em>not</em> 1365 * receive this broadcast. The data contains the name of the package. 1366 * <ul> 1367 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 1368 * </ul> 1369 * 1370 * <p class="note">This is a protected intent that can only be sent 1371 * by the system. 1372 */ 1373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1374 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; 1375 /** 1376 * Broadcast Action: A user ID has been removed from the system. The user 1377 * ID number is stored in the extra data under {@link #EXTRA_UID}. 1378 * 1379 * <p class="note">This is a protected intent that can only be sent 1380 * by the system. 1381 */ 1382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1383 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; 1384 1385 /** 1386 * Broadcast Action: Resources for a set of packages (which were 1387 * previously unavailable) are currently 1388 * available since the media on which they exist is available. 1389 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 1390 * list of packages whose availability changed. 1391 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 1392 * list of uids of packages whose availability changed. 1393 * Note that the 1394 * packages in this list do <em>not</em> receive this broadcast. 1395 * The specified set of packages are now available on the system. 1396 * <p>Includes the following extras: 1397 * <ul> 1398 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 1399 * whose resources(were previously unavailable) are currently available. 1400 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the 1401 * packages whose resources(were previously unavailable) 1402 * are currently available. 1403 * </ul> 1404 * 1405 * <p class="note">This is a protected intent that can only be sent 1406 * by the system. 1407 */ 1408 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1409 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = 1410 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; 1411 1412 /** 1413 * Broadcast Action: Resources for a set of packages are currently 1414 * unavailable since the media on which they exist is unavailable. 1415 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 1416 * list of packages whose availability changed. 1417 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 1418 * list of uids of packages whose availability changed. 1419 * The specified set of packages can no longer be 1420 * launched and are practically unavailable on the system. 1421 * <p>Inclues the following extras: 1422 * <ul> 1423 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 1424 * whose resources are no longer available. 1425 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages 1426 * whose resources are no longer available. 1427 * </ul> 1428 * 1429 * <p class="note">This is a protected intent that can only be sent 1430 * by the system. 1431 */ 1432 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1433 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = 1434 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; 1435 1436 /** 1437 * Broadcast Action: The current system wallpaper has changed. See 1438 * {@link android.app.WallpaperManager} for retrieving the new wallpaper. 1439 */ 1440 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1441 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; 1442 /** 1443 * Broadcast Action: The current device {@link android.content.res.Configuration} 1444 * (orientation, locale, etc) has changed. When such a change happens, the 1445 * UIs (view hierarchy) will need to be rebuilt based on this new 1446 * information; for the most part, applications don't need to worry about 1447 * this, because the system will take care of stopping and restarting the 1448 * application to make sure it sees the new changes. Some system code that 1449 * can not be restarted will need to watch for this action and handle it 1450 * appropriately. 1451 * 1452 * <p class="note"> 1453 * You can <em>not</em> receive this through components declared 1454 * in manifests, only by explicitly registering for it with 1455 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 1456 * Context.registerReceiver()}. 1457 * 1458 * <p class="note">This is a protected intent that can only be sent 1459 * by the system. 1460 * 1461 * @see android.content.res.Configuration 1462 */ 1463 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1464 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; 1465 /** 1466 * Broadcast Action: The current device's locale has changed. 1467 * 1468 * <p class="note">This is a protected intent that can only be sent 1469 * by the system. 1470 */ 1471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1472 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; 1473 /** 1474 * Broadcast Action: This is a <em>sticky broadcast</em> containing the 1475 * charging state, level, and other information about the battery. 1476 * See {@link android.os.BatteryManager} for documentation on the 1477 * contents of the Intent. 1478 * 1479 * <p class="note"> 1480 * You can <em>not</em> receive this through components declared 1481 * in manifests, only by explicitly registering for it with 1482 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 1483 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, 1484 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, 1485 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related 1486 * broadcasts that are sent and can be received through manifest 1487 * receivers. 1488 * 1489 * <p class="note">This is a protected intent that can only be sent 1490 * by the system. 1491 */ 1492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1493 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; 1494 /** 1495 * Broadcast Action: Indicates low battery condition on the device. 1496 * This broadcast corresponds to the "Low battery warning" system dialog. 1497 * 1498 * <p class="note">This is a protected intent that can only be sent 1499 * by the system. 1500 */ 1501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1502 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; 1503 /** 1504 * Broadcast Action: Indicates the battery is now okay after being low. 1505 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has 1506 * gone back up to an okay state. 1507 * 1508 * <p class="note">This is a protected intent that can only be sent 1509 * by the system. 1510 */ 1511 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1512 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; 1513 /** 1514 * Broadcast Action: External power has been connected to the device. 1515 * This is intended for applications that wish to register specifically to this notification. 1516 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 1517 * stay active to receive this notification. This action can be used to implement actions 1518 * that wait until power is available to trigger. 1519 * 1520 * <p class="note">This is a protected intent that can only be sent 1521 * by the system. 1522 */ 1523 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1524 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; 1525 /** 1526 * Broadcast Action: External power has been removed from the device. 1527 * This is intended for applications that wish to register specifically to this notification. 1528 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 1529 * stay active to receive this notification. This action can be used to implement actions 1530 * that wait until power is available to trigger. 1531 * 1532 * <p class="note">This is a protected intent that can only be sent 1533 * by the system. 1534 */ 1535 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1536 public static final String ACTION_POWER_DISCONNECTED = 1537 "android.intent.action.ACTION_POWER_DISCONNECTED"; 1538 /** 1539 * Broadcast Action: Device is shutting down. 1540 * This is broadcast when the device is being shut down (completely turned 1541 * off, not sleeping). Once the broadcast is complete, the final shutdown 1542 * will proceed and all unsaved data lost. Apps will not normally need 1543 * to handle this, since the foreground activity will be paused as well. 1544 * 1545 * <p class="note">This is a protected intent that can only be sent 1546 * by the system. 1547 */ 1548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1549 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; 1550 /** 1551 * Activity Action: Start this activity to request system shutdown. 1552 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true 1553 * to request confirmation from the user before shutting down. 1554 * 1555 * <p class="note">This is a protected intent that can only be sent 1556 * by the system. 1557 * 1558 * {@hide} 1559 */ 1560 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN"; 1561 /** 1562 * Broadcast Action: A sticky broadcast that indicates low memory 1563 * condition on the device 1564 * 1565 * <p class="note">This is a protected intent that can only be sent 1566 * by the system. 1567 */ 1568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1569 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; 1570 /** 1571 * Broadcast Action: Indicates low memory condition on the device no longer exists 1572 * 1573 * <p class="note">This is a protected intent that can only be sent 1574 * by the system. 1575 */ 1576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1577 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; 1578 /** 1579 * Broadcast Action: Indicates low memory condition notification acknowledged by user 1580 * and package management should be started. 1581 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW 1582 * notification. 1583 */ 1584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1585 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; 1586 /** 1587 * Broadcast Action: The device has entered USB Mass Storage mode. 1588 * This is used mainly for the USB Settings panel. 1589 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 1590 * when the SD card file system is mounted or unmounted 1591 */ 1592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1593 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; 1594 1595 /** 1596 * Broadcast Action: The device has exited USB Mass Storage mode. 1597 * This is used mainly for the USB Settings panel. 1598 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 1599 * when the SD card file system is mounted or unmounted 1600 */ 1601 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1602 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; 1603 1604 /** 1605 * Broadcast Action: External media has been removed. 1606 * The path to the mount point for the removed media is contained in the Intent.mData field. 1607 */ 1608 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1609 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; 1610 1611 /** 1612 * Broadcast Action: External media is present, but not mounted at its mount point. 1613 * The path to the mount point for the removed media is contained in the Intent.mData field. 1614 */ 1615 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1616 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; 1617 1618 /** 1619 * Broadcast Action: External media is present, and being disk-checked 1620 * The path to the mount point for the checking media is contained in the Intent.mData field. 1621 */ 1622 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1623 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; 1624 1625 /** 1626 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) 1627 * The path to the mount point for the checking media is contained in the Intent.mData field. 1628 */ 1629 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1630 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; 1631 1632 /** 1633 * Broadcast Action: External media is present and mounted at its mount point. 1634 * The path to the mount point for the removed media is contained in the Intent.mData field. 1635 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the 1636 * media was mounted read only. 1637 */ 1638 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1639 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; 1640 1641 /** 1642 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. 1643 * The path to the mount point for the shared media is contained in the Intent.mData field. 1644 */ 1645 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1646 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; 1647 1648 /** 1649 * Broadcast Action: External media is no longer being shared via USB mass storage. 1650 * The path to the mount point for the previously shared media is contained in the Intent.mData field. 1651 * 1652 * @hide 1653 */ 1654 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; 1655 1656 /** 1657 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. 1658 * The path to the mount point for the removed media is contained in the Intent.mData field. 1659 */ 1660 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1661 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; 1662 1663 /** 1664 * Broadcast Action: External media is present but cannot be mounted. 1665 * The path to the mount point for the removed media is contained in the Intent.mData field. 1666 */ 1667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1668 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; 1669 1670 /** 1671 * Broadcast Action: User has expressed the desire to remove the external storage media. 1672 * Applications should close all files they have open within the mount point when they receive this intent. 1673 * The path to the mount point for the media to be ejected is contained in the Intent.mData field. 1674 */ 1675 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1676 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; 1677 1678 /** 1679 * Broadcast Action: The media scanner has started scanning a directory. 1680 * The path to the directory being scanned is contained in the Intent.mData field. 1681 */ 1682 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1683 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; 1684 1685 /** 1686 * Broadcast Action: The media scanner has finished scanning a directory. 1687 * The path to the scanned directory is contained in the Intent.mData field. 1688 */ 1689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1690 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; 1691 1692 /** 1693 * Broadcast Action: Request the media scanner to scan a file and add it to the media database. 1694 * The path to the file is contained in the Intent.mData field. 1695 */ 1696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1697 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; 1698 1699 /** 1700 * Broadcast Action: The "Media Button" was pressed. Includes a single 1701 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 1702 * caused the broadcast. 1703 */ 1704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1705 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; 1706 1707 /** 1708 * Broadcast Action: The "Camera Button" was pressed. Includes a single 1709 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 1710 * caused the broadcast. 1711 */ 1712 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1713 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; 1714 1715 // *** NOTE: @todo(*) The following really should go into a more domain-specific 1716 // location; they are not general-purpose actions. 1717 1718 /** 1719 * Broadcast Action: An GTalk connection has been established. 1720 */ 1721 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1722 public static final String ACTION_GTALK_SERVICE_CONNECTED = 1723 "android.intent.action.GTALK_CONNECTED"; 1724 1725 /** 1726 * Broadcast Action: An GTalk connection has been disconnected. 1727 */ 1728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1729 public static final String ACTION_GTALK_SERVICE_DISCONNECTED = 1730 "android.intent.action.GTALK_DISCONNECTED"; 1731 1732 /** 1733 * Broadcast Action: An input method has been changed. 1734 */ 1735 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1736 public static final String ACTION_INPUT_METHOD_CHANGED = 1737 "android.intent.action.INPUT_METHOD_CHANGED"; 1738 1739 /** 1740 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or 1741 * more radios have been turned off or on. The intent will have the following extra value:</p> 1742 * <ul> 1743 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, 1744 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been 1745 * turned off</li> 1746 * </ul> 1747 * 1748 * <p class="note">This is a protected intent that can only be sent 1749 * by the system. 1750 */ 1751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1752 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; 1753 1754 /** 1755 * Broadcast Action: Some content providers have parts of their namespace 1756 * where they publish new events or items that the user may be especially 1757 * interested in. For these things, they may broadcast this action when the 1758 * set of interesting items change. 1759 * 1760 * For example, GmailProvider sends this notification when the set of unread 1761 * mail in the inbox changes. 1762 * 1763 * <p>The data of the intent identifies which part of which provider 1764 * changed. When queried through the content resolver, the data URI will 1765 * return the data set in question. 1766 * 1767 * <p>The intent will have the following extra values: 1768 * <ul> 1769 * <li><em>count</em> - The number of items in the data set. This is the 1770 * same as the number of items in the cursor returned by querying the 1771 * data URI. </li> 1772 * </ul> 1773 * 1774 * This intent will be sent at boot (if the count is non-zero) and when the 1775 * data set changes. It is possible for the data set to change without the 1776 * count changing (for example, if a new unread message arrives in the same 1777 * sync operation in which a message is archived). The phone should still 1778 * ring/vibrate/etc as normal in this case. 1779 */ 1780 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1781 public static final String ACTION_PROVIDER_CHANGED = 1782 "android.intent.action.PROVIDER_CHANGED"; 1783 1784 /** 1785 * Broadcast Action: Wired Headset plugged in or unplugged. 1786 * 1787 * <p>The intent will have the following extra values: 1788 * <ul> 1789 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li> 1790 * <li><em>name</em> - Headset type, human readable string </li> 1791 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li> 1792 * </ul> 1793 * </ul> 1794 */ 1795 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1796 public static final String ACTION_HEADSET_PLUG = 1797 "android.intent.action.HEADSET_PLUG"; 1798 1799 /** 1800 * Broadcast Action: An outgoing call is about to be placed. 1801 * 1802 * <p>The Intent will have the following extra value: 1803 * <ul> 1804 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - 1805 * the phone number originally intended to be dialed.</li> 1806 * </ul> 1807 * <p>Once the broadcast is finished, the resultData is used as the actual 1808 * number to call. If <code>null</code>, no call will be placed.</p> 1809 * <p>It is perfectly acceptable for multiple receivers to process the 1810 * outgoing call in turn: for example, a parental control application 1811 * might verify that the user is authorized to place the call at that 1812 * time, then a number-rewriting application might add an area code if 1813 * one was not specified.</p> 1814 * <p>For consistency, any receiver whose purpose is to prohibit phone 1815 * calls should have a priority of 0, to ensure it will see the final 1816 * phone number to be dialed. 1817 * Any receiver whose purpose is to rewrite phone numbers to be called 1818 * should have a positive priority. 1819 * Negative priorities are reserved for the system for this broadcast; 1820 * using them may cause problems.</p> 1821 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> 1822 * abort the broadcast.</p> 1823 * <p>Emergency calls cannot be intercepted using this mechanism, and 1824 * other calls cannot be modified to call emergency numbers using this 1825 * mechanism. 1826 * <p>You must hold the 1827 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} 1828 * permission to receive this Intent.</p> 1829 * 1830 * <p class="note">This is a protected intent that can only be sent 1831 * by the system. 1832 */ 1833 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1834 public static final String ACTION_NEW_OUTGOING_CALL = 1835 "android.intent.action.NEW_OUTGOING_CALL"; 1836 1837 /** 1838 * Broadcast Action: Have the device reboot. This is only for use by 1839 * system code. 1840 * 1841 * <p class="note">This is a protected intent that can only be sent 1842 * by the system. 1843 */ 1844 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1845 public static final String ACTION_REBOOT = 1846 "android.intent.action.REBOOT"; 1847 1848 /** 1849 * Broadcast Action: A sticky broadcast for changes in the physical 1850 * docking state of the device. 1851 * 1852 * <p>The intent will have the following extra values: 1853 * <ul> 1854 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock 1855 * state, indicating which dock the device is physically in.</li> 1856 * </ul> 1857 * <p>This is intended for monitoring the current physical dock state. 1858 * See {@link android.app.UiModeManager} for the normal API dealing with 1859 * dock mode changes. 1860 */ 1861 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1862 public static final String ACTION_DOCK_EVENT = 1863 "android.intent.action.DOCK_EVENT"; 1864 1865 /** 1866 * Broadcast Action: a remote intent is to be broadcasted. 1867 * 1868 * A remote intent is used for remote RPC between devices. The remote intent 1869 * is serialized and sent from one device to another device. The receiving 1870 * device parses the remote intent and broadcasts it. Note that anyone can 1871 * broadcast a remote intent. However, if the intent receiver of the remote intent 1872 * does not trust intent broadcasts from arbitrary intent senders, it should require 1873 * the sender to hold certain permissions so only trusted sender's broadcast will be 1874 * let through. 1875 * @hide 1876 */ 1877 public static final String ACTION_REMOTE_INTENT = 1878 "com.google.android.c2dm.intent.RECEIVE"; 1879 1880 /** 1881 * Broadcast Action: hook for permforming cleanup after a system update. 1882 * 1883 * The broadcast is sent when the system is booting, before the 1884 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system 1885 * image. A receiver for this should do its work and then disable itself 1886 * so that it does not get run again at the next boot. 1887 * @hide 1888 */ 1889 public static final String ACTION_PRE_BOOT_COMPLETED = 1890 "android.intent.action.PRE_BOOT_COMPLETED"; 1891 1892 // --------------------------------------------------------------------- 1893 // --------------------------------------------------------------------- 1894 // Standard intent categories (see addCategory()). 1895 1896 /** 1897 * Set if the activity should be an option for the default action 1898 * (center press) to perform on a piece of data. Setting this will 1899 * hide from the user any activities without it set when performing an 1900 * action on some data. Note that this is normal -not- set in the 1901 * Intent when initiating an action -- it is for use in intent filters 1902 * specified in packages. 1903 */ 1904 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1905 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; 1906 /** 1907 * Activities that can be safely invoked from a browser must support this 1908 * category. For example, if the user is viewing a web page or an e-mail 1909 * and clicks on a link in the text, the Intent generated execute that 1910 * link will require the BROWSABLE category, so that only activities 1911 * supporting this category will be considered as possible actions. By 1912 * supporting this category, you are promising that there is nothing 1913 * damaging (without user intervention) that can happen by invoking any 1914 * matching Intent. 1915 */ 1916 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1917 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; 1918 /** 1919 * Set if the activity should be considered as an alternative action to 1920 * the data the user is currently viewing. See also 1921 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that 1922 * applies to the selection in a list of items. 1923 * 1924 * <p>Supporting this category means that you would like your activity to be 1925 * displayed in the set of alternative things the user can do, usually as 1926 * part of the current activity's options menu. You will usually want to 1927 * include a specific label in the <intent-filter> of this action 1928 * describing to the user what it does. 1929 * 1930 * <p>The action of IntentFilter with this category is important in that it 1931 * describes the specific action the target will perform. This generally 1932 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather 1933 * a specific name such as "com.android.camera.action.CROP. Only one 1934 * alternative of any particular action will be shown to the user, so using 1935 * a specific action like this makes sure that your alternative will be 1936 * displayed while also allowing other applications to provide their own 1937 * overrides of that particular action. 1938 */ 1939 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1940 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; 1941 /** 1942 * Set if the activity should be considered as an alternative selection 1943 * action to the data the user has currently selected. This is like 1944 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list 1945 * of items from which the user can select, giving them alternatives to the 1946 * default action that will be performed on it. 1947 */ 1948 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1949 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; 1950 /** 1951 * Intended to be used as a tab inside of an containing TabActivity. 1952 */ 1953 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1954 public static final String CATEGORY_TAB = "android.intent.category.TAB"; 1955 /** 1956 * Should be displayed in the top-level launcher. 1957 */ 1958 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1959 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; 1960 /** 1961 * Provides information about the package it is in; typically used if 1962 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide 1963 * a front-door to the user without having to be shown in the all apps list. 1964 */ 1965 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1966 public static final String CATEGORY_INFO = "android.intent.category.INFO"; 1967 /** 1968 * This is the home activity, that is the first activity that is displayed 1969 * when the device boots. 1970 */ 1971 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1972 public static final String CATEGORY_HOME = "android.intent.category.HOME"; 1973 /** 1974 * This activity is a preference panel. 1975 */ 1976 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1977 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; 1978 /** 1979 * This activity is a development preference panel. 1980 */ 1981 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1982 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; 1983 /** 1984 * Capable of running inside a parent activity container. 1985 */ 1986 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1987 public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; 1988 /** 1989 * This activity may be exercised by the monkey or other automated test tools. 1990 */ 1991 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 1992 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; 1993 /** 1994 * To be used as a test (not part of the normal user experience). 1995 */ 1996 public static final String CATEGORY_TEST = "android.intent.category.TEST"; 1997 /** 1998 * To be used as a unit test (run through the Test Harness). 1999 */ 2000 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; 2001 /** 2002 * To be used as an sample code example (not part of the normal user 2003 * experience). 2004 */ 2005 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; 2006 /** 2007 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with 2008 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns 2009 * when queried, though it is allowable for those columns to be blank. 2010 */ 2011 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 2012 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; 2013 2014 /** 2015 * To be used as code under test for framework instrumentation tests. 2016 */ 2017 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = 2018 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; 2019 /** 2020 * An activity to run when device is inserted into a car dock. 2021 * Used with {@link #ACTION_MAIN} to launch an activity. For more 2022 * information, see {@link android.app.UiModeManager}. 2023 */ 2024 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 2025 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; 2026 /** 2027 * An activity to run when device is inserted into a car dock. 2028 * Used with {@link #ACTION_MAIN} to launch an activity. For more 2029 * information, see {@link android.app.UiModeManager}. 2030 */ 2031 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 2032 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; 2033 2034 /** 2035 * Used to indicate that the activity can be used in a car environment. 2036 */ 2037 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 2038 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; 2039 2040 // --------------------------------------------------------------------- 2041 // --------------------------------------------------------------------- 2042 // Standard extra data keys. 2043 2044 /** 2045 * The initial data to place in a newly created record. Use with 2046 * {@link #ACTION_INSERT}. The data here is a Map containing the same 2047 * fields as would be given to the underlying ContentProvider.insert() 2048 * call. 2049 */ 2050 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; 2051 2052 /** 2053 * A constant CharSequence that is associated with the Intent, used with 2054 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that 2055 * this may be a styled CharSequence, so you must use 2056 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to 2057 * retrieve it. 2058 */ 2059 public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; 2060 2061 /** 2062 * A content: URI holding a stream of data associated with the Intent, 2063 * used with {@link #ACTION_SEND} to supply the data being sent. 2064 */ 2065 public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; 2066 2067 /** 2068 * A String[] holding e-mail addresses that should be delivered to. 2069 */ 2070 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; 2071 2072 /** 2073 * A String[] holding e-mail addresses that should be carbon copied. 2074 */ 2075 public static final String EXTRA_CC = "android.intent.extra.CC"; 2076 2077 /** 2078 * A String[] holding e-mail addresses that should be blind carbon copied. 2079 */ 2080 public static final String EXTRA_BCC = "android.intent.extra.BCC"; 2081 2082 /** 2083 * A constant string holding the desired subject line of a message. 2084 */ 2085 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; 2086 2087 /** 2088 * An Intent describing the choices you would like shown with 2089 * {@link #ACTION_PICK_ACTIVITY}. 2090 */ 2091 public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; 2092 2093 /** 2094 * A CharSequence dialog title to provide to the user when used with a 2095 * {@link #ACTION_CHOOSER}. 2096 */ 2097 public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; 2098 2099 /** 2100 * A Parcelable[] of {@link Intent} or 2101 * {@link android.content.pm.LabeledIntent} objects as set with 2102 * {@link #putExtra(String, Parcelable[])} of additional activities to place 2103 * a the front of the list of choices, when shown to the user with a 2104 * {@link #ACTION_CHOOSER}. 2105 */ 2106 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; 2107 2108 /** 2109 * A {@link android.view.KeyEvent} object containing the event that 2110 * triggered the creation of the Intent it is in. 2111 */ 2112 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; 2113 2114 /** 2115 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user 2116 * before shutting down. 2117 * 2118 * {@hide} 2119 */ 2120 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; 2121 2122 /** 2123 * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 2124 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action 2125 * of restarting the application. 2126 */ 2127 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; 2128 2129 /** 2130 * A String holding the phone number originally entered in 2131 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual 2132 * number to call in a {@link android.content.Intent#ACTION_CALL}. 2133 */ 2134 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; 2135 2136 /** 2137 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} 2138 * intents to supply the uid the package had been assigned. Also an optional 2139 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 2140 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same 2141 * purpose. 2142 */ 2143 public static final String EXTRA_UID = "android.intent.extra.UID"; 2144 2145 /** 2146 * @hide String array of package names. 2147 */ 2148 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; 2149 2150 /** 2151 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 2152 * intents to indicate whether this represents a full uninstall (removing 2153 * both the code and its data) or a partial uninstall (leaving its data, 2154 * implying that this is an update). 2155 */ 2156 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; 2157 2158 /** 2159 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 2160 * intents to indicate that this is a replacement of the package, so this 2161 * broadcast will immediately be followed by an add broadcast for a 2162 * different version of the same package. 2163 */ 2164 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING"; 2165 2166 /** 2167 * Used as an int extra field in {@link android.app.AlarmManager} intents 2168 * to tell the application being invoked how many pending alarms are being 2169 * delievered with the intent. For one-shot alarms this will always be 1. 2170 * For recurring alarms, this might be greater than 1 if the device was 2171 * asleep or powered off at the time an earlier alarm would have been 2172 * delivered. 2173 */ 2174 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; 2175 2176 /** 2177 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} 2178 * intents to request the dock state. Possible values are 2179 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, 2180 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or 2181 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}. 2182 */ 2183 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; 2184 2185 /** 2186 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 2187 * to represent that the phone is not in any dock. 2188 */ 2189 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; 2190 2191 /** 2192 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 2193 * to represent that the phone is in a desk dock. 2194 */ 2195 public static final int EXTRA_DOCK_STATE_DESK = 1; 2196 2197 /** 2198 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 2199 * to represent that the phone is in a car dock. 2200 */ 2201 public static final int EXTRA_DOCK_STATE_CAR = 2; 2202 2203 /** 2204 * Boolean that can be supplied as meta-data with a dock activity, to 2205 * indicate that the dock should take over the home key when it is active. 2206 */ 2207 public static final String METADATA_DOCK_HOME = "android.dock_home"; 2208 2209 /** 2210 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing 2211 * the bug report. 2212 * 2213 * @hide 2214 */ 2215 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; 2216 2217 /** 2218 * Used as a string extra field when sending an intent to PackageInstaller to install a 2219 * package. Specifies the installer package name; this package will receive the 2220 * {@link #ACTION_APP_ERROR} intent. 2221 * 2222 * @hide 2223 */ 2224 public static final String EXTRA_INSTALLER_PACKAGE_NAME 2225 = "android.intent.extra.INSTALLER_PACKAGE_NAME"; 2226 2227 /** 2228 * Used in the extra field in the remote intent. It's astring token passed with the 2229 * remote intent. 2230 */ 2231 public static final String EXTRA_REMOTE_INTENT_TOKEN = 2232 "android.intent.extra.remote_intent_token"; 2233 2234 /** 2235 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field 2236 * will contain only the first name in the list. 2237 */ 2238 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = 2239 "android.intent.extra.changed_component_name"; 2240 2241 /** 2242 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, 2243 * and contains a string array of all of the components that have changed. 2244 */ 2245 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = 2246 "android.intent.extra.changed_component_name_list"; 2247 2248 /** 2249 * This field is part of 2250 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 2251 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 2252 * and contains a string array of all of the components that have changed. 2253 */ 2254 public static final String EXTRA_CHANGED_PACKAGE_LIST = 2255 "android.intent.extra.changed_package_list"; 2256 2257 /** 2258 * This field is part of 2259 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 2260 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 2261 * and contains an integer array of uids of all of the components 2262 * that have changed. 2263 */ 2264 public static final String EXTRA_CHANGED_UID_LIST = 2265 "android.intent.extra.changed_uid_list"; 2266 2267 /** 2268 * @hide 2269 * Magic extra system code can use when binding, to give a label for 2270 * who it is that has bound to a service. This is an integer giving 2271 * a framework string resource that can be displayed to the user. 2272 */ 2273 public static final String EXTRA_CLIENT_LABEL = 2274 "android.intent.extra.client_label"; 2275 2276 /** 2277 * @hide 2278 * Magic extra system code can use when binding, to give a PendingIntent object 2279 * that can be launched for the user to disable the system's use of this 2280 * service. 2281 */ 2282 public static final String EXTRA_CLIENT_INTENT = 2283 "android.intent.extra.client_intent"; 2284 2285 // --------------------------------------------------------------------- 2286 // --------------------------------------------------------------------- 2287 // Intent flags (see mFlags variable). 2288 2289 /** 2290 * If set, the recipient of this Intent will be granted permission to 2291 * perform read operations on the Uri in the Intent's data. 2292 */ 2293 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; 2294 /** 2295 * If set, the recipient of this Intent will be granted permission to 2296 * perform write operations on the Uri in the Intent's data. 2297 */ 2298 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; 2299 /** 2300 * Can be set by the caller to indicate that this Intent is coming from 2301 * a background operation, not from direct user interaction. 2302 */ 2303 public static final int FLAG_FROM_BACKGROUND = 0x00000004; 2304 /** 2305 * A flag you can enable for debugging: when set, log messages will be 2306 * printed during the resolution of this intent to show you what has 2307 * been found to create the final resolved list. 2308 */ 2309 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; 2310 2311 /** 2312 * If set, the new activity is not kept in the history stack. As soon as 2313 * the user navigates away from it, the activity is finished. This may also 2314 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory 2315 * noHistory} attribute. 2316 */ 2317 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; 2318 /** 2319 * If set, the activity will not be launched if it is already running 2320 * at the top of the history stack. 2321 */ 2322 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; 2323 /** 2324 * If set, this activity will become the start of a new task on this 2325 * history stack. A task (from the activity that started it to the 2326 * next task activity) defines an atomic group of activities that the 2327 * user can move to. Tasks can be moved to the foreground and background; 2328 * all of the activities inside of a particular task always remain in 2329 * the same order. See 2330 * <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals: 2331 * Activities and Tasks</a> for more details on tasks. 2332 * 2333 * <p>This flag is generally used by activities that want 2334 * to present a "launcher" style behavior: they give the user a list of 2335 * separate things that can be done, which otherwise run completely 2336 * independently of the activity launching them. 2337 * 2338 * <p>When using this flag, if a task is already running for the activity 2339 * you are now starting, then a new activity will not be started; instead, 2340 * the current task will simply be brought to the front of the screen with 2341 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag 2342 * to disable this behavior. 2343 * 2344 * <p>This flag can not be used when the caller is requesting a result from 2345 * the activity being launched. 2346 */ 2347 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; 2348 /** 2349 * <strong>Do not use this flag unless you are implementing your own 2350 * top-level application launcher.</strong> Used in conjunction with 2351 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the 2352 * behavior of bringing an existing task to the foreground. When set, 2353 * a new task is <em>always</em> started to host the Activity for the 2354 * Intent, regardless of whether there is already an existing task running 2355 * the same thing. 2356 * 2357 * <p><strong>Because the default system does not include graphical task management, 2358 * you should not use this flag unless you provide some way for a user to 2359 * return back to the tasks you have launched.</strong> 2360 * 2361 * <p>This flag is ignored if 2362 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set. 2363 * 2364 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals: 2365 * Activities and Tasks</a> for more details on tasks. 2366 */ 2367 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; 2368 /** 2369 * If set, and the activity being launched is already running in the 2370 * current task, then instead of launching a new instance of that activity, 2371 * all of the other activities on top of it will be closed and this Intent 2372 * will be delivered to the (now on top) old activity as a new Intent. 2373 * 2374 * <p>For example, consider a task consisting of the activities: A, B, C, D. 2375 * If D calls startActivity() with an Intent that resolves to the component 2376 * of activity B, then C and D will be finished and B receive the given 2377 * Intent, resulting in the stack now being: A, B. 2378 * 2379 * <p>The currently running instance of activity B in the above example will 2380 * either receive the new intent you are starting here in its 2381 * onNewIntent() method, or be itself finished and restarted with the 2382 * new intent. If it has declared its launch mode to be "multiple" (the 2383 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in 2384 * the same intent, then it will be finished and re-created; for all other 2385 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this 2386 * Intent will be delivered to the current instance's onNewIntent(). 2387 * 2388 * <p>This launch mode can also be used to good effect in conjunction with 2389 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity 2390 * of a task, it will bring any currently running instance of that task 2391 * to the foreground, and then clear it to its root state. This is 2392 * especially useful, for example, when launching an activity from the 2393 * notification manager. 2394 * 2395 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals: 2396 * Activities and Tasks</a> for more details on tasks. 2397 */ 2398 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; 2399 /** 2400 * If set and this intent is being used to launch a new activity from an 2401 * existing one, then the reply target of the existing activity will be 2402 * transfered to the new activity. This way the new activity can call 2403 * {@link android.app.Activity#setResult} and have that result sent back to 2404 * the reply target of the original activity. 2405 */ 2406 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; 2407 /** 2408 * If set and this intent is being used to launch a new activity from an 2409 * existing one, the current activity will not be counted as the top 2410 * activity for deciding whether the new intent should be delivered to 2411 * the top instead of starting a new one. The previous activity will 2412 * be used as the top, with the assumption being that the current activity 2413 * will finish itself immediately. 2414 */ 2415 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; 2416 /** 2417 * If set, the new activity is not kept in the list of recently launched 2418 * activities. 2419 */ 2420 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; 2421 /** 2422 * This flag is not normally set by application code, but set for you by 2423 * the system as described in the 2424 * {@link android.R.styleable#AndroidManifestActivity_launchMode 2425 * launchMode} documentation for the singleTask mode. 2426 */ 2427 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; 2428 /** 2429 * If set, and this activity is either being started in a new task or 2430 * bringing to the top an existing task, then it will be launched as 2431 * the front door of the task. This will result in the application of 2432 * any affinities needed to have that task in the proper state (either 2433 * moving activities to or from it), or simply resetting that task to 2434 * its initial state if needed. 2435 */ 2436 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; 2437 /** 2438 * This flag is not normally set by application code, but set for you by 2439 * the system if this activity is being launched from history 2440 * (longpress home key). 2441 */ 2442 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; 2443 /** 2444 * If set, this marks a point in the task's activity stack that should 2445 * be cleared when the task is reset. That is, the next time the task 2446 * is brought to the foreground with 2447 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of 2448 * the user re-launching it from home), this activity and all on top of 2449 * it will be finished so that the user does not return to them, but 2450 * instead returns to whatever activity preceeded it. 2451 * 2452 * <p>This is useful for cases where you have a logical break in your 2453 * application. For example, an e-mail application may have a command 2454 * to view an attachment, which launches an image view activity to 2455 * display it. This activity should be part of the e-mail application's 2456 * task, since it is a part of the task the user is involved in. However, 2457 * if the user leaves that task, and later selects the e-mail app from 2458 * home, we may like them to return to the conversation they were 2459 * viewing, not the picture attachment, since that is confusing. By 2460 * setting this flag when launching the image viewer, that viewer and 2461 * any activities it starts will be removed the next time the user returns 2462 * to mail. 2463 */ 2464 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; 2465 /** 2466 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} 2467 * callback from occurring on the current frontmost activity before it is 2468 * paused as the newly-started activity is brought to the front. 2469 * 2470 * <p>Typically, an activity can rely on that callback to indicate that an 2471 * explicit user action has caused their activity to be moved out of the 2472 * foreground. The callback marks an appropriate point in the activity's 2473 * lifecycle for it to dismiss any notifications that it intends to display 2474 * "until the user has seen them," such as a blinking LED. 2475 * 2476 * <p>If an activity is ever started via any non-user-driven events such as 2477 * phone-call receipt or an alarm handler, this flag should be passed to {@link 2478 * Context#startActivity Context.startActivity}, ensuring that the pausing 2479 * activity does not think the user has acknowledged its notification. 2480 */ 2481 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; 2482 /** 2483 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 2484 * this flag will cause the launched activity to be brought to the front of its 2485 * task's history stack if it is already running. 2486 * 2487 * <p>For example, consider a task consisting of four activities: A, B, C, D. 2488 * If D calls startActivity() with an Intent that resolves to the component 2489 * of activity B, then B will be brought to the front of the history stack, 2490 * with this resulting order: A, C, D, B. 2491 * 2492 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also 2493 * specified. 2494 */ 2495 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; 2496 /** 2497 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 2498 * this flag will prevent the system from applying an activity transition 2499 * animation to go to the next activity state. This doesn't mean an 2500 * animation will never run -- if another activity change happens that doesn't 2501 * specify this flag before the activity started here is displayed, then 2502 * that transition will be used. This this flag can be put to good use 2503 * when you are going to do a series of activity operations but the 2504 * animation seen by the user shouldn't be driven by the first activity 2505 * change but rather a later one. 2506 */ 2507 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; 2508 /** 2509 * If set, when sending a broadcast only registered receivers will be 2510 * called -- no BroadcastReceiver components will be launched. 2511 */ 2512 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 2513 /** 2514 * If set, when sending a broadcast the new broadcast will replace 2515 * any existing pending broadcast that matches it. Matching is defined 2516 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning 2517 * true for the intents of the two broadcasts. When a match is found, 2518 * the new broadcast (and receivers associated with it) will replace the 2519 * existing one in the pending broadcast list, remaining at the same 2520 * position in the list. 2521 * 2522 * <p>This flag is most typically used with sticky broadcasts, which 2523 * only care about delivering the most recent values of the broadcast 2524 * to their receivers. 2525 */ 2526 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; 2527 /** 2528 * If set, when sending a broadcast <i>before boot has completed</i> only 2529 * registered receivers will be called -- no BroadcastReceiver components 2530 * will be launched. Sticky intent state will be recorded properly even 2531 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} 2532 * is specified in the broadcast intent, this flag is unnecessary. 2533 * 2534 * <p>This flag is only for use by system sevices as a convenience to 2535 * avoid having to implement a more complex mechanism around detection 2536 * of boot completion. 2537 * 2538 * @hide 2539 */ 2540 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000; 2541 /** 2542 * Set when this broadcast is for a boot upgrade, a special mode that 2543 * allows the broadcast to be sent before the system is ready and launches 2544 * the app process with no providers running in it. 2545 * @hide 2546 */ 2547 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000; 2548 2549 /** 2550 * @hide Flags that can't be changed with PendingIntent. 2551 */ 2552 public static final int IMMUTABLE_FLAGS = 2553 FLAG_GRANT_READ_URI_PERMISSION 2554 | FLAG_GRANT_WRITE_URI_PERMISSION; 2555 2556 // --------------------------------------------------------------------- 2557 // --------------------------------------------------------------------- 2558 // toUri() and parseUri() options. 2559 2560 /** 2561 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 2562 * always has the "intent:" scheme. This syntax can be used when you want 2563 * to later disambiguate between URIs that are intended to describe an 2564 * Intent vs. all others that should be treated as raw URIs. When used 2565 * with {@link #parseUri}, any other scheme will result in a generic 2566 * VIEW action for that raw URI. 2567 */ 2568 public static final int URI_INTENT_SCHEME = 1<<0; 2569 2570 // --------------------------------------------------------------------- 2571 2572 private String mAction; 2573 private Uri mData; 2574 private String mType; 2575 private String mPackage; 2576 private ComponentName mComponent; 2577 private int mFlags; 2578 private HashSet<String> mCategories; 2579 private Bundle mExtras; 2580 private Rect mSourceBounds; 2581 2582 // --------------------------------------------------------------------- 2583 2584 /** 2585 * Create an empty intent. 2586 */ 2587 public Intent() { 2588 } 2589 2590 /** 2591 * Copy constructor. 2592 */ 2593 public Intent(Intent o) { 2594 this.mAction = o.mAction; 2595 this.mData = o.mData; 2596 this.mType = o.mType; 2597 this.mPackage = o.mPackage; 2598 this.mComponent = o.mComponent; 2599 this.mFlags = o.mFlags; 2600 if (o.mCategories != null) { 2601 this.mCategories = new HashSet<String>(o.mCategories); 2602 } 2603 if (o.mExtras != null) { 2604 this.mExtras = new Bundle(o.mExtras); 2605 } 2606 if (o.mSourceBounds != null) { 2607 this.mSourceBounds = new Rect(o.mSourceBounds); 2608 } 2609 } 2610 2611 @Override 2612 public Object clone() { 2613 return new Intent(this); 2614 } 2615 2616 private Intent(Intent o, boolean all) { 2617 this.mAction = o.mAction; 2618 this.mData = o.mData; 2619 this.mType = o.mType; 2620 this.mPackage = o.mPackage; 2621 this.mComponent = o.mComponent; 2622 if (o.mCategories != null) { 2623 this.mCategories = new HashSet<String>(o.mCategories); 2624 } 2625 } 2626 2627 /** 2628 * Make a clone of only the parts of the Intent that are relevant for 2629 * filter matching: the action, data, type, component, and categories. 2630 */ 2631 public Intent cloneFilter() { 2632 return new Intent(this, false); 2633 } 2634 2635 /** 2636 * Create an intent with a given action. All other fields (data, type, 2637 * class) are null. Note that the action <em>must</em> be in a 2638 * namespace because Intents are used globally in the system -- for 2639 * example the system VIEW action is android.intent.action.VIEW; an 2640 * application's custom action would be something like 2641 * com.google.app.myapp.CUSTOM_ACTION. 2642 * 2643 * @param action The Intent action, such as ACTION_VIEW. 2644 */ 2645 public Intent(String action) { 2646 mAction = action; 2647 } 2648 2649 /** 2650 * Create an intent with a given action and for a given data url. Note 2651 * that the action <em>must</em> be in a namespace because Intents are 2652 * used globally in the system -- for example the system VIEW action is 2653 * android.intent.action.VIEW; an application's custom action would be 2654 * something like com.google.app.myapp.CUSTOM_ACTION. 2655 * 2656 * <p><em>Note: scheme and host name matching in the Android framework is 2657 * case-sensitive, unlike the formal RFC. As a result, 2658 * you should always ensure that you write your Uri with these elements 2659 * using lower case letters, and normalize any Uris you receive from 2660 * outside of Android to ensure the scheme and host is lower case.</em></p> 2661 * 2662 * @param action The Intent action, such as ACTION_VIEW. 2663 * @param uri The Intent data URI. 2664 */ 2665 public Intent(String action, Uri uri) { 2666 mAction = action; 2667 mData = uri; 2668 } 2669 2670 /** 2671 * Create an intent for a specific component. All other fields (action, data, 2672 * type, class) are null, though they can be modified later with explicit 2673 * calls. This provides a convenient way to create an intent that is 2674 * intended to execute a hard-coded class name, rather than relying on the 2675 * system to find an appropriate class for you; see {@link #setComponent} 2676 * for more information on the repercussions of this. 2677 * 2678 * @param packageContext A Context of the application package implementing 2679 * this class. 2680 * @param cls The component class that is to be used for the intent. 2681 * 2682 * @see #setClass 2683 * @see #setComponent 2684 * @see #Intent(String, android.net.Uri , Context, Class) 2685 */ 2686 public Intent(Context packageContext, Class<?> cls) { 2687 mComponent = new ComponentName(packageContext, cls); 2688 } 2689 2690 /** 2691 * Create an intent for a specific component with a specified action and data. 2692 * This is equivalent using {@link #Intent(String, android.net.Uri)} to 2693 * construct the Intent and then calling {@link #setClass} to set its 2694 * class. 2695 * 2696 * <p><em>Note: scheme and host name matching in the Android framework is 2697 * case-sensitive, unlike the formal RFC. As a result, 2698 * you should always ensure that you write your Uri with these elements 2699 * using lower case letters, and normalize any Uris you receive from 2700 * outside of Android to ensure the scheme and host is lower case.</em></p> 2701 * 2702 * @param action The Intent action, such as ACTION_VIEW. 2703 * @param uri The Intent data URI. 2704 * @param packageContext A Context of the application package implementing 2705 * this class. 2706 * @param cls The component class that is to be used for the intent. 2707 * 2708 * @see #Intent(String, android.net.Uri) 2709 * @see #Intent(Context, Class) 2710 * @see #setClass 2711 * @see #setComponent 2712 */ 2713 public Intent(String action, Uri uri, 2714 Context packageContext, Class<?> cls) { 2715 mAction = action; 2716 mData = uri; 2717 mComponent = new ComponentName(packageContext, cls); 2718 } 2719 2720 /** 2721 * Call {@link #parseUri} with 0 flags. 2722 * @deprecated Use {@link #parseUri} instead. 2723 */ 2724 @Deprecated 2725 public static Intent getIntent(String uri) throws URISyntaxException { 2726 return parseUri(uri, 0); 2727 } 2728 2729 /** 2730 * Create an intent from a URI. This URI may encode the action, 2731 * category, and other intent fields, if it was returned by 2732 * {@link #toUri}. If the Intent was not generate by toUri(), its data 2733 * will be the entire URI and its action will be ACTION_VIEW. 2734 * 2735 * <p>The URI given here must not be relative -- that is, it must include 2736 * the scheme and full path. 2737 * 2738 * @param uri The URI to turn into an Intent. 2739 * @param flags Additional processing flags. Either 0 or 2740 * {@link #URI_INTENT_SCHEME}. 2741 * 2742 * @return Intent The newly created Intent object. 2743 * 2744 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax 2745 * it bad (as parsed by the Uri class) or the Intent data within the 2746 * URI is invalid. 2747 * 2748 * @see #toUri 2749 */ 2750 public static Intent parseUri(String uri, int flags) throws URISyntaxException { 2751 int i = 0; 2752 try { 2753 // Validate intent scheme for if requested. 2754 if ((flags&URI_INTENT_SCHEME) != 0) { 2755 if (!uri.startsWith("intent:")) { 2756 Intent intent = new Intent(ACTION_VIEW); 2757 try { 2758 intent.setData(Uri.parse(uri)); 2759 } catch (IllegalArgumentException e) { 2760 throw new URISyntaxException(uri, e.getMessage()); 2761 } 2762 return intent; 2763 } 2764 } 2765 2766 // simple case 2767 i = uri.lastIndexOf("#"); 2768 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri)); 2769 2770 // old format Intent URI 2771 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri); 2772 2773 // new format 2774 Intent intent = new Intent(ACTION_VIEW); 2775 2776 // fetch data part, if present 2777 String data = i >= 0 ? uri.substring(0, i) : null; 2778 String scheme = null; 2779 i += "#Intent;".length(); 2780 2781 // loop over contents of Intent, all name=value; 2782 while (!uri.startsWith("end", i)) { 2783 int eq = uri.indexOf('=', i); 2784 int semi = uri.indexOf(';', eq); 2785 String value = Uri.decode(uri.substring(eq + 1, semi)); 2786 2787 // action 2788 if (uri.startsWith("action=", i)) { 2789 intent.mAction = value; 2790 } 2791 2792 // categories 2793 else if (uri.startsWith("category=", i)) { 2794 intent.addCategory(value); 2795 } 2796 2797 // type 2798 else if (uri.startsWith("type=", i)) { 2799 intent.mType = value; 2800 } 2801 2802 // launch flags 2803 else if (uri.startsWith("launchFlags=", i)) { 2804 intent.mFlags = Integer.decode(value).intValue(); 2805 } 2806 2807 // package 2808 else if (uri.startsWith("package=", i)) { 2809 intent.mPackage = value; 2810 } 2811 2812 // component 2813 else if (uri.startsWith("component=", i)) { 2814 intent.mComponent = ComponentName.unflattenFromString(value); 2815 } 2816 2817 // scheme 2818 else if (uri.startsWith("scheme=", i)) { 2819 scheme = value; 2820 } 2821 2822 // source bounds 2823 else if (uri.startsWith("sourceBounds=", i)) { 2824 intent.mSourceBounds = Rect.unflattenFromString(value); 2825 } 2826 2827 // extra 2828 else { 2829 String key = Uri.decode(uri.substring(i + 2, eq)); 2830 // create Bundle if it doesn't already exist 2831 if (intent.mExtras == null) intent.mExtras = new Bundle(); 2832 Bundle b = intent.mExtras; 2833 // add EXTRA 2834 if (uri.startsWith("S.", i)) b.putString(key, value); 2835 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); 2836 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); 2837 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); 2838 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); 2839 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); 2840 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); 2841 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); 2842 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); 2843 else throw new URISyntaxException(uri, "unknown EXTRA type", i); 2844 } 2845 2846 // move to the next item 2847 i = semi + 1; 2848 } 2849 2850 if (data != null) { 2851 if (data.startsWith("intent:")) { 2852 data = data.substring(7); 2853 if (scheme != null) { 2854 data = scheme + ':' + data; 2855 } 2856 } 2857 2858 if (data.length() > 0) { 2859 try { 2860 intent.mData = Uri.parse(data); 2861 } catch (IllegalArgumentException e) { 2862 throw new URISyntaxException(uri, e.getMessage()); 2863 } 2864 } 2865 } 2866 2867 return intent; 2868 2869 } catch (IndexOutOfBoundsException e) { 2870 throw new URISyntaxException(uri, "illegal Intent URI format", i); 2871 } 2872 } 2873 2874 public static Intent getIntentOld(String uri) throws URISyntaxException { 2875 Intent intent; 2876 2877 int i = uri.lastIndexOf('#'); 2878 if (i >= 0) { 2879 String action = null; 2880 final int intentFragmentStart = i; 2881 boolean isIntentFragment = false; 2882 2883 i++; 2884 2885 if (uri.regionMatches(i, "action(", 0, 7)) { 2886 isIntentFragment = true; 2887 i += 7; 2888 int j = uri.indexOf(')', i); 2889 action = uri.substring(i, j); 2890 i = j + 1; 2891 } 2892 2893 intent = new Intent(action); 2894 2895 if (uri.regionMatches(i, "categories(", 0, 11)) { 2896 isIntentFragment = true; 2897 i += 11; 2898 int j = uri.indexOf(')', i); 2899 while (i < j) { 2900 int sep = uri.indexOf('!', i); 2901 if (sep < 0) sep = j; 2902 if (i < sep) { 2903 intent.addCategory(uri.substring(i, sep)); 2904 } 2905 i = sep + 1; 2906 } 2907 i = j + 1; 2908 } 2909 2910 if (uri.regionMatches(i, "type(", 0, 5)) { 2911 isIntentFragment = true; 2912 i += 5; 2913 int j = uri.indexOf(')', i); 2914 intent.mType = uri.substring(i, j); 2915 i = j + 1; 2916 } 2917 2918 if (uri.regionMatches(i, "launchFlags(", 0, 12)) { 2919 isIntentFragment = true; 2920 i += 12; 2921 int j = uri.indexOf(')', i); 2922 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); 2923 i = j + 1; 2924 } 2925 2926 if (uri.regionMatches(i, "component(", 0, 10)) { 2927 isIntentFragment = true; 2928 i += 10; 2929 int j = uri.indexOf(')', i); 2930 int sep = uri.indexOf('!', i); 2931 if (sep >= 0 && sep < j) { 2932 String pkg = uri.substring(i, sep); 2933 String cls = uri.substring(sep + 1, j); 2934 intent.mComponent = new ComponentName(pkg, cls); 2935 } 2936 i = j + 1; 2937 } 2938 2939 if (uri.regionMatches(i, "extras(", 0, 7)) { 2940 isIntentFragment = true; 2941 i += 7; 2942 2943 final int closeParen = uri.indexOf(')', i); 2944 if (closeParen == -1) throw new URISyntaxException(uri, 2945 "EXTRA missing trailing ')'", i); 2946 2947 while (i < closeParen) { 2948 // fetch the key value 2949 int j = uri.indexOf('=', i); 2950 if (j <= i + 1 || i >= closeParen) { 2951 throw new URISyntaxException(uri, "EXTRA missing '='", i); 2952 } 2953 char type = uri.charAt(i); 2954 i++; 2955 String key = uri.substring(i, j); 2956 i = j + 1; 2957 2958 // get type-value 2959 j = uri.indexOf('!', i); 2960 if (j == -1 || j >= closeParen) j = closeParen; 2961 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); 2962 String value = uri.substring(i, j); 2963 i = j; 2964 2965 // create Bundle if it doesn't already exist 2966 if (intent.mExtras == null) intent.mExtras = new Bundle(); 2967 2968 // add item to bundle 2969 try { 2970 switch (type) { 2971 case 'S': 2972 intent.mExtras.putString(key, Uri.decode(value)); 2973 break; 2974 case 'B': 2975 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); 2976 break; 2977 case 'b': 2978 intent.mExtras.putByte(key, Byte.parseByte(value)); 2979 break; 2980 case 'c': 2981 intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); 2982 break; 2983 case 'd': 2984 intent.mExtras.putDouble(key, Double.parseDouble(value)); 2985 break; 2986 case 'f': 2987 intent.mExtras.putFloat(key, Float.parseFloat(value)); 2988 break; 2989 case 'i': 2990 intent.mExtras.putInt(key, Integer.parseInt(value)); 2991 break; 2992 case 'l': 2993 intent.mExtras.putLong(key, Long.parseLong(value)); 2994 break; 2995 case 's': 2996 intent.mExtras.putShort(key, Short.parseShort(value)); 2997 break; 2998 default: 2999 throw new URISyntaxException(uri, "EXTRA has unknown type", i); 3000 } 3001 } catch (NumberFormatException e) { 3002 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); 3003 } 3004 3005 char ch = uri.charAt(i); 3006 if (ch == ')') break; 3007 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); 3008 i++; 3009 } 3010 } 3011 3012 if (isIntentFragment) { 3013 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); 3014 } else { 3015 intent.mData = Uri.parse(uri); 3016 } 3017 3018 if (intent.mAction == null) { 3019 // By default, if no action is specified, then use VIEW. 3020 intent.mAction = ACTION_VIEW; 3021 } 3022 3023 } else { 3024 intent = new Intent(ACTION_VIEW, Uri.parse(uri)); 3025 } 3026 3027 return intent; 3028 } 3029 3030 /** 3031 * Retrieve the general action to be performed, such as 3032 * {@link #ACTION_VIEW}. The action describes the general way the rest of 3033 * the information in the intent should be interpreted -- most importantly, 3034 * what to do with the data returned by {@link #getData}. 3035 * 3036 * @return The action of this intent or null if none is specified. 3037 * 3038 * @see #setAction 3039 */ 3040 public String getAction() { 3041 return mAction; 3042 } 3043 3044 /** 3045 * Retrieve data this intent is operating on. This URI specifies the name 3046 * of the data; often it uses the content: scheme, specifying data in a 3047 * content provider. Other schemes may be handled by specific activities, 3048 * such as http: by the web browser. 3049 * 3050 * @return The URI of the data this intent is targeting or null. 3051 * 3052 * @see #getScheme 3053 * @see #setData 3054 */ 3055 public Uri getData() { 3056 return mData; 3057 } 3058 3059 /** 3060 * The same as {@link #getData()}, but returns the URI as an encoded 3061 * String. 3062 */ 3063 public String getDataString() { 3064 return mData != null ? mData.toString() : null; 3065 } 3066 3067 /** 3068 * Return the scheme portion of the intent's data. If the data is null or 3069 * does not include a scheme, null is returned. Otherwise, the scheme 3070 * prefix without the final ':' is returned, i.e. "http". 3071 * 3072 * <p>This is the same as calling getData().getScheme() (and checking for 3073 * null data). 3074 * 3075 * @return The scheme of this intent. 3076 * 3077 * @see #getData 3078 */ 3079 public String getScheme() { 3080 return mData != null ? mData.getScheme() : null; 3081 } 3082 3083 /** 3084 * Retrieve any explicit MIME type included in the intent. This is usually 3085 * null, as the type is determined by the intent data. 3086 * 3087 * @return If a type was manually set, it is returned; else null is 3088 * returned. 3089 * 3090 * @see #resolveType(ContentResolver) 3091 * @see #setType 3092 */ 3093 public String getType() { 3094 return mType; 3095 } 3096 3097 /** 3098 * Return the MIME data type of this intent. If the type field is 3099 * explicitly set, that is simply returned. Otherwise, if the data is set, 3100 * the type of that data is returned. If neither fields are set, a null is 3101 * returned. 3102 * 3103 * @return The MIME type of this intent. 3104 * 3105 * @see #getType 3106 * @see #resolveType(ContentResolver) 3107 */ 3108 public String resolveType(Context context) { 3109 return resolveType(context.getContentResolver()); 3110 } 3111 3112 /** 3113 * Return the MIME data type of this intent. If the type field is 3114 * explicitly set, that is simply returned. Otherwise, if the data is set, 3115 * the type of that data is returned. If neither fields are set, a null is 3116 * returned. 3117 * 3118 * @param resolver A ContentResolver that can be used to determine the MIME 3119 * type of the intent's data. 3120 * 3121 * @return The MIME type of this intent. 3122 * 3123 * @see #getType 3124 * @see #resolveType(Context) 3125 */ 3126 public String resolveType(ContentResolver resolver) { 3127 if (mType != null) { 3128 return mType; 3129 } 3130 if (mData != null) { 3131 if ("content".equals(mData.getScheme())) { 3132 return resolver.getType(mData); 3133 } 3134 } 3135 return null; 3136 } 3137 3138 /** 3139 * Return the MIME data type of this intent, only if it will be needed for 3140 * intent resolution. This is not generally useful for application code; 3141 * it is used by the frameworks for communicating with back-end system 3142 * services. 3143 * 3144 * @param resolver A ContentResolver that can be used to determine the MIME 3145 * type of the intent's data. 3146 * 3147 * @return The MIME type of this intent, or null if it is unknown or not 3148 * needed. 3149 */ 3150 public String resolveTypeIfNeeded(ContentResolver resolver) { 3151 if (mComponent != null) { 3152 return mType; 3153 } 3154 return resolveType(resolver); 3155 } 3156 3157 /** 3158 * Check if an category exists in the intent. 3159 * 3160 * @param category The category to check. 3161 * 3162 * @return boolean True if the intent contains the category, else false. 3163 * 3164 * @see #getCategories 3165 * @see #addCategory 3166 */ 3167 public boolean hasCategory(String category) { 3168 return mCategories != null && mCategories.contains(category); 3169 } 3170 3171 /** 3172 * Return the set of all categories in the intent. If there are no categories, 3173 * returns NULL. 3174 * 3175 * @return Set The set of categories you can examine. Do not modify! 3176 * 3177 * @see #hasCategory 3178 * @see #addCategory 3179 */ 3180 public Set<String> getCategories() { 3181 return mCategories; 3182 } 3183 3184 /** 3185 * Sets the ClassLoader that will be used when unmarshalling 3186 * any Parcelable values from the extras of this Intent. 3187 * 3188 * @param loader a ClassLoader, or null to use the default loader 3189 * at the time of unmarshalling. 3190 */ 3191 public void setExtrasClassLoader(ClassLoader loader) { 3192 if (mExtras != null) { 3193 mExtras.setClassLoader(loader); 3194 } 3195 } 3196 3197 /** 3198 * Returns true if an extra value is associated with the given name. 3199 * @param name the extra's name 3200 * @return true if the given extra is present. 3201 */ 3202 public boolean hasExtra(String name) { 3203 return mExtras != null && mExtras.containsKey(name); 3204 } 3205 3206 /** 3207 * Returns true if the Intent's extras contain a parcelled file descriptor. 3208 * @return true if the Intent contains a parcelled file descriptor. 3209 */ 3210 public boolean hasFileDescriptors() { 3211 return mExtras != null && mExtras.hasFileDescriptors(); 3212 } 3213 3214 /** 3215 * Retrieve extended data from the intent. 3216 * 3217 * @param name The name of the desired item. 3218 * 3219 * @return the value of an item that previously added with putExtra() 3220 * or null if none was found. 3221 * 3222 * @deprecated 3223 * @hide 3224 */ 3225 @Deprecated 3226 public Object getExtra(String name) { 3227 return getExtra(name, null); 3228 } 3229 3230 /** 3231 * Retrieve extended data from the intent. 3232 * 3233 * @param name The name of the desired item. 3234 * @param defaultValue the value to be returned if no value of the desired 3235 * type is stored with the given name. 3236 * 3237 * @return the value of an item that previously added with putExtra() 3238 * or the default value if none was found. 3239 * 3240 * @see #putExtra(String, boolean) 3241 */ 3242 public boolean getBooleanExtra(String name, boolean defaultValue) { 3243 return mExtras == null ? defaultValue : 3244 mExtras.getBoolean(name, defaultValue); 3245 } 3246 3247 /** 3248 * Retrieve extended data from the intent. 3249 * 3250 * @param name The name of the desired item. 3251 * @param defaultValue the value to be returned if no value of the desired 3252 * type is stored with the given name. 3253 * 3254 * @return the value of an item that previously added with putExtra() 3255 * or the default value if none was found. 3256 * 3257 * @see #putExtra(String, byte) 3258 */ 3259 public byte getByteExtra(String name, byte defaultValue) { 3260 return mExtras == null ? defaultValue : 3261 mExtras.getByte(name, defaultValue); 3262 } 3263 3264 /** 3265 * Retrieve extended data from the intent. 3266 * 3267 * @param name The name of the desired item. 3268 * @param defaultValue the value to be returned if no value of the desired 3269 * type is stored with the given name. 3270 * 3271 * @return the value of an item that previously added with putExtra() 3272 * or the default value if none was found. 3273 * 3274 * @see #putExtra(String, short) 3275 */ 3276 public short getShortExtra(String name, short defaultValue) { 3277 return mExtras == null ? defaultValue : 3278 mExtras.getShort(name, defaultValue); 3279 } 3280 3281 /** 3282 * Retrieve extended data from the intent. 3283 * 3284 * @param name The name of the desired item. 3285 * @param defaultValue the value to be returned if no value of the desired 3286 * type is stored with the given name. 3287 * 3288 * @return the value of an item that previously added with putExtra() 3289 * or the default value if none was found. 3290 * 3291 * @see #putExtra(String, char) 3292 */ 3293 public char getCharExtra(String name, char defaultValue) { 3294 return mExtras == null ? defaultValue : 3295 mExtras.getChar(name, defaultValue); 3296 } 3297 3298 /** 3299 * Retrieve extended data from the intent. 3300 * 3301 * @param name The name of the desired item. 3302 * @param defaultValue the value to be returned if no value of the desired 3303 * type is stored with the given name. 3304 * 3305 * @return the value of an item that previously added with putExtra() 3306 * or the default value if none was found. 3307 * 3308 * @see #putExtra(String, int) 3309 */ 3310 public int getIntExtra(String name, int defaultValue) { 3311 return mExtras == null ? defaultValue : 3312 mExtras.getInt(name, defaultValue); 3313 } 3314 3315 /** 3316 * Retrieve extended data from the intent. 3317 * 3318 * @param name The name of the desired item. 3319 * @param defaultValue the value to be returned if no value of the desired 3320 * type is stored with the given name. 3321 * 3322 * @return the value of an item that previously added with putExtra() 3323 * or the default value if none was found. 3324 * 3325 * @see #putExtra(String, long) 3326 */ 3327 public long getLongExtra(String name, long defaultValue) { 3328 return mExtras == null ? defaultValue : 3329 mExtras.getLong(name, defaultValue); 3330 } 3331 3332 /** 3333 * Retrieve extended data from the intent. 3334 * 3335 * @param name The name of the desired item. 3336 * @param defaultValue the value to be returned if no value of the desired 3337 * type is stored with the given name. 3338 * 3339 * @return the value of an item that previously added with putExtra(), 3340 * or the default value if no such item is present 3341 * 3342 * @see #putExtra(String, float) 3343 */ 3344 public float getFloatExtra(String name, float defaultValue) { 3345 return mExtras == null ? defaultValue : 3346 mExtras.getFloat(name, defaultValue); 3347 } 3348 3349 /** 3350 * Retrieve extended data from the intent. 3351 * 3352 * @param name The name of the desired item. 3353 * @param defaultValue the value to be returned if no value of the desired 3354 * type is stored with the given name. 3355 * 3356 * @return the value of an item that previously added with putExtra() 3357 * or the default value if none was found. 3358 * 3359 * @see #putExtra(String, double) 3360 */ 3361 public double getDoubleExtra(String name, double defaultValue) { 3362 return mExtras == null ? defaultValue : 3363 mExtras.getDouble(name, defaultValue); 3364 } 3365 3366 /** 3367 * Retrieve extended data from the intent. 3368 * 3369 * @param name The name of the desired item. 3370 * 3371 * @return the value of an item that previously added with putExtra() 3372 * or null if no String value was found. 3373 * 3374 * @see #putExtra(String, String) 3375 */ 3376 public String getStringExtra(String name) { 3377 return mExtras == null ? null : mExtras.getString(name); 3378 } 3379 3380 /** 3381 * Retrieve extended data from the intent. 3382 * 3383 * @param name The name of the desired item. 3384 * 3385 * @return the value of an item that previously added with putExtra() 3386 * or null if no CharSequence value was found. 3387 * 3388 * @see #putExtra(String, CharSequence) 3389 */ 3390 public CharSequence getCharSequenceExtra(String name) { 3391 return mExtras == null ? null : mExtras.getCharSequence(name); 3392 } 3393 3394 /** 3395 * Retrieve extended data from the intent. 3396 * 3397 * @param name The name of the desired item. 3398 * 3399 * @return the value of an item that previously added with putExtra() 3400 * or null if no Parcelable value was found. 3401 * 3402 * @see #putExtra(String, Parcelable) 3403 */ 3404 public <T extends Parcelable> T getParcelableExtra(String name) { 3405 return mExtras == null ? null : mExtras.<T>getParcelable(name); 3406 } 3407 3408 /** 3409 * Retrieve extended data from the intent. 3410 * 3411 * @param name The name of the desired item. 3412 * 3413 * @return the value of an item that previously added with putExtra() 3414 * or null if no Parcelable[] value was found. 3415 * 3416 * @see #putExtra(String, Parcelable[]) 3417 */ 3418 public Parcelable[] getParcelableArrayExtra(String name) { 3419 return mExtras == null ? null : mExtras.getParcelableArray(name); 3420 } 3421 3422 /** 3423 * Retrieve extended data from the intent. 3424 * 3425 * @param name The name of the desired item. 3426 * 3427 * @return the value of an item that previously added with putExtra() 3428 * or null if no ArrayList<Parcelable> value was found. 3429 * 3430 * @see #putParcelableArrayListExtra(String, ArrayList) 3431 */ 3432 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { 3433 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); 3434 } 3435 3436 /** 3437 * Retrieve extended data from the intent. 3438 * 3439 * @param name The name of the desired item. 3440 * 3441 * @return the value of an item that previously added with putExtra() 3442 * or null if no Serializable value was found. 3443 * 3444 * @see #putExtra(String, Serializable) 3445 */ 3446 public Serializable getSerializableExtra(String name) { 3447 return mExtras == null ? null : mExtras.getSerializable(name); 3448 } 3449 3450 /** 3451 * Retrieve extended data from the intent. 3452 * 3453 * @param name The name of the desired item. 3454 * 3455 * @return the value of an item that previously added with putExtra() 3456 * or null if no ArrayList<Integer> value was found. 3457 * 3458 * @see #putIntegerArrayListExtra(String, ArrayList) 3459 */ 3460 public ArrayList<Integer> getIntegerArrayListExtra(String name) { 3461 return mExtras == null ? null : mExtras.getIntegerArrayList(name); 3462 } 3463 3464 /** 3465 * Retrieve extended data from the intent. 3466 * 3467 * @param name The name of the desired item. 3468 * 3469 * @return the value of an item that previously added with putExtra() 3470 * or null if no ArrayList<String> value was found. 3471 * 3472 * @see #putStringArrayListExtra(String, ArrayList) 3473 */ 3474 public ArrayList<String> getStringArrayListExtra(String name) { 3475 return mExtras == null ? null : mExtras.getStringArrayList(name); 3476 } 3477 3478 /** 3479 * Retrieve extended data from the intent. 3480 * 3481 * @param name The name of the desired item. 3482 * 3483 * @return the value of an item that previously added with putExtra() 3484 * or null if no ArrayList<CharSequence> value was found. 3485 * 3486 * @see #putCharSequenceArrayListExtra(String, ArrayList) 3487 */ 3488 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { 3489 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); 3490 } 3491 3492 /** 3493 * Retrieve extended data from the intent. 3494 * 3495 * @param name The name of the desired item. 3496 * 3497 * @return the value of an item that previously added with putExtra() 3498 * or null if no boolean array value was found. 3499 * 3500 * @see #putExtra(String, boolean[]) 3501 */ 3502 public boolean[] getBooleanArrayExtra(String name) { 3503 return mExtras == null ? null : mExtras.getBooleanArray(name); 3504 } 3505 3506 /** 3507 * Retrieve extended data from the intent. 3508 * 3509 * @param name The name of the desired item. 3510 * 3511 * @return the value of an item that previously added with putExtra() 3512 * or null if no byte array value was found. 3513 * 3514 * @see #putExtra(String, byte[]) 3515 */ 3516 public byte[] getByteArrayExtra(String name) { 3517 return mExtras == null ? null : mExtras.getByteArray(name); 3518 } 3519 3520 /** 3521 * Retrieve extended data from the intent. 3522 * 3523 * @param name The name of the desired item. 3524 * 3525 * @return the value of an item that previously added with putExtra() 3526 * or null if no short array value was found. 3527 * 3528 * @see #putExtra(String, short[]) 3529 */ 3530 public short[] getShortArrayExtra(String name) { 3531 return mExtras == null ? null : mExtras.getShortArray(name); 3532 } 3533 3534 /** 3535 * Retrieve extended data from the intent. 3536 * 3537 * @param name The name of the desired item. 3538 * 3539 * @return the value of an item that previously added with putExtra() 3540 * or null if no char array value was found. 3541 * 3542 * @see #putExtra(String, char[]) 3543 */ 3544 public char[] getCharArrayExtra(String name) { 3545 return mExtras == null ? null : mExtras.getCharArray(name); 3546 } 3547 3548 /** 3549 * Retrieve extended data from the intent. 3550 * 3551 * @param name The name of the desired item. 3552 * 3553 * @return the value of an item that previously added with putExtra() 3554 * or null if no int array value was found. 3555 * 3556 * @see #putExtra(String, int[]) 3557 */ 3558 public int[] getIntArrayExtra(String name) { 3559 return mExtras == null ? null : mExtras.getIntArray(name); 3560 } 3561 3562 /** 3563 * Retrieve extended data from the intent. 3564 * 3565 * @param name The name of the desired item. 3566 * 3567 * @return the value of an item that previously added with putExtra() 3568 * or null if no long array value was found. 3569 * 3570 * @see #putExtra(String, long[]) 3571 */ 3572 public long[] getLongArrayExtra(String name) { 3573 return mExtras == null ? null : mExtras.getLongArray(name); 3574 } 3575 3576 /** 3577 * Retrieve extended data from the intent. 3578 * 3579 * @param name The name of the desired item. 3580 * 3581 * @return the value of an item that previously added with putExtra() 3582 * or null if no float array value was found. 3583 * 3584 * @see #putExtra(String, float[]) 3585 */ 3586 public float[] getFloatArrayExtra(String name) { 3587 return mExtras == null ? null : mExtras.getFloatArray(name); 3588 } 3589 3590 /** 3591 * Retrieve extended data from the intent. 3592 * 3593 * @param name The name of the desired item. 3594 * 3595 * @return the value of an item that previously added with putExtra() 3596 * or null if no double array value was found. 3597 * 3598 * @see #putExtra(String, double[]) 3599 */ 3600 public double[] getDoubleArrayExtra(String name) { 3601 return mExtras == null ? null : mExtras.getDoubleArray(name); 3602 } 3603 3604 /** 3605 * Retrieve extended data from the intent. 3606 * 3607 * @param name The name of the desired item. 3608 * 3609 * @return the value of an item that previously added with putExtra() 3610 * or null if no String array value was found. 3611 * 3612 * @see #putExtra(String, String[]) 3613 */ 3614 public String[] getStringArrayExtra(String name) { 3615 return mExtras == null ? null : mExtras.getStringArray(name); 3616 } 3617 3618 /** 3619 * Retrieve extended data from the intent. 3620 * 3621 * @param name The name of the desired item. 3622 * 3623 * @return the value of an item that previously added with putExtra() 3624 * or null if no CharSequence array value was found. 3625 * 3626 * @see #putExtra(String, CharSequence[]) 3627 */ 3628 public CharSequence[] getCharSequenceArrayExtra(String name) { 3629 return mExtras == null ? null : mExtras.getCharSequenceArray(name); 3630 } 3631 3632 /** 3633 * Retrieve extended data from the intent. 3634 * 3635 * @param name The name of the desired item. 3636 * 3637 * @return the value of an item that previously added with putExtra() 3638 * or null if no Bundle value was found. 3639 * 3640 * @see #putExtra(String, Bundle) 3641 */ 3642 public Bundle getBundleExtra(String name) { 3643 return mExtras == null ? null : mExtras.getBundle(name); 3644 } 3645 3646 /** 3647 * Retrieve extended data from the intent. 3648 * 3649 * @param name The name of the desired item. 3650 * 3651 * @return the value of an item that previously added with putExtra() 3652 * or null if no IBinder value was found. 3653 * 3654 * @see #putExtra(String, IBinder) 3655 * 3656 * @deprecated 3657 * @hide 3658 */ 3659 @Deprecated 3660 public IBinder getIBinderExtra(String name) { 3661 return mExtras == null ? null : mExtras.getIBinder(name); 3662 } 3663 3664 /** 3665 * Retrieve extended data from the intent. 3666 * 3667 * @param name The name of the desired item. 3668 * @param defaultValue The default value to return in case no item is 3669 * associated with the key 'name' 3670 * 3671 * @return the value of an item that previously added with putExtra() 3672 * or defaultValue if none was found. 3673 * 3674 * @see #putExtra 3675 * 3676 * @deprecated 3677 * @hide 3678 */ 3679 @Deprecated 3680 public Object getExtra(String name, Object defaultValue) { 3681 Object result = defaultValue; 3682 if (mExtras != null) { 3683 Object result2 = mExtras.get(name); 3684 if (result2 != null) { 3685 result = result2; 3686 } 3687 } 3688 3689 return result; 3690 } 3691 3692 /** 3693 * Retrieves a map of extended data from the intent. 3694 * 3695 * @return the map of all extras previously added with putExtra(), 3696 * or null if none have been added. 3697 */ 3698 public Bundle getExtras() { 3699 return (mExtras != null) 3700 ? new Bundle(mExtras) 3701 : null; 3702 } 3703 3704 /** 3705 * Retrieve any special flags associated with this intent. You will 3706 * normally just set them with {@link #setFlags} and let the system 3707 * take the appropriate action with them. 3708 * 3709 * @return int The currently set flags. 3710 * 3711 * @see #setFlags 3712 */ 3713 public int getFlags() { 3714 return mFlags; 3715 } 3716 3717 /** 3718 * Retrieve the application package name this Intent is limited to. When 3719 * resolving an Intent, if non-null this limits the resolution to only 3720 * components in the given application package. 3721 * 3722 * @return The name of the application package for the Intent. 3723 * 3724 * @see #resolveActivity 3725 * @see #setPackage 3726 */ 3727 public String getPackage() { 3728 return mPackage; 3729 } 3730 3731 /** 3732 * Retrieve the concrete component associated with the intent. When receiving 3733 * an intent, this is the component that was found to best handle it (that is, 3734 * yourself) and will always be non-null; in all other cases it will be 3735 * null unless explicitly set. 3736 * 3737 * @return The name of the application component to handle the intent. 3738 * 3739 * @see #resolveActivity 3740 * @see #setComponent 3741 */ 3742 public ComponentName getComponent() { 3743 return mComponent; 3744 } 3745 3746 /** 3747 * Get the bounds of the sender of this intent, in screen coordinates. This can be 3748 * used as a hint to the receiver for animations and the like. Null means that there 3749 * is no source bounds. 3750 */ 3751 public Rect getSourceBounds() { 3752 return mSourceBounds; 3753 } 3754 3755 /** 3756 * Return the Activity component that should be used to handle this intent. 3757 * The appropriate component is determined based on the information in the 3758 * intent, evaluated as follows: 3759 * 3760 * <p>If {@link #getComponent} returns an explicit class, that is returned 3761 * without any further consideration. 3762 * 3763 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent 3764 * category to be considered. 3765 * 3766 * <p>If {@link #getAction} is non-NULL, the activity must handle this 3767 * action. 3768 * 3769 * <p>If {@link #resolveType} returns non-NULL, the activity must handle 3770 * this type. 3771 * 3772 * <p>If {@link #addCategory} has added any categories, the activity must 3773 * handle ALL of the categories specified. 3774 * 3775 * <p>If {@link #getPackage} is non-NULL, only activity components in 3776 * that application package will be considered. 3777 * 3778 * <p>If there are no activities that satisfy all of these conditions, a 3779 * null string is returned. 3780 * 3781 * <p>If multiple activities are found to satisfy the intent, the one with 3782 * the highest priority will be used. If there are multiple activities 3783 * with the same priority, the system will either pick the best activity 3784 * based on user preference, or resolve to a system class that will allow 3785 * the user to pick an activity and forward from there. 3786 * 3787 * <p>This method is implemented simply by calling 3788 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter 3789 * true.</p> 3790 * <p> This API is called for you as part of starting an activity from an 3791 * intent. You do not normally need to call it yourself.</p> 3792 * 3793 * @param pm The package manager with which to resolve the Intent. 3794 * 3795 * @return Name of the component implementing an activity that can 3796 * display the intent. 3797 * 3798 * @see #setComponent 3799 * @see #getComponent 3800 * @see #resolveActivityInfo 3801 */ 3802 public ComponentName resolveActivity(PackageManager pm) { 3803 if (mComponent != null) { 3804 return mComponent; 3805 } 3806 3807 ResolveInfo info = pm.resolveActivity( 3808 this, PackageManager.MATCH_DEFAULT_ONLY); 3809 if (info != null) { 3810 return new ComponentName( 3811 info.activityInfo.applicationInfo.packageName, 3812 info.activityInfo.name); 3813 } 3814 3815 return null; 3816 } 3817 3818 /** 3819 * Resolve the Intent into an {@link ActivityInfo} 3820 * describing the activity that should execute the intent. Resolution 3821 * follows the same rules as described for {@link #resolveActivity}, but 3822 * you get back the completely information about the resolved activity 3823 * instead of just its class name. 3824 * 3825 * @param pm The package manager with which to resolve the Intent. 3826 * @param flags Addition information to retrieve as per 3827 * {@link PackageManager#getActivityInfo(ComponentName, int) 3828 * PackageManager.getActivityInfo()}. 3829 * 3830 * @return PackageManager.ActivityInfo 3831 * 3832 * @see #resolveActivity 3833 */ 3834 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) { 3835 ActivityInfo ai = null; 3836 if (mComponent != null) { 3837 try { 3838 ai = pm.getActivityInfo(mComponent, flags); 3839 } catch (PackageManager.NameNotFoundException e) { 3840 // ignore 3841 } 3842 } else { 3843 ResolveInfo info = pm.resolveActivity( 3844 this, PackageManager.MATCH_DEFAULT_ONLY | flags); 3845 if (info != null) { 3846 ai = info.activityInfo; 3847 } 3848 } 3849 3850 return ai; 3851 } 3852 3853 /** 3854 * Set the general action to be performed. 3855 * 3856 * @param action An action name, such as ACTION_VIEW. Application-specific 3857 * actions should be prefixed with the vendor's package name. 3858 * 3859 * @return Returns the same Intent object, for chaining multiple calls 3860 * into a single statement. 3861 * 3862 * @see #getAction 3863 */ 3864 public Intent setAction(String action) { 3865 mAction = action; 3866 return this; 3867 } 3868 3869 /** 3870 * Set the data this intent is operating on. This method automatically 3871 * clears any type that was previously set by {@link #setType}. 3872 * 3873 * <p><em>Note: scheme and host name matching in the Android framework is 3874 * case-sensitive, unlike the formal RFC. As a result, 3875 * you should always ensure that you write your Uri with these elements 3876 * using lower case letters, and normalize any Uris you receive from 3877 * outside of Android to ensure the scheme and host is lower case.</em></p> 3878 * 3879 * @param data The URI of the data this intent is now targeting. 3880 * 3881 * @return Returns the same Intent object, for chaining multiple calls 3882 * into a single statement. 3883 * 3884 * @see #getData 3885 * @see #setType 3886 * @see #setDataAndType 3887 */ 3888 public Intent setData(Uri data) { 3889 mData = data; 3890 mType = null; 3891 return this; 3892 } 3893 3894 /** 3895 * Set an explicit MIME data type. This is used to create intents that 3896 * only specify a type and not data, for example to indicate the type of 3897 * data to return. This method automatically clears any data that was 3898 * previously set by {@link #setData}. 3899 * 3900 * <p><em>Note: MIME type matching in the Android framework is 3901 * case-sensitive, unlike formal RFC MIME types. As a result, 3902 * you should always write your MIME types with lower case letters, 3903 * and any MIME types you receive from outside of Android should be 3904 * converted to lower case before supplying them here.</em></p> 3905 * 3906 * @param type The MIME type of the data being handled by this intent. 3907 * 3908 * @return Returns the same Intent object, for chaining multiple calls 3909 * into a single statement. 3910 * 3911 * @see #getType 3912 * @see #setData 3913 * @see #setDataAndType 3914 */ 3915 public Intent setType(String type) { 3916 mData = null; 3917 mType = type; 3918 return this; 3919 } 3920 3921 /** 3922 * (Usually optional) Set the data for the intent along with an explicit 3923 * MIME data type. This method should very rarely be used -- it allows you 3924 * to override the MIME type that would ordinarily be inferred from the 3925 * data with your own type given here. 3926 * 3927 * <p><em>Note: MIME type, Uri scheme, and host name matching in the 3928 * Android framework is case-sensitive, unlike the formal RFC definitions. 3929 * As a result, you should always write these elements with lower case letters, 3930 * and normalize any MIME types or Uris you receive from 3931 * outside of Android to ensure these elements are lower case before 3932 * supplying them here.</em></p> 3933 * 3934 * @param data The URI of the data this intent is now targeting. 3935 * @param type The MIME type of the data being handled by this intent. 3936 * 3937 * @return Returns the same Intent object, for chaining multiple calls 3938 * into a single statement. 3939 * 3940 * @see #setData 3941 * @see #setType 3942 */ 3943 public Intent setDataAndType(Uri data, String type) { 3944 mData = data; 3945 mType = type; 3946 return this; 3947 } 3948 3949 /** 3950 * Add a new category to the intent. Categories provide additional detail 3951 * about the action the intent is perform. When resolving an intent, only 3952 * activities that provide <em>all</em> of the requested categories will be 3953 * used. 3954 * 3955 * @param category The desired category. This can be either one of the 3956 * predefined Intent categories, or a custom category in your own 3957 * namespace. 3958 * 3959 * @return Returns the same Intent object, for chaining multiple calls 3960 * into a single statement. 3961 * 3962 * @see #hasCategory 3963 * @see #removeCategory 3964 */ 3965 public Intent addCategory(String category) { 3966 if (mCategories == null) { 3967 mCategories = new HashSet<String>(); 3968 } 3969 mCategories.add(category); 3970 return this; 3971 } 3972 3973 /** 3974 * Remove an category from an intent. 3975 * 3976 * @param category The category to remove. 3977 * 3978 * @see #addCategory 3979 */ 3980 public void removeCategory(String category) { 3981 if (mCategories != null) { 3982 mCategories.remove(category); 3983 if (mCategories.size() == 0) { 3984 mCategories = null; 3985 } 3986 } 3987 } 3988 3989 /** 3990 * Add extended data to the intent. The name must include a package 3991 * prefix, for example the app com.android.contacts would use names 3992 * like "com.android.contacts.ShowAll". 3993 * 3994 * @param name The name of the extra data, with package prefix. 3995 * @param value The boolean data value. 3996 * 3997 * @return Returns the same Intent object, for chaining multiple calls 3998 * into a single statement. 3999 * 4000 * @see #putExtras 4001 * @see #removeExtra 4002 * @see #getBooleanExtra(String, boolean) 4003 */ 4004 public Intent putExtra(String name, boolean value) { 4005 if (mExtras == null) { 4006 mExtras = new Bundle(); 4007 } 4008 mExtras.putBoolean(name, value); 4009 return this; 4010 } 4011 4012 /** 4013 * Add extended data to the intent. The name must include a package 4014 * prefix, for example the app com.android.contacts would use names 4015 * like "com.android.contacts.ShowAll". 4016 * 4017 * @param name The name of the extra data, with package prefix. 4018 * @param value The byte data value. 4019 * 4020 * @return Returns the same Intent object, for chaining multiple calls 4021 * into a single statement. 4022 * 4023 * @see #putExtras 4024 * @see #removeExtra 4025 * @see #getByteExtra(String, byte) 4026 */ 4027 public Intent putExtra(String name, byte value) { 4028 if (mExtras == null) { 4029 mExtras = new Bundle(); 4030 } 4031 mExtras.putByte(name, value); 4032 return this; 4033 } 4034 4035 /** 4036 * Add extended data to the intent. The name must include a package 4037 * prefix, for example the app com.android.contacts would use names 4038 * like "com.android.contacts.ShowAll". 4039 * 4040 * @param name The name of the extra data, with package prefix. 4041 * @param value The char data value. 4042 * 4043 * @return Returns the same Intent object, for chaining multiple calls 4044 * into a single statement. 4045 * 4046 * @see #putExtras 4047 * @see #removeExtra 4048 * @see #getCharExtra(String, char) 4049 */ 4050 public Intent putExtra(String name, char value) { 4051 if (mExtras == null) { 4052 mExtras = new Bundle(); 4053 } 4054 mExtras.putChar(name, value); 4055 return this; 4056 } 4057 4058 /** 4059 * Add extended data to the intent. The name must include a package 4060 * prefix, for example the app com.android.contacts would use names 4061 * like "com.android.contacts.ShowAll". 4062 * 4063 * @param name The name of the extra data, with package prefix. 4064 * @param value The short data value. 4065 * 4066 * @return Returns the same Intent object, for chaining multiple calls 4067 * into a single statement. 4068 * 4069 * @see #putExtras 4070 * @see #removeExtra 4071 * @see #getShortExtra(String, short) 4072 */ 4073 public Intent putExtra(String name, short value) { 4074 if (mExtras == null) { 4075 mExtras = new Bundle(); 4076 } 4077 mExtras.putShort(name, value); 4078 return this; 4079 } 4080 4081 /** 4082 * Add extended data to the intent. The name must include a package 4083 * prefix, for example the app com.android.contacts would use names 4084 * like "com.android.contacts.ShowAll". 4085 * 4086 * @param name The name of the extra data, with package prefix. 4087 * @param value The integer data value. 4088 * 4089 * @return Returns the same Intent object, for chaining multiple calls 4090 * into a single statement. 4091 * 4092 * @see #putExtras 4093 * @see #removeExtra 4094 * @see #getIntExtra(String, int) 4095 */ 4096 public Intent putExtra(String name, int value) { 4097 if (mExtras == null) { 4098 mExtras = new Bundle(); 4099 } 4100 mExtras.putInt(name, value); 4101 return this; 4102 } 4103 4104 /** 4105 * Add extended data to the intent. The name must include a package 4106 * prefix, for example the app com.android.contacts would use names 4107 * like "com.android.contacts.ShowAll". 4108 * 4109 * @param name The name of the extra data, with package prefix. 4110 * @param value The long data value. 4111 * 4112 * @return Returns the same Intent object, for chaining multiple calls 4113 * into a single statement. 4114 * 4115 * @see #putExtras 4116 * @see #removeExtra 4117 * @see #getLongExtra(String, long) 4118 */ 4119 public Intent putExtra(String name, long value) { 4120 if (mExtras == null) { 4121 mExtras = new Bundle(); 4122 } 4123 mExtras.putLong(name, value); 4124 return this; 4125 } 4126 4127 /** 4128 * Add extended data to the intent. The name must include a package 4129 * prefix, for example the app com.android.contacts would use names 4130 * like "com.android.contacts.ShowAll". 4131 * 4132 * @param name The name of the extra data, with package prefix. 4133 * @param value The float data value. 4134 * 4135 * @return Returns the same Intent object, for chaining multiple calls 4136 * into a single statement. 4137 * 4138 * @see #putExtras 4139 * @see #removeExtra 4140 * @see #getFloatExtra(String, float) 4141 */ 4142 public Intent putExtra(String name, float value) { 4143 if (mExtras == null) { 4144 mExtras = new Bundle(); 4145 } 4146 mExtras.putFloat(name, value); 4147 return this; 4148 } 4149 4150 /** 4151 * Add extended data to the intent. The name must include a package 4152 * prefix, for example the app com.android.contacts would use names 4153 * like "com.android.contacts.ShowAll". 4154 * 4155 * @param name The name of the extra data, with package prefix. 4156 * @param value The double data value. 4157 * 4158 * @return Returns the same Intent object, for chaining multiple calls 4159 * into a single statement. 4160 * 4161 * @see #putExtras 4162 * @see #removeExtra 4163 * @see #getDoubleExtra(String, double) 4164 */ 4165 public Intent putExtra(String name, double value) { 4166 if (mExtras == null) { 4167 mExtras = new Bundle(); 4168 } 4169 mExtras.putDouble(name, value); 4170 return this; 4171 } 4172 4173 /** 4174 * Add extended data to the intent. The name must include a package 4175 * prefix, for example the app com.android.contacts would use names 4176 * like "com.android.contacts.ShowAll". 4177 * 4178 * @param name The name of the extra data, with package prefix. 4179 * @param value The String data value. 4180 * 4181 * @return Returns the same Intent object, for chaining multiple calls 4182 * into a single statement. 4183 * 4184 * @see #putExtras 4185 * @see #removeExtra 4186 * @see #getStringExtra(String) 4187 */ 4188 public Intent putExtra(String name, String value) { 4189 if (mExtras == null) { 4190 mExtras = new Bundle(); 4191 } 4192 mExtras.putString(name, value); 4193 return this; 4194 } 4195 4196 /** 4197 * Add extended data to the intent. The name must include a package 4198 * prefix, for example the app com.android.contacts would use names 4199 * like "com.android.contacts.ShowAll". 4200 * 4201 * @param name The name of the extra data, with package prefix. 4202 * @param value The CharSequence data value. 4203 * 4204 * @return Returns the same Intent object, for chaining multiple calls 4205 * into a single statement. 4206 * 4207 * @see #putExtras 4208 * @see #removeExtra 4209 * @see #getCharSequenceExtra(String) 4210 */ 4211 public Intent putExtra(String name, CharSequence value) { 4212 if (mExtras == null) { 4213 mExtras = new Bundle(); 4214 } 4215 mExtras.putCharSequence(name, value); 4216 return this; 4217 } 4218 4219 /** 4220 * Add extended data to the intent. The name must include a package 4221 * prefix, for example the app com.android.contacts would use names 4222 * like "com.android.contacts.ShowAll". 4223 * 4224 * @param name The name of the extra data, with package prefix. 4225 * @param value The Parcelable data value. 4226 * 4227 * @return Returns the same Intent object, for chaining multiple calls 4228 * into a single statement. 4229 * 4230 * @see #putExtras 4231 * @see #removeExtra 4232 * @see #getParcelableExtra(String) 4233 */ 4234 public Intent putExtra(String name, Parcelable value) { 4235 if (mExtras == null) { 4236 mExtras = new Bundle(); 4237 } 4238 mExtras.putParcelable(name, value); 4239 return this; 4240 } 4241 4242 /** 4243 * Add extended data to the intent. The name must include a package 4244 * prefix, for example the app com.android.contacts would use names 4245 * like "com.android.contacts.ShowAll". 4246 * 4247 * @param name The name of the extra data, with package prefix. 4248 * @param value The Parcelable[] data value. 4249 * 4250 * @return Returns the same Intent object, for chaining multiple calls 4251 * into a single statement. 4252 * 4253 * @see #putExtras 4254 * @see #removeExtra 4255 * @see #getParcelableArrayExtra(String) 4256 */ 4257 public Intent putExtra(String name, Parcelable[] value) { 4258 if (mExtras == null) { 4259 mExtras = new Bundle(); 4260 } 4261 mExtras.putParcelableArray(name, value); 4262 return this; 4263 } 4264 4265 /** 4266 * Add extended data to the intent. The name must include a package 4267 * prefix, for example the app com.android.contacts would use names 4268 * like "com.android.contacts.ShowAll". 4269 * 4270 * @param name The name of the extra data, with package prefix. 4271 * @param value The ArrayList<Parcelable> data value. 4272 * 4273 * @return Returns the same Intent object, for chaining multiple calls 4274 * into a single statement. 4275 * 4276 * @see #putExtras 4277 * @see #removeExtra 4278 * @see #getParcelableArrayListExtra(String) 4279 */ 4280 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) { 4281 if (mExtras == null) { 4282 mExtras = new Bundle(); 4283 } 4284 mExtras.putParcelableArrayList(name, value); 4285 return this; 4286 } 4287 4288 /** 4289 * Add extended data to the intent. The name must include a package 4290 * prefix, for example the app com.android.contacts would use names 4291 * like "com.android.contacts.ShowAll". 4292 * 4293 * @param name The name of the extra data, with package prefix. 4294 * @param value The ArrayList<Integer> data value. 4295 * 4296 * @return Returns the same Intent object, for chaining multiple calls 4297 * into a single statement. 4298 * 4299 * @see #putExtras 4300 * @see #removeExtra 4301 * @see #getIntegerArrayListExtra(String) 4302 */ 4303 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) { 4304 if (mExtras == null) { 4305 mExtras = new Bundle(); 4306 } 4307 mExtras.putIntegerArrayList(name, value); 4308 return this; 4309 } 4310 4311 /** 4312 * Add extended data to the intent. The name must include a package 4313 * prefix, for example the app com.android.contacts would use names 4314 * like "com.android.contacts.ShowAll". 4315 * 4316 * @param name The name of the extra data, with package prefix. 4317 * @param value The ArrayList<String> data value. 4318 * 4319 * @return Returns the same Intent object, for chaining multiple calls 4320 * into a single statement. 4321 * 4322 * @see #putExtras 4323 * @see #removeExtra 4324 * @see #getStringArrayListExtra(String) 4325 */ 4326 public Intent putStringArrayListExtra(String name, ArrayList<String> value) { 4327 if (mExtras == null) { 4328 mExtras = new Bundle(); 4329 } 4330 mExtras.putStringArrayList(name, value); 4331 return this; 4332 } 4333 4334 /** 4335 * Add extended data to the intent. The name must include a package 4336 * prefix, for example the app com.android.contacts would use names 4337 * like "com.android.contacts.ShowAll". 4338 * 4339 * @param name The name of the extra data, with package prefix. 4340 * @param value The ArrayList<CharSequence> data value. 4341 * 4342 * @return Returns the same Intent object, for chaining multiple calls 4343 * into a single statement. 4344 * 4345 * @see #putExtras 4346 * @see #removeExtra 4347 * @see #getCharSequenceArrayListExtra(String) 4348 */ 4349 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) { 4350 if (mExtras == null) { 4351 mExtras = new Bundle(); 4352 } 4353 mExtras.putCharSequenceArrayList(name, value); 4354 return this; 4355 } 4356 4357 /** 4358 * Add extended data to the intent. The name must include a package 4359 * prefix, for example the app com.android.contacts would use names 4360 * like "com.android.contacts.ShowAll". 4361 * 4362 * @param name The name of the extra data, with package prefix. 4363 * @param value The Serializable data value. 4364 * 4365 * @return Returns the same Intent object, for chaining multiple calls 4366 * into a single statement. 4367 * 4368 * @see #putExtras 4369 * @see #removeExtra 4370 * @see #getSerializableExtra(String) 4371 */ 4372 public Intent putExtra(String name, Serializable value) { 4373 if (mExtras == null) { 4374 mExtras = new Bundle(); 4375 } 4376 mExtras.putSerializable(name, value); 4377 return this; 4378 } 4379 4380 /** 4381 * Add extended data to the intent. The name must include a package 4382 * prefix, for example the app com.android.contacts would use names 4383 * like "com.android.contacts.ShowAll". 4384 * 4385 * @param name The name of the extra data, with package prefix. 4386 * @param value The boolean array data value. 4387 * 4388 * @return Returns the same Intent object, for chaining multiple calls 4389 * into a single statement. 4390 * 4391 * @see #putExtras 4392 * @see #removeExtra 4393 * @see #getBooleanArrayExtra(String) 4394 */ 4395 public Intent putExtra(String name, boolean[] value) { 4396 if (mExtras == null) { 4397 mExtras = new Bundle(); 4398 } 4399 mExtras.putBooleanArray(name, value); 4400 return this; 4401 } 4402 4403 /** 4404 * Add extended data to the intent. The name must include a package 4405 * prefix, for example the app com.android.contacts would use names 4406 * like "com.android.contacts.ShowAll". 4407 * 4408 * @param name The name of the extra data, with package prefix. 4409 * @param value The byte array data value. 4410 * 4411 * @return Returns the same Intent object, for chaining multiple calls 4412 * into a single statement. 4413 * 4414 * @see #putExtras 4415 * @see #removeExtra 4416 * @see #getByteArrayExtra(String) 4417 */ 4418 public Intent putExtra(String name, byte[] value) { 4419 if (mExtras == null) { 4420 mExtras = new Bundle(); 4421 } 4422 mExtras.putByteArray(name, value); 4423 return this; 4424 } 4425 4426 /** 4427 * Add extended data to the intent. The name must include a package 4428 * prefix, for example the app com.android.contacts would use names 4429 * like "com.android.contacts.ShowAll". 4430 * 4431 * @param name The name of the extra data, with package prefix. 4432 * @param value The short array data value. 4433 * 4434 * @return Returns the same Intent object, for chaining multiple calls 4435 * into a single statement. 4436 * 4437 * @see #putExtras 4438 * @see #removeExtra 4439 * @see #getShortArrayExtra(String) 4440 */ 4441 public Intent putExtra(String name, short[] value) { 4442 if (mExtras == null) { 4443 mExtras = new Bundle(); 4444 } 4445 mExtras.putShortArray(name, value); 4446 return this; 4447 } 4448 4449 /** 4450 * Add extended data to the intent. The name must include a package 4451 * prefix, for example the app com.android.contacts would use names 4452 * like "com.android.contacts.ShowAll". 4453 * 4454 * @param name The name of the extra data, with package prefix. 4455 * @param value The char array data value. 4456 * 4457 * @return Returns the same Intent object, for chaining multiple calls 4458 * into a single statement. 4459 * 4460 * @see #putExtras 4461 * @see #removeExtra 4462 * @see #getCharArrayExtra(String) 4463 */ 4464 public Intent putExtra(String name, char[] value) { 4465 if (mExtras == null) { 4466 mExtras = new Bundle(); 4467 } 4468 mExtras.putCharArray(name, value); 4469 return this; 4470 } 4471 4472 /** 4473 * Add extended data to the intent. The name must include a package 4474 * prefix, for example the app com.android.contacts would use names 4475 * like "com.android.contacts.ShowAll". 4476 * 4477 * @param name The name of the extra data, with package prefix. 4478 * @param value The int array data value. 4479 * 4480 * @return Returns the same Intent object, for chaining multiple calls 4481 * into a single statement. 4482 * 4483 * @see #putExtras 4484 * @see #removeExtra 4485 * @see #getIntArrayExtra(String) 4486 */ 4487 public Intent putExtra(String name, int[] value) { 4488 if (mExtras == null) { 4489 mExtras = new Bundle(); 4490 } 4491 mExtras.putIntArray(name, value); 4492 return this; 4493 } 4494 4495 /** 4496 * Add extended data to the intent. The name must include a package 4497 * prefix, for example the app com.android.contacts would use names 4498 * like "com.android.contacts.ShowAll". 4499 * 4500 * @param name The name of the extra data, with package prefix. 4501 * @param value The byte array data value. 4502 * 4503 * @return Returns the same Intent object, for chaining multiple calls 4504 * into a single statement. 4505 * 4506 * @see #putExtras 4507 * @see #removeExtra 4508 * @see #getLongArrayExtra(String) 4509 */ 4510 public Intent putExtra(String name, long[] value) { 4511 if (mExtras == null) { 4512 mExtras = new Bundle(); 4513 } 4514 mExtras.putLongArray(name, value); 4515 return this; 4516 } 4517 4518 /** 4519 * Add extended data to the intent. The name must include a package 4520 * prefix, for example the app com.android.contacts would use names 4521 * like "com.android.contacts.ShowAll". 4522 * 4523 * @param name The name of the extra data, with package prefix. 4524 * @param value The float array data value. 4525 * 4526 * @return Returns the same Intent object, for chaining multiple calls 4527 * into a single statement. 4528 * 4529 * @see #putExtras 4530 * @see #removeExtra 4531 * @see #getFloatArrayExtra(String) 4532 */ 4533 public Intent putExtra(String name, float[] value) { 4534 if (mExtras == null) { 4535 mExtras = new Bundle(); 4536 } 4537 mExtras.putFloatArray(name, value); 4538 return this; 4539 } 4540 4541 /** 4542 * Add extended data to the intent. The name must include a package 4543 * prefix, for example the app com.android.contacts would use names 4544 * like "com.android.contacts.ShowAll". 4545 * 4546 * @param name The name of the extra data, with package prefix. 4547 * @param value The double array data value. 4548 * 4549 * @return Returns the same Intent object, for chaining multiple calls 4550 * into a single statement. 4551 * 4552 * @see #putExtras 4553 * @see #removeExtra 4554 * @see #getDoubleArrayExtra(String) 4555 */ 4556 public Intent putExtra(String name, double[] value) { 4557 if (mExtras == null) { 4558 mExtras = new Bundle(); 4559 } 4560 mExtras.putDoubleArray(name, value); 4561 return this; 4562 } 4563 4564 /** 4565 * Add extended data to the intent. The name must include a package 4566 * prefix, for example the app com.android.contacts would use names 4567 * like "com.android.contacts.ShowAll". 4568 * 4569 * @param name The name of the extra data, with package prefix. 4570 * @param value The String array data value. 4571 * 4572 * @return Returns the same Intent object, for chaining multiple calls 4573 * into a single statement. 4574 * 4575 * @see #putExtras 4576 * @see #removeExtra 4577 * @see #getStringArrayExtra(String) 4578 */ 4579 public Intent putExtra(String name, String[] value) { 4580 if (mExtras == null) { 4581 mExtras = new Bundle(); 4582 } 4583 mExtras.putStringArray(name, value); 4584 return this; 4585 } 4586 4587 /** 4588 * Add extended data to the intent. The name must include a package 4589 * prefix, for example the app com.android.contacts would use names 4590 * like "com.android.contacts.ShowAll". 4591 * 4592 * @param name The name of the extra data, with package prefix. 4593 * @param value The CharSequence array data value. 4594 * 4595 * @return Returns the same Intent object, for chaining multiple calls 4596 * into a single statement. 4597 * 4598 * @see #putExtras 4599 * @see #removeExtra 4600 * @see #getCharSequenceArrayExtra(String) 4601 */ 4602 public Intent putExtra(String name, CharSequence[] value) { 4603 if (mExtras == null) { 4604 mExtras = new Bundle(); 4605 } 4606 mExtras.putCharSequenceArray(name, value); 4607 return this; 4608 } 4609 4610 /** 4611 * Add extended data to the intent. The name must include a package 4612 * prefix, for example the app com.android.contacts would use names 4613 * like "com.android.contacts.ShowAll". 4614 * 4615 * @param name The name of the extra data, with package prefix. 4616 * @param value The Bundle data value. 4617 * 4618 * @return Returns the same Intent object, for chaining multiple calls 4619 * into a single statement. 4620 * 4621 * @see #putExtras 4622 * @see #removeExtra 4623 * @see #getBundleExtra(String) 4624 */ 4625 public Intent putExtra(String name, Bundle value) { 4626 if (mExtras == null) { 4627 mExtras = new Bundle(); 4628 } 4629 mExtras.putBundle(name, value); 4630 return this; 4631 } 4632 4633 /** 4634 * Add extended data to the intent. The name must include a package 4635 * prefix, for example the app com.android.contacts would use names 4636 * like "com.android.contacts.ShowAll". 4637 * 4638 * @param name The name of the extra data, with package prefix. 4639 * @param value The IBinder data value. 4640 * 4641 * @return Returns the same Intent object, for chaining multiple calls 4642 * into a single statement. 4643 * 4644 * @see #putExtras 4645 * @see #removeExtra 4646 * @see #getIBinderExtra(String) 4647 * 4648 * @deprecated 4649 * @hide 4650 */ 4651 @Deprecated 4652 public Intent putExtra(String name, IBinder value) { 4653 if (mExtras == null) { 4654 mExtras = new Bundle(); 4655 } 4656 mExtras.putIBinder(name, value); 4657 return this; 4658 } 4659 4660 /** 4661 * Copy all extras in 'src' in to this intent. 4662 * 4663 * @param src Contains the extras to copy. 4664 * 4665 * @see #putExtra 4666 */ 4667 public Intent putExtras(Intent src) { 4668 if (src.mExtras != null) { 4669 if (mExtras == null) { 4670 mExtras = new Bundle(src.mExtras); 4671 } else { 4672 mExtras.putAll(src.mExtras); 4673 } 4674 } 4675 return this; 4676 } 4677 4678 /** 4679 * Add a set of extended data to the intent. The keys must include a package 4680 * prefix, for example the app com.android.contacts would use names 4681 * like "com.android.contacts.ShowAll". 4682 * 4683 * @param extras The Bundle of extras to add to this intent. 4684 * 4685 * @see #putExtra 4686 * @see #removeExtra 4687 */ 4688 public Intent putExtras(Bundle extras) { 4689 if (mExtras == null) { 4690 mExtras = new Bundle(); 4691 } 4692 mExtras.putAll(extras); 4693 return this; 4694 } 4695 4696 /** 4697 * Completely replace the extras in the Intent with the extras in the 4698 * given Intent. 4699 * 4700 * @param src The exact extras contained in this Intent are copied 4701 * into the target intent, replacing any that were previously there. 4702 */ 4703 public Intent replaceExtras(Intent src) { 4704 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; 4705 return this; 4706 } 4707 4708 /** 4709 * Completely replace the extras in the Intent with the given Bundle of 4710 * extras. 4711 * 4712 * @param extras The new set of extras in the Intent, or null to erase 4713 * all extras. 4714 */ 4715 public Intent replaceExtras(Bundle extras) { 4716 mExtras = extras != null ? new Bundle(extras) : null; 4717 return this; 4718 } 4719 4720 /** 4721 * Remove extended data from the intent. 4722 * 4723 * @see #putExtra 4724 */ 4725 public void removeExtra(String name) { 4726 if (mExtras != null) { 4727 mExtras.remove(name); 4728 if (mExtras.size() == 0) { 4729 mExtras = null; 4730 } 4731 } 4732 } 4733 4734 /** 4735 * Set special flags controlling how this intent is handled. Most values 4736 * here depend on the type of component being executed by the Intent, 4737 * specifically the FLAG_ACTIVITY_* flags are all for use with 4738 * {@link Context#startActivity Context.startActivity()} and the 4739 * FLAG_RECEIVER_* flags are all for use with 4740 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. 4741 * 4742 * <p>See the <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals: 4743 * Activities and Tasks</a> documentation for important information on how some of these options impact 4744 * the behavior of your application. 4745 * 4746 * @param flags The desired flags. 4747 * 4748 * @return Returns the same Intent object, for chaining multiple calls 4749 * into a single statement. 4750 * 4751 * @see #getFlags 4752 * @see #addFlags 4753 * 4754 * @see #FLAG_GRANT_READ_URI_PERMISSION 4755 * @see #FLAG_GRANT_WRITE_URI_PERMISSION 4756 * @see #FLAG_DEBUG_LOG_RESOLUTION 4757 * @see #FLAG_FROM_BACKGROUND 4758 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT 4759 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET 4760 * @see #FLAG_ACTIVITY_CLEAR_TOP 4761 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS 4762 * @see #FLAG_ACTIVITY_FORWARD_RESULT 4763 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY 4764 * @see #FLAG_ACTIVITY_MULTIPLE_TASK 4765 * @see #FLAG_ACTIVITY_NEW_TASK 4766 * @see #FLAG_ACTIVITY_NO_HISTORY 4767 * @see #FLAG_ACTIVITY_NO_USER_ACTION 4768 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP 4769 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED 4770 * @see #FLAG_ACTIVITY_SINGLE_TOP 4771 * @see #FLAG_RECEIVER_REGISTERED_ONLY 4772 */ 4773 public Intent setFlags(int flags) { 4774 mFlags = flags; 4775 return this; 4776 } 4777 4778 /** 4779 * Add additional flags to the intent (or with existing flags 4780 * value). 4781 * 4782 * @param flags The new flags to set. 4783 * 4784 * @return Returns the same Intent object, for chaining multiple calls 4785 * into a single statement. 4786 * 4787 * @see #setFlags 4788 */ 4789 public Intent addFlags(int flags) { 4790 mFlags |= flags; 4791 return this; 4792 } 4793 4794 /** 4795 * (Usually optional) Set an explicit application package name that limits 4796 * the components this Intent will resolve to. If left to the default 4797 * value of null, all components in all applications will considered. 4798 * If non-null, the Intent can only match the components in the given 4799 * application package. 4800 * 4801 * @param packageName The name of the application package to handle the 4802 * intent, or null to allow any application package. 4803 * 4804 * @return Returns the same Intent object, for chaining multiple calls 4805 * into a single statement. 4806 * 4807 * @see #getPackage 4808 * @see #resolveActivity 4809 */ 4810 public Intent setPackage(String packageName) { 4811 mPackage = packageName; 4812 return this; 4813 } 4814 4815 /** 4816 * (Usually optional) Explicitly set the component to handle the intent. 4817 * If left with the default value of null, the system will determine the 4818 * appropriate class to use based on the other fields (action, data, 4819 * type, categories) in the Intent. If this class is defined, the 4820 * specified class will always be used regardless of the other fields. You 4821 * should only set this value when you know you absolutely want a specific 4822 * class to be used; otherwise it is better to let the system find the 4823 * appropriate class so that you will respect the installed applications 4824 * and user preferences. 4825 * 4826 * @param component The name of the application component to handle the 4827 * intent, or null to let the system find one for you. 4828 * 4829 * @return Returns the same Intent object, for chaining multiple calls 4830 * into a single statement. 4831 * 4832 * @see #setClass 4833 * @see #setClassName(Context, String) 4834 * @see #setClassName(String, String) 4835 * @see #getComponent 4836 * @see #resolveActivity 4837 */ 4838 public Intent setComponent(ComponentName component) { 4839 mComponent = component; 4840 return this; 4841 } 4842 4843 /** 4844 * Convenience for calling {@link #setComponent} with an 4845 * explicit class name. 4846 * 4847 * @param packageContext A Context of the application package implementing 4848 * this class. 4849 * @param className The name of a class inside of the application package 4850 * that will be used as the component for this Intent. 4851 * 4852 * @return Returns the same Intent object, for chaining multiple calls 4853 * into a single statement. 4854 * 4855 * @see #setComponent 4856 * @see #setClass 4857 */ 4858 public Intent setClassName(Context packageContext, String className) { 4859 mComponent = new ComponentName(packageContext, className); 4860 return this; 4861 } 4862 4863 /** 4864 * Convenience for calling {@link #setComponent} with an 4865 * explicit application package name and class name. 4866 * 4867 * @param packageName The name of the package implementing the desired 4868 * component. 4869 * @param className The name of a class inside of the application package 4870 * that will be used as the component for this Intent. 4871 * 4872 * @return Returns the same Intent object, for chaining multiple calls 4873 * into a single statement. 4874 * 4875 * @see #setComponent 4876 * @see #setClass 4877 */ 4878 public Intent setClassName(String packageName, String className) { 4879 mComponent = new ComponentName(packageName, className); 4880 return this; 4881 } 4882 4883 /** 4884 * Convenience for calling {@link #setComponent(ComponentName)} with the 4885 * name returned by a {@link Class} object. 4886 * 4887 * @param packageContext A Context of the application package implementing 4888 * this class. 4889 * @param cls The class name to set, equivalent to 4890 * <code>setClassName(context, cls.getName())</code>. 4891 * 4892 * @return Returns the same Intent object, for chaining multiple calls 4893 * into a single statement. 4894 * 4895 * @see #setComponent 4896 */ 4897 public Intent setClass(Context packageContext, Class<?> cls) { 4898 mComponent = new ComponentName(packageContext, cls); 4899 return this; 4900 } 4901 4902 /** 4903 * Set the bounds of the sender of this intent, in screen coordinates. This can be 4904 * used as a hint to the receiver for animations and the like. Null means that there 4905 * is no source bounds. 4906 */ 4907 public void setSourceBounds(Rect r) { 4908 if (r != null) { 4909 mSourceBounds = new Rect(r); 4910 } else { 4911 r = null; 4912 } 4913 } 4914 4915 /** 4916 * Use with {@link #fillIn} to allow the current action value to be 4917 * overwritten, even if it is already set. 4918 */ 4919 public static final int FILL_IN_ACTION = 1<<0; 4920 4921 /** 4922 * Use with {@link #fillIn} to allow the current data or type value 4923 * overwritten, even if it is already set. 4924 */ 4925 public static final int FILL_IN_DATA = 1<<1; 4926 4927 /** 4928 * Use with {@link #fillIn} to allow the current categories to be 4929 * overwritten, even if they are already set. 4930 */ 4931 public static final int FILL_IN_CATEGORIES = 1<<2; 4932 4933 /** 4934 * Use with {@link #fillIn} to allow the current component value to be 4935 * overwritten, even if it is already set. 4936 */ 4937 public static final int FILL_IN_COMPONENT = 1<<3; 4938 4939 /** 4940 * Use with {@link #fillIn} to allow the current package value to be 4941 * overwritten, even if it is already set. 4942 */ 4943 public static final int FILL_IN_PACKAGE = 1<<4; 4944 4945 /** 4946 * Use with {@link #fillIn} to allow the current package value to be 4947 * overwritten, even if it is already set. 4948 */ 4949 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; 4950 4951 /** 4952 * Copy the contents of <var>other</var> in to this object, but only 4953 * where fields are not defined by this object. For purposes of a field 4954 * being defined, the following pieces of data in the Intent are 4955 * considered to be separate fields: 4956 * 4957 * <ul> 4958 * <li> action, as set by {@link #setAction}. 4959 * <li> data URI and MIME type, as set by {@link #setData(Uri)}, 4960 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. 4961 * <li> categories, as set by {@link #addCategory}. 4962 * <li> package, as set by {@link #setPackage}. 4963 * <li> component, as set by {@link #setComponent(ComponentName)} or 4964 * related methods. 4965 * <li> source bounds, as set by {@link #setSourceBounds} 4966 * <li> each top-level name in the associated extras. 4967 * </ul> 4968 * 4969 * <p>In addition, you can use the {@link #FILL_IN_ACTION}, 4970 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 4971 * and {@link #FILL_IN_COMPONENT} to override the restriction where the 4972 * corresponding field will not be replaced if it is already set. 4973 * 4974 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly 4975 * specified. 4976 * 4977 * <p>For example, consider Intent A with {data="foo", categories="bar"} 4978 * and Intent B with {action="gotit", data-type="some/thing", 4979 * categories="one","two"}. 4980 * 4981 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now 4982 * containing: {action="gotit", data-type="some/thing", 4983 * categories="bar"}. 4984 * 4985 * @param other Another Intent whose values are to be used to fill in 4986 * the current one. 4987 * @param flags Options to control which fields can be filled in. 4988 * 4989 * @return Returns a bit mask of {@link #FILL_IN_ACTION}, 4990 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 4991 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed. 4992 */ 4993 public int fillIn(Intent other, int flags) { 4994 int changes = 0; 4995 if (other.mAction != null 4996 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { 4997 mAction = other.mAction; 4998 changes |= FILL_IN_ACTION; 4999 } 5000 if ((other.mData != null || other.mType != null) 5001 && ((mData == null && mType == null) 5002 || (flags&FILL_IN_DATA) != 0)) { 5003 mData = other.mData; 5004 mType = other.mType; 5005 changes |= FILL_IN_DATA; 5006 } 5007 if (other.mCategories != null 5008 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { 5009 if (other.mCategories != null) { 5010 mCategories = new HashSet<String>(other.mCategories); 5011 } 5012 changes |= FILL_IN_CATEGORIES; 5013 } 5014 if (other.mPackage != null 5015 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { 5016 mPackage = other.mPackage; 5017 changes |= FILL_IN_PACKAGE; 5018 } 5019 // Component is special: it can -only- be set if explicitly allowed, 5020 // since otherwise the sender could force the intent somewhere the 5021 // originator didn't intend. 5022 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { 5023 mComponent = other.mComponent; 5024 changes |= FILL_IN_COMPONENT; 5025 } 5026 mFlags |= other.mFlags; 5027 if (other.mSourceBounds != null 5028 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { 5029 mSourceBounds = new Rect(other.mSourceBounds); 5030 changes |= FILL_IN_SOURCE_BOUNDS; 5031 } 5032 if (mExtras == null) { 5033 if (other.mExtras != null) { 5034 mExtras = new Bundle(other.mExtras); 5035 } 5036 } else if (other.mExtras != null) { 5037 try { 5038 Bundle newb = new Bundle(other.mExtras); 5039 newb.putAll(mExtras); 5040 mExtras = newb; 5041 } catch (RuntimeException e) { 5042 // Modifying the extras can cause us to unparcel the contents 5043 // of the bundle, and if we do this in the system process that 5044 // may fail. We really should handle this (i.e., the Bundle 5045 // impl shouldn't be on top of a plain map), but for now just 5046 // ignore it and keep the original contents. :( 5047 Log.w("Intent", "Failure filling in extras", e); 5048 } 5049 } 5050 return changes; 5051 } 5052 5053 /** 5054 * Wrapper class holding an Intent and implementing comparisons on it for 5055 * the purpose of filtering. The class implements its 5056 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as 5057 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and 5058 * {@link android.content.Intent#filterHashCode()} filterHashCode()} 5059 * on the wrapped Intent. 5060 */ 5061 public static final class FilterComparison { 5062 private final Intent mIntent; 5063 private final int mHashCode; 5064 5065 public FilterComparison(Intent intent) { 5066 mIntent = intent; 5067 mHashCode = intent.filterHashCode(); 5068 } 5069 5070 /** 5071 * Return the Intent that this FilterComparison represents. 5072 * @return Returns the Intent held by the FilterComparison. Do 5073 * not modify! 5074 */ 5075 public Intent getIntent() { 5076 return mIntent; 5077 } 5078 5079 @Override 5080 public boolean equals(Object obj) { 5081 if (obj instanceof FilterComparison) { 5082 Intent other = ((FilterComparison)obj).mIntent; 5083 return mIntent.filterEquals(other); 5084 } 5085 return false; 5086 } 5087 5088 @Override 5089 public int hashCode() { 5090 return mHashCode; 5091 } 5092 } 5093 5094 /** 5095 * Determine if two intents are the same for the purposes of intent 5096 * resolution (filtering). That is, if their action, data, type, 5097 * class, and categories are the same. This does <em>not</em> compare 5098 * any extra data included in the intents. 5099 * 5100 * @param other The other Intent to compare against. 5101 * 5102 * @return Returns true if action, data, type, class, and categories 5103 * are the same. 5104 */ 5105 public boolean filterEquals(Intent other) { 5106 if (other == null) { 5107 return false; 5108 } 5109 if (mAction != other.mAction) { 5110 if (mAction != null) { 5111 if (!mAction.equals(other.mAction)) { 5112 return false; 5113 } 5114 } else { 5115 if (!other.mAction.equals(mAction)) { 5116 return false; 5117 } 5118 } 5119 } 5120 if (mData != other.mData) { 5121 if (mData != null) { 5122 if (!mData.equals(other.mData)) { 5123 return false; 5124 } 5125 } else { 5126 if (!other.mData.equals(mData)) { 5127 return false; 5128 } 5129 } 5130 } 5131 if (mType != other.mType) { 5132 if (mType != null) { 5133 if (!mType.equals(other.mType)) { 5134 return false; 5135 } 5136 } else { 5137 if (!other.mType.equals(mType)) { 5138 return false; 5139 } 5140 } 5141 } 5142 if (mPackage != other.mPackage) { 5143 if (mPackage != null) { 5144 if (!mPackage.equals(other.mPackage)) { 5145 return false; 5146 } 5147 } else { 5148 if (!other.mPackage.equals(mPackage)) { 5149 return false; 5150 } 5151 } 5152 } 5153 if (mComponent != other.mComponent) { 5154 if (mComponent != null) { 5155 if (!mComponent.equals(other.mComponent)) { 5156 return false; 5157 } 5158 } else { 5159 if (!other.mComponent.equals(mComponent)) { 5160 return false; 5161 } 5162 } 5163 } 5164 if (mCategories != other.mCategories) { 5165 if (mCategories != null) { 5166 if (!mCategories.equals(other.mCategories)) { 5167 return false; 5168 } 5169 } else { 5170 if (!other.mCategories.equals(mCategories)) { 5171 return false; 5172 } 5173 } 5174 } 5175 5176 return true; 5177 } 5178 5179 /** 5180 * Generate hash code that matches semantics of filterEquals(). 5181 * 5182 * @return Returns the hash value of the action, data, type, class, and 5183 * categories. 5184 * 5185 * @see #filterEquals 5186 */ 5187 public int filterHashCode() { 5188 int code = 0; 5189 if (mAction != null) { 5190 code += mAction.hashCode(); 5191 } 5192 if (mData != null) { 5193 code += mData.hashCode(); 5194 } 5195 if (mType != null) { 5196 code += mType.hashCode(); 5197 } 5198 if (mPackage != null) { 5199 code += mPackage.hashCode(); 5200 } 5201 if (mComponent != null) { 5202 code += mComponent.hashCode(); 5203 } 5204 if (mCategories != null) { 5205 code += mCategories.hashCode(); 5206 } 5207 return code; 5208 } 5209 5210 @Override 5211 public String toString() { 5212 StringBuilder b = new StringBuilder(128); 5213 5214 b.append("Intent { "); 5215 toShortString(b, true, true); 5216 b.append(" }"); 5217 5218 return b.toString(); 5219 } 5220 5221 /** @hide */ 5222 public String toShortString(boolean comp, boolean extras) { 5223 StringBuilder b = new StringBuilder(128); 5224 toShortString(b, comp, extras); 5225 return b.toString(); 5226 } 5227 5228 /** @hide */ 5229 public void toShortString(StringBuilder b, boolean comp, boolean extras) { 5230 boolean first = true; 5231 if (mAction != null) { 5232 b.append("act=").append(mAction); 5233 first = false; 5234 } 5235 if (mCategories != null) { 5236 if (!first) { 5237 b.append(' '); 5238 } 5239 first = false; 5240 b.append("cat=["); 5241 Iterator<String> i = mCategories.iterator(); 5242 boolean didone = false; 5243 while (i.hasNext()) { 5244 if (didone) b.append(","); 5245 didone = true; 5246 b.append(i.next()); 5247 } 5248 b.append("]"); 5249 } 5250 if (mData != null) { 5251 if (!first) { 5252 b.append(' '); 5253 } 5254 first = false; 5255 b.append("dat=").append(mData); 5256 } 5257 if (mType != null) { 5258 if (!first) { 5259 b.append(' '); 5260 } 5261 first = false; 5262 b.append("typ=").append(mType); 5263 } 5264 if (mFlags != 0) { 5265 if (!first) { 5266 b.append(' '); 5267 } 5268 first = false; 5269 b.append("flg=0x").append(Integer.toHexString(mFlags)); 5270 } 5271 if (mPackage != null) { 5272 if (!first) { 5273 b.append(' '); 5274 } 5275 first = false; 5276 b.append("pkg=").append(mPackage); 5277 } 5278 if (comp && mComponent != null) { 5279 if (!first) { 5280 b.append(' '); 5281 } 5282 first = false; 5283 b.append("cmp=").append(mComponent.flattenToShortString()); 5284 } 5285 if (mSourceBounds != null) { 5286 if (!first) { 5287 b.append(' '); 5288 } 5289 first = false; 5290 b.append("bnds=").append(mSourceBounds.toShortString()); 5291 } 5292 if (extras && mExtras != null) { 5293 if (!first) { 5294 b.append(' '); 5295 } 5296 first = false; 5297 b.append("(has extras)"); 5298 } 5299 } 5300 5301 /** 5302 * Call {@link #toUri} with 0 flags. 5303 * @deprecated Use {@link #toUri} instead. 5304 */ 5305 @Deprecated 5306 public String toURI() { 5307 return toUri(0); 5308 } 5309 5310 /** 5311 * Convert this Intent into a String holding a URI representation of it. 5312 * The returned URI string has been properly URI encoded, so it can be 5313 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the 5314 * Intent's data as the base URI, with an additional fragment describing 5315 * the action, categories, type, flags, package, component, and extras. 5316 * 5317 * <p>You can convert the returned string back to an Intent with 5318 * {@link #getIntent}. 5319 * 5320 * @param flags Additional operating flags. Either 0 or 5321 * {@link #URI_INTENT_SCHEME}. 5322 * 5323 * @return Returns a URI encoding URI string describing the entire contents 5324 * of the Intent. 5325 */ 5326 public String toUri(int flags) { 5327 StringBuilder uri = new StringBuilder(128); 5328 String scheme = null; 5329 if (mData != null) { 5330 String data = mData.toString(); 5331 if ((flags&URI_INTENT_SCHEME) != 0) { 5332 final int N = data.length(); 5333 for (int i=0; i<N; i++) { 5334 char c = data.charAt(i); 5335 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 5336 || c == '.' || c == '-') { 5337 continue; 5338 } 5339 if (c == ':' && i > 0) { 5340 // Valid scheme. 5341 scheme = data.substring(0, i); 5342 uri.append("intent:"); 5343 data = data.substring(i+1); 5344 break; 5345 } 5346 5347 // No scheme. 5348 break; 5349 } 5350 } 5351 uri.append(data); 5352 5353 } else if ((flags&URI_INTENT_SCHEME) != 0) { 5354 uri.append("intent:"); 5355 } 5356 5357 uri.append("#Intent;"); 5358 5359 if (scheme != null) { 5360 uri.append("scheme=").append(scheme).append(';'); 5361 } 5362 if (mAction != null) { 5363 uri.append("action=").append(Uri.encode(mAction)).append(';'); 5364 } 5365 if (mCategories != null) { 5366 for (String category : mCategories) { 5367 uri.append("category=").append(Uri.encode(category)).append(';'); 5368 } 5369 } 5370 if (mType != null) { 5371 uri.append("type=").append(Uri.encode(mType, "/")).append(';'); 5372 } 5373 if (mFlags != 0) { 5374 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); 5375 } 5376 if (mPackage != null) { 5377 uri.append("package=").append(Uri.encode(mPackage)).append(';'); 5378 } 5379 if (mComponent != null) { 5380 uri.append("component=").append(Uri.encode( 5381 mComponent.flattenToShortString(), "/")).append(';'); 5382 } 5383 if (mSourceBounds != null) { 5384 uri.append("sourceBounds=") 5385 .append(Uri.encode(mSourceBounds.flattenToString())) 5386 .append(';'); 5387 } 5388 if (mExtras != null) { 5389 for (String key : mExtras.keySet()) { 5390 final Object value = mExtras.get(key); 5391 char entryType = 5392 value instanceof String ? 'S' : 5393 value instanceof Boolean ? 'B' : 5394 value instanceof Byte ? 'b' : 5395 value instanceof Character ? 'c' : 5396 value instanceof Double ? 'd' : 5397 value instanceof Float ? 'f' : 5398 value instanceof Integer ? 'i' : 5399 value instanceof Long ? 'l' : 5400 value instanceof Short ? 's' : 5401 '\0'; 5402 5403 if (entryType != '\0') { 5404 uri.append(entryType); 5405 uri.append('.'); 5406 uri.append(Uri.encode(key)); 5407 uri.append('='); 5408 uri.append(Uri.encode(value.toString())); 5409 uri.append(';'); 5410 } 5411 } 5412 } 5413 5414 uri.append("end"); 5415 5416 return uri.toString(); 5417 } 5418 5419 public int describeContents() { 5420 return (mExtras != null) ? mExtras.describeContents() : 0; 5421 } 5422 5423 public void writeToParcel(Parcel out, int flags) { 5424 out.writeString(mAction); 5425 Uri.writeToParcel(out, mData); 5426 out.writeString(mType); 5427 out.writeInt(mFlags); 5428 out.writeString(mPackage); 5429 ComponentName.writeToParcel(mComponent, out); 5430 5431 if (mSourceBounds != null) { 5432 out.writeInt(1); 5433 mSourceBounds.writeToParcel(out, flags); 5434 } else { 5435 out.writeInt(0); 5436 } 5437 5438 if (mCategories != null) { 5439 out.writeInt(mCategories.size()); 5440 for (String category : mCategories) { 5441 out.writeString(category); 5442 } 5443 } else { 5444 out.writeInt(0); 5445 } 5446 5447 out.writeBundle(mExtras); 5448 } 5449 5450 public static final Parcelable.Creator<Intent> CREATOR 5451 = new Parcelable.Creator<Intent>() { 5452 public Intent createFromParcel(Parcel in) { 5453 return new Intent(in); 5454 } 5455 public Intent[] newArray(int size) { 5456 return new Intent[size]; 5457 } 5458 }; 5459 5460 /** @hide */ 5461 protected Intent(Parcel in) { 5462 readFromParcel(in); 5463 } 5464 5465 public void readFromParcel(Parcel in) { 5466 mAction = in.readString(); 5467 mData = Uri.CREATOR.createFromParcel(in); 5468 mType = in.readString(); 5469 mFlags = in.readInt(); 5470 mPackage = in.readString(); 5471 mComponent = ComponentName.readFromParcel(in); 5472 5473 if (in.readInt() != 0) { 5474 mSourceBounds = Rect.CREATOR.createFromParcel(in); 5475 } 5476 5477 int N = in.readInt(); 5478 if (N > 0) { 5479 mCategories = new HashSet<String>(); 5480 int i; 5481 for (i=0; i<N; i++) { 5482 mCategories.add(in.readString()); 5483 } 5484 } else { 5485 mCategories = null; 5486 } 5487 5488 mExtras = in.readBundle(); 5489 } 5490 5491 /** 5492 * Parses the "intent" element (and its children) from XML and instantiates 5493 * an Intent object. The given XML parser should be located at the tag 5494 * where parsing should start (often named "intent"), from which the 5495 * basic action, data, type, and package and class name will be 5496 * retrieved. The function will then parse in to any child elements, 5497 * looking for <category android:name="xxx"> tags to add categories and 5498 * <extra android:name="xxx" android:value="yyy"> to attach extra data 5499 * to the intent. 5500 * 5501 * @param resources The Resources to use when inflating resources. 5502 * @param parser The XML parser pointing at an "intent" tag. 5503 * @param attrs The AttributeSet interface for retrieving extended 5504 * attribute data at the current <var>parser</var> location. 5505 * @return An Intent object matching the XML data. 5506 * @throws XmlPullParserException If there was an XML parsing error. 5507 * @throws IOException If there was an I/O error. 5508 */ 5509 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs) 5510 throws XmlPullParserException, IOException { 5511 Intent intent = new Intent(); 5512 5513 TypedArray sa = resources.obtainAttributes(attrs, 5514 com.android.internal.R.styleable.Intent); 5515 5516 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); 5517 5518 String data = sa.getString(com.android.internal.R.styleable.Intent_data); 5519 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); 5520 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); 5521 5522 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); 5523 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); 5524 if (packageName != null && className != null) { 5525 intent.setComponent(new ComponentName(packageName, className)); 5526 } 5527 5528 sa.recycle(); 5529 5530 int outerDepth = parser.getDepth(); 5531 int type; 5532 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 5533 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 5534 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 5535 continue; 5536 } 5537 5538 String nodeName = parser.getName(); 5539 if (nodeName.equals("category")) { 5540 sa = resources.obtainAttributes(attrs, 5541 com.android.internal.R.styleable.IntentCategory); 5542 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); 5543 sa.recycle(); 5544 5545 if (cat != null) { 5546 intent.addCategory(cat); 5547 } 5548 XmlUtils.skipCurrentTag(parser); 5549 5550 } else if (nodeName.equals("extra")) { 5551 if (intent.mExtras == null) { 5552 intent.mExtras = new Bundle(); 5553 } 5554 resources.parseBundleExtra("extra", attrs, intent.mExtras); 5555 XmlUtils.skipCurrentTag(parser); 5556 5557 } else { 5558 XmlUtils.skipCurrentTag(parser); 5559 } 5560 } 5561 5562 return intent; 5563 } 5564} 5565