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