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