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