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