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