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