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