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