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