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