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