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