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