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