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