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