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