The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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 | |
| 17 | package android.content; |
| 18 | |
Makoto Onuki | 7d1911f | 2017-06-09 12:30:09 -0700 | [diff] [blame] | 19 | import static android.content.ContentProvider.maybeAddUserId; |
| 20 | |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 21 | import android.annotation.AnyRes; |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 22 | import android.annotation.BroadcastBehavior; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 23 | import android.annotation.IntDef; |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 24 | import android.annotation.NonNull; |
| 25 | import android.annotation.Nullable; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 26 | import android.annotation.SdkConstant; |
| 27 | import android.annotation.SdkConstant.SdkConstantType; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 28 | import android.annotation.SystemApi; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 29 | import android.content.pm.ActivityInfo; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 30 | import android.content.pm.ApplicationInfo; |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 31 | import android.content.pm.ComponentInfo; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 32 | import android.content.pm.PackageManager; |
| 33 | import android.content.pm.ResolveInfo; |
| 34 | import android.content.res.Resources; |
| 35 | import android.content.res.TypedArray; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 36 | import android.graphics.Rect; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 37 | import android.net.Uri; |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 38 | import android.os.Build; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 39 | import android.os.Bundle; |
| 40 | import android.os.IBinder; |
| 41 | import android.os.Parcel; |
| 42 | import android.os.Parcelable; |
Nicolas Prevot | c4fc00a | 2014-10-31 12:01:32 +0000 | [diff] [blame] | 43 | import android.os.Process; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 44 | import android.os.ResultReceiver; |
| 45 | import android.os.ShellCommand; |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 46 | import android.os.StrictMode; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 47 | import android.os.UserHandle; |
Makoto Onuki | 7d1911f | 2017-06-09 12:30:09 -0700 | [diff] [blame] | 48 | import android.provider.ContactsContract.QuickContact; |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 49 | import android.provider.DocumentsContract; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 50 | import android.provider.DocumentsProvider; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 51 | import android.provider.MediaStore; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 52 | import android.provider.OpenableColumns; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 53 | import android.util.ArraySet; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 54 | import android.util.AttributeSet; |
| 55 | import android.util.Log; |
Makoto Onuki | 7d1911f | 2017-06-09 12:30:09 -0700 | [diff] [blame] | 56 | |
Dianne Hackborn | 2269d157 | 2010-02-24 19:54:22 -0800 | [diff] [blame] | 57 | import com.android.internal.util.XmlUtils; |
Makoto Onuki | 7d1911f | 2017-06-09 12:30:09 -0700 | [diff] [blame] | 58 | |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 59 | import org.xmlpull.v1.XmlPullParser; |
| 60 | import org.xmlpull.v1.XmlPullParserException; |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 61 | import org.xmlpull.v1.XmlSerializer; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 62 | |
| 63 | import java.io.IOException; |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 64 | import java.io.PrintWriter; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 65 | import java.io.Serializable; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 66 | import java.lang.annotation.Retention; |
| 67 | import java.lang.annotation.RetentionPolicy; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 68 | import java.net.URISyntaxException; |
| 69 | import java.util.ArrayList; |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 70 | import java.util.HashSet; |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 71 | import java.util.List; |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 72 | import java.util.Locale; |
Christopher Tate | 63d9ae1 | 2014-06-19 19:07:26 -0700 | [diff] [blame] | 73 | import java.util.Objects; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 74 | import java.util.Set; |
| 75 | |
| 76 | /** |
| 77 | * An intent is an abstract description of an operation to be performed. It |
| 78 | * can be used with {@link Context#startActivity(Intent) startActivity} to |
| 79 | * launch an {@link android.app.Activity}, |
| 80 | * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to |
| 81 | * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, |
| 82 | * and {@link android.content.Context#startService} or |
| 83 | * {@link android.content.Context#bindService} to communicate with a |
| 84 | * background {@link android.app.Service}. |
| 85 | * |
Joe Fernandez | b54e7a3 | 2011-10-03 15:09:50 -0700 | [diff] [blame] | 86 | * <p>An Intent provides a facility for performing late runtime binding between the code in |
| 87 | * different applications. Its most significant use is in the launching of activities, where it |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 88 | * can be thought of as the glue between activities. It is basically a passive data structure |
| 89 | * holding an abstract description of an action to be performed.</p> |
Joe Fernandez | b54e7a3 | 2011-10-03 15:09:50 -0700 | [diff] [blame] | 90 | * |
| 91 | * <div class="special reference"> |
| 92 | * <h3>Developer Guides</h3> |
| 93 | * <p>For information about how to create and resolve intents, read the |
| 94 | * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> |
| 95 | * developer guide.</p> |
| 96 | * </div> |
| 97 | * |
| 98 | * <a name="IntentStructure"></a> |
| 99 | * <h3>Intent Structure</h3> |
| 100 | * <p>The primary pieces of information in an intent are:</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 101 | * |
| 102 | * <ul> |
| 103 | * <li> <p><b>action</b> -- The general action to be performed, such as |
| 104 | * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, |
| 105 | * etc.</p> |
| 106 | * </li> |
| 107 | * <li> <p><b>data</b> -- The data to operate on, such as a person record |
| 108 | * in the contacts database, expressed as a {@link android.net.Uri}.</p> |
| 109 | * </li> |
| 110 | * </ul> |
| 111 | * |
| 112 | * |
| 113 | * <p>Some examples of action/data pairs are:</p> |
| 114 | * |
| 115 | * <ul> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 116 | * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 117 | * information about the person whose identifier is "1".</p> |
| 118 | * </li> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 119 | * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 120 | * the phone dialer with the person filled in.</p> |
| 121 | * </li> |
| 122 | * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display |
| 123 | * the phone dialer with the given number filled in. Note how the |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 124 | * VIEW action does what is considered the most reasonable thing for |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 125 | * a particular URI.</p> |
| 126 | * </li> |
| 127 | * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display |
| 128 | * the phone dialer with the given number filled in.</p> |
| 129 | * </li> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 130 | * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 131 | * information about the person whose identifier is "1".</p> |
| 132 | * </li> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 133 | * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 134 | * a list of people, which the user can browse through. This example is a |
| 135 | * typical top-level entry into the Contacts application, showing you the |
| 136 | * list of people. Selecting a particular person to view would result in a |
Kevin Hufnagle | aedfd75 | 2016-09-08 21:56:25 -0700 | [diff] [blame] | 137 | * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 138 | * being used to start an activity to display that person.</p> |
| 139 | * </li> |
| 140 | * </ul> |
| 141 | * |
| 142 | * <p>In addition to these primary attributes, there are a number of secondary |
| 143 | * attributes that you can also include with an intent:</p> |
| 144 | * |
| 145 | * <ul> |
| 146 | * <li> <p><b>category</b> -- Gives additional information about the action |
| 147 | * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should |
| 148 | * appear in the Launcher as a top-level application, while |
| 149 | * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list |
| 150 | * of alternative actions the user can perform on a piece of data.</p> |
| 151 | * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the |
| 152 | * intent data. Normally the type is inferred from the data itself. |
| 153 | * By setting this attribute, you disable that evaluation and force |
| 154 | * an explicit type.</p> |
| 155 | * <li> <p><b>component</b> -- Specifies an explicit name of a component |
| 156 | * class to use for the intent. Normally this is determined by looking |
| 157 | * at the other information in the intent (the action, data/type, and |
| 158 | * categories) and matching that with a component that can handle it. |
| 159 | * If this attribute is set then none of the evaluation is performed, |
| 160 | * and this component is used exactly as is. By specifying this attribute, |
| 161 | * all of the other Intent attributes become optional.</p> |
| 162 | * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. |
| 163 | * This can be used to provide extended information to the component. |
| 164 | * For example, if we have a action to send an e-mail message, we could |
| 165 | * also include extra pieces of data here to supply a subject, body, |
| 166 | * etc.</p> |
| 167 | * </ul> |
| 168 | * |
| 169 | * <p>Here are some examples of other operations you can specify as intents |
| 170 | * using these additional parameters:</p> |
| 171 | * |
| 172 | * <ul> |
| 173 | * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- |
| 174 | * Launch the home screen.</p> |
| 175 | * </li> |
| 176 | * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type |
| 177 | * <i>{@link android.provider.Contacts.Phones#CONTENT_URI |
| 178 | * vnd.android.cursor.item/phone}</i></b> |
| 179 | * -- Display the list of people's phone numbers, allowing the user to |
| 180 | * browse through them and pick one and return it to the parent activity.</p> |
| 181 | * </li> |
| 182 | * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type |
| 183 | * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> |
| 184 | * -- Display all pickers for data that can be opened with |
| 185 | * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, |
| 186 | * allowing the user to pick one of them and then some data inside of it |
| 187 | * and returning the resulting URI to the caller. This can be used, |
| 188 | * for example, in an e-mail application to allow the user to pick some |
| 189 | * data to include as an attachment.</p> |
| 190 | * </li> |
| 191 | * </ul> |
| 192 | * |
| 193 | * <p>There are a variety of standard Intent action and category constants |
| 194 | * defined in the Intent class, but applications can also define their own. |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 195 | * These strings use Java-style scoping, to ensure they are unique -- for |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 196 | * example, the standard {@link #ACTION_VIEW} is called |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 197 | * "android.intent.action.VIEW".</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 198 | * |
| 199 | * <p>Put together, the set of actions, data types, categories, and extra data |
| 200 | * defines a language for the system allowing for the expression of phrases |
| 201 | * such as "call john smith's cell". As applications are added to the system, |
| 202 | * they can extend this language by adding new actions, types, and categories, or |
| 203 | * they can modify the behavior of existing phrases by supplying their own |
| 204 | * activities that handle them.</p> |
| 205 | * |
| 206 | * <a name="IntentResolution"></a> |
| 207 | * <h3>Intent Resolution</h3> |
| 208 | * |
| 209 | * <p>There are two primary forms of intents you will use. |
| 210 | * |
| 211 | * <ul> |
| 212 | * <li> <p><b>Explicit Intents</b> have specified a component (via |
| 213 | * {@link #setComponent} or {@link #setClass}), which provides the exact |
| 214 | * class to be run. Often these will not include any other information, |
| 215 | * simply being a way for an application to launch various internal |
| 216 | * activities it has as the user interacts with the application. |
| 217 | * |
| 218 | * <li> <p><b>Implicit Intents</b> have not specified a component; |
| 219 | * instead, they must include enough information for the system to |
| 220 | * determine which of the available components is best to run for that |
| 221 | * intent. |
| 222 | * </ul> |
| 223 | * |
| 224 | * <p>When using implicit intents, given such an arbitrary intent we need to |
| 225 | * know what to do with it. This is handled by the process of <em>Intent |
| 226 | * resolution</em>, which maps an Intent to an {@link android.app.Activity}, |
| 227 | * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or |
| 228 | * more activities/receivers) that can handle it.</p> |
| 229 | * |
| 230 | * <p>The intent resolution mechanism basically revolves around matching an |
| 231 | * Intent against all of the <intent-filter> descriptions in the |
| 232 | * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} |
| 233 | * objects explicitly registered with {@link Context#registerReceiver}.) More |
| 234 | * details on this can be found in the documentation on the {@link |
| 235 | * IntentFilter} class.</p> |
| 236 | * |
| 237 | * <p>There are three pieces of information in the Intent that are used for |
| 238 | * resolution: the action, type, and category. Using this information, a query |
| 239 | * is done on the {@link PackageManager} for a component that can handle the |
| 240 | * intent. The appropriate component is determined based on the intent |
| 241 | * information supplied in the <code>AndroidManifest.xml</code> file as |
| 242 | * follows:</p> |
| 243 | * |
| 244 | * <ul> |
| 245 | * <li> <p>The <b>action</b>, if given, must be listed by the component as |
| 246 | * one it handles.</p> |
| 247 | * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not |
| 248 | * already supplied in the Intent. Like the action, if a type is |
| 249 | * included in the intent (either explicitly or implicitly in its |
| 250 | * data), then this must be listed by the component as one it handles.</p> |
| 251 | * <li> For data that is not a <code>content:</code> URI and where no explicit |
| 252 | * type is included in the Intent, instead the <b>scheme</b> of the |
| 253 | * intent data (such as <code>http:</code> or <code>mailto:</code>) is |
| 254 | * considered. Again like the action, if we are matching a scheme it |
| 255 | * must be listed by the component as one it can handle. |
| 256 | * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed |
| 257 | * by the activity as categories it handles. That is, if you include |
| 258 | * the categories {@link #CATEGORY_LAUNCHER} and |
| 259 | * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components |
| 260 | * with an intent that lists <em>both</em> of those categories. |
| 261 | * Activities will very often need to support the |
| 262 | * {@link #CATEGORY_DEFAULT} so that they can be found by |
| 263 | * {@link Context#startActivity Context.startActivity()}.</p> |
| 264 | * </ul> |
| 265 | * |
| 266 | * <p>For example, consider the Note Pad sample application that |
| 267 | * allows user to browse through a list of notes data and view details about |
| 268 | * individual items. Text in italics indicate places were you would replace a |
| 269 | * name with one specific to your own package.</p> |
| 270 | * |
| 271 | * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 272 | * package="<i>com.android.notepad</i>"> |
| 273 | * <application android:icon="@drawable/app_notes" |
| 274 | * android:label="@string/app_name"> |
| 275 | * |
| 276 | * <provider class=".NotePadProvider" |
| 277 | * android:authorities="<i>com.google.provider.NotePad</i>" /> |
| 278 | * |
| 279 | * <activity class=".NotesList" android:label="@string/title_notes_list"> |
| 280 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 281 | * <action android:name="android.intent.action.MAIN" /> |
| 282 | * <category android:name="android.intent.category.LAUNCHER" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 283 | * </intent-filter> |
| 284 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 285 | * <action android:name="android.intent.action.VIEW" /> |
| 286 | * <action android:name="android.intent.action.EDIT" /> |
| 287 | * <action android:name="android.intent.action.PICK" /> |
| 288 | * <category android:name="android.intent.category.DEFAULT" /> |
| 289 | * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 290 | * </intent-filter> |
| 291 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 292 | * <action android:name="android.intent.action.GET_CONTENT" /> |
| 293 | * <category android:name="android.intent.category.DEFAULT" /> |
| 294 | * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 295 | * </intent-filter> |
| 296 | * </activity> |
| 297 | * |
| 298 | * <activity class=".NoteEditor" android:label="@string/title_note"> |
| 299 | * <intent-filter android:label="@string/resolve_edit"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 300 | * <action android:name="android.intent.action.VIEW" /> |
| 301 | * <action android:name="android.intent.action.EDIT" /> |
| 302 | * <category android:name="android.intent.category.DEFAULT" /> |
| 303 | * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 304 | * </intent-filter> |
| 305 | * |
| 306 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 307 | * <action android:name="android.intent.action.INSERT" /> |
| 308 | * <category android:name="android.intent.category.DEFAULT" /> |
| 309 | * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 310 | * </intent-filter> |
| 311 | * |
| 312 | * </activity> |
| 313 | * |
| 314 | * <activity class=".TitleEditor" android:label="@string/title_edit_title" |
| 315 | * android:theme="@android:style/Theme.Dialog"> |
| 316 | * <intent-filter android:label="@string/resolve_title"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 317 | * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> |
| 318 | * <category android:name="android.intent.category.DEFAULT" /> |
| 319 | * <category android:name="android.intent.category.ALTERNATIVE" /> |
| 320 | * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> |
| 321 | * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 322 | * </intent-filter> |
| 323 | * </activity> |
| 324 | * |
| 325 | * </application> |
| 326 | * </manifest></pre> |
| 327 | * |
| 328 | * <p>The first activity, |
| 329 | * <code>com.android.notepad.NotesList</code>, serves as our main |
| 330 | * entry into the app. It can do three things as described by its three intent |
| 331 | * templates: |
| 332 | * <ol> |
| 333 | * <li><pre> |
| 334 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 335 | * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> |
| 336 | * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 337 | * </intent-filter></pre> |
| 338 | * <p>This provides a top-level entry into the NotePad application: the standard |
| 339 | * MAIN action is a main entry point (not requiring any other information in |
| 340 | * the Intent), and the LAUNCHER category says that this entry point should be |
| 341 | * listed in the application launcher.</p> |
| 342 | * <li><pre> |
| 343 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 344 | * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> |
| 345 | * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> |
| 346 | * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> |
| 347 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 348 | * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 349 | * </intent-filter></pre> |
| 350 | * <p>This declares the things that the activity can do on a directory of |
| 351 | * notes. The type being supported is given with the <type> tag, where |
| 352 | * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which |
| 353 | * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can |
| 354 | * be retrieved which holds our note pad data (<code>vnd.google.note</code>). |
| 355 | * The activity allows the user to view or edit the directory of data (via |
| 356 | * the VIEW and EDIT actions), or to pick a particular note and return it |
| 357 | * to the caller (via the PICK action). Note also the DEFAULT category |
| 358 | * supplied here: this is <em>required</em> for the |
| 359 | * {@link Context#startActivity Context.startActivity} method to resolve your |
| 360 | * activity when its component name is not explicitly specified.</p> |
| 361 | * <li><pre> |
| 362 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 363 | * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> |
| 364 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 365 | * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 366 | * </intent-filter></pre> |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 367 | * <p>This filter describes the ability to return to the caller a note selected by |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 368 | * the user without needing to know where it came from. The data type |
| 369 | * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which |
| 370 | * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can |
| 371 | * be retrieved which contains our note pad data (<code>vnd.google.note</code>). |
| 372 | * The GET_CONTENT action is similar to the PICK action, where the activity |
| 373 | * will return to its caller a piece of data selected by the user. Here, |
| 374 | * however, the caller specifies the type of data they desire instead of |
| 375 | * the type of data the user will be picking from.</p> |
| 376 | * </ol> |
| 377 | * |
| 378 | * <p>Given these capabilities, the following intents will resolve to the |
| 379 | * NotesList activity:</p> |
| 380 | * |
| 381 | * <ul> |
| 382 | * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the |
| 383 | * activities that can be used as top-level entry points into an |
| 384 | * application.</p> |
| 385 | * <li> <p><b>{ action=android.app.action.MAIN, |
| 386 | * category=android.app.category.LAUNCHER }</b> is the actual intent |
| 387 | * used by the Launcher to populate its top-level list.</p> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 388 | * <li> <p><b>{ action=android.intent.action.VIEW |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 389 | * data=content://com.google.provider.NotePad/notes }</b> |
| 390 | * displays a list of all the notes under |
| 391 | * "content://com.google.provider.NotePad/notes", which |
| 392 | * the user can browse through and see the details on.</p> |
| 393 | * <li> <p><b>{ action=android.app.action.PICK |
| 394 | * data=content://com.google.provider.NotePad/notes }</b> |
| 395 | * provides a list of the notes under |
| 396 | * "content://com.google.provider.NotePad/notes", from which |
| 397 | * the user can pick a note whose data URL is returned back to the caller.</p> |
| 398 | * <li> <p><b>{ action=android.app.action.GET_CONTENT |
| 399 | * type=vnd.android.cursor.item/vnd.google.note }</b> |
| 400 | * is similar to the pick action, but allows the caller to specify the |
| 401 | * kind of data they want back so that the system can find the appropriate |
| 402 | * activity to pick something of that data type.</p> |
| 403 | * </ul> |
| 404 | * |
| 405 | * <p>The second activity, |
| 406 | * <code>com.android.notepad.NoteEditor</code>, shows the user a single |
| 407 | * note entry and allows them to edit it. It can do two things as described |
| 408 | * by its two intent templates: |
| 409 | * <ol> |
| 410 | * <li><pre> |
| 411 | * <intent-filter android:label="@string/resolve_edit"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 412 | * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> |
| 413 | * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> |
| 414 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 415 | * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 416 | * </intent-filter></pre> |
| 417 | * <p>The first, primary, purpose of this activity is to let the user interact |
| 418 | * with a single note, as decribed by the MIME type |
| 419 | * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can |
| 420 | * either VIEW a note or allow the user to EDIT it. Again we support the |
| 421 | * DEFAULT category to allow the activity to be launched without explicitly |
| 422 | * specifying its component.</p> |
| 423 | * <li><pre> |
| 424 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 425 | * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> |
| 426 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 427 | * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 428 | * </intent-filter></pre> |
| 429 | * <p>The secondary use of this activity is to insert a new note entry into |
| 430 | * an existing directory of notes. This is used when the user creates a new |
| 431 | * note: the INSERT action is executed on the directory of notes, causing |
| 432 | * this activity to run and have the user create the new note data which |
| 433 | * it then adds to the content provider.</p> |
| 434 | * </ol> |
| 435 | * |
| 436 | * <p>Given these capabilities, the following intents will resolve to the |
| 437 | * NoteEditor activity:</p> |
| 438 | * |
| 439 | * <ul> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 440 | * <li> <p><b>{ action=android.intent.action.VIEW |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 441 | * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> |
| 442 | * shows the user the content of note <var>{ID}</var>.</p> |
| 443 | * <li> <p><b>{ action=android.app.action.EDIT |
| 444 | * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> |
| 445 | * allows the user to edit the content of note <var>{ID}</var>.</p> |
| 446 | * <li> <p><b>{ action=android.app.action.INSERT |
| 447 | * data=content://com.google.provider.NotePad/notes }</b> |
| 448 | * creates a new, empty note in the notes list at |
| 449 | * "content://com.google.provider.NotePad/notes" |
| 450 | * and allows the user to edit it. If they keep their changes, the URI |
| 451 | * of the newly created note is returned to the caller.</p> |
| 452 | * </ul> |
| 453 | * |
| 454 | * <p>The last activity, |
| 455 | * <code>com.android.notepad.TitleEditor</code>, allows the user to |
| 456 | * edit the title of a note. This could be implemented as a class that the |
| 457 | * application directly invokes (by explicitly setting its component in |
| 458 | * the Intent), but here we show a way you can publish alternative |
| 459 | * operations on existing data:</p> |
| 460 | * |
| 461 | * <pre> |
| 462 | * <intent-filter android:label="@string/resolve_title"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 463 | * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> |
| 464 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 465 | * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> |
| 466 | * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> |
| 467 | * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 468 | * </intent-filter></pre> |
| 469 | * |
| 470 | * <p>In the single intent template here, we |
| 471 | * have created our own private action called |
| 472 | * <code>com.android.notepad.action.EDIT_TITLE</code> which means to |
| 473 | * edit the title of a note. It must be invoked on a specific note |
| 474 | * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous |
| 475 | * view and edit actions, but here displays and edits the title contained |
| 476 | * in the note data. |
| 477 | * |
| 478 | * <p>In addition to supporting the default category as usual, our title editor |
| 479 | * also supports two other standard categories: ALTERNATIVE and |
| 480 | * SELECTED_ALTERNATIVE. Implementing |
| 481 | * these categories allows others to find the special action it provides |
| 482 | * without directly knowing about it, through the |
| 483 | * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or |
| 484 | * more often to build dynamic menu items with |
| 485 | * {@link android.view.Menu#addIntentOptions}. Note that in the intent |
| 486 | * template here was also supply an explicit name for the template |
| 487 | * (via <code>android:label="@string/resolve_title"</code>) to better control |
| 488 | * what the user sees when presented with this activity as an alternative |
| 489 | * action to the data they are viewing. |
| 490 | * |
| 491 | * <p>Given these capabilities, the following intent will resolve to the |
| 492 | * TitleEditor activity:</p> |
| 493 | * |
| 494 | * <ul> |
| 495 | * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE |
| 496 | * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> |
| 497 | * displays and allows the user to edit the title associated |
| 498 | * with note <var>{ID}</var>.</p> |
| 499 | * </ul> |
| 500 | * |
| 501 | * <h3>Standard Activity Actions</h3> |
| 502 | * |
| 503 | * <p>These are the current standard actions that Intent defines for launching |
| 504 | * activities (usually through {@link Context#startActivity}. The most |
| 505 | * important, and by far most frequently used, are {@link #ACTION_MAIN} and |
| 506 | * {@link #ACTION_EDIT}. |
| 507 | * |
| 508 | * <ul> |
| 509 | * <li> {@link #ACTION_MAIN} |
| 510 | * <li> {@link #ACTION_VIEW} |
| 511 | * <li> {@link #ACTION_ATTACH_DATA} |
| 512 | * <li> {@link #ACTION_EDIT} |
| 513 | * <li> {@link #ACTION_PICK} |
| 514 | * <li> {@link #ACTION_CHOOSER} |
| 515 | * <li> {@link #ACTION_GET_CONTENT} |
| 516 | * <li> {@link #ACTION_DIAL} |
| 517 | * <li> {@link #ACTION_CALL} |
| 518 | * <li> {@link #ACTION_SEND} |
| 519 | * <li> {@link #ACTION_SENDTO} |
| 520 | * <li> {@link #ACTION_ANSWER} |
| 521 | * <li> {@link #ACTION_INSERT} |
| 522 | * <li> {@link #ACTION_DELETE} |
| 523 | * <li> {@link #ACTION_RUN} |
| 524 | * <li> {@link #ACTION_SYNC} |
| 525 | * <li> {@link #ACTION_PICK_ACTIVITY} |
| 526 | * <li> {@link #ACTION_SEARCH} |
| 527 | * <li> {@link #ACTION_WEB_SEARCH} |
| 528 | * <li> {@link #ACTION_FACTORY_TEST} |
| 529 | * </ul> |
| 530 | * |
| 531 | * <h3>Standard Broadcast Actions</h3> |
| 532 | * |
| 533 | * <p>These are the current standard actions that Intent defines for receiving |
| 534 | * broadcasts (usually through {@link Context#registerReceiver} or a |
| 535 | * <receiver> tag in a manifest). |
| 536 | * |
| 537 | * <ul> |
| 538 | * <li> {@link #ACTION_TIME_TICK} |
| 539 | * <li> {@link #ACTION_TIME_CHANGED} |
| 540 | * <li> {@link #ACTION_TIMEZONE_CHANGED} |
| 541 | * <li> {@link #ACTION_BOOT_COMPLETED} |
| 542 | * <li> {@link #ACTION_PACKAGE_ADDED} |
| 543 | * <li> {@link #ACTION_PACKAGE_CHANGED} |
| 544 | * <li> {@link #ACTION_PACKAGE_REMOVED} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 545 | * <li> {@link #ACTION_PACKAGE_RESTARTED} |
| 546 | * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 547 | * <li> {@link #ACTION_PACKAGES_SUSPENDED} |
| 548 | * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 549 | * <li> {@link #ACTION_UID_REMOVED} |
| 550 | * <li> {@link #ACTION_BATTERY_CHANGED} |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 551 | * <li> {@link #ACTION_POWER_CONNECTED} |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 552 | * <li> {@link #ACTION_POWER_DISCONNECTED} |
| 553 | * <li> {@link #ACTION_SHUTDOWN} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 554 | * </ul> |
| 555 | * |
| 556 | * <h3>Standard Categories</h3> |
| 557 | * |
| 558 | * <p>These are the current standard categories that can be used to further |
| 559 | * clarify an Intent via {@link #addCategory}. |
| 560 | * |
| 561 | * <ul> |
| 562 | * <li> {@link #CATEGORY_DEFAULT} |
| 563 | * <li> {@link #CATEGORY_BROWSABLE} |
| 564 | * <li> {@link #CATEGORY_TAB} |
| 565 | * <li> {@link #CATEGORY_ALTERNATIVE} |
| 566 | * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} |
| 567 | * <li> {@link #CATEGORY_LAUNCHER} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | * <li> {@link #CATEGORY_INFO} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 569 | * <li> {@link #CATEGORY_HOME} |
| 570 | * <li> {@link #CATEGORY_PREFERENCE} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 571 | * <li> {@link #CATEGORY_TEST} |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 572 | * <li> {@link #CATEGORY_CAR_DOCK} |
| 573 | * <li> {@link #CATEGORY_DESK_DOCK} |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 574 | * <li> {@link #CATEGORY_LE_DESK_DOCK} |
| 575 | * <li> {@link #CATEGORY_HE_DESK_DOCK} |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 576 | * <li> {@link #CATEGORY_CAR_MODE} |
Patrick Dubroy | 6dabe24 | 2010-08-30 10:43:47 -0700 | [diff] [blame] | 577 | * <li> {@link #CATEGORY_APP_MARKET} |
Zak Cohen | db6ca49 | 2017-01-26 14:09:00 -0800 | [diff] [blame] | 578 | * <li> {@link #CATEGORY_VR_HOME} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 579 | * </ul> |
| 580 | * |
| 581 | * <h3>Standard Extra Data</h3> |
| 582 | * |
| 583 | * <p>These are the current standard fields that can be used as extra data via |
| 584 | * {@link #putExtra}. |
| 585 | * |
| 586 | * <ul> |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 587 | * <li> {@link #EXTRA_ALARM_COUNT} |
| 588 | * <li> {@link #EXTRA_BCC} |
| 589 | * <li> {@link #EXTRA_CC} |
| 590 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} |
| 591 | * <li> {@link #EXTRA_DATA_REMOVED} |
| 592 | * <li> {@link #EXTRA_DOCK_STATE} |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 593 | * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} |
| 594 | * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 595 | * <li> {@link #EXTRA_DOCK_STATE_CAR} |
| 596 | * <li> {@link #EXTRA_DOCK_STATE_DESK} |
| 597 | * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} |
| 598 | * <li> {@link #EXTRA_DONT_KILL_APP} |
| 599 | * <li> {@link #EXTRA_EMAIL} |
| 600 | * <li> {@link #EXTRA_INITIAL_INTENTS} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 601 | * <li> {@link #EXTRA_INTENT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 602 | * <li> {@link #EXTRA_KEY_EVENT} |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 603 | * <li> {@link #EXTRA_ORIGINATING_URI} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 604 | * <li> {@link #EXTRA_PHONE_NUMBER} |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 605 | * <li> {@link #EXTRA_REFERRER} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 606 | * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} |
| 607 | * <li> {@link #EXTRA_REPLACING} |
| 608 | * <li> {@link #EXTRA_SHORTCUT_ICON} |
| 609 | * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} |
| 610 | * <li> {@link #EXTRA_SHORTCUT_INTENT} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 611 | * <li> {@link #EXTRA_STREAM} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 612 | * <li> {@link #EXTRA_SHORTCUT_NAME} |
| 613 | * <li> {@link #EXTRA_SUBJECT} |
| 614 | * <li> {@link #EXTRA_TEMPLATE} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 615 | * <li> {@link #EXTRA_TEXT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 616 | * <li> {@link #EXTRA_TITLE} |
| 617 | * <li> {@link #EXTRA_UID} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 618 | * </ul> |
| 619 | * |
| 620 | * <h3>Flags</h3> |
| 621 | * |
| 622 | * <p>These are the possible flags that can be used in the Intent via |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 623 | * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list |
| 624 | * of all possible flags. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 625 | */ |
Dianne Hackborn | ee0511d | 2009-12-21 18:08:13 -0800 | [diff] [blame] | 626 | public class Intent implements Parcelable, Cloneable { |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 627 | private static final String ATTR_ACTION = "action"; |
| 628 | private static final String TAG_CATEGORIES = "categories"; |
| 629 | private static final String ATTR_CATEGORY = "category"; |
| 630 | private static final String TAG_EXTRA = "extra"; |
| 631 | private static final String ATTR_TYPE = "type"; |
| 632 | private static final String ATTR_COMPONENT = "component"; |
| 633 | private static final String ATTR_DATA = "data"; |
| 634 | private static final String ATTR_FLAGS = "flags"; |
| 635 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 636 | // --------------------------------------------------------------------- |
| 637 | // --------------------------------------------------------------------- |
| 638 | // Standard intent activity actions (see action variable). |
| 639 | |
| 640 | /** |
| 641 | * Activity Action: Start as a main entry point, does not expect to |
| 642 | * receive data. |
| 643 | * <p>Input: nothing |
| 644 | * <p>Output: nothing |
| 645 | */ |
| 646 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 647 | public static final String ACTION_MAIN = "android.intent.action.MAIN"; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 648 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 649 | /** |
| 650 | * Activity Action: Display the data to the user. This is the most common |
| 651 | * action performed on data -- it is the generic action you can use on |
| 652 | * a piece of data to get the most reasonable thing to occur. For example, |
| 653 | * when used on a contacts entry it will view the entry; when used on a |
| 654 | * mailto: URI it will bring up a compose window filled with the information |
| 655 | * supplied by the URI; when used with a tel: URI it will invoke the |
| 656 | * dialer. |
| 657 | * <p>Input: {@link #getData} is URI from which to retrieve data. |
| 658 | * <p>Output: nothing. |
| 659 | */ |
| 660 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 661 | public static final String ACTION_VIEW = "android.intent.action.VIEW"; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 662 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 663 | /** |
Dianne Hackborn | a320f01 | 2017-04-07 13:57:48 -0700 | [diff] [blame] | 664 | * Extra that can be included on activity intents coming from the storage UI |
| 665 | * when it launches sub-activities to manage various types of storage. For example, |
| 666 | * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show |
| 667 | * the images on the device, and in that case also include this extra to tell the |
| 668 | * app it is coming from the storage UI so should help the user manage storage of |
| 669 | * this type. |
| 670 | */ |
| 671 | public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE"; |
| 672 | |
| 673 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 674 | * A synonym for {@link #ACTION_VIEW}, the "standard" action that is |
| 675 | * performed on a piece of data. |
| 676 | */ |
| 677 | public static final String ACTION_DEFAULT = ACTION_VIEW; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 678 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 679 | /** |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 680 | * Activity Action: Quick view the data. Launches a quick viewer for |
| 681 | * a URI or a list of URIs. |
Tomasz Mikolajewski | fe02313 | 2016-03-10 17:42:35 +0900 | [diff] [blame] | 682 | * <p>Activities handling this intent action should handle the vast majority of |
| 683 | * MIME types rather than only specific ones. |
Garfield Tan | ce1d0e9 | 2017-03-23 10:52:48 -0700 | [diff] [blame] | 684 | * <p>Quick viewers must render the quick view image locally, and must not send |
| 685 | * file content outside current device. |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 686 | * <p>Input: {@link #getData} is a mandatory content URI of the item to |
| 687 | * preview. {@link #getClipData} contains an optional list of content URIs |
| 688 | * if there is more than one item to preview. {@link #EXTRA_INDEX} is an |
| 689 | * optional index of the URI in the clip data to show first. |
Garfield Tan | ce1d0e9 | 2017-03-23 10:52:48 -0700 | [diff] [blame] | 690 | * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features |
| 691 | * that can be shown in the quick view UI. |
Steve McKay | c78bcb8 | 2015-07-31 14:35:22 -0700 | [diff] [blame] | 692 | * <p>Output: nothing. |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 693 | * @see #EXTRA_INDEX |
Garfield Tan | ce1d0e9 | 2017-03-23 10:52:48 -0700 | [diff] [blame] | 694 | * @see #EXTRA_QUICK_VIEW_FEATURES |
Steve McKay | c78bcb8 | 2015-07-31 14:35:22 -0700 | [diff] [blame] | 695 | */ |
| 696 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 697 | public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; |
| 698 | |
| 699 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 700 | * Used to indicate that some piece of data should be attached to some other |
| 701 | * place. For example, image data could be attached to a contact. It is up |
| 702 | * to the recipient to decide where the data should be attached; the intent |
| 703 | * does not specify the ultimate destination. |
| 704 | * <p>Input: {@link #getData} is URI of data to be attached. |
| 705 | * <p>Output: nothing. |
| 706 | */ |
| 707 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 708 | public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 709 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 710 | /** |
| 711 | * Activity Action: Provide explicit editable access to the given data. |
| 712 | * <p>Input: {@link #getData} is URI of data to be edited. |
| 713 | * <p>Output: nothing. |
| 714 | */ |
| 715 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 716 | public static final String ACTION_EDIT = "android.intent.action.EDIT"; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 717 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 718 | /** |
| 719 | * Activity Action: Pick an existing item, or insert a new item, and then edit it. |
| 720 | * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. |
| 721 | * The extras can contain type specific data to pass through to the editing/creating |
| 722 | * activity. |
| 723 | * <p>Output: The URI of the item that was picked. This must be a content: |
| 724 | * URI so that any receiver can access it. |
| 725 | */ |
| 726 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 727 | public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 728 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 729 | /** |
| 730 | * Activity Action: Pick an item from the data, returning what was selected. |
| 731 | * <p>Input: {@link #getData} is URI containing a directory of data |
| 732 | * (vnd.android.cursor.dir/*) from which to pick an item. |
| 733 | * <p>Output: The URI of the item that was picked. |
| 734 | */ |
| 735 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 736 | public static final String ACTION_PICK = "android.intent.action.PICK"; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 737 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 738 | /** |
| 739 | * Activity Action: Creates a shortcut. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 740 | * <p>Input: Nothing.</p> |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 741 | * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> |
| 742 | * <p>For compatibility with older versions of android the intent may also contain three |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 743 | * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), |
| 744 | * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 745 | * (value: ShortcutIconResource).</p> |
| 746 | * |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 747 | * @see android.content.pm.ShortcutManager#createShortcutResultIntent |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 748 | * @see #EXTRA_SHORTCUT_INTENT |
| 749 | * @see #EXTRA_SHORTCUT_NAME |
| 750 | * @see #EXTRA_SHORTCUT_ICON |
| 751 | * @see #EXTRA_SHORTCUT_ICON_RESOURCE |
| 752 | * @see android.content.Intent.ShortcutIconResource |
| 753 | */ |
| 754 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 755 | public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; |
| 756 | |
| 757 | /** |
| 758 | * The name of the extra used to define the Intent of a shortcut. |
| 759 | * |
| 760 | * @see #ACTION_CREATE_SHORTCUT |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 761 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 762 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 763 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 764 | public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; |
| 765 | /** |
| 766 | * The name of the extra used to define the name of a shortcut. |
| 767 | * |
| 768 | * @see #ACTION_CREATE_SHORTCUT |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 769 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 770 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 771 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 772 | public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; |
| 773 | /** |
| 774 | * The name of the extra used to define the icon, as a Bitmap, of a shortcut. |
| 775 | * |
| 776 | * @see #ACTION_CREATE_SHORTCUT |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 777 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 778 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 779 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 780 | public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; |
| 781 | /** |
| 782 | * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. |
| 783 | * |
| 784 | * @see #ACTION_CREATE_SHORTCUT |
| 785 | * @see android.content.Intent.ShortcutIconResource |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 786 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 787 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 788 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 789 | public static final String EXTRA_SHORTCUT_ICON_RESOURCE = |
| 790 | "android.intent.extra.shortcut.ICON_RESOURCE"; |
| 791 | |
| 792 | /** |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 793 | * An activity that provides a user interface for adjusting application preferences. |
| 794 | * Optional but recommended settings for all applications which have settings. |
| 795 | */ |
| 796 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 797 | public static final String ACTION_APPLICATION_PREFERENCES |
| 798 | = "android.intent.action.APPLICATION_PREFERENCES"; |
| 799 | |
| 800 | /** |
Sudheer Shanka | 80b6641 | 2016-04-06 18:31:10 -0700 | [diff] [blame] | 801 | * Activity Action: Launch an activity showing the app information. |
| 802 | * For applications which install other applications (such as app stores), it is recommended |
| 803 | * to handle this action for providing the app information to the user. |
| 804 | * |
| 805 | * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs |
| 806 | * to be displayed. |
| 807 | * <p>Output: Nothing. |
| 808 | */ |
| 809 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 810 | public static final String ACTION_SHOW_APP_INFO |
| 811 | = "android.intent.action.SHOW_APP_INFO"; |
| 812 | |
| 813 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 814 | * Represents a shortcut/live folder icon resource. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 815 | * |
| 816 | * @see Intent#ACTION_CREATE_SHORTCUT |
| 817 | * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 818 | * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER |
| 819 | * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 820 | */ |
| 821 | public static class ShortcutIconResource implements Parcelable { |
| 822 | /** |
| 823 | * The package name of the application containing the icon. |
| 824 | */ |
| 825 | public String packageName; |
| 826 | |
| 827 | /** |
| 828 | * The resource name of the icon, including package, name and type. |
| 829 | */ |
| 830 | public String resourceName; |
| 831 | |
| 832 | /** |
| 833 | * Creates a new ShortcutIconResource for the specified context and resource |
| 834 | * identifier. |
| 835 | * |
| 836 | * @param context The context of the application. |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 837 | * @param resourceId The resource identifier for the icon. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 838 | * @return A new ShortcutIconResource with the specified's context package name |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 839 | * and icon resource identifier.`` |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 840 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 841 | public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 842 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 843 | icon.packageName = context.getPackageName(); |
| 844 | icon.resourceName = context.getResources().getResourceName(resourceId); |
| 845 | return icon; |
| 846 | } |
| 847 | |
| 848 | /** |
| 849 | * Used to read a ShortcutIconResource from a Parcel. |
| 850 | */ |
| 851 | public static final Parcelable.Creator<ShortcutIconResource> CREATOR = |
| 852 | new Parcelable.Creator<ShortcutIconResource>() { |
| 853 | |
| 854 | public ShortcutIconResource createFromParcel(Parcel source) { |
| 855 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 856 | icon.packageName = source.readString(); |
| 857 | icon.resourceName = source.readString(); |
| 858 | return icon; |
| 859 | } |
| 860 | |
| 861 | public ShortcutIconResource[] newArray(int size) { |
| 862 | return new ShortcutIconResource[size]; |
| 863 | } |
| 864 | }; |
| 865 | |
| 866 | /** |
| 867 | * No special parcel contents. |
| 868 | */ |
| 869 | public int describeContents() { |
| 870 | return 0; |
| 871 | } |
| 872 | |
| 873 | public void writeToParcel(Parcel dest, int flags) { |
| 874 | dest.writeString(packageName); |
| 875 | dest.writeString(resourceName); |
| 876 | } |
| 877 | |
| 878 | @Override |
| 879 | public String toString() { |
| 880 | return resourceName; |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | /** |
| 885 | * Activity Action: Display an activity chooser, allowing the user to pick |
| 886 | * what they want to before proceeding. This can be used as an alternative |
| 887 | * to the standard activity picker that is displayed by the system when |
| 888 | * you try to start an activity with multiple possible matches, with these |
| 889 | * differences in behavior: |
| 890 | * <ul> |
| 891 | * <li>You can specify the title that will appear in the activity chooser. |
| 892 | * <li>The user does not have the option to make one of the matching |
| 893 | * activities a preferred activity, and all possible activities will |
| 894 | * always be shown even if one of them is currently marked as the |
| 895 | * preferred activity. |
| 896 | * </ul> |
| 897 | * <p> |
| 898 | * This action should be used when the user will naturally expect to |
| 899 | * select an activity in order to proceed. An example if when not to use |
| 900 | * it is when the user clicks on a "mailto:" link. They would naturally |
| 901 | * expect to go directly to their mail app, so startActivity() should be |
| 902 | * called directly: it will |
| 903 | * either launch the current preferred app, or put up a dialog allowing the |
| 904 | * user to pick an app to use and optionally marking that as preferred. |
| 905 | * <p> |
| 906 | * In contrast, if the user is selecting a menu item to send a picture |
| 907 | * they are viewing to someone else, there are many different things they |
| 908 | * may want to do at this point: send it through e-mail, upload it to a |
| 909 | * web service, etc. In this case the CHOOSER action should be used, to |
| 910 | * always present to the user a list of the things they can do, with a |
| 911 | * nice title given by the caller such as "Send this photo with:". |
| 912 | * <p> |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 913 | * If you need to grant URI permissions through a chooser, you must specify |
| 914 | * the permissions to be granted on the ACTION_CHOOSER Intent |
| 915 | * <em>in addition</em> to the EXTRA_INTENT inside. This means using |
| 916 | * {@link #setClipData} to specify the URIs to be granted as well as |
| 917 | * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 918 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. |
| 919 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 920 | * As a convenience, an Intent of this form can be created with the |
| 921 | * {@link #createChooser} function. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 922 | * <p> |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 923 | * Input: No data should be specified. get*Extra must have |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 924 | * a {@link #EXTRA_INTENT} field containing the Intent being executed, |
| 925 | * and can optionally have a {@link #EXTRA_TITLE} field containing the |
| 926 | * title text to display in the chooser. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 927 | * <p> |
| 928 | * Output: Depends on the protocol of {@link #EXTRA_INTENT}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 929 | */ |
| 930 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 931 | public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; |
| 932 | |
| 933 | /** |
| 934 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 935 | * |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 936 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 937 | * target intent, also optionally supplying a title. If the target |
| 938 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 939 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 940 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 941 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
John Spurlock | 3390018 | 2014-01-02 11:04:18 -0500 | [diff] [blame] | 942 | * or a new ClipData built from {@link #getData()}. |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 943 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 944 | * @param target The Intent that the user will be selecting an activity |
| 945 | * to perform. |
| 946 | * @param title Optional title that will be displayed in the chooser. |
| 947 | * @return Return a new Intent object that you can hand to |
| 948 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 949 | * related methods. |
| 950 | */ |
| 951 | public static Intent createChooser(Intent target, CharSequence title) { |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 952 | return createChooser(target, title, null); |
| 953 | } |
| 954 | |
| 955 | /** |
| 956 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 957 | * |
| 958 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 959 | * target intent, also optionally supplying a title. If the target |
| 960 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 961 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 962 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 963 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
| 964 | * or a new ClipData built from {@link #getData()}.</p> |
| 965 | * |
| 966 | * <p>The caller may optionally supply an {@link IntentSender} to receive a callback |
| 967 | * when the user makes a choice. This can be useful if the calling application wants |
| 968 | * to remember the last chosen target and surface it as a more prominent or one-touch |
| 969 | * affordance elsewhere in the UI for next time.</p> |
| 970 | * |
| 971 | * @param target The Intent that the user will be selecting an activity |
| 972 | * to perform. |
| 973 | * @param title Optional title that will be displayed in the chooser. |
| 974 | * @param sender Optional IntentSender to be called when a choice is made. |
| 975 | * @return Return a new Intent object that you can hand to |
| 976 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 977 | * related methods. |
| 978 | */ |
| 979 | public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 980 | Intent intent = new Intent(ACTION_CHOOSER); |
| 981 | intent.putExtra(EXTRA_INTENT, target); |
| 982 | if (title != null) { |
| 983 | intent.putExtra(EXTRA_TITLE, title); |
| 984 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 985 | |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 986 | if (sender != null) { |
| 987 | intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); |
| 988 | } |
| 989 | |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 990 | // Migrate any clip data and flags from target. |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 991 | int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION |
| 992 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 993 | | FLAG_GRANT_PREFIX_URI_PERMISSION); |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 994 | if (permFlags != 0) { |
| 995 | ClipData targetClipData = target.getClipData(); |
| 996 | if (targetClipData == null && target.getData() != null) { |
| 997 | ClipData.Item item = new ClipData.Item(target.getData()); |
| 998 | String[] mimeTypes; |
| 999 | if (target.getType() != null) { |
| 1000 | mimeTypes = new String[] { target.getType() }; |
| 1001 | } else { |
| 1002 | mimeTypes = new String[] { }; |
| 1003 | } |
| 1004 | targetClipData = new ClipData(null, mimeTypes, item); |
| 1005 | } |
| 1006 | if (targetClipData != null) { |
| 1007 | intent.setClipData(targetClipData); |
| 1008 | intent.addFlags(permFlags); |
| 1009 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 1010 | } |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 1011 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1012 | return intent; |
| 1013 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 1014 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1015 | /** |
| 1016 | * Activity Action: Allow the user to select a particular kind of data and |
| 1017 | * return it. This is different than {@link #ACTION_PICK} in that here we |
| 1018 | * just say what kind of data is desired, not a URI of existing data from |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 1019 | * which the user can pick. An ACTION_GET_CONTENT could allow the user to |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1020 | * create the data as it runs (for example taking a picture or recording a |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1021 | * sound), let them browse over the web and download the desired data, |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1022 | * etc. |
| 1023 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1024 | * There are two main ways to use this action: if you want a specific kind |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1025 | * of data, such as a person contact, you set the MIME type to the kind of |
| 1026 | * data you want and launch it with {@link Context#startActivity(Intent)}. |
| 1027 | * The system will then launch the best application to select that kind |
| 1028 | * of data for you. |
| 1029 | * <p> |
| 1030 | * You may also be interested in any of a set of types of content the user |
| 1031 | * can pick. For example, an e-mail application that wants to allow the |
| 1032 | * user to add an attachment to an e-mail message can use this action to |
| 1033 | * bring up a list of all of the types of content the user can attach. |
| 1034 | * <p> |
| 1035 | * In this case, you should wrap the GET_CONTENT intent with a chooser |
| 1036 | * (through {@link #createChooser}), which will give the proper interface |
| 1037 | * for the user to pick how to send your data and allow you to specify |
| 1038 | * a prompt indicating what they are doing. You will usually specify a |
| 1039 | * broad MIME type (such as image/* or {@literal *}/*), resulting in a |
| 1040 | * broad range of content types the user can select from. |
| 1041 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1042 | * When using such a broad GET_CONTENT action, it is often desirable to |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1043 | * only pick from data that can be represented as a stream. This is |
| 1044 | * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. |
| 1045 | * <p> |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1046 | * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1047 | * the launched content chooser only returns results representing data that |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1048 | * is locally available on the device. For example, if this extra is set |
| 1049 | * to true then an image picker should not show any pictures that are available |
| 1050 | * from a remote server but not already on the local device (thus requiring |
| 1051 | * they be downloaded when opened). |
| 1052 | * <p> |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 1053 | * If the caller can handle multiple returned items (the user performing |
| 1054 | * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 1055 | * to indicate this. |
| 1056 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1057 | * Input: {@link #getType} is the desired MIME type to retrieve. Note |
| 1058 | * that no URI is supplied in the intent, as there are no constraints on |
| 1059 | * where the returned data originally comes from. You may also include the |
| 1060 | * {@link #CATEGORY_OPENABLE} if you can only accept data that can be |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1061 | * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 1062 | * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to |
| 1063 | * allow the user to select multiple items. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1064 | * <p> |
| 1065 | * Output: The URI of the item that was picked. This must be a content: |
| 1066 | * URI so that any receiver can access it. |
| 1067 | */ |
| 1068 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1069 | public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; |
| 1070 | /** |
| 1071 | * Activity Action: Dial a number as specified by the data. This shows a |
| 1072 | * UI with the number being dialed, allowing the user to explicitly |
| 1073 | * initiate the call. |
| 1074 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1075 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1076 | * number. |
| 1077 | * <p>Output: nothing. |
| 1078 | */ |
| 1079 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1080 | public static final String ACTION_DIAL = "android.intent.action.DIAL"; |
| 1081 | /** |
| 1082 | * Activity Action: Perform a call to someone specified by the data. |
| 1083 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1084 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1085 | * number. |
| 1086 | * <p>Output: nothing. |
| 1087 | * |
| 1088 | * <p>Note: there will be restrictions on which applications can initiate a |
| 1089 | * call; most applications should use the {@link #ACTION_DIAL}. |
| 1090 | * <p>Note: this Intent <strong>cannot</strong> be used to call emergency |
| 1091 | * numbers. Applications can <strong>dial</strong> emergency numbers using |
| 1092 | * {@link #ACTION_DIAL}, however. |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1093 | * |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 1094 | * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M} |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1095 | * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE} |
Svet Ganov | 7121e18 | 2015-07-13 22:38:12 -0700 | [diff] [blame] | 1096 | * permission which is not granted, then attempting to use this action will |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1097 | * result in a {@link java.lang.SecurityException}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1098 | */ |
| 1099 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1100 | public static final String ACTION_CALL = "android.intent.action.CALL"; |
| 1101 | /** |
| 1102 | * Activity Action: Perform a call to an emergency number specified by the |
| 1103 | * data. |
| 1104 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1105 | * tel: URI of an explicit phone number. |
| 1106 | * <p>Output: nothing. |
| 1107 | * @hide |
| 1108 | */ |
Brad Ebinger | 7a8d352 | 2017-03-31 10:21:09 -0700 | [diff] [blame] | 1109 | @SystemApi |
| 1110 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1111 | public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; |
| 1112 | /** |
| 1113 | * Activity action: Perform a call to any number (emergency or not) |
| 1114 | * specified by the data. |
| 1115 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1116 | * tel: URI of an explicit phone number. |
| 1117 | * <p>Output: nothing. |
| 1118 | * @hide |
| 1119 | */ |
Brad Ebinger | 7a8d352 | 2017-03-31 10:21:09 -0700 | [diff] [blame] | 1120 | @SystemApi |
| 1121 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1122 | public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; |
fionaxu | 77a744c | 2017-03-17 14:35:39 -0700 | [diff] [blame] | 1123 | |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 1124 | /** |
fionaxu | adfe700 | 2017-02-17 17:20:46 -0800 | [diff] [blame] | 1125 | * Activity Action: Main entry point for carrier setup apps. |
| 1126 | * <p>Carrier apps that provide an implementation for this action may be invoked to configure |
| 1127 | * carrier service and typically require |
| 1128 | * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to |
| 1129 | * fulfill their duties. |
| 1130 | */ |
| 1131 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1132 | public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP"; |
| 1133 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1134 | * Activity Action: Send a message to someone specified by the data. |
| 1135 | * <p>Input: {@link #getData} is URI describing the target. |
| 1136 | * <p>Output: nothing. |
| 1137 | */ |
| 1138 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1139 | public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; |
| 1140 | /** |
| 1141 | * Activity Action: Deliver some data to someone else. Who the data is |
| 1142 | * being delivered to is not specified; it is up to the receiver of this |
| 1143 | * action to ask the user where the data should be sent. |
| 1144 | * <p> |
| 1145 | * When launching a SEND intent, you should usually wrap it in a chooser |
| 1146 | * (through {@link #createChooser}), which will give the proper interface |
| 1147 | * for the user to pick how to send your data and allow you to specify |
| 1148 | * a prompt indicating what they are doing. |
| 1149 | * <p> |
| 1150 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1151 | * get*Extra can have either a {@link #EXTRA_TEXT} |
| 1152 | * or {@link #EXTRA_STREAM} field, containing the data to be sent. If |
| 1153 | * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it |
| 1154 | * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* |
| 1155 | * if the MIME type is unknown (this will only allow senders that can |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1156 | * handle generic data streams). If using {@link #EXTRA_TEXT}, you can |
| 1157 | * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve |
| 1158 | * your text with HTML formatting. |
| 1159 | * <p> |
| 1160 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1161 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1162 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1163 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1164 | * using this approach, you still must supply the same data through the |
| 1165 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1166 | * for compatibility with old applications. If you don't set a ClipData, |
| 1167 | * it will be copied there for you when calling {@link Context#startActivity(Intent)}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1168 | * <p> |
Tomasz Mikolajewski | d8a2e19 | 2016-12-15 16:10:46 +0900 | [diff] [blame] | 1169 | * Starting from {@link android.os.Build.VERSION_CODES#O}, if |
| 1170 | * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in |
| 1171 | * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may |
| 1172 | * be openable only as asset typed files using |
| 1173 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
| 1174 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1175 | * Optional standard extras, which may be interpreted by some recipients as |
| 1176 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1177 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1178 | * <p> |
| 1179 | * Output: nothing. |
| 1180 | */ |
| 1181 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1182 | public static final String ACTION_SEND = "android.intent.action.SEND"; |
| 1183 | /** |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1184 | * Activity Action: Deliver multiple data to someone else. |
| 1185 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1186 | * Like {@link #ACTION_SEND}, except the data is multiple. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1187 | * <p> |
| 1188 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1189 | * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1190 | * #EXTRA_STREAM} field, containing the data to be sent. If using |
| 1191 | * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} |
| 1192 | * for clients to retrieve your text with HTML formatting. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1193 | * <p> |
Chih-Chung Chang | 5962d27 | 2009-09-04 14:36:01 +0800 | [diff] [blame] | 1194 | * Multiple types are supported, and receivers should handle mixed types |
| 1195 | * whenever possible. The right way for the receiver to check them is to |
| 1196 | * use the content resolver on each URI. The intent sender should try to |
| 1197 | * put the most concrete mime type in the intent type, but it can fall |
| 1198 | * back to {@literal <type>/*} or {@literal *}/* as needed. |
| 1199 | * <p> |
| 1200 | * e.g. if you are sending image/jpg and image/jpg, the intent's type can |
| 1201 | * be image/jpg, but if you are sending image/jpg and image/png, then the |
| 1202 | * intent's type should be image/*. |
| 1203 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1204 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1205 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1206 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1207 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1208 | * using this approach, you still must supply the same data through the |
| 1209 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1210 | * for compatibility with old applications. If you don't set a ClipData, |
| 1211 | * it will be copied there for you when calling {@link Context#startActivity(Intent)}. |
| 1212 | * <p> |
Tomasz Mikolajewski | d8a2e19 | 2016-12-15 16:10:46 +0900 | [diff] [blame] | 1213 | * Starting from {@link android.os.Build.VERSION_CODES#O}, if |
| 1214 | * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in |
| 1215 | * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may |
| 1216 | * be openable only as asset typed files using |
| 1217 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
| 1218 | * <p> |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1219 | * Optional standard extras, which may be interpreted by some recipients as |
| 1220 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1221 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1222 | * <p> |
| 1223 | * Output: nothing. |
| 1224 | */ |
| 1225 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1226 | public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; |
| 1227 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1228 | * Activity Action: Handle an incoming phone call. |
| 1229 | * <p>Input: nothing. |
| 1230 | * <p>Output: nothing. |
| 1231 | */ |
| 1232 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1233 | public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; |
| 1234 | /** |
| 1235 | * Activity Action: Insert an empty item into the given container. |
| 1236 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1237 | * in which to place the data. |
| 1238 | * <p>Output: URI of the new data that was created. |
| 1239 | */ |
| 1240 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1241 | public static final String ACTION_INSERT = "android.intent.action.INSERT"; |
| 1242 | /** |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 1243 | * Activity Action: Create a new item in the given container, initializing it |
| 1244 | * from the current contents of the clipboard. |
| 1245 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1246 | * in which to place the data. |
| 1247 | * <p>Output: URI of the new data that was created. |
| 1248 | */ |
| 1249 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1250 | public static final String ACTION_PASTE = "android.intent.action.PASTE"; |
| 1251 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1252 | * Activity Action: Delete the given data from its container. |
| 1253 | * <p>Input: {@link #getData} is URI of data to be deleted. |
| 1254 | * <p>Output: nothing. |
| 1255 | */ |
| 1256 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1257 | public static final String ACTION_DELETE = "android.intent.action.DELETE"; |
| 1258 | /** |
| 1259 | * Activity Action: Run the data, whatever that means. |
| 1260 | * <p>Input: ? (Note: this is currently specific to the test harness.) |
| 1261 | * <p>Output: nothing. |
| 1262 | */ |
| 1263 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1264 | public static final String ACTION_RUN = "android.intent.action.RUN"; |
| 1265 | /** |
| 1266 | * Activity Action: Perform a data synchronization. |
| 1267 | * <p>Input: ? |
| 1268 | * <p>Output: ? |
| 1269 | */ |
| 1270 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1271 | public static final String ACTION_SYNC = "android.intent.action.SYNC"; |
| 1272 | /** |
| 1273 | * Activity Action: Pick an activity given an intent, returning the class |
| 1274 | * selected. |
| 1275 | * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent |
| 1276 | * used with {@link PackageManager#queryIntentActivities} to determine the |
| 1277 | * set of activities from which to pick. |
| 1278 | * <p>Output: Class name of the activity that was selected. |
| 1279 | */ |
| 1280 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1281 | public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; |
| 1282 | /** |
| 1283 | * Activity Action: Perform a search. |
| 1284 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1285 | * is the text to search for. If empty, simply |
| 1286 | * enter your search results Activity with the search UI activated. |
| 1287 | * <p>Output: nothing. |
| 1288 | */ |
| 1289 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1290 | public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; |
| 1291 | /** |
Jim Miller | 7e4ad35 | 2009-03-25 18:16:41 -0700 | [diff] [blame] | 1292 | * Activity Action: Start the platform-defined tutorial |
| 1293 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1294 | * is the text to search for. If empty, simply |
| 1295 | * enter your search results Activity with the search UI activated. |
| 1296 | * <p>Output: nothing. |
| 1297 | */ |
| 1298 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1299 | public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; |
| 1300 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1301 | * Activity Action: Perform a web search. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1302 | * <p> |
| 1303 | * Input: {@link android.app.SearchManager#QUERY |
| 1304 | * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is |
| 1305 | * a url starts with http or https, the site will be opened. If it is plain |
| 1306 | * text, Google search will be applied. |
| 1307 | * <p> |
| 1308 | * Output: nothing. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1309 | */ |
| 1310 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1311 | public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1312 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1313 | /** |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1314 | * Activity Action: Perform assist action. |
| 1315 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1316 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1317 | * additional optional contextual information about where the user was when they |
Dianne Hackborn | a3acdb3 | 2015-06-08 17:07:40 -0700 | [diff] [blame] | 1318 | * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer |
| 1319 | * information. |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1320 | * Output: nothing. |
| 1321 | */ |
| 1322 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1323 | public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1324 | |
| 1325 | /** |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1326 | * Activity Action: Perform voice assist action. |
| 1327 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1328 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1329 | * additional optional contextual information about where the user was when they |
Adam Skory | dfc7fd7 | 2013-08-05 19:23:41 -0700 | [diff] [blame] | 1330 | * requested the voice assist. |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1331 | * Output: nothing. |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1332 | * @hide |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1333 | */ |
Amith Yamasani | 1645203 | 2017-03-03 10:15:57 -0800 | [diff] [blame] | 1334 | @SystemApi |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1335 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1336 | public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; |
| 1337 | |
| 1338 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1339 | * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground |
| 1340 | * application package at the time the assist was invoked. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1341 | */ |
| 1342 | public static final String EXTRA_ASSIST_PACKAGE |
| 1343 | = "android.intent.extra.ASSIST_PACKAGE"; |
| 1344 | |
| 1345 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 1346 | * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground |
| 1347 | * application package at the time the assist was invoked. |
| 1348 | */ |
| 1349 | public static final String EXTRA_ASSIST_UID |
| 1350 | = "android.intent.extra.ASSIST_UID"; |
| 1351 | |
| 1352 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1353 | * An optional field on {@link #ACTION_ASSIST} and containing additional contextual |
| 1354 | * information supplied by the current foreground app at the time of the assist request. |
| 1355 | * This is a {@link Bundle} of additional data. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1356 | */ |
| 1357 | public static final String EXTRA_ASSIST_CONTEXT |
| 1358 | = "android.intent.extra.ASSIST_CONTEXT"; |
| 1359 | |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1360 | /** |
Michael Wright | 8ab940a | 2014-09-01 11:01:27 -0700 | [diff] [blame] | 1361 | * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a |
| 1362 | * keyboard as the primary input device for assistance. |
| 1363 | */ |
| 1364 | public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = |
| 1365 | "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; |
| 1366 | |
| 1367 | /** |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 1368 | * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id |
| 1369 | * that was used to invoke the assist. |
| 1370 | */ |
| 1371 | public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = |
| 1372 | "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; |
| 1373 | |
| 1374 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 1375 | * Activity Action: List all available applications. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1376 | * <p>Input: Nothing. |
| 1377 | * <p>Output: nothing. |
| 1378 | */ |
| 1379 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1380 | public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; |
| 1381 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 1382 | * Activity Action: Show settings for choosing wallpaper. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1383 | * <p>Input: Nothing. |
| 1384 | * <p>Output: Nothing. |
| 1385 | */ |
| 1386 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1387 | public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; |
| 1388 | |
| 1389 | /** |
| 1390 | * Activity Action: Show activity for reporting a bug. |
| 1391 | * <p>Input: Nothing. |
| 1392 | * <p>Output: Nothing. |
| 1393 | */ |
| 1394 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1395 | public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; |
| 1396 | |
| 1397 | /** |
| 1398 | * Activity Action: Main entry point for factory tests. Only used when |
| 1399 | * the device is booting in factory test node. The implementing package |
| 1400 | * must be installed in the system image. |
| 1401 | * <p>Input: nothing |
| 1402 | * <p>Output: nothing |
| 1403 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 1404 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1405 | public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; |
| 1406 | |
| 1407 | /** |
| 1408 | * Activity Action: The user pressed the "call" button to go to the dialer |
| 1409 | * or other appropriate UI for placing a call. |
| 1410 | * <p>Input: Nothing. |
| 1411 | * <p>Output: Nothing. |
| 1412 | */ |
| 1413 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1414 | public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; |
| 1415 | |
| 1416 | /** |
| 1417 | * Activity Action: Start Voice Command. |
| 1418 | * <p>Input: Nothing. |
| 1419 | * <p>Output: Nothing. |
| 1420 | */ |
| 1421 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1422 | public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1423 | |
| 1424 | /** |
| 1425 | * Activity Action: Start action associated with long pressing on the |
| 1426 | * search key. |
| 1427 | * <p>Input: Nothing. |
| 1428 | * <p>Output: Nothing. |
| 1429 | */ |
| 1430 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1431 | public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1432 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1433 | /** |
| 1434 | * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. |
| 1435 | * This intent is delivered to the package which installed the application, usually |
Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 1436 | * Google Play. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1437 | * <p>Input: No data is specified. The bug report is passed in using |
| 1438 | * an {@link #EXTRA_BUG_REPORT} field. |
| 1439 | * <p>Output: Nothing. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1440 | * |
| 1441 | * @see #EXTRA_BUG_REPORT |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1442 | */ |
| 1443 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1444 | public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; |
Dianne Hackborn | 3d74bb4 | 2009-06-19 10:35:21 -0700 | [diff] [blame] | 1445 | |
| 1446 | /** |
| 1447 | * Activity Action: Show power usage information to the user. |
| 1448 | * <p>Input: Nothing. |
| 1449 | * <p>Output: Nothing. |
| 1450 | */ |
| 1451 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1452 | public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1453 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1454 | /** |
Russell Brenner | 4cd32e5 | 2017-02-24 11:11:47 -0800 | [diff] [blame] | 1455 | * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs |
| 1456 | * to run. |
| 1457 | * <p>Input: Nothing. |
| 1458 | * <p>Output: Nothing. |
| 1459 | * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified |
| 1460 | * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD} |
| 1461 | * @hide |
| 1462 | */ |
| 1463 | @Deprecated |
| 1464 | @SystemApi |
| 1465 | public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = |
| 1466 | "android.intent.action.DEVICE_INITIALIZATION_WIZARD"; |
| 1467 | |
| 1468 | /** |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1469 | * Activity Action: Setup wizard to launch after a platform update. This |
| 1470 | * activity should have a string meta-data field associated with it, |
| 1471 | * {@link #METADATA_SETUP_VERSION}, which defines the current version of |
| 1472 | * the platform for setup. The activity will be launched only if |
| 1473 | * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the |
| 1474 | * same value. |
| 1475 | * <p>Input: Nothing. |
| 1476 | * <p>Output: Nothing. |
| 1477 | * @hide |
| 1478 | */ |
Russell Brenner | 4cd32e5 | 2017-02-24 11:11:47 -0800 | [diff] [blame] | 1479 | @SystemApi |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1480 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1481 | public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1482 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1483 | /** |
Clara Bayarri | eb3c2d3 | 2016-04-01 14:37:32 +0100 | [diff] [blame] | 1484 | * Activity Action: Start the Keyboard Shortcuts Helper screen. |
| 1485 | * <p>Input: Nothing. |
| 1486 | * <p>Output: Nothing. |
| 1487 | * @hide |
| 1488 | */ |
| 1489 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1490 | public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = |
Clara Bayarri | 847d868 | 2017-03-06 16:48:44 +0000 | [diff] [blame] | 1491 | "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; |
Clara Bayarri | eb3c2d3 | 2016-04-01 14:37:32 +0100 | [diff] [blame] | 1492 | |
| 1493 | /** |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 1494 | * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. |
| 1495 | * <p>Input: Nothing. |
| 1496 | * <p>Output: Nothing. |
| 1497 | * @hide |
| 1498 | */ |
| 1499 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1500 | public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = |
Clara Bayarri | 847d868 | 2017-03-06 16:48:44 +0000 | [diff] [blame] | 1501 | "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 1502 | |
| 1503 | /** |
Jeff Sharkey | 7f86827 | 2011-06-05 16:05:02 -0700 | [diff] [blame] | 1504 | * Activity Action: Show settings for managing network data usage of a |
| 1505 | * specific application. Applications should define an activity that offers |
| 1506 | * options to control data usage. |
| 1507 | */ |
| 1508 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1509 | public static final String ACTION_MANAGE_NETWORK_USAGE = |
| 1510 | "android.intent.action.MANAGE_NETWORK_USAGE"; |
| 1511 | |
| 1512 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1513 | * Activity Action: Launch application installer. |
| 1514 | * <p> |
Todd Kennedy | 9cc589a | 2016-08-18 16:23:17 -0700 | [diff] [blame] | 1515 | * Input: The data must be a content: URI at which the application |
Dianne Hackborn | eba784ff | 2012-09-19 12:42:37 -0700 | [diff] [blame] | 1516 | * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, |
| 1517 | * you can also use "package:<package-name>" to install an application for the |
| 1518 | * current user that is already installed for another user. You can optionally supply |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1519 | * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, |
| 1520 | * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. |
| 1521 | * <p> |
| 1522 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1523 | * succeeded. |
Svet Ganov | 86877e4 | 2015-05-28 08:19:48 -0700 | [diff] [blame] | 1524 | * <p> |
Suprabh Shukla | 54a10e6 | 2017-04-14 18:17:23 -0700 | [diff] [blame] | 1525 | * <strong>Note:</strong>If your app is targeting API level higher than 25 you |
Svet Ganov | 86877e4 | 2015-05-28 08:19:48 -0700 | [diff] [blame] | 1526 | * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} |
| 1527 | * in order to launch the application installer. |
| 1528 | * </p> |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1529 | * |
| 1530 | * @see #EXTRA_INSTALLER_PACKAGE_NAME |
| 1531 | * @see #EXTRA_NOT_UNKNOWN_SOURCE |
| 1532 | * @see #EXTRA_RETURN_RESULT |
| 1533 | */ |
| 1534 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1535 | public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; |
| 1536 | |
| 1537 | /** |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1538 | * @hide |
| 1539 | * @deprecated Do not use. This will go away. |
| 1540 | * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}. |
| 1541 | */ |
| 1542 | @SystemApi |
| 1543 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1544 | public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE |
| 1545 | = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE"; |
| 1546 | /** |
| 1547 | * Activity Action: Launch instant application installer. |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1548 | * <p class="note"> |
| 1549 | * This is a protected intent that can only be sent by the system. |
| 1550 | * </p> |
| 1551 | * |
| 1552 | * @hide |
| 1553 | */ |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1554 | @SystemApi |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1555 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1556 | public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE |
| 1557 | = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE"; |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1558 | |
| 1559 | /** |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1560 | * @hide |
| 1561 | * @deprecated Do not use. This will go away. |
| 1562 | * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}. |
| 1563 | */ |
| 1564 | @SystemApi |
| 1565 | @SdkConstant(SdkConstantType.SERVICE_ACTION) |
| 1566 | public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE |
| 1567 | = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE"; |
| 1568 | /** |
| 1569 | * Service Action: Resolve instant application. |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1570 | * <p> |
| 1571 | * The system will have a persistent connection to this service. |
| 1572 | * This is a protected intent that can only be sent by the system. |
| 1573 | * </p> |
| 1574 | * |
| 1575 | * @hide |
| 1576 | */ |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1577 | @SystemApi |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1578 | @SdkConstant(SdkConstantType.SERVICE_ACTION) |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1579 | public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE |
| 1580 | = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1581 | |
| 1582 | /** |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1583 | * @hide |
| 1584 | * @deprecated Do not use. This will go away. |
| 1585 | * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}. |
| 1586 | */ |
| 1587 | @SystemApi |
| 1588 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1589 | public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS |
| 1590 | = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS"; |
| 1591 | /** |
| 1592 | * Activity Action: Launch instant app settings. |
Chad Brubaker | 336ae5b | 2017-03-24 15:53:09 -0700 | [diff] [blame] | 1593 | * |
| 1594 | * <p class="note"> |
| 1595 | * This is a protected intent that can only be sent by the system. |
| 1596 | * </p> |
| 1597 | * |
| 1598 | * @hide |
| 1599 | */ |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1600 | @SystemApi |
Chad Brubaker | 336ae5b | 2017-03-24 15:53:09 -0700 | [diff] [blame] | 1601 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Todd Kennedy | d46a160 | 2017-04-03 15:22:38 -0700 | [diff] [blame] | 1602 | public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS |
| 1603 | = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS"; |
Chad Brubaker | 336ae5b | 2017-03-24 15:53:09 -0700 | [diff] [blame] | 1604 | |
| 1605 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1606 | * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1607 | * package. Specifies the installer package name; this package will receive the |
| 1608 | * {@link #ACTION_APP_ERROR} intent. |
| 1609 | */ |
| 1610 | public static final String EXTRA_INSTALLER_PACKAGE_NAME |
| 1611 | = "android.intent.extra.INSTALLER_PACKAGE_NAME"; |
| 1612 | |
| 1613 | /** |
| 1614 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1615 | * package. Specifies that the application being installed should not be |
| 1616 | * treated as coming from an unknown source, but as coming from the app |
| 1617 | * invoking the Intent. For this to work you must start the installer with |
| 1618 | * startActivityForResult(). |
| 1619 | */ |
| 1620 | public static final String EXTRA_NOT_UNKNOWN_SOURCE |
| 1621 | = "android.intent.extra.NOT_UNKNOWN_SOURCE"; |
| 1622 | |
| 1623 | /** |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1624 | * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and |
| 1625 | * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1626 | * data field originated from. |
| 1627 | */ |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1628 | public static final String EXTRA_ORIGINATING_URI |
| 1629 | = "android.intent.extra.ORIGINATING_URI"; |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1630 | |
| 1631 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1632 | * This extra can be used with any Intent used to launch an activity, supplying information |
| 1633 | * about who is launching that activity. This field contains a {@link android.net.Uri} |
| 1634 | * object, typically an http: or https: URI of the web site that the referral came from; |
| 1635 | * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify |
| 1636 | * a native application that it came from. |
| 1637 | * |
| 1638 | * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} |
| 1639 | * instead of directly retrieving the extra. It is also valid for applications to |
| 1640 | * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create |
| 1641 | * a string, not a Uri; the field here, if supplied, will always take precedence, |
| 1642 | * however.</p> |
| 1643 | * |
| 1644 | * @see #EXTRA_REFERRER_NAME |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1645 | */ |
| 1646 | public static final String EXTRA_REFERRER |
| 1647 | = "android.intent.extra.REFERRER"; |
| 1648 | |
| 1649 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1650 | * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather |
| 1651 | * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can |
| 1652 | * not be created, in particular when Intent extras are supplied through the |
| 1653 | * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} |
| 1654 | * schemes. |
| 1655 | * |
| 1656 | * @see #EXTRA_REFERRER |
| 1657 | */ |
| 1658 | public static final String EXTRA_REFERRER_NAME |
| 1659 | = "android.intent.extra.REFERRER_NAME"; |
| 1660 | |
| 1661 | /** |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1662 | * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and |
Gina Dimino | 98ad888 | 2016-05-31 17:25:48 -0700 | [diff] [blame] | 1663 | * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install |
Suprabh Shukla | 54a10e6 | 2017-04-14 18:17:23 -0700 | [diff] [blame] | 1664 | * Currently only a system app that hosts the provider authority "downloads" or holds the |
| 1665 | * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this. |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1666 | * @hide |
| 1667 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1668 | @SystemApi |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1669 | public static final String EXTRA_ORIGINATING_UID |
| 1670 | = "android.intent.extra.ORIGINATING_UID"; |
| 1671 | |
| 1672 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1673 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1674 | * package. Tells the installer UI to skip the confirmation with the user |
| 1675 | * if the .apk is replacing an existing one. |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1676 | * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android |
| 1677 | * will no longer show an interstitial message about updating existing |
| 1678 | * applications so this is no longer needed. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1679 | */ |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1680 | @Deprecated |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1681 | public static final String EXTRA_ALLOW_REPLACE |
| 1682 | = "android.intent.extra.ALLOW_REPLACE"; |
| 1683 | |
| 1684 | /** |
| 1685 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or |
| 1686 | * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should |
| 1687 | * return to the application the result code of the install/uninstall. The returned result |
| 1688 | * code will be {@link android.app.Activity#RESULT_OK} on success or |
| 1689 | * {@link android.app.Activity#RESULT_FIRST_USER} on failure. |
| 1690 | */ |
| 1691 | public static final String EXTRA_RETURN_RESULT |
| 1692 | = "android.intent.extra.RETURN_RESULT"; |
| 1693 | |
| 1694 | /** |
| 1695 | * Package manager install result code. @hide because result codes are not |
| 1696 | * yet ready to be exposed. |
| 1697 | */ |
| 1698 | public static final String EXTRA_INSTALL_RESULT |
| 1699 | = "android.intent.extra.INSTALL_RESULT"; |
| 1700 | |
| 1701 | /** |
| 1702 | * Activity Action: Launch application uninstaller. |
| 1703 | * <p> |
| 1704 | * Input: The data must be a package: URI whose scheme specific part is |
| 1705 | * the package name of the current installed package to be uninstalled. |
| 1706 | * You can optionally supply {@link #EXTRA_RETURN_RESULT}. |
| 1707 | * <p> |
| 1708 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1709 | * succeeded. |
| 1710 | */ |
| 1711 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1712 | public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; |
| 1713 | |
| 1714 | /** |
Dianne Hackborn | 6d235d8 | 2012-09-16 18:25:40 -0700 | [diff] [blame] | 1715 | * Specify whether the package should be uninstalled for all users. |
| 1716 | * @hide because these should not be part of normal application flow. |
| 1717 | */ |
| 1718 | public static final String EXTRA_UNINSTALL_ALL_USERS |
| 1719 | = "android.intent.extra.UNINSTALL_ALL_USERS"; |
| 1720 | |
| 1721 | /** |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1722 | * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity |
| 1723 | * describing the last run version of the platform that was setup. |
| 1724 | * @hide |
| 1725 | */ |
| 1726 | public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; |
| 1727 | |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1728 | /** |
| 1729 | * Activity action: Launch UI to manage the permissions of an app. |
| 1730 | * <p> |
| 1731 | * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions |
| 1732 | * will be managed by the launched UI. |
| 1733 | * </p> |
| 1734 | * <p> |
| 1735 | * Output: Nothing. |
| 1736 | * </p> |
| 1737 | * |
| 1738 | * @see #EXTRA_PACKAGE_NAME |
| 1739 | * |
| 1740 | * @hide |
| 1741 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1742 | @SystemApi |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1743 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1744 | public static final String ACTION_MANAGE_APP_PERMISSIONS = |
| 1745 | "android.intent.action.MANAGE_APP_PERMISSIONS"; |
| 1746 | |
| 1747 | /** |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1748 | * Activity action: Launch UI to manage permissions. |
| 1749 | * <p> |
| 1750 | * Input: Nothing. |
| 1751 | * </p> |
| 1752 | * <p> |
| 1753 | * Output: Nothing. |
| 1754 | * </p> |
| 1755 | * |
| 1756 | * @hide |
| 1757 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1758 | @SystemApi |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1759 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1760 | public static final String ACTION_MANAGE_PERMISSIONS = |
| 1761 | "android.intent.action.MANAGE_PERMISSIONS"; |
| 1762 | |
| 1763 | /** |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1764 | * Activity action: Launch UI to review permissions for an app. |
| 1765 | * The system uses this intent if permission review for apps not |
| 1766 | * supporting the new runtime permissions model is enabled. In |
| 1767 | * this mode a permission review is required before any of the |
| 1768 | * app components can run. |
| 1769 | * <p> |
| 1770 | * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose |
| 1771 | * permissions will be reviewed (mandatory). |
| 1772 | * </p> |
| 1773 | * <p> |
| 1774 | * Input: {@link #EXTRA_INTENT} specifies a pending intent to |
| 1775 | * be fired after the permission review (optional). |
| 1776 | * </p> |
| 1777 | * <p> |
| 1778 | * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to |
| 1779 | * be invoked after the permission review (optional). |
| 1780 | * </p> |
| 1781 | * <p> |
| 1782 | * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent |
| 1783 | * passed via {@link #EXTRA_INTENT} needs a result (optional). |
| 1784 | * </p> |
| 1785 | * <p> |
| 1786 | * Output: Nothing. |
| 1787 | * </p> |
| 1788 | * |
| 1789 | * @see #EXTRA_PACKAGE_NAME |
| 1790 | * @see #EXTRA_INTENT |
| 1791 | * @see #EXTRA_REMOTE_CALLBACK |
| 1792 | * @see #EXTRA_RESULT_NEEDED |
| 1793 | * |
| 1794 | * @hide |
| 1795 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1796 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1797 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1798 | public static final String ACTION_REVIEW_PERMISSIONS = |
| 1799 | "android.intent.action.REVIEW_PERMISSIONS"; |
| 1800 | |
| 1801 | /** |
| 1802 | * Intent extra: A callback for reporting remote result as a bundle. |
| 1803 | * <p> |
| 1804 | * Type: IRemoteCallback |
| 1805 | * </p> |
| 1806 | * |
| 1807 | * @hide |
| 1808 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1809 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1810 | public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; |
| 1811 | |
| 1812 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1813 | * Intent extra: An app package name. |
| 1814 | * <p> |
| 1815 | * Type: String |
Svet Ganov | 0b31670 | 2015-05-23 13:25:11 -0700 | [diff] [blame] | 1816 | * </p> |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1817 | * |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1818 | */ |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1819 | public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; |
| 1820 | |
| 1821 | /** |
Todd Kennedy | e5195dd | 2016-10-19 15:29:19 -0700 | [diff] [blame] | 1822 | * Intent extra: An app split name. |
| 1823 | * <p> |
| 1824 | * Type: String |
| 1825 | * </p> |
| 1826 | * @hide |
| 1827 | */ |
| 1828 | @SystemApi |
| 1829 | public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; |
| 1830 | |
| 1831 | /** |
Jeff Sharkey | 1a74942 | 2017-04-28 14:19:50 -0600 | [diff] [blame] | 1832 | * Intent extra: A {@link ComponentName} value. |
| 1833 | * <p> |
| 1834 | * Type: String |
| 1835 | * </p> |
| 1836 | */ |
| 1837 | public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME"; |
| 1838 | |
| 1839 | /** |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1840 | * Intent extra: An extra for specifying whether a result is needed. |
| 1841 | * <p> |
| 1842 | * Type: boolean |
| 1843 | * </p> |
| 1844 | * |
| 1845 | * @hide |
| 1846 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1847 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1848 | public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; |
| 1849 | |
| 1850 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1851 | * Activity action: Launch UI to manage which apps have a given permission. |
| 1852 | * <p> |
| 1853 | * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access |
| 1854 | * to which will be managed by the launched UI. |
| 1855 | * </p> |
| 1856 | * <p> |
| 1857 | * Output: Nothing. |
| 1858 | * </p> |
| 1859 | * |
| 1860 | * @see #EXTRA_PERMISSION_NAME |
| 1861 | * |
| 1862 | * @hide |
| 1863 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1864 | @SystemApi |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1865 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1866 | public static final String ACTION_MANAGE_PERMISSION_APPS = |
| 1867 | "android.intent.action.MANAGE_PERMISSION_APPS"; |
| 1868 | |
| 1869 | /** |
| 1870 | * Intent extra: The name of a permission. |
| 1871 | * <p> |
| 1872 | * Type: String |
| 1873 | * </p> |
| 1874 | * |
| 1875 | * @hide |
| 1876 | */ |
| 1877 | @SystemApi |
| 1878 | public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; |
| 1879 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1880 | // --------------------------------------------------------------------- |
| 1881 | // --------------------------------------------------------------------- |
| 1882 | // Standard intent broadcast actions (see action variable). |
| 1883 | |
| 1884 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1885 | * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. |
| 1886 | * <p> |
| 1887 | * For historical reasons, the name of this broadcast action refers to the power |
| 1888 | * state of the screen but it is actually sent in response to changes in the |
| 1889 | * overall interactive state of the device. |
| 1890 | * </p><p> |
| 1891 | * This broadcast is sent when the device becomes non-interactive which may have |
| 1892 | * nothing to do with the screen turning off. To determine the |
| 1893 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1894 | * </p><p> |
| 1895 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1896 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1897 | * You <em>cannot</em> receive this through components declared in |
| 1898 | * manifests, only by explicitly registering for it with |
| 1899 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1900 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1901 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1902 | * <p class="note">This is a protected intent that can only be sent |
| 1903 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1904 | */ |
| 1905 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1906 | public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1907 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1908 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1909 | * Broadcast Action: Sent when the device wakes up and becomes interactive. |
| 1910 | * <p> |
| 1911 | * For historical reasons, the name of this broadcast action refers to the power |
| 1912 | * state of the screen but it is actually sent in response to changes in the |
| 1913 | * overall interactive state of the device. |
| 1914 | * </p><p> |
| 1915 | * This broadcast is sent when the device becomes interactive which may have |
| 1916 | * nothing to do with the screen turning on. To determine the |
| 1917 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1918 | * </p><p> |
| 1919 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1920 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1921 | * You <em>cannot</em> receive this through components declared in |
| 1922 | * manifests, only by explicitly registering for it with |
| 1923 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1924 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1925 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1926 | * <p class="note">This is a protected intent that can only be sent |
| 1927 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1928 | */ |
| 1929 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1930 | public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1931 | |
| 1932 | /** |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 1933 | * Broadcast Action: Sent after the system stops dreaming. |
| 1934 | * |
| 1935 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1936 | * It is only sent to registered receivers.</p> |
| 1937 | */ |
| 1938 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1939 | public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; |
| 1940 | |
| 1941 | /** |
| 1942 | * Broadcast Action: Sent after the system starts dreaming. |
| 1943 | * |
| 1944 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1945 | * It is only sent to registered receivers.</p> |
| 1946 | */ |
| 1947 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1948 | public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; |
| 1949 | |
| 1950 | /** |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1951 | * Broadcast Action: Sent when the user is present after device wakes up (e.g when the |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1952 | * keyguard is gone). |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1953 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1954 | * <p class="note">This is a protected intent that can only be sent |
| 1955 | * by the system. |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1956 | */ |
| 1957 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 1958 | public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1959 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1960 | /** |
| 1961 | * Broadcast Action: The current time has changed. Sent every |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1962 | * minute. You <em>cannot</em> receive this through components declared |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1963 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1964 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1965 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1966 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1967 | * <p class="note">This is a protected intent that can only be sent |
| 1968 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1969 | */ |
| 1970 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1971 | public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; |
| 1972 | /** |
| 1973 | * Broadcast Action: The time was set. |
| 1974 | */ |
| 1975 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1976 | public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; |
| 1977 | /** |
| 1978 | * Broadcast Action: The date has changed. |
| 1979 | */ |
| 1980 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1981 | public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; |
| 1982 | /** |
| 1983 | * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> |
| 1984 | * <ul> |
| 1985 | * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li> |
| 1986 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1987 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1988 | * <p class="note">This is a protected intent that can only be sent |
| 1989 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1990 | */ |
| 1991 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1992 | public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; |
| 1993 | /** |
Robert Greenwalt | 03595d0 | 2010-11-02 14:08:23 -0700 | [diff] [blame] | 1994 | * Clear DNS Cache Action: This is broadcast when networks have changed and old |
| 1995 | * DNS entries should be tossed. |
| 1996 | * @hide |
| 1997 | */ |
| 1998 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1999 | public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE"; |
| 2000 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2001 | * Alarm Changed Action: This is broadcast when the AlarmClock |
| 2002 | * application's alarm is set or unset. It is used by the |
| 2003 | * AlarmClock application and the StatusBar service. |
| 2004 | * @hide |
| 2005 | */ |
| 2006 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2007 | public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 2008 | |
| 2009 | /** |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 2010 | * Broadcast Action: This is broadcast once, after the user has finished |
| 2011 | * booting, but while still in the "locked" state. It can be used to perform |
| 2012 | * application-specific initialization, such as installing alarms. You must |
| 2013 | * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} |
| 2014 | * permission in order to receive this broadcast. |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 2015 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 2016 | * This broadcast is sent immediately at boot by all devices (regardless of |
| 2017 | * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or |
| 2018 | * higher. Upon receipt of this broadcast, the user is still locked and only |
| 2019 | * device-protected storage can be accessed safely. If you want to access |
| 2020 | * credential-protected storage, you need to wait for the user to be |
| 2021 | * unlocked (typically by entering their lock pattern or PIN for the first |
| 2022 | * time), after which the {@link #ACTION_USER_UNLOCKED} and |
| 2023 | * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. |
| 2024 | * <p> |
| 2025 | * To receive this broadcast, your receiver component must be marked as |
| 2026 | * being {@link ComponentInfo#directBootAware}. |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 2027 | * <p class="note"> |
| 2028 | * This is a protected intent that can only be sent by the system. |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 2029 | * |
| 2030 | * @see Context#createDeviceProtectedStorageContext() |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 2031 | */ |
| 2032 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2033 | public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; |
| 2034 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2035 | /** |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 2036 | * Broadcast Action: This is broadcast once, after the user has finished |
| 2037 | * booting. It can be used to perform application-specific initialization, |
| 2038 | * such as installing alarms. You must hold the |
| 2039 | * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in |
| 2040 | * order to receive this broadcast. |
| 2041 | * <p> |
| 2042 | * This broadcast is sent at boot by all devices (both with and without |
| 2043 | * direct boot support). Upon receipt of this broadcast, the user is |
| 2044 | * unlocked and both device-protected and credential-protected storage can |
| 2045 | * accessed safely. |
| 2046 | * <p> |
| 2047 | * If you need to run while the user is still locked (before they've entered |
| 2048 | * their lock pattern or PIN for the first time), you can listen for the |
| 2049 | * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. |
| 2050 | * <p class="note"> |
| 2051 | * This is a protected intent that can only be sent by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2052 | */ |
| 2053 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 32ee8ee | 2017-03-08 20:17:51 -0700 | [diff] [blame] | 2054 | @BroadcastBehavior(includeBackground = true) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2055 | public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 2056 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2057 | /** |
| 2058 | * Broadcast Action: This is broadcast when a user action should request a |
| 2059 | * temporary system dialog to dismiss. Some examples of temporary system |
| 2060 | * dialogs are the notification window-shade and the recent tasks dialog. |
| 2061 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 2062 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2063 | public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; |
| 2064 | /** |
| 2065 | * Broadcast Action: Trigger the download and eventual installation |
| 2066 | * of a package. |
| 2067 | * <p>Input: {@link #getData} is the URI of the package file to download. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2068 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2069 | * <p class="note">This is a protected intent that can only be sent |
| 2070 | * by the system. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 2071 | * |
| 2072 | * @deprecated This constant has never been used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2073 | */ |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 2074 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2075 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2076 | public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; |
| 2077 | /** |
Christopher Tate | 94b91db | 2017-04-19 15:49:17 -0700 | [diff] [blame] | 2078 | * Broadcast Action: A new application package has been installed on the |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2079 | * device. The data contains the name of the package. Note that the |
| 2080 | * newly installed package does <em>not</em> receive this broadcast. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 2081 | * <p>May include the following extras: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2082 | * <ul> |
Christopher Tate | 94b91db | 2017-04-19 15:49:17 -0700 | [diff] [blame] | 2083 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 2084 | * <li> {@link #EXTRA_REPLACING} is set to true if this is following |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2085 | * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. |
| 2086 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2087 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2088 | * <p class="note">This is a protected intent that can only be sent |
| 2089 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2090 | */ |
| 2091 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2092 | public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; |
| 2093 | /** |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2094 | * Broadcast Action: A new version of an application package has been |
| 2095 | * installed, replacing an existing version that was previously installed. |
| 2096 | * The data contains the name of the package. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 2097 | * <p>May include the following extras: |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2098 | * <ul> |
| 2099 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 2100 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2101 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2102 | * <p class="note">This is a protected intent that can only be sent |
| 2103 | * by the system. |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2104 | */ |
| 2105 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2106 | public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; |
| 2107 | /** |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 2108 | * Broadcast Action: A new version of your application has been installed |
| 2109 | * over an existing one. This is only sent to the application that was |
| 2110 | * replaced. It does not contain any additional data; to receive it, just |
| 2111 | * use an intent filter for this action. |
| 2112 | * |
| 2113 | * <p class="note">This is a protected intent that can only be sent |
| 2114 | * by the system. |
| 2115 | */ |
| 2116 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2117 | public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; |
| 2118 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2119 | * Broadcast Action: An existing application package has been removed from |
| 2120 | * the device. The data contains the name of the package. The package |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2121 | * that is being removed does <em>not</em> receive this Intent. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2122 | * <ul> |
| 2123 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 2124 | * to the package. |
| 2125 | * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire |
| 2126 | * application -- data and code -- is being removed. |
| 2127 | * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed |
| 2128 | * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. |
| 2129 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2130 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2131 | * <p class="note">This is a protected intent that can only be sent |
| 2132 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2133 | */ |
| 2134 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2135 | public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; |
| 2136 | /** |
Dianne Hackborn | f9abb40 | 2011-08-10 15:00:59 -0700 | [diff] [blame] | 2137 | * Broadcast Action: An existing application package has been completely |
| 2138 | * removed from the device. The data contains the name of the package. |
| 2139 | * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when |
| 2140 | * {@link #EXTRA_DATA_REMOVED} is true and |
| 2141 | * {@link #EXTRA_REPLACING} is false of that broadcast. |
| 2142 | * |
| 2143 | * <ul> |
| 2144 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 2145 | * to the package. |
| 2146 | * </ul> |
| 2147 | * |
| 2148 | * <p class="note">This is a protected intent that can only be sent |
| 2149 | * by the system. |
| 2150 | */ |
| 2151 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2152 | public static final String ACTION_PACKAGE_FULLY_REMOVED |
| 2153 | = "android.intent.action.PACKAGE_FULLY_REMOVED"; |
| 2154 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2155 | * Broadcast Action: An existing application package has been changed (for |
| 2156 | * example, a component has been enabled or disabled). The data contains |
| 2157 | * the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2158 | * <ul> |
| 2159 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 2160 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 2161 | * of the changed components (or the package name itself). |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 2162 | * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the |
| 2163 | * default action of restarting the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2164 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2165 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2166 | * <p class="note">This is a protected intent that can only be sent |
| 2167 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2168 | */ |
| 2169 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2170 | public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; |
| 2171 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 2172 | * @hide |
| 2173 | * Broadcast Action: Ask system services if there is any reason to |
| 2174 | * restart the given package. The data contains the name of the |
| 2175 | * package. |
| 2176 | * <ul> |
| 2177 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2178 | * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. |
| 2179 | * </ul> |
| 2180 | * |
| 2181 | * <p class="note">This is a protected intent that can only be sent |
| 2182 | * by the system. |
| 2183 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 2184 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 2185 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2186 | public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; |
| 2187 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2188 | * Broadcast Action: The user has restarted a package, and all of its |
| 2189 | * processes have been killed. All runtime state |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2190 | * associated with it (processes, alarms, notifications, etc) should |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2191 | * be removed. Note that the restarted package does <em>not</em> |
| 2192 | * receive this broadcast. |
| 2193 | * The data contains the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2194 | * <ul> |
| 2195 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2196 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2197 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2198 | * <p class="note">This is a protected intent that can only be sent |
| 2199 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2200 | */ |
| 2201 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2202 | public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; |
| 2203 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2204 | * Broadcast Action: The user has cleared the data of a package. This should |
| 2205 | * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2206 | * its persistent data is erased and this broadcast sent. |
| 2207 | * Note that the cleared package does <em>not</em> |
| 2208 | * receive this broadcast. The data contains the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2209 | * <ul> |
| 2210 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2211 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2212 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2213 | * <p class="note">This is a protected intent that can only be sent |
| 2214 | * by the system. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2215 | */ |
| 2216 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2217 | public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; |
| 2218 | /** |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 2219 | * Broadcast Action: Packages have been suspended. |
| 2220 | * <p>Includes the following extras: |
| 2221 | * <ul> |
| 2222 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended |
| 2223 | * </ul> |
| 2224 | * |
| 2225 | * <p class="note">This is a protected intent that can only be sent |
| 2226 | * by the system. It is only sent to registered receivers. |
| 2227 | */ |
| 2228 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2229 | public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; |
| 2230 | /** |
| 2231 | * Broadcast Action: Packages have been unsuspended. |
| 2232 | * <p>Includes the following extras: |
| 2233 | * <ul> |
| 2234 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended |
| 2235 | * </ul> |
| 2236 | * |
| 2237 | * <p class="note">This is a protected intent that can only be sent |
| 2238 | * by the system. It is only sent to registered receivers. |
| 2239 | */ |
| 2240 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2241 | public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; |
| 2242 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2243 | * Broadcast Action: A user ID has been removed from the system. The user |
| 2244 | * ID number is stored in the extra data under {@link #EXTRA_UID}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2245 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2246 | * <p class="note">This is a protected intent that can only be sent |
| 2247 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2248 | */ |
| 2249 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2250 | public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2251 | |
| 2252 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2253 | * Broadcast Action: Sent to the installer package of an application when |
| 2254 | * that application is first launched (that is the first time it is moved |
| 2255 | * out of the stopped state). The data contains the name of the package. |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 2256 | * |
| 2257 | * <p class="note">This is a protected intent that can only be sent |
| 2258 | * by the system. |
| 2259 | */ |
| 2260 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2261 | public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; |
| 2262 | |
| 2263 | /** |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2264 | * Broadcast Action: Sent to the system package verifier when a package |
| 2265 | * needs to be verified. The data contains the package URI. |
| 2266 | * <p class="note"> |
| 2267 | * This is a protected intent that can only be sent by the system. |
| 2268 | * </p> |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2269 | */ |
| 2270 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2271 | public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; |
| 2272 | |
| 2273 | /** |
rich cannings | d1b5cfc | 2012-08-29 14:49:51 -0700 | [diff] [blame] | 2274 | * Broadcast Action: Sent to the system package verifier when a package is |
| 2275 | * verified. The data contains the package URI. |
| 2276 | * <p class="note"> |
| 2277 | * This is a protected intent that can only be sent by the system. |
| 2278 | */ |
| 2279 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2280 | public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; |
| 2281 | |
| 2282 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2283 | * Broadcast Action: Sent to the system intent filter verifier when an |
| 2284 | * intent filter needs to be verified. The data contains the filter data |
| 2285 | * hosts to be verified against. |
Fabrice Di Meglio | 1c1b471 | 2014-11-19 17:12:32 -0800 | [diff] [blame] | 2286 | * <p class="note"> |
| 2287 | * This is a protected intent that can only be sent by the system. |
| 2288 | * </p> |
| 2289 | * |
| 2290 | * @hide |
| 2291 | */ |
| 2292 | @SystemApi |
| 2293 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2294 | public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; |
| 2295 | |
| 2296 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2297 | * Broadcast Action: Resources for a set of packages (which were |
| 2298 | * previously unavailable) are currently |
| 2299 | * available since the media on which they exist is available. |
| 2300 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2301 | * list of packages whose availability changed. |
| 2302 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2303 | * list of uids of packages whose availability changed. |
| 2304 | * Note that the |
| 2305 | * packages in this list do <em>not</em> receive this broadcast. |
| 2306 | * The specified set of packages are now available on the system. |
| 2307 | * <p>Includes the following extras: |
| 2308 | * <ul> |
| 2309 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2310 | * whose resources(were previously unavailable) are currently available. |
| 2311 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the |
| 2312 | * packages whose resources(were previously unavailable) |
| 2313 | * are currently available. |
| 2314 | * </ul> |
| 2315 | * |
| 2316 | * <p class="note">This is a protected intent that can only be sent |
| 2317 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2318 | */ |
| 2319 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2320 | public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = |
| 2321 | "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2322 | |
| 2323 | /** |
| 2324 | * Broadcast Action: Resources for a set of packages are currently |
| 2325 | * unavailable since the media on which they exist is unavailable. |
| 2326 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2327 | * list of packages whose availability changed. |
| 2328 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2329 | * list of uids of packages whose availability changed. |
| 2330 | * The specified set of packages can no longer be |
| 2331 | * launched and are practically unavailable on the system. |
| 2332 | * <p>Inclues the following extras: |
| 2333 | * <ul> |
| 2334 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2335 | * whose resources are no longer available. |
| 2336 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages |
| 2337 | * whose resources are no longer available. |
| 2338 | * </ul> |
| 2339 | * |
| 2340 | * <p class="note">This is a protected intent that can only be sent |
| 2341 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2342 | */ |
| 2343 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2344 | public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = |
Joe Onorato | 8a051a4 | 2010-03-04 15:54:50 -0500 | [diff] [blame] | 2345 | "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2346 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2347 | /** |
Makoto Onuki | 1030520 | 2016-07-14 18:14:08 -0700 | [diff] [blame] | 2348 | * Broadcast Action: preferred activities have changed *explicitly*. |
| 2349 | * |
| 2350 | * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. |
| 2351 | * when an app is installed or uninstalled, but in such cases this broadcast will *not* |
| 2352 | * be sent. |
| 2353 | * |
| 2354 | * {@link #EXTRA_USER_HANDLE} contains the user ID in question. |
| 2355 | * |
| 2356 | * @hide |
| 2357 | */ |
| 2358 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2359 | public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = |
| 2360 | "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; |
| 2361 | |
| 2362 | |
| 2363 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2364 | * Broadcast Action: The current system wallpaper has changed. See |
Scott Main | 8b2e000 | 2009-09-29 18:17:31 -0700 | [diff] [blame] | 2365 | * {@link android.app.WallpaperManager} for retrieving the new wallpaper. |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2366 | * This should <em>only</em> be used to determine when the wallpaper |
| 2367 | * has changed to show the new wallpaper to the user. You should certainly |
| 2368 | * never, in response to this, change the wallpaper or other attributes of |
| 2369 | * it such as the suggested size. That would be crazy, right? You'd cause |
| 2370 | * all kinds of loops, especially if other apps are doing similar things, |
| 2371 | * right? Of course. So please don't do this. |
| 2372 | * |
| 2373 | * @deprecated Modern applications should use |
| 2374 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER |
| 2375 | * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper |
| 2376 | * shown behind their UI, rather than watching for this broadcast and |
| 2377 | * rendering the wallpaper on their own. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2378 | */ |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2379 | @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2380 | public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; |
| 2381 | /** |
| 2382 | * Broadcast Action: The current device {@link android.content.res.Configuration} |
| 2383 | * (orientation, locale, etc) has changed. When such a change happens, the |
| 2384 | * UIs (view hierarchy) will need to be rebuilt based on this new |
| 2385 | * information; for the most part, applications don't need to worry about |
| 2386 | * this, because the system will take care of stopping and restarting the |
| 2387 | * application to make sure it sees the new changes. Some system code that |
| 2388 | * can not be restarted will need to watch for this action and handle it |
| 2389 | * appropriately. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2390 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2391 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2392 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2393 | * in manifests, only by explicitly registering for it with |
| 2394 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2395 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2396 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2397 | * <p class="note">This is a protected intent that can only be sent |
| 2398 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2399 | * |
| 2400 | * @see android.content.res.Configuration |
| 2401 | */ |
| 2402 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2403 | public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; |
| 2404 | /** |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2405 | * Broadcast Action: The current device's locale has changed. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2406 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2407 | * <p class="note">This is a protected intent that can only be sent |
| 2408 | * by the system. |
| 2409 | */ |
| 2410 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2411 | public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; |
| 2412 | /** |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2413 | * Broadcast Action: This is a <em>sticky broadcast</em> containing the |
| 2414 | * charging state, level, and other information about the battery. |
| 2415 | * See {@link android.os.BatteryManager} for documentation on the |
| 2416 | * contents of the Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2417 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2418 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2419 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2420 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2421 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2422 | * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, |
| 2423 | * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, |
| 2424 | * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related |
| 2425 | * broadcasts that are sent and can be received through manifest |
| 2426 | * receivers. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2427 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2428 | * <p class="note">This is a protected intent that can only be sent |
| 2429 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2430 | */ |
| 2431 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2432 | public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; |
| 2433 | /** |
| 2434 | * Broadcast Action: Indicates low battery condition on the device. |
| 2435 | * This broadcast corresponds to the "Low battery warning" system dialog. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2436 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2437 | * <p class="note">This is a protected intent that can only be sent |
| 2438 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2439 | */ |
| 2440 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2441 | public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; |
| 2442 | /** |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2443 | * Broadcast Action: Indicates the battery is now okay after being low. |
| 2444 | * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has |
| 2445 | * gone back up to an okay state. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2446 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2447 | * <p class="note">This is a protected intent that can only be sent |
| 2448 | * by the system. |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2449 | */ |
| 2450 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2451 | public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; |
| 2452 | /** |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2453 | * Broadcast Action: External power has been connected to the device. |
| 2454 | * This is intended for applications that wish to register specifically to this notification. |
| 2455 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2456 | * stay active to receive this notification. This action can be used to implement actions |
| 2457 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2458 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2459 | * <p class="note">This is a protected intent that can only be sent |
| 2460 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2461 | */ |
| 2462 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2463 | public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2464 | /** |
| 2465 | * Broadcast Action: External power has been removed from the device. |
| 2466 | * This is intended for applications that wish to register specifically to this notification. |
| 2467 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2468 | * stay active to receive this notification. This action can be used to implement actions |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 2469 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2470 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2471 | * <p class="note">This is a protected intent that can only be sent |
| 2472 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2473 | */ |
| 2474 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Baptiste Queru | 1ef4564 | 2008-10-24 11:49:25 -0700 | [diff] [blame] | 2475 | public static final String ACTION_POWER_DISCONNECTED = |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2476 | "android.intent.action.ACTION_POWER_DISCONNECTED"; |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2477 | /** |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2478 | * Broadcast Action: Device is shutting down. |
| 2479 | * This is broadcast when the device is being shut down (completely turned |
| 2480 | * off, not sleeping). Once the broadcast is complete, the final shutdown |
| 2481 | * will proceed and all unsaved data lost. Apps will not normally need |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2482 | * to handle this, since the foreground activity will be paused as well. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2483 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2484 | * <p class="note">This is a protected intent that can only be sent |
| 2485 | * by the system. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 2486 | * <p>May include the following extras: |
| 2487 | * <ul> |
| 2488 | * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this |
| 2489 | * shutdown is only for userspace processes. If not set, assumed to be false. |
| 2490 | * </ul> |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2491 | */ |
| 2492 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 2493 | public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2494 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2495 | * Activity Action: Start this activity to request system shutdown. |
| 2496 | * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true |
Yusuke Sato | 705ffd1 | 2015-07-21 15:52:11 -0700 | [diff] [blame] | 2497 | * to request confirmation from the user before shutting down. The optional boolean |
| 2498 | * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to |
| 2499 | * indicate that the shutdown is requested by the user. |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2500 | * |
| 2501 | * <p class="note">This is a protected intent that can only be sent |
| 2502 | * by the system. |
| 2503 | * |
| 2504 | * {@hide} |
| 2505 | */ |
Sudheer Shanka | 218190a | 2017-03-30 16:07:54 -0700 | [diff] [blame] | 2506 | public static final String ACTION_REQUEST_SHUTDOWN |
| 2507 | = "com.android.internal.intent.action.REQUEST_SHUTDOWN"; |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2508 | /** |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2509 | * Broadcast Action: A sticky broadcast that indicates low storage space |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2510 | * condition on the device |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2511 | * <p class="note"> |
| 2512 | * This is a protected intent that can only be sent by the system. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2513 | * |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2514 | * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} |
| 2515 | * or above, this broadcast will no longer be delivered to any |
| 2516 | * {@link BroadcastReceiver} defined in your manifest. Instead, |
| 2517 | * apps are strongly encouraged to use the improved |
| 2518 | * {@link Context#getCacheDir()} behavior so the system can |
| 2519 | * automatically free up storage when needed. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2520 | */ |
| 2521 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2522 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2523 | public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; |
| 2524 | /** |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2525 | * Broadcast Action: Indicates low storage space condition on the device no |
| 2526 | * longer exists |
| 2527 | * <p class="note"> |
| 2528 | * This is a protected intent that can only be sent by the system. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2529 | * |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2530 | * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} |
| 2531 | * or above, this broadcast will no longer be delivered to any |
| 2532 | * {@link BroadcastReceiver} defined in your manifest. Instead, |
| 2533 | * apps are strongly encouraged to use the improved |
| 2534 | * {@link Context#getCacheDir()} behavior so the system can |
| 2535 | * automatically free up storage when needed. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2536 | */ |
| 2537 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2538 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2539 | public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; |
| 2540 | /** |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2541 | * Broadcast Action: A sticky broadcast that indicates a storage space full |
| 2542 | * condition on the device. This is intended for activities that want to be |
| 2543 | * able to fill the data partition completely, leaving only enough free |
| 2544 | * space to prevent system-wide SQLite failures. |
| 2545 | * <p class="note"> |
| 2546 | * This is a protected intent that can only be sent by the system. |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2547 | * |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2548 | * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} |
| 2549 | * or above, this broadcast will no longer be delivered to any |
| 2550 | * {@link BroadcastReceiver} defined in your manifest. Instead, |
| 2551 | * apps are strongly encouraged to use the improved |
| 2552 | * {@link Context#getCacheDir()} behavior so the system can |
| 2553 | * automatically free up storage when needed. |
| 2554 | * @hide |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2555 | */ |
| 2556 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2557 | @Deprecated |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2558 | public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; |
| 2559 | /** |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2560 | * Broadcast Action: Indicates storage space full condition on the device no |
| 2561 | * longer exists. |
| 2562 | * <p class="note"> |
| 2563 | * This is a protected intent that can only be sent by the system. |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2564 | * |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2565 | * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} |
| 2566 | * or above, this broadcast will no longer be delivered to any |
| 2567 | * {@link BroadcastReceiver} defined in your manifest. Instead, |
| 2568 | * apps are strongly encouraged to use the improved |
| 2569 | * {@link Context#getCacheDir()} behavior so the system can |
| 2570 | * automatically free up storage when needed. |
| 2571 | * @hide |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2572 | */ |
| 2573 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 179d6b3 | 2017-03-12 17:27:47 -0600 | [diff] [blame] | 2574 | @Deprecated |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2575 | public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; |
| 2576 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2577 | * Broadcast Action: Indicates low memory condition notification acknowledged by user |
| 2578 | * and package management should be started. |
| 2579 | * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW |
| 2580 | * notification. |
| 2581 | */ |
| 2582 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2583 | public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; |
| 2584 | /** |
| 2585 | * Broadcast Action: The device has entered USB Mass Storage mode. |
| 2586 | * This is used mainly for the USB Settings panel. |
| 2587 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2588 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2589 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2590 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2591 | @Deprecated |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 2592 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2593 | public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; |
| 2594 | |
| 2595 | /** |
| 2596 | * Broadcast Action: The device has exited USB Mass Storage mode. |
| 2597 | * This is used mainly for the USB Settings panel. |
| 2598 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2599 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2600 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2601 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2602 | @Deprecated |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 2603 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2604 | public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; |
| 2605 | |
| 2606 | /** |
| 2607 | * Broadcast Action: External media has been removed. |
| 2608 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2609 | */ |
| 2610 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2611 | public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; |
| 2612 | |
| 2613 | /** |
| 2614 | * Broadcast Action: External media is present, but not mounted at its mount point. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2615 | * The path to the mount point for the unmounted media is contained in the Intent.mData field. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2616 | */ |
| 2617 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2618 | public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; |
| 2619 | |
| 2620 | /** |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 2621 | * Broadcast Action: External media is present, and being disk-checked |
| 2622 | * The path to the mount point for the checking media is contained in the Intent.mData field. |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 2623 | */ |
| 2624 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2625 | public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; |
| 2626 | |
| 2627 | /** |
| 2628 | * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) |
| 2629 | * The path to the mount point for the checking media is contained in the Intent.mData field. |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 2630 | */ |
| 2631 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2632 | public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; |
| 2633 | |
| 2634 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2635 | * Broadcast Action: External media is present and mounted at its mount point. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2636 | * The path to the mount point for the mounted media is contained in the Intent.mData field. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2637 | * The Intent contains an extra with name "read-only" and Boolean value to indicate if the |
| 2638 | * media was mounted read only. |
| 2639 | */ |
| 2640 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2641 | public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; |
| 2642 | |
| 2643 | /** |
| 2644 | * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. |
Mike Lockwood | bf2dd44 | 2010-03-03 06:16:52 -0500 | [diff] [blame] | 2645 | * The path to the mount point for the shared media is contained in the Intent.mData field. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2646 | */ |
| 2647 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2648 | public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; |
| 2649 | |
| 2650 | /** |
Mike Lockwood | bf2dd44 | 2010-03-03 06:16:52 -0500 | [diff] [blame] | 2651 | * Broadcast Action: External media is no longer being shared via USB mass storage. |
| 2652 | * The path to the mount point for the previously shared media is contained in the Intent.mData field. |
| 2653 | * |
| 2654 | * @hide |
| 2655 | */ |
| 2656 | public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; |
| 2657 | |
| 2658 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2659 | * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. |
| 2660 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2661 | */ |
| 2662 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2663 | public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; |
| 2664 | |
| 2665 | /** |
| 2666 | * Broadcast Action: External media is present but cannot be mounted. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2667 | * The path to the mount point for the unmountable media is contained in the Intent.mData field. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2668 | */ |
| 2669 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2670 | public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; |
| 2671 | |
| 2672 | /** |
| 2673 | * Broadcast Action: User has expressed the desire to remove the external storage media. |
| 2674 | * Applications should close all files they have open within the mount point when they receive this intent. |
| 2675 | * The path to the mount point for the media to be ejected is contained in the Intent.mData field. |
| 2676 | */ |
| 2677 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2678 | public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; |
| 2679 | |
| 2680 | /** |
| 2681 | * Broadcast Action: The media scanner has started scanning a directory. |
| 2682 | * The path to the directory being scanned is contained in the Intent.mData field. |
| 2683 | */ |
| 2684 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2685 | public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; |
| 2686 | |
| 2687 | /** |
| 2688 | * Broadcast Action: The media scanner has finished scanning a directory. |
| 2689 | * The path to the scanned directory is contained in the Intent.mData field. |
| 2690 | */ |
| 2691 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2692 | public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; |
| 2693 | |
| 2694 | /** |
| 2695 | * Broadcast Action: Request the media scanner to scan a file and add it to the media database. |
| 2696 | * The path to the file is contained in the Intent.mData field. |
| 2697 | */ |
| 2698 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2699 | public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; |
| 2700 | |
| 2701 | /** |
| 2702 | * Broadcast Action: The "Media Button" was pressed. Includes a single |
| 2703 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2704 | * caused the broadcast. |
| 2705 | */ |
| 2706 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2707 | public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; |
| 2708 | |
| 2709 | /** |
| 2710 | * Broadcast Action: The "Camera Button" was pressed. Includes a single |
| 2711 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2712 | * caused the broadcast. |
| 2713 | */ |
| 2714 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2715 | public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; |
| 2716 | |
| 2717 | // *** NOTE: @todo(*) The following really should go into a more domain-specific |
| 2718 | // location; they are not general-purpose actions. |
| 2719 | |
| 2720 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2721 | * Broadcast Action: A GTalk connection has been established. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2722 | */ |
| 2723 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2724 | public static final String ACTION_GTALK_SERVICE_CONNECTED = |
| 2725 | "android.intent.action.GTALK_CONNECTED"; |
| 2726 | |
| 2727 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2728 | * Broadcast Action: A GTalk connection has been disconnected. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2729 | */ |
| 2730 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2731 | public static final String ACTION_GTALK_SERVICE_DISCONNECTED = |
| 2732 | "android.intent.action.GTALK_DISCONNECTED"; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2733 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2734 | /** |
| 2735 | * Broadcast Action: An input method has been changed. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2736 | */ |
| 2737 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2738 | public static final String ACTION_INPUT_METHOD_CHANGED = |
| 2739 | "android.intent.action.INPUT_METHOD_CHANGED"; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2740 | |
| 2741 | /** |
| 2742 | * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or |
| 2743 | * more radios have been turned off or on. The intent will have the following extra value:</p> |
| 2744 | * <ul> |
| 2745 | * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, |
| 2746 | * then cell radio and possibly other radios such as bluetooth or WiFi may have also been |
| 2747 | * turned off</li> |
| 2748 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2749 | * |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 2750 | * <p class="note">This is a protected intent that can only be sent by the system.</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2751 | */ |
| 2752 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2753 | public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; |
| 2754 | |
| 2755 | /** |
| 2756 | * Broadcast Action: Some content providers have parts of their namespace |
| 2757 | * where they publish new events or items that the user may be especially |
| 2758 | * interested in. For these things, they may broadcast this action when the |
| 2759 | * set of interesting items change. |
| 2760 | * |
| 2761 | * For example, GmailProvider sends this notification when the set of unread |
| 2762 | * mail in the inbox changes. |
| 2763 | * |
| 2764 | * <p>The data of the intent identifies which part of which provider |
| 2765 | * changed. When queried through the content resolver, the data URI will |
| 2766 | * return the data set in question. |
| 2767 | * |
| 2768 | * <p>The intent will have the following extra values: |
| 2769 | * <ul> |
| 2770 | * <li><em>count</em> - The number of items in the data set. This is the |
| 2771 | * same as the number of items in the cursor returned by querying the |
| 2772 | * data URI. </li> |
| 2773 | * </ul> |
| 2774 | * |
| 2775 | * This intent will be sent at boot (if the count is non-zero) and when the |
| 2776 | * data set changes. It is possible for the data set to change without the |
| 2777 | * count changing (for example, if a new unread message arrives in the same |
| 2778 | * sync operation in which a message is archived). The phone should still |
| 2779 | * ring/vibrate/etc as normal in this case. |
| 2780 | */ |
| 2781 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2782 | public static final String ACTION_PROVIDER_CHANGED = |
| 2783 | "android.intent.action.PROVIDER_CHANGED"; |
| 2784 | |
| 2785 | /** |
| 2786 | * Broadcast Action: Wired Headset plugged in or unplugged. |
| 2787 | * |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2788 | * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value |
| 2789 | * and documentation. |
| 2790 | * <p>If the minimum SDK version of your application is |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 2791 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2792 | * to the <code>AudioManager</code> constant in your receiver registration code instead. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2793 | */ |
| 2794 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2795 | public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG; |
Eric Laurent | 59f4827 | 2012-04-05 19:42:21 -0700 | [diff] [blame] | 2796 | |
| 2797 | /** |
Joe Onorato | 9cdffa1 | 2011-04-06 18:27:27 -0700 | [diff] [blame] | 2798 | * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> |
| 2799 | * <ul> |
| 2800 | * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> |
| 2801 | * </ul> |
| 2802 | * |
| 2803 | * <p class="note">This is a protected intent that can only be sent |
| 2804 | * by the system. |
| 2805 | * |
| 2806 | * @hide |
| 2807 | */ |
| 2808 | //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2809 | public static final String ACTION_ADVANCED_SETTINGS_CHANGED |
| 2810 | = "android.intent.action.ADVANCED_SETTINGS"; |
| 2811 | |
| 2812 | /** |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 2813 | * Broadcast Action: Sent after application restrictions are changed. |
| 2814 | * |
| 2815 | * <p class="note">This is a protected intent that can only be sent |
| 2816 | * by the system.</p> |
| 2817 | */ |
| 2818 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2819 | public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = |
| 2820 | "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; |
| 2821 | |
| 2822 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2823 | * Broadcast Action: An outgoing call is about to be placed. |
| 2824 | * |
Dirk Dougherty | 367ce90 | 2013-05-28 17:37:12 -0700 | [diff] [blame] | 2825 | * <p>The Intent will have the following extra value:</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2826 | * <ul> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2827 | * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2828 | * the phone number originally intended to be dialed.</li> |
| 2829 | * </ul> |
| 2830 | * <p>Once the broadcast is finished, the resultData is used as the actual |
| 2831 | * number to call. If <code>null</code>, no call will be placed.</p> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2832 | * <p>It is perfectly acceptable for multiple receivers to process the |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2833 | * outgoing call in turn: for example, a parental control application |
| 2834 | * might verify that the user is authorized to place the call at that |
| 2835 | * time, then a number-rewriting application might add an area code if |
| 2836 | * one was not specified.</p> |
| 2837 | * <p>For consistency, any receiver whose purpose is to prohibit phone |
| 2838 | * calls should have a priority of 0, to ensure it will see the final |
| 2839 | * phone number to be dialed. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2840 | * Any receiver whose purpose is to rewrite phone numbers to be called |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2841 | * should have a positive priority. |
| 2842 | * Negative priorities are reserved for the system for this broadcast; |
| 2843 | * using them may cause problems.</p> |
Dirk Dougherty | 932fbcc | 2013-05-29 15:19:14 -0700 | [diff] [blame] | 2844 | * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> |
| 2845 | * abort the broadcast.</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2846 | * <p>Emergency calls cannot be intercepted using this mechanism, and |
| 2847 | * other calls cannot be modified to call emergency numbers using this |
| 2848 | * mechanism. |
Santos Cordon | ba70136 | 2013-05-17 14:48:54 -0700 | [diff] [blame] | 2849 | * <p>Some apps (such as VoIP apps) may want to redirect the outgoing |
| 2850 | * call to use their own service instead. Those apps should first prevent |
| 2851 | * the call from being placed by setting resultData to <code>null</code> |
| 2852 | * and then start their own app to make the call. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2853 | * <p>You must hold the |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2854 | * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} |
| 2855 | * permission to receive this Intent.</p> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2856 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2857 | * <p class="note">This is a protected intent that can only be sent |
| 2858 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2859 | */ |
| 2860 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2861 | public static final String ACTION_NEW_OUTGOING_CALL = |
| 2862 | "android.intent.action.NEW_OUTGOING_CALL"; |
| 2863 | |
| 2864 | /** |
| 2865 | * Broadcast Action: Have the device reboot. This is only for use by |
| 2866 | * system code. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2867 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2868 | * <p class="note">This is a protected intent that can only be sent |
| 2869 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2870 | */ |
| 2871 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2872 | public static final String ACTION_REBOOT = |
| 2873 | "android.intent.action.REBOOT"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2874 | |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2875 | /** |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2876 | * Broadcast Action: A sticky broadcast for changes in the physical |
| 2877 | * docking state of the device. |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2878 | * |
| 2879 | * <p>The intent will have the following extra values: |
| 2880 | * <ul> |
| 2881 | * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2882 | * state, indicating which dock the device is physically in.</li> |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2883 | * </ul> |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2884 | * <p>This is intended for monitoring the current physical dock state. |
| 2885 | * See {@link android.app.UiModeManager} for the normal API dealing with |
| 2886 | * dock mode changes. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2887 | */ |
| 2888 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2889 | public static final String ACTION_DOCK_EVENT = |
| 2890 | "android.intent.action.DOCK_EVENT"; |
| 2891 | |
| 2892 | /** |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2893 | * Broadcast Action: A broadcast when idle maintenance can be started. |
| 2894 | * This means that the user is not interacting with the device and is |
| 2895 | * not expected to do so soon. Typical use of the idle maintenance is |
| 2896 | * to perform somehow expensive tasks that can be postponed at a moment |
| 2897 | * when they will not degrade user experience. |
| 2898 | * <p> |
| 2899 | * <p class="note">In order to keep the device responsive in case of an |
| 2900 | * unexpected user interaction, implementations of a maintenance task |
| 2901 | * should be interruptible. In such a scenario a broadcast with action |
| 2902 | * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you |
| 2903 | * should not do the maintenance work in |
| 2904 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a |
| 2905 | * maintenance service by {@link Context#startService(Intent)}. Also |
| 2906 | * you should hold a wake lock while your maintenance service is running |
| 2907 | * to prevent the device going to sleep. |
| 2908 | * </p> |
| 2909 | * <p> |
| 2910 | * <p class="note">This is a protected intent that can only be sent by |
| 2911 | * the system. |
| 2912 | * </p> |
| 2913 | * |
| 2914 | * @see #ACTION_IDLE_MAINTENANCE_END |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2915 | * |
| 2916 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2917 | */ |
| 2918 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2919 | public static final String ACTION_IDLE_MAINTENANCE_START = |
| 2920 | "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; |
| 2921 | |
| 2922 | /** |
| 2923 | * Broadcast Action: A broadcast when idle maintenance should be stopped. |
| 2924 | * This means that the user was not interacting with the device as a result |
| 2925 | * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} |
| 2926 | * was sent and now the user started interacting with the device. Typical |
| 2927 | * use of the idle maintenance is to perform somehow expensive tasks that |
| 2928 | * can be postponed at a moment when they will not degrade user experience. |
| 2929 | * <p> |
| 2930 | * <p class="note">In order to keep the device responsive in case of an |
| 2931 | * unexpected user interaction, implementations of a maintenance task |
| 2932 | * should be interruptible. Hence, on receiving a broadcast with this |
| 2933 | * action, the maintenance task should be interrupted as soon as possible. |
| 2934 | * In other words, you should not do the maintenance work in |
| 2935 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the |
| 2936 | * maintenance service that was started on receiving of |
| 2937 | * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake |
| 2938 | * lock you acquired when your maintenance service started. |
| 2939 | * </p> |
| 2940 | * <p class="note">This is a protected intent that can only be sent |
| 2941 | * by the system. |
| 2942 | * |
| 2943 | * @see #ACTION_IDLE_MAINTENANCE_START |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2944 | * |
| 2945 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2946 | */ |
| 2947 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2948 | public static final String ACTION_IDLE_MAINTENANCE_END = |
| 2949 | "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; |
| 2950 | |
| 2951 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2952 | * Broadcast Action: a remote intent is to be broadcasted. |
| 2953 | * |
| 2954 | * A remote intent is used for remote RPC between devices. The remote intent |
| 2955 | * is serialized and sent from one device to another device. The receiving |
| 2956 | * device parses the remote intent and broadcasts it. Note that anyone can |
| 2957 | * broadcast a remote intent. However, if the intent receiver of the remote intent |
| 2958 | * does not trust intent broadcasts from arbitrary intent senders, it should require |
| 2959 | * the sender to hold certain permissions so only trusted sender's broadcast will be |
| 2960 | * let through. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2961 | * @hide |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2962 | */ |
| 2963 | public static final String ACTION_REMOTE_INTENT = |
Costin Manolache | 8d83f9e | 2010-05-12 16:04:10 -0700 | [diff] [blame] | 2964 | "com.google.android.c2dm.intent.RECEIVE"; |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2965 | |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2966 | /** |
Jeff Sharkey | bd91e2f | 2016-03-22 15:32:31 -0600 | [diff] [blame] | 2967 | * Broadcast Action: This is broadcast once when the user is booting after a |
| 2968 | * system update. It can be used to perform cleanup or upgrades after a |
| 2969 | * system update. |
| 2970 | * <p> |
| 2971 | * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} |
| 2972 | * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's |
| 2973 | * only sent when the {@link Build#FINGERPRINT} has changed, and it's only |
| 2974 | * sent to receivers in the system image. |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2975 | * |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2976 | * @hide |
| 2977 | */ |
Amith Yamasani | cbabb8d | 2017-02-17 16:50:05 -0800 | [diff] [blame] | 2978 | @SystemApi |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2979 | public static final String ACTION_PRE_BOOT_COMPLETED = |
| 2980 | "android.intent.action.PRE_BOOT_COMPLETED"; |
| 2981 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2982 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2983 | * Broadcast to a specific application to query any supported restrictions to impose |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 2984 | * on restricted users. The broadcast intent contains an extra |
| 2985 | * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted |
| 2986 | * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or |
| 2987 | * String[] depending on the restriction type.<p/> |
| 2988 | * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 2989 | * which is of type <code>ArrayList<RestrictionEntry></code>. It can also |
| 2990 | * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. |
| 2991 | * The activity specified by that intent will be launched for a result which must contain |
Amith Yamasani | 3b458ad | 2013-04-18 18:40:07 -0700 | [diff] [blame] | 2992 | * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. |
| 2993 | * The keys and values of the returned restrictions will be persisted. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2994 | * @see RestrictionEntry |
| 2995 | */ |
| 2996 | public static final String ACTION_GET_RESTRICTION_ENTRIES = |
| 2997 | "android.intent.action.GET_RESTRICTION_ENTRIES"; |
| 2998 | |
| 2999 | /** |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3000 | * Sent the first time a user is starting, to allow system apps to |
| 3001 | * perform one time initialization. (This will not be seen by third |
| 3002 | * party applications because a newly initialized user does not have any |
| 3003 | * third party applications installed for it.) This is sent early in |
| 3004 | * starting the user, around the time the home app is started, before |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 3005 | * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground |
| 3006 | * broadcast, since it is part of a visible user interaction; be as quick |
| 3007 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3008 | */ |
| 3009 | public static final String ACTION_USER_INITIALIZE = |
| 3010 | "android.intent.action.USER_INITIALIZE"; |
| 3011 | |
| 3012 | /** |
| 3013 | * Sent when a user switch is happening, causing the process's user to be |
| 3014 | * brought to the foreground. This is only sent to receivers registered |
| 3015 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 3016 | * Context.registerReceiver}. It is sent to the user that is going to the |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 3017 | * foreground. This is sent as a foreground |
| 3018 | * broadcast, since it is part of a visible user interaction; be as quick |
| 3019 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3020 | */ |
| 3021 | public static final String ACTION_USER_FOREGROUND = |
| 3022 | "android.intent.action.USER_FOREGROUND"; |
| 3023 | |
| 3024 | /** |
| 3025 | * Sent when a user switch is happening, causing the process's user to be |
| 3026 | * sent to the background. This is only sent to receivers registered |
| 3027 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 3028 | * Context.registerReceiver}. It is sent to the user that is going to the |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 3029 | * background. This is sent as a foreground |
| 3030 | * broadcast, since it is part of a visible user interaction; be as quick |
| 3031 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3032 | */ |
| 3033 | public static final String ACTION_USER_BACKGROUND = |
| 3034 | "android.intent.action.USER_BACKGROUND"; |
| 3035 | |
| 3036 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 3037 | * Broadcast sent to the system when a user is added. Carries an extra |
| 3038 | * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to |
| 3039 | * all running users. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3040 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3041 | * @hide |
| 3042 | */ |
| 3043 | public static final String ACTION_USER_ADDED = |
| 3044 | "android.intent.action.USER_ADDED"; |
| 3045 | |
| 3046 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 3047 | * Broadcast sent by the system when a user is started. Carries an extra |
| 3048 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3049 | * registered receivers, not manifest receivers. It is sent to the user |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 3050 | * that has been started. This is sent as a foreground |
| 3051 | * broadcast, since it is part of a visible user interaction; be as quick |
| 3052 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3053 | * @hide |
| 3054 | */ |
| 3055 | public static final String ACTION_USER_STARTED = |
| 3056 | "android.intent.action.USER_STARTED"; |
| 3057 | |
| 3058 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 3059 | * Broadcast sent when a user is in the process of starting. Carries an extra |
| 3060 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 3061 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 3062 | * users (including the one that is being started). You must hold |
| 3063 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 3064 | * this broadcast. This is sent as a background broadcast, since |
| 3065 | * its result is not part of the primary UX flow; to safely keep track of |
| 3066 | * started/stopped state of a user you can use this in conjunction with |
| 3067 | * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with |
| 3068 | * other user state broadcasts since those are foreground broadcasts so can |
| 3069 | * execute in a different order. |
| 3070 | * @hide |
| 3071 | */ |
| 3072 | public static final String ACTION_USER_STARTING = |
| 3073 | "android.intent.action.USER_STARTING"; |
| 3074 | |
| 3075 | /** |
| 3076 | * Broadcast sent when a user is going to be stopped. Carries an extra |
| 3077 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 3078 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 3079 | * users (including the one that is being stopped). You must hold |
| 3080 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 3081 | * this broadcast. The user will not stop until all receivers have |
| 3082 | * handled the broadcast. This is sent as a background broadcast, since |
| 3083 | * its result is not part of the primary UX flow; to safely keep track of |
| 3084 | * started/stopped state of a user you can use this in conjunction with |
| 3085 | * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with |
| 3086 | * other user state broadcasts since those are foreground broadcasts so can |
| 3087 | * execute in a different order. |
| 3088 | * @hide |
| 3089 | */ |
| 3090 | public static final String ACTION_USER_STOPPING = |
| 3091 | "android.intent.action.USER_STOPPING"; |
| 3092 | |
| 3093 | /** |
| 3094 | * Broadcast sent to the system when a user is stopped. Carries an extra |
| 3095 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to |
| 3096 | * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a |
| 3097 | * specific package. This is only sent to registered receivers, not manifest |
| 3098 | * receivers. It is sent to all running users <em>except</em> the one that |
| 3099 | * has just been stopped (which is no longer running). |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 3100 | * @hide |
| 3101 | */ |
| 3102 | public static final String ACTION_USER_STOPPED = |
| 3103 | "android.intent.action.USER_STOPPED"; |
| 3104 | |
| 3105 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 3106 | * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3107 | * the userHandle of the user. It is sent to all running users except the |
Amith Yamasani | db6a14c | 2012-10-17 21:16:52 -0700 | [diff] [blame] | 3108 | * one that has been removed. The user will not be completely removed until all receivers have |
| 3109 | * handled the broadcast. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3110 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3111 | * @hide |
| 3112 | */ |
Sudheer Shanka | 166a81b | 2017-03-30 15:42:51 -0700 | [diff] [blame] | 3113 | @SystemApi |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3114 | public static final String ACTION_USER_REMOVED = |
| 3115 | "android.intent.action.USER_REMOVED"; |
| 3116 | |
| 3117 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 3118 | * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3119 | * the userHandle of the user to become the current one. This is only sent to |
| 3120 | * registered receivers, not manifest receivers. It is sent to all running users. |
| 3121 | * You must hold |
| 3122 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3123 | * @hide |
| 3124 | */ |
| 3125 | public static final String ACTION_USER_SWITCHED = |
| 3126 | "android.intent.action.USER_SWITCHED"; |
| 3127 | |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 3128 | /** |
Jeff Sharkey | 8924e87 | 2015-11-30 12:52:10 -0700 | [diff] [blame] | 3129 | * Broadcast Action: Sent when the credential-encrypted private storage has |
| 3130 | * become unlocked for the target user. This is only sent to registered |
| 3131 | * receivers, not manifest receivers. |
| 3132 | */ |
| 3133 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3134 | public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; |
| 3135 | |
| 3136 | /** |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 3137 | * Broadcast sent to the system when a user's information changes. Carries an extra |
| 3138 | * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 3139 | * This is only sent to registered receivers, not manifest receivers. It is sent to all users. |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 3140 | * @hide |
| 3141 | */ |
| 3142 | public static final String ACTION_USER_INFO_CHANGED = |
| 3143 | "android.intent.action.USER_INFO_CHANGED"; |
| 3144 | |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 3145 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3146 | * Broadcast sent to the primary user when an associated managed profile is added (the profile |
| 3147 | * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies |
Adam Connors | d4b584e | 2014-06-09 13:55:47 +0100 | [diff] [blame] | 3148 | * the UserHandle of the profile that was added. Only applications (for example Launchers) |
| 3149 | * that need to display merged content across both primary and managed profiles need to |
| 3150 | * worry about this broadcast. This is only sent to registered receivers, |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3151 | * not manifest receivers. |
| 3152 | */ |
| 3153 | public static final String ACTION_MANAGED_PROFILE_ADDED = |
| 3154 | "android.intent.action.MANAGED_PROFILE_ADDED"; |
| 3155 | |
| 3156 | /** |
| 3157 | * Broadcast sent to the primary user when an associated managed profile is removed. Carries an |
Adam Connors | d4b584e | 2014-06-09 13:55:47 +0100 | [diff] [blame] | 3158 | * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. |
| 3159 | * Only applications (for example Launchers) that need to display merged content across both |
| 3160 | * primary and managed profiles need to worry about this broadcast. This is only sent to |
| 3161 | * registered receivers, not manifest receivers. |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3162 | */ |
| 3163 | public static final String ACTION_MANAGED_PROFILE_REMOVED = |
| 3164 | "android.intent.action.MANAGED_PROFILE_REMOVED"; |
| 3165 | |
| 3166 | /** |
Kenny Guy | b1b3026 | 2016-02-09 16:02:35 +0000 | [diff] [blame] | 3167 | * Broadcast sent to the primary user when the credential-encrypted private storage for |
| 3168 | * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that |
| 3169 | * specifies the UserHandle of the profile that was unlocked. Only applications (for example |
| 3170 | * Launchers) that need to display merged content across both primary and managed profiles |
| 3171 | * need to worry about this broadcast. This is only sent to registered receivers, |
| 3172 | * not manifest receivers. |
| 3173 | */ |
| 3174 | public static final String ACTION_MANAGED_PROFILE_UNLOCKED = |
| 3175 | "android.intent.action.MANAGED_PROFILE_UNLOCKED"; |
| 3176 | |
| 3177 | /** |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 3178 | * Broadcast sent to the primary user when an associated managed profile has become available. |
| 3179 | * Currently this includes when the user disables quiet mode for the profile. Carries an extra |
Rubin Xu | f13c980 | 2016-01-21 18:06:00 +0000 | [diff] [blame] | 3180 | * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, |
| 3181 | * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state |
| 3182 | * of quiet mode. This is only sent to registered receivers, not manifest receivers. |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 3183 | */ |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 3184 | public static final String ACTION_MANAGED_PROFILE_AVAILABLE = |
| 3185 | "android.intent.action.MANAGED_PROFILE_AVAILABLE"; |
| 3186 | |
| 3187 | /** |
| 3188 | * Broadcast sent to the primary user when an associated managed profile has become unavailable. |
| 3189 | * Currently this includes when the user enables quiet mode for the profile. Carries an extra |
| 3190 | * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, |
| 3191 | * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state |
| 3192 | * of quiet mode. This is only sent to registered receivers, not manifest receivers. |
| 3193 | */ |
| 3194 | public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = |
| 3195 | "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 3196 | |
| 3197 | /** |
Robin Lee | 92b83c6 | 2016-08-31 13:27:51 +0100 | [diff] [blame] | 3198 | * Broadcast sent to the system user when the 'device locked' state changes for any user. |
| 3199 | * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which |
| 3200 | * the device was locked or unlocked. |
| 3201 | * |
| 3202 | * This is only sent to registered receivers. |
| 3203 | * |
| 3204 | * @hide |
| 3205 | */ |
| 3206 | public static final String ACTION_DEVICE_LOCKED_CHANGED = |
| 3207 | "android.intent.action.DEVICE_LOCKED_CHANGED"; |
| 3208 | |
| 3209 | /** |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 3210 | * Sent when the user taps on the clock widget in the system's "quick settings" area. |
| 3211 | */ |
| 3212 | public static final String ACTION_QUICK_CLOCK = |
| 3213 | "android.intent.action.QUICK_CLOCK"; |
| 3214 | |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 3215 | /** |
Alan Viverette | 5a39949 | 2014-07-14 16:19:38 -0700 | [diff] [blame] | 3216 | * Activity Action: Shows the brightness setting dialog. |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 3217 | * @hide |
| 3218 | */ |
| 3219 | public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = |
Clara Bayarri | 847d868 | 2017-03-06 16:48:44 +0000 | [diff] [blame] | 3220 | "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 3221 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3222 | /** |
| 3223 | * Broadcast Action: A global button was pressed. Includes a single |
| 3224 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 3225 | * caused the broadcast. |
| 3226 | * @hide |
| 3227 | */ |
Sujith Ramakrishnan | 48e19c8 | 2017-04-24 15:57:58 -0700 | [diff] [blame] | 3228 | @SystemApi |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3229 | public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; |
| 3230 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3231 | /** |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 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"> |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 3241 | * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 3242 | * </p> |
| 3243 | * |
| 3244 | * @hide |
| 3245 | */ |
| 3246 | public static final String ACTION_MEDIA_RESOURCE_GRANTED = |
| 3247 | "android.intent.action.MEDIA_RESOURCE_GRANTED"; |
| 3248 | |
| 3249 | /** |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 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 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3267 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 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 *}/*. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3284 | * <p> |
| 3285 | * If the caller can handle multiple returned items (the user performing |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3286 | * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 3287 | * to indicate this. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3288 | * <p> |
Tomasz Mikolajewski | a8057a9 | 2015-11-16 11:41:28 +0900 | [diff] [blame] | 3289 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain |
| 3290 | * URIs that can be opened with |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3291 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3292 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 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. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3298 | * <p> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 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()}. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3303 | * |
| 3304 | * @see DocumentsContract |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3305 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3306 | * @see #ACTION_CREATE_DOCUMENT |
| 3307 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3308 | */ |
| 3309 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3310 | public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; |
| 3311 | |
| 3312 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3318 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3330 | * <p> |
Tomasz Mikolajewski | a8057a9 | 2015-11-16 11:41:28 +0900 | [diff] [blame] | 3331 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain |
| 3332 | * URIs that can be opened with |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3333 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3334 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 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. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3340 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3343 | * |
| 3344 | * @see DocumentsContract |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3345 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3346 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3347 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3348 | */ |
| 3349 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3350 | public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; |
| 3351 | |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3352 | /** |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 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. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3357 | * <p> |
| 3358 | * To gain access to descendant (child, grandchild, etc) documents, use |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3359 | * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and |
| 3360 | * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} |
| 3361 | * with the returned URI. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3362 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 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. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3368 | * <p> |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3369 | * Output: The URI representing the selected directory tree. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3370 | * |
| 3371 | * @see DocumentsContract |
| 3372 | */ |
| 3373 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3374 | public static final String |
| 3375 | ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3376 | |
Felipe Leme | c7b1f89 | 2016-01-15 15:02:31 -0800 | [diff] [blame] | 3377 | /** |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 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 | |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3389 | /** |
Sam Lin | e707f83 | 2017-04-13 17:00:55 -0700 | [diff] [blame] | 3390 | * Deprecated - use ACTION_FACTORY_RESET instead. |
Amith Yamasani | e99757e4 | 2017-04-14 14:41:45 -0700 | [diff] [blame] | 3391 | * @hide |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3392 | */ |
| 3393 | @Deprecated |
Amith Yamasani | e99757e4 | 2017-04-14 14:41:45 -0700 | [diff] [blame] | 3394 | @SystemApi |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 3395 | public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; |
| 3396 | |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 3397 | /** |
Amith Yamasani | cbabb8d | 2017-02-17 16:50:05 -0800 | [diff] [blame] | 3398 | * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe) |
| 3399 | * is about to be performed. |
| 3400 | * @hide |
| 3401 | */ |
| 3402 | @SystemApi |
| 3403 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3404 | public static final String ACTION_MASTER_CLEAR_NOTIFICATION |
| 3405 | = "android.intent.action.MASTER_CLEAR_NOTIFICATION"; |
| 3406 | |
| 3407 | /** |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3408 | * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory |
| 3409 | * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. |
| 3410 | * |
| 3411 | * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. |
| 3412 | * |
Benjamin Franz | f9d5e6a | 2016-05-26 14:24:29 +0100 | [diff] [blame] | 3413 | * @hide |
| 3414 | */ |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3415 | @Deprecated |
Benjamin Franz | f9d5e6a | 2016-05-26 14:24:29 +0100 | [diff] [blame] | 3416 | public static final String EXTRA_FORCE_MASTER_CLEAR = |
| 3417 | "android.intent.extra.FORCE_MASTER_CLEAR"; |
| 3418 | |
| 3419 | /** |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3420 | * A broadcast action to trigger a factory reset. |
| 3421 | * |
| 3422 | * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. |
| 3423 | * |
| 3424 | * <p>Not for use by third-party applications. |
| 3425 | * |
| 3426 | * @see #EXTRA_FORCE_MASTER_CLEAR |
| 3427 | * |
| 3428 | * {@hide} |
| 3429 | */ |
| 3430 | @SystemApi |
| 3431 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3432 | public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; |
| 3433 | |
| 3434 | /** |
| 3435 | * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory |
| 3436 | * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. |
| 3437 | * |
| 3438 | * <p>Not for use by third-party applications. |
| 3439 | * |
| 3440 | * @hide |
| 3441 | */ |
| 3442 | @SystemApi |
| 3443 | public static final String EXTRA_FORCE_FACTORY_RESET = |
| 3444 | "android.intent.extra.FORCE_FACTORY_RESET"; |
| 3445 | |
| 3446 | /** |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 3447 | * Broadcast action: report that a settings element is being restored from backup. The intent |
| 3448 | * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting, |
| 3449 | * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE |
| 3450 | * is the value of that settings entry prior to the restore operation. All of these values are |
| 3451 | * represented as strings. |
| 3452 | * |
| 3453 | * <p>This broadcast is sent only for settings provider entries known to require special handling |
| 3454 | * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within |
| 3455 | * the provider's backup agent implementation. |
| 3456 | * |
| 3457 | * @see #EXTRA_SETTING_NAME |
| 3458 | * @see #EXTRA_SETTING_PREVIOUS_VALUE |
| 3459 | * @see #EXTRA_SETTING_NEW_VALUE |
| 3460 | * {@hide} |
| 3461 | */ |
| 3462 | public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; |
| 3463 | |
| 3464 | /** {@hide} */ |
| 3465 | public static final String EXTRA_SETTING_NAME = "setting_name"; |
| 3466 | /** {@hide} */ |
| 3467 | public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; |
| 3468 | /** {@hide} */ |
| 3469 | public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; |
| 3470 | |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3471 | /** |
| 3472 | * Activity Action: Process a piece of text. |
| 3473 | * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. |
| 3474 | * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> |
| 3475 | * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> |
| 3476 | */ |
| 3477 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3478 | public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; |
Amith Yamasani | cbabb8d | 2017-02-17 16:50:05 -0800 | [diff] [blame] | 3479 | |
| 3480 | /** |
| 3481 | * Broadcast Action: The sim card state has changed. |
| 3482 | * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here |
| 3483 | * because TelephonyIntents is an internal class. |
| 3484 | * @hide |
| 3485 | */ |
| 3486 | @SystemApi |
| 3487 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3488 | public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED"; |
| 3489 | |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3490 | /** |
fionaxu | 90fee27 | 2017-03-31 12:45:12 -0700 | [diff] [blame] | 3491 | * Broadcast Action: indicate that the phone service state has changed. |
| 3492 | * The intent will have the following extra values:</p> |
| 3493 | * <p> |
| 3494 | * @see #EXTRA_VOICE_REG_STATE |
| 3495 | * @see #EXTRA_DATA_REG_STATE |
| 3496 | * @see #EXTRA_VOICE_ROAMING_TYPE |
| 3497 | * @see #EXTRA_DATA_ROAMING_TYPE |
| 3498 | * @see #EXTRA_OPERATOR_ALPHA_LONG |
| 3499 | * @see #EXTRA_OPERATOR_ALPHA_SHORT |
| 3500 | * @see #EXTRA_OPERATOR_NUMERIC |
| 3501 | * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG |
| 3502 | * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT |
| 3503 | * @see #EXTRA_DATA_OPERATOR_NUMERIC |
| 3504 | * @see #EXTRA_MANUAL |
| 3505 | * @see #EXTRA_VOICE_RADIO_TECH |
| 3506 | * @see #EXTRA_DATA_RADIO_TECH |
| 3507 | * @see #EXTRA_CSS_INDICATOR |
| 3508 | * @see #EXTRA_NETWORK_ID |
| 3509 | * @see #EXTRA_SYSTEM_ID |
| 3510 | * @see #EXTRA_CDMA_ROAMING_INDICATOR |
| 3511 | * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR |
| 3512 | * @see #EXTRA_EMERGENCY_ONLY |
| 3513 | * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION |
| 3514 | * @see #EXTRA_IS_USING_CARRIER_AGGREGATION |
| 3515 | * @see #EXTRA_LTE_EARFCN_RSRP_BOOST |
| 3516 | * |
| 3517 | * <p class="note"> |
| 3518 | * Requires the READ_PHONE_STATE permission. |
| 3519 | * |
| 3520 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 3521 | * @hide |
| 3522 | */ |
| 3523 | @Deprecated |
| 3524 | @SystemApi |
| 3525 | @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3526 | public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE"; |
| 3527 | |
| 3528 | /** |
| 3529 | * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration |
| 3530 | * state. |
| 3531 | * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY |
| 3532 | * @see android.telephony.ServiceState#STATE_IN_SERVICE |
| 3533 | * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE |
| 3534 | * @see android.telephony.ServiceState#STATE_POWER_OFF |
| 3535 | * @hide |
| 3536 | */ |
| 3537 | @Deprecated |
| 3538 | @SystemApi |
| 3539 | public static final String EXTRA_VOICE_REG_STATE = "voiceRegState"; |
| 3540 | |
| 3541 | /** |
| 3542 | * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state. |
| 3543 | * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY |
| 3544 | * @see android.telephony.ServiceState#STATE_IN_SERVICE |
| 3545 | * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE |
| 3546 | * @see android.telephony.ServiceState#STATE_POWER_OFF |
| 3547 | * @hide |
| 3548 | */ |
| 3549 | @Deprecated |
| 3550 | @SystemApi |
| 3551 | public static final String EXTRA_DATA_REG_STATE = "dataRegState"; |
| 3552 | |
| 3553 | /** |
| 3554 | * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming |
| 3555 | * type. |
| 3556 | * @hide |
| 3557 | */ |
| 3558 | @Deprecated |
| 3559 | @SystemApi |
| 3560 | public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType"; |
| 3561 | |
| 3562 | /** |
| 3563 | * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming |
| 3564 | * type. |
| 3565 | * @hide |
| 3566 | */ |
| 3567 | @Deprecated |
| 3568 | @SystemApi |
| 3569 | public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType"; |
| 3570 | |
| 3571 | /** |
| 3572 | * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current |
| 3573 | * registered voice operator name in long alphanumeric format. |
| 3574 | * {@code null} if the operator name is not known or unregistered. |
| 3575 | * @hide |
| 3576 | */ |
| 3577 | @Deprecated |
| 3578 | @SystemApi |
| 3579 | public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long"; |
| 3580 | |
| 3581 | /** |
| 3582 | * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current |
| 3583 | * registered voice operator name in short alphanumeric format. |
| 3584 | * {@code null} if the operator name is not known or unregistered. |
| 3585 | * @hide |
| 3586 | */ |
| 3587 | @Deprecated |
| 3588 | @SystemApi |
| 3589 | public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short"; |
| 3590 | |
| 3591 | /** |
| 3592 | * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC |
| 3593 | * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile |
| 3594 | * network. |
| 3595 | * @hide |
| 3596 | */ |
| 3597 | @Deprecated |
| 3598 | @SystemApi |
| 3599 | public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric"; |
| 3600 | |
| 3601 | /** |
| 3602 | * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current |
| 3603 | * registered data operator name in long alphanumeric format. |
| 3604 | * {@code null} if the operator name is not known or unregistered. |
| 3605 | * @hide |
| 3606 | */ |
| 3607 | @Deprecated |
| 3608 | @SystemApi |
| 3609 | public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long"; |
| 3610 | |
| 3611 | /** |
| 3612 | * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current |
| 3613 | * registered data operator name in short alphanumeric format. |
| 3614 | * {@code null} if the operator name is not known or unregistered. |
| 3615 | * @hide |
| 3616 | */ |
| 3617 | @Deprecated |
| 3618 | @SystemApi |
| 3619 | public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short"; |
| 3620 | |
| 3621 | /** |
| 3622 | * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC |
| 3623 | * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the |
| 3624 | * data operator. |
| 3625 | * @hide |
| 3626 | */ |
| 3627 | @Deprecated |
| 3628 | @SystemApi |
| 3629 | public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric"; |
| 3630 | |
| 3631 | /** |
| 3632 | * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current |
| 3633 | * network selection mode is manual. |
| 3634 | * Will be {@code true} if manual mode, {@code false} if automatic mode. |
| 3635 | * @hide |
| 3636 | */ |
| 3637 | @Deprecated |
| 3638 | @SystemApi |
| 3639 | public static final String EXTRA_MANUAL = "manual"; |
| 3640 | |
| 3641 | /** |
| 3642 | * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice |
| 3643 | * radio technology. |
| 3644 | * @hide |
| 3645 | */ |
| 3646 | @Deprecated |
| 3647 | @SystemApi |
| 3648 | public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology"; |
| 3649 | |
| 3650 | /** |
| 3651 | * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data |
| 3652 | * radio technology. |
| 3653 | * @hide |
| 3654 | */ |
| 3655 | @Deprecated |
| 3656 | @SystemApi |
| 3657 | public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology"; |
| 3658 | |
| 3659 | /** |
| 3660 | * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service |
| 3661 | * support on CDMA network. |
| 3662 | * Will be {@code true} if support, {@code false} otherwise. |
| 3663 | * @hide |
| 3664 | */ |
| 3665 | @Deprecated |
| 3666 | @SystemApi |
| 3667 | public static final String EXTRA_CSS_INDICATOR = "cssIndicator"; |
| 3668 | |
| 3669 | /** |
| 3670 | * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network |
| 3671 | * id. {@code Integer.MAX_VALUE} if unknown. |
| 3672 | * @hide |
| 3673 | */ |
| 3674 | @Deprecated |
| 3675 | @SystemApi |
| 3676 | public static final String EXTRA_NETWORK_ID = "networkId"; |
| 3677 | |
| 3678 | /** |
| 3679 | * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id. |
| 3680 | * {@code Integer.MAX_VALUE} if unknown. |
| 3681 | * @hide |
| 3682 | */ |
| 3683 | @Deprecated |
| 3684 | @SystemApi |
| 3685 | public static final String EXTRA_SYSTEM_ID = "systemId"; |
| 3686 | |
| 3687 | /** |
| 3688 | * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming |
| 3689 | * indicator if registered on a CDMA or EVDO system or {@code -1} if not. |
| 3690 | * @hide |
| 3691 | */ |
| 3692 | @Deprecated |
| 3693 | @SystemApi |
| 3694 | public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator"; |
| 3695 | |
| 3696 | /** |
| 3697 | * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming |
| 3698 | * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not. |
| 3699 | * @hide |
| 3700 | */ |
| 3701 | @Deprecated |
| 3702 | @SystemApi |
| 3703 | public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator"; |
| 3704 | |
| 3705 | /** |
| 3706 | * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency |
| 3707 | * only mode. |
| 3708 | * {@code true} if in emergency only mode, {@code false} otherwise. |
| 3709 | * @hide |
| 3710 | */ |
| 3711 | @Deprecated |
| 3712 | @SystemApi |
| 3713 | public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly"; |
| 3714 | |
| 3715 | /** |
| 3716 | * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network |
| 3717 | * registration state is roaming. |
| 3718 | * {@code true} if registration indicates roaming, {@code false} otherwise |
| 3719 | * @hide |
| 3720 | */ |
| 3721 | @Deprecated |
| 3722 | @SystemApi |
| 3723 | public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION = |
| 3724 | "isDataRoamingFromRegistration"; |
| 3725 | |
| 3726 | /** |
| 3727 | * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier |
| 3728 | * aggregation is in use. |
| 3729 | * {@code true} if carrier aggregation is in use, {@code false} otherwise. |
| 3730 | * @hide |
| 3731 | */ |
| 3732 | @Deprecated |
| 3733 | @SystemApi |
| 3734 | public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation"; |
| 3735 | |
| 3736 | /** |
| 3737 | * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which |
| 3738 | * is reduced from the rsrp threshold while calculating signal strength level. |
| 3739 | * @hide |
| 3740 | */ |
| 3741 | @Deprecated |
| 3742 | @SystemApi |
| 3743 | public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; |
| 3744 | |
| 3745 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3746 | * The name of the extra used to define the text to be processed, as a |
| 3747 | * CharSequence. Note that this may be a styled CharSequence, so you must use |
| 3748 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3749 | */ |
| 3750 | public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; |
| 3751 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3752 | * The name of the boolean extra used to define if the processed text will be used as read-only. |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3753 | */ |
| 3754 | public static final String EXTRA_PROCESS_TEXT_READONLY = |
| 3755 | "android.intent.extra.PROCESS_TEXT_READONLY"; |
| 3756 | |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3757 | /** |
| 3758 | * Broadcast action: reports when a new thermal event has been reached. When the device |
| 3759 | * is reaching its maximum temperatue, the thermal level reported |
| 3760 | * {@hide} |
| 3761 | */ |
| 3762 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3763 | public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; |
| 3764 | |
| 3765 | /** {@hide} */ |
| 3766 | public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; |
| 3767 | |
| 3768 | /** |
| 3769 | * Thermal state when the device is normal. This state is sent in the |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 3770 | * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3771 | * {@hide} |
| 3772 | */ |
| 3773 | public static final int EXTRA_THERMAL_STATE_NORMAL = 0; |
| 3774 | |
| 3775 | /** |
| 3776 | * Thermal state where the device is approaching its maximum threshold. This state is sent in |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 3777 | * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3778 | * {@hide} |
| 3779 | */ |
| 3780 | public static final int EXTRA_THERMAL_STATE_WARNING = 1; |
| 3781 | |
| 3782 | /** |
| 3783 | * Thermal state where the device has reached its maximum threshold. This state is sent in the |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 3784 | * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3785 | * {@hide} |
| 3786 | */ |
| 3787 | public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; |
| 3788 | |
| 3789 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3790 | // --------------------------------------------------------------------- |
| 3791 | // --------------------------------------------------------------------- |
| 3792 | // Standard intent categories (see addCategory()). |
| 3793 | |
| 3794 | /** |
| 3795 | * Set if the activity should be an option for the default action |
| 3796 | * (center press) to perform on a piece of data. Setting this will |
| 3797 | * hide from the user any activities without it set when performing an |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3798 | * action on some data. Note that this is normally -not- set in the |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3799 | * Intent when initiating an action -- it is for use in intent filters |
| 3800 | * specified in packages. |
| 3801 | */ |
| 3802 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3803 | public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; |
| 3804 | /** |
| 3805 | * Activities that can be safely invoked from a browser must support this |
| 3806 | * category. For example, if the user is viewing a web page or an e-mail |
| 3807 | * and clicks on a link in the text, the Intent generated execute that |
| 3808 | * link will require the BROWSABLE category, so that only activities |
| 3809 | * supporting this category will be considered as possible actions. By |
| 3810 | * supporting this category, you are promising that there is nothing |
| 3811 | * damaging (without user intervention) that can happen by invoking any |
| 3812 | * matching Intent. |
| 3813 | */ |
| 3814 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3815 | public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; |
| 3816 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3817 | * Categories for activities that can participate in voice interaction. |
| 3818 | * An activity that supports this category must be prepared to run with |
| 3819 | * no UI shown at all (though in some case it may have a UI shown), and |
| 3820 | * rely on {@link android.app.VoiceInteractor} to interact with the user. |
| 3821 | */ |
| 3822 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3823 | public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; |
| 3824 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3825 | * Set if the activity should be considered as an alternative action to |
| 3826 | * the data the user is currently viewing. See also |
| 3827 | * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that |
| 3828 | * applies to the selection in a list of items. |
| 3829 | * |
| 3830 | * <p>Supporting this category means that you would like your activity to be |
| 3831 | * displayed in the set of alternative things the user can do, usually as |
| 3832 | * part of the current activity's options menu. You will usually want to |
| 3833 | * include a specific label in the <intent-filter> of this action |
| 3834 | * describing to the user what it does. |
| 3835 | * |
| 3836 | * <p>The action of IntentFilter with this category is important in that it |
| 3837 | * describes the specific action the target will perform. This generally |
| 3838 | * should not be a generic action (such as {@link #ACTION_VIEW}, but rather |
| 3839 | * a specific name such as "com.android.camera.action.CROP. Only one |
| 3840 | * alternative of any particular action will be shown to the user, so using |
| 3841 | * a specific action like this makes sure that your alternative will be |
| 3842 | * displayed while also allowing other applications to provide their own |
| 3843 | * overrides of that particular action. |
| 3844 | */ |
| 3845 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3846 | public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; |
| 3847 | /** |
| 3848 | * Set if the activity should be considered as an alternative selection |
| 3849 | * action to the data the user has currently selected. This is like |
| 3850 | * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list |
| 3851 | * of items from which the user can select, giving them alternatives to the |
| 3852 | * default action that will be performed on it. |
| 3853 | */ |
| 3854 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3855 | public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; |
| 3856 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3857 | * Intended to be used as a tab inside of a containing TabActivity. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3858 | */ |
| 3859 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3860 | public static final String CATEGORY_TAB = "android.intent.category.TAB"; |
| 3861 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3862 | * Should be displayed in the top-level launcher. |
| 3863 | */ |
| 3864 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3865 | public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; |
| 3866 | /** |
Jose Lima | 38b75b6 | 2014-03-11 10:41:39 -0700 | [diff] [blame] | 3867 | * Indicates an activity optimized for Leanback mode, and that should |
| 3868 | * be displayed in the Leanback launcher. |
| 3869 | */ |
| 3870 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3871 | public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; |
| 3872 | /** |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 3873 | * Indicates a Leanback settings activity to be displayed in the Leanback launcher. |
| 3874 | * @hide |
| 3875 | */ |
| 3876 | @SystemApi |
| 3877 | public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; |
| 3878 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3879 | * Provides information about the package it is in; typically used if |
| 3880 | * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide |
| 3881 | * a front-door to the user without having to be shown in the all apps list. |
| 3882 | */ |
| 3883 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3884 | public static final String CATEGORY_INFO = "android.intent.category.INFO"; |
| 3885 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3886 | * This is the home activity, that is the first activity that is displayed |
| 3887 | * when the device boots. |
| 3888 | */ |
| 3889 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3890 | public static final String CATEGORY_HOME = "android.intent.category.HOME"; |
| 3891 | /** |
Anthony Hugh | 979b81a | 2015-09-29 16:50:35 -0700 | [diff] [blame] | 3892 | * This is the home activity that is displayed when the device is finished setting up and ready |
| 3893 | * for use. |
| 3894 | * @hide |
| 3895 | */ |
| 3896 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3897 | public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; |
| 3898 | /** |
Svet Ganov | 50a8bf4 | 2015-07-15 11:04:18 -0700 | [diff] [blame] | 3899 | * This is the setup wizard activity, that is the first activity that is displayed |
| 3900 | * when the user sets up the device for the first time. |
| 3901 | * @hide |
| 3902 | */ |
| 3903 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3904 | public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; |
| 3905 | /** |
Svet Ganov | 5bb6bc6 | 2017-08-28 12:39:35 -0700 | [diff] [blame^] | 3906 | * This is the home activity, that is the activity that serves as the launcher app |
| 3907 | * from there the user can start other apps. Often components with lower/higher |
| 3908 | * priority intent filters handle the home intent, for example SetupWizard, to |
| 3909 | * setup the device and we need to be able to distinguish the home app from these |
| 3910 | * setup helpers. |
| 3911 | * @hide |
| 3912 | */ |
| 3913 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3914 | public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP"; |
| 3915 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3916 | * This activity is a preference panel. |
| 3917 | */ |
| 3918 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3919 | public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; |
| 3920 | /** |
| 3921 | * This activity is a development preference panel. |
| 3922 | */ |
| 3923 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3924 | public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; |
| 3925 | /** |
| 3926 | * Capable of running inside a parent activity container. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3927 | */ |
| 3928 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3929 | public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; |
| 3930 | /** |
Patrick Dubroy | 6dabe24 | 2010-08-30 10:43:47 -0700 | [diff] [blame] | 3931 | * This activity allows the user to browse and download new applications. |
| 3932 | */ |
| 3933 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3934 | public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; |
| 3935 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3936 | * This activity may be exercised by the monkey or other automated test tools. |
| 3937 | */ |
| 3938 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3939 | public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; |
| 3940 | /** |
| 3941 | * To be used as a test (not part of the normal user experience). |
| 3942 | */ |
| 3943 | public static final String CATEGORY_TEST = "android.intent.category.TEST"; |
| 3944 | /** |
| 3945 | * To be used as a unit test (run through the Test Harness). |
| 3946 | */ |
| 3947 | public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; |
| 3948 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3949 | * To be used as a sample code example (not part of the normal user |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3950 | * experience). |
| 3951 | */ |
| 3952 | public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3953 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3954 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3955 | * Used to indicate that an intent only wants URIs that can be opened with |
| 3956 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs |
| 3957 | * must support at least the columns defined in {@link OpenableColumns} when |
| 3958 | * queried. |
| 3959 | * |
| 3960 | * @see #ACTION_GET_CONTENT |
| 3961 | * @see #ACTION_OPEN_DOCUMENT |
| 3962 | * @see #ACTION_CREATE_DOCUMENT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3963 | */ |
| 3964 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3965 | public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; |
| 3966 | |
| 3967 | /** |
Tomasz Mikolajewski | 28a815c | 2016-10-28 15:54:11 +0900 | [diff] [blame] | 3968 | * Used to indicate that an intent filter can accept files which are not necessarily |
| 3969 | * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but |
| 3970 | * at least streamable via |
| 3971 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} |
| 3972 | * using one of the stream types exposed via |
| 3973 | * {@link ContentResolver#getStreamTypes(Uri, String)}. |
| 3974 | * |
| 3975 | * @see #ACTION_SEND |
| 3976 | * @see #ACTION_SEND_MULTIPLE |
| 3977 | */ |
| 3978 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3979 | public static final String CATEGORY_TYPED_OPENABLE = |
| 3980 | "android.intent.category.TYPED_OPENABLE"; |
| 3981 | |
| 3982 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3983 | * To be used as code under test for framework instrumentation tests. |
| 3984 | */ |
| 3985 | public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = |
| 3986 | "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3987 | /** |
| 3988 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3989 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3990 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3991 | */ |
| 3992 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3993 | public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; |
| 3994 | /** |
| 3995 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3996 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3997 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3998 | */ |
| 3999 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4000 | public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 4001 | /** |
| 4002 | * An activity to run when device is inserted into a analog (low end) dock. |
| 4003 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 4004 | * information, see {@link android.app.UiModeManager}. |
| 4005 | */ |
| 4006 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4007 | public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; |
| 4008 | |
| 4009 | /** |
| 4010 | * An activity to run when device is inserted into a digital (high end) dock. |
| 4011 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 4012 | * information, see {@link android.app.UiModeManager}. |
| 4013 | */ |
| 4014 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4015 | public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK"; |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4016 | |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 4017 | /** |
| 4018 | * Used to indicate that the activity can be used in a car environment. |
| 4019 | */ |
| 4020 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4021 | public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; |
| 4022 | |
Zak Cohen | db6ca49 | 2017-01-26 14:09:00 -0800 | [diff] [blame] | 4023 | /** |
| 4024 | * An activity to use for the launcher when the device is placed in a VR Headset viewer. |
| 4025 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 4026 | * information, see {@link android.app.UiModeManager}. |
| 4027 | */ |
| 4028 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4029 | public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4030 | // --------------------------------------------------------------------- |
| 4031 | // --------------------------------------------------------------------- |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4032 | // Application launch intent categories (see addCategory()). |
| 4033 | |
| 4034 | /** |
| 4035 | * Used with {@link #ACTION_MAIN} to launch the browser application. |
| 4036 | * The activity should be able to browse the Internet. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4037 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4038 | * since it will not result in the app launching with the correct |
| 4039 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4040 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4041 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4042 | */ |
| 4043 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4044 | public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; |
| 4045 | |
| 4046 | /** |
| 4047 | * Used with {@link #ACTION_MAIN} to launch the calculator application. |
| 4048 | * The activity should be able to perform standard arithmetic operations. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4049 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4050 | * since it will not result in the app launching with the correct |
| 4051 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4052 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4053 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4054 | */ |
| 4055 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4056 | public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; |
| 4057 | |
| 4058 | /** |
| 4059 | * Used with {@link #ACTION_MAIN} to launch the calendar application. |
| 4060 | * The activity should be able to view and manipulate calendar entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4061 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4062 | * since it will not result in the app launching with the correct |
| 4063 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4064 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4065 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4066 | */ |
| 4067 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4068 | public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; |
| 4069 | |
| 4070 | /** |
| 4071 | * Used with {@link #ACTION_MAIN} to launch the contacts application. |
| 4072 | * The activity should be able to view and manipulate address book entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4073 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4074 | * since it will not result in the app launching with the correct |
| 4075 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4076 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4077 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4078 | */ |
| 4079 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4080 | public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; |
| 4081 | |
| 4082 | /** |
| 4083 | * Used with {@link #ACTION_MAIN} to launch the email application. |
| 4084 | * The activity should be able to send and receive email. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4085 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4086 | * since it will not result in the app launching with the correct |
| 4087 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4088 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4089 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4090 | */ |
| 4091 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4092 | public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; |
| 4093 | |
| 4094 | /** |
| 4095 | * Used with {@link #ACTION_MAIN} to launch the gallery application. |
| 4096 | * The activity should be able to view and manipulate image and video files |
| 4097 | * stored on the device. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4098 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4099 | * since it will not result in the app launching with the correct |
| 4100 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4101 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4102 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4103 | */ |
| 4104 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4105 | public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; |
| 4106 | |
| 4107 | /** |
| 4108 | * Used with {@link #ACTION_MAIN} to launch the maps application. |
| 4109 | * The activity should be able to show the user's current location and surroundings. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4110 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4111 | * since it will not result in the app launching with the correct |
| 4112 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4113 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4114 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4115 | */ |
| 4116 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4117 | public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; |
| 4118 | |
| 4119 | /** |
| 4120 | * Used with {@link #ACTION_MAIN} to launch the messaging application. |
| 4121 | * The activity should be able to send and receive text messages. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4122 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4123 | * since it will not result in the app launching with the correct |
| 4124 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4125 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4126 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4127 | */ |
| 4128 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4129 | public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; |
| 4130 | |
| 4131 | /** |
| 4132 | * Used with {@link #ACTION_MAIN} to launch the music application. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4133 | * The activity should be able to play, browse, or manipulate music files |
| 4134 | * stored on the device. |
| 4135 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 4136 | * since it will not result in the app launching with the correct |
| 4137 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 4138 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4139 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 4140 | */ |
| 4141 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 4142 | public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; |
| 4143 | |
| 4144 | // --------------------------------------------------------------------- |
| 4145 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4146 | // Standard extra data keys. |
| 4147 | |
| 4148 | /** |
| 4149 | * The initial data to place in a newly created record. Use with |
| 4150 | * {@link #ACTION_INSERT}. The data here is a Map containing the same |
| 4151 | * fields as would be given to the underlying ContentProvider.insert() |
| 4152 | * call. |
| 4153 | */ |
| 4154 | public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; |
| 4155 | |
| 4156 | /** |
| 4157 | * A constant CharSequence that is associated with the Intent, used with |
| 4158 | * {@link #ACTION_SEND} to supply the literal data to be sent. Note that |
| 4159 | * this may be a styled CharSequence, so you must use |
| 4160 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to |
| 4161 | * retrieve it. |
| 4162 | */ |
| 4163 | public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; |
| 4164 | |
| 4165 | /** |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 4166 | * A constant String that is associated with the Intent, used with |
| 4167 | * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} |
| 4168 | * as HTML formatted text. Note that you <em>must</em> also supply |
| 4169 | * {@link #EXTRA_TEXT}. |
| 4170 | */ |
| 4171 | public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; |
| 4172 | |
| 4173 | /** |
Jeff Sharkey | 81aebe7 | 2017-04-03 20:14:10 +0000 | [diff] [blame] | 4174 | * A content: URI holding a stream of data associated with the Intent, |
| 4175 | * used with {@link #ACTION_SEND} to supply the data being sent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4176 | */ |
| 4177 | public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; |
| 4178 | |
| 4179 | /** |
| 4180 | * A String[] holding e-mail addresses that should be delivered to. |
| 4181 | */ |
| 4182 | public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; |
| 4183 | |
| 4184 | /** |
| 4185 | * A String[] holding e-mail addresses that should be carbon copied. |
| 4186 | */ |
| 4187 | public static final String EXTRA_CC = "android.intent.extra.CC"; |
| 4188 | |
| 4189 | /** |
| 4190 | * A String[] holding e-mail addresses that should be blind carbon copied. |
| 4191 | */ |
| 4192 | public static final String EXTRA_BCC = "android.intent.extra.BCC"; |
| 4193 | |
| 4194 | /** |
| 4195 | * A constant string holding the desired subject line of a message. |
| 4196 | */ |
| 4197 | public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; |
| 4198 | |
| 4199 | /** |
| 4200 | * An Intent describing the choices you would like shown with |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 4201 | * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4202 | */ |
| 4203 | public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; |
| 4204 | |
| 4205 | /** |
Clara Bayarri | f7fea16 | 2015-10-22 16:09:52 +0100 | [diff] [blame] | 4206 | * An int representing the user id to be used. |
| 4207 | * |
| 4208 | * @hide |
| 4209 | */ |
| 4210 | public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; |
| 4211 | |
| 4212 | /** |
Clara Bayarri | ea9b10e | 2015-12-04 15:36:26 +0000 | [diff] [blame] | 4213 | * An int representing the task id to be retrieved. This is used when a launch from recents is |
| 4214 | * intercepted by another action such as credentials confirmation to remember which task should |
| 4215 | * be resumed when complete. |
| 4216 | * |
| 4217 | * @hide |
| 4218 | */ |
| 4219 | public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; |
| 4220 | |
| 4221 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 4222 | * An Intent[] describing additional, alternate choices you would like shown with |
| 4223 | * {@link #ACTION_CHOOSER}. |
| 4224 | * |
| 4225 | * <p>An app may be capable of providing several different payload types to complete a |
| 4226 | * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos |
| 4227 | * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer |
| 4228 | * several different supported sending mechanisms for sharing, such as the actual "image/*" |
| 4229 | * photo data or a hosted link where the photos can be viewed.</p> |
| 4230 | * |
| 4231 | * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the |
| 4232 | * first/primary/preferred intent in the set. Additional intents specified in |
| 4233 | * this extra are ordered; by default intents that appear earlier in the array will be |
| 4234 | * preferred over intents that appear later in the array as matches for the same |
| 4235 | * target component. To alter this preference, a calling app may also supply |
| 4236 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> |
| 4237 | */ |
| 4238 | public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; |
| 4239 | |
| 4240 | /** |
Adam Powell | 52c3921 | 2016-04-07 15:14:18 -0700 | [diff] [blame] | 4241 | * A {@link ComponentName ComponentName[]} describing components that should be filtered out |
| 4242 | * and omitted from a list of components presented to the user. |
| 4243 | * |
| 4244 | * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components |
| 4245 | * in this array if it otherwise would have shown them. Useful for omitting specific targets |
| 4246 | * from your own package or other apps from your organization if the idea of sending to those |
| 4247 | * targets would be redundant with other app functionality. Filtered components will not |
| 4248 | * be able to present targets from an associated <code>ChooserTargetService</code>.</p> |
| 4249 | */ |
| 4250 | public static final String EXTRA_EXCLUDE_COMPONENTS |
| 4251 | = "android.intent.extra.EXCLUDE_COMPONENTS"; |
| 4252 | |
| 4253 | /** |
| 4254 | * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} |
| 4255 | * describing additional high-priority deep-link targets for the chooser to present to the user. |
| 4256 | * |
| 4257 | * <p>Targets provided in this way will be presented inline with all other targets provided |
| 4258 | * by services from other apps. They will be prioritized before other service targets, but |
| 4259 | * after those targets provided by sources that the user has manually pinned to the front.</p> |
| 4260 | * |
| 4261 | * @see #ACTION_CHOOSER |
| 4262 | */ |
| 4263 | public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; |
| 4264 | |
| 4265 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 4266 | * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection |
| 4267 | * from the chooser activity presented by {@link #ACTION_CHOOSER}. |
| 4268 | * |
| 4269 | * <p>An app preparing an action for another app to complete may wish to allow the user to |
| 4270 | * disambiguate between several options for completing the action based on the chosen target |
| 4271 | * or otherwise refine the action before it is invoked. |
| 4272 | * </p> |
| 4273 | * |
| 4274 | * <p>When sent, this IntentSender may be filled in with the following extras:</p> |
| 4275 | * <ul> |
| 4276 | * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> |
| 4277 | * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's |
| 4278 | * chosen target beyond the first</li> |
| 4279 | * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity |
| 4280 | * should fill in and send once the disambiguation is complete</li> |
| 4281 | * </ul> |
| 4282 | */ |
| 4283 | public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER |
| 4284 | = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; |
| 4285 | |
| 4286 | /** |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4287 | * An {@code ArrayList} of {@code String} annotations describing content for |
| 4288 | * {@link #ACTION_CHOOSER}. |
| 4289 | * |
| 4290 | * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a |
| 4291 | * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> |
| 4292 | * |
| 4293 | * <p>Annotations should describe the major components or topics of the content. It is up to |
| 4294 | * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be |
| 4295 | * learned in advance, e.g., when creating or saving content, to avoid increasing latency to |
Kang Li | 2f85e8a | 2017-04-26 09:19:54 -0700 | [diff] [blame] | 4296 | * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon |
| 4297 | * character. Performance on customized annotations can suffer, if they are rarely used for |
| 4298 | * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the |
| 4299 | * following annotations when applicable.</p> |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4300 | * <ul> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4301 | * <li>"product" represents that the topic of the content is mainly about products, e.g., |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4302 | * health & beauty, and office supplies.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4303 | * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g., |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4304 | * happy, and sad.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4305 | * <li>"person" represents that the topic of the content is mainly about persons, e.g., |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4306 | * face, finger, standing, and walking.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4307 | * <li>"child" represents that the topic of the content is mainly about children, e.g., |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4308 | * child, and baby.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4309 | * <li>"selfie" represents that the topic of the content is mainly about selfies.</li> |
| 4310 | * <li>"crowd" represents that the topic of the content is mainly about crowds.</li> |
| 4311 | * <li>"party" represents that the topic of the content is mainly about parties.</li> |
| 4312 | * <li>"animal" represent that the topic of the content is mainly about animals.</li> |
| 4313 | * <li>"plant" represents that the topic of the content is mainly about plants, e.g., |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4314 | * flowers.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4315 | * <li>"vacation" represents that the topic of the content is mainly about vacations.</li> |
| 4316 | * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g. |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4317 | * sunglasses, jewelry, handbags and clothing.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4318 | * <li>"material" represents that the topic of the content is mainly about materials, e.g., |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4319 | * paper, and silk.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4320 | * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4321 | * cars, and boats.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4322 | * <li>"document" represents that the topic of the content is mainly about documents, e.g. |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4323 | * posters.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4324 | * <li>"design" represents that the topic of the content is mainly about design, e.g. arts |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4325 | * and designs of houses.</li> |
Kang Li | fadc016 | 2017-04-19 11:56:05 -0700 | [diff] [blame] | 4326 | * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g., |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 4327 | * Christmas and Thanksgiving.</li> |
| 4328 | * </ul> |
| 4329 | */ |
| 4330 | public static final String EXTRA_CONTENT_ANNOTATIONS |
| 4331 | = "android.intent.extra.CONTENT_ANNOTATIONS"; |
| 4332 | |
| 4333 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 4334 | * A {@link ResultReceiver} used to return data back to the sender. |
| 4335 | * |
| 4336 | * <p>Used to complete an app-specific |
| 4337 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> |
| 4338 | * |
| 4339 | * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent |
| 4340 | * used to start a {@link #ACTION_CHOOSER} activity this extra will be |
| 4341 | * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent |
| 4342 | * when the user selects a target component from the chooser. It is up to the recipient |
| 4343 | * to send a result to this ResultReceiver to signal that disambiguation is complete |
| 4344 | * and that the chooser should invoke the user's choice.</p> |
| 4345 | * |
| 4346 | * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent |
| 4347 | * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser |
| 4348 | * to match and fill in the final Intent or ChooserTarget before starting it. |
| 4349 | * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from |
| 4350 | * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to |
| 4351 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> |
| 4352 | * |
| 4353 | * <p>The result code passed to the ResultReceiver should be |
| 4354 | * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's |
| 4355 | * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if |
| 4356 | * the chooser should finish without starting a target.</p> |
| 4357 | */ |
| 4358 | public static final String EXTRA_RESULT_RECEIVER |
| 4359 | = "android.intent.extra.RESULT_RECEIVER"; |
| 4360 | |
| 4361 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4362 | * A CharSequence dialog title to provide to the user when used with a |
Jim Miller | 4d64746d | 2014-08-13 21:08:41 +0000 | [diff] [blame] | 4363 | * {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4364 | */ |
| 4365 | public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; |
| 4366 | |
| 4367 | /** |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 4368 | * A Parcelable[] of {@link Intent} or |
| 4369 | * {@link android.content.pm.LabeledIntent} objects as set with |
| 4370 | * {@link #putExtra(String, Parcelable[])} of additional activities to place |
| 4371 | * a the front of the list of choices, when shown to the user with a |
| 4372 | * {@link #ACTION_CHOOSER}. |
| 4373 | */ |
| 4374 | public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; |
| 4375 | |
| 4376 | /** |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 4377 | * A {@link IntentSender} to start after ephemeral installation success. |
| 4378 | * @hide |
| 4379 | */ |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 4380 | public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS"; |
| 4381 | |
| 4382 | /** |
| 4383 | * A {@link IntentSender} to start after ephemeral installation failure. |
| 4384 | * @hide |
| 4385 | */ |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 4386 | public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE"; |
| 4387 | |
| 4388 | /** |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 4389 | * The host name that triggered an ephemeral resolution. |
| 4390 | * @hide |
| 4391 | */ |
| 4392 | public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME"; |
| 4393 | |
| 4394 | /** |
| 4395 | * An opaque token to track ephemeral resolution. |
| 4396 | * @hide |
| 4397 | */ |
| 4398 | public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN"; |
| 4399 | |
| 4400 | /** |
Todd Kennedy | 316c2f2 | 2017-01-23 15:40:07 -0800 | [diff] [blame] | 4401 | * The version code of the app to install components from. |
| 4402 | * @hide |
| 4403 | */ |
| 4404 | public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; |
| 4405 | |
| 4406 | /** |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 4407 | * The app that triggered the ephemeral installation. |
| 4408 | * @hide |
| 4409 | */ |
| 4410 | public static final String EXTRA_CALLING_PACKAGE |
| 4411 | = "android.intent.extra.CALLING_PACKAGE"; |
| 4412 | |
| 4413 | /** |
| 4414 | * Optional calling app provided bundle containing additional launch information the |
| 4415 | * installer may use. |
| 4416 | * @hide |
| 4417 | */ |
| 4418 | public static final String EXTRA_VERIFICATION_BUNDLE |
| 4419 | = "android.intent.extra.VERIFICATION_BUNDLE"; |
| 4420 | |
| 4421 | /** |
Adam Powell | e49d939 | 2014-07-17 18:45:19 -0700 | [diff] [blame] | 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 | /** |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 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 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 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 | /** |
Yusuke Sato | 705ffd1 | 2015-07-21 15:52:11 -0700 | [diff] [blame] | 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 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 4492 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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"; |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 4504 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 4515 | * @hide String array of package names. |
| 4516 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 4517 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 4518 | public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; |
| 4519 | |
| 4520 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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"; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4527 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4528 | /** |
Dianne Hackborn | c72fc67 | 2012-09-20 13:12:03 -0700 | [diff] [blame] | 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 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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"; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4544 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4545 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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"; |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 4554 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4555 | /** |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 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 |
Mike Lockwood | 725fcbf | 2009-08-24 13:09:20 -0700 | [diff] [blame] | 4558 | * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, |
| 4559 | * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 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}. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 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. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 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. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 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. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4581 | */ |
| 4582 | public static final int EXTRA_DOCK_STATE_CAR = 2; |
| 4583 | |
| 4584 | /** |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 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 | /** |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 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"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4601 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 4602 | /** |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4603 | * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing |
| 4604 | * the bug report. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4605 | */ |
| 4606 | public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; |
| 4607 | |
| 4608 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 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 | |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4615 | /** |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 4616 | * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 4617 | * will contain only the first name in the list. |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4618 | */ |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 4619 | @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4620 | "android.intent.extra.changed_component_name"; |
| 4621 | |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 4622 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4623 | * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 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. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 4627 | */ |
| 4628 | public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = |
| 4629 | "android.intent.extra.changed_component_name_list"; |
| 4630 | |
| 4631 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4632 | * This field is part of |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 4633 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 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} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4637 | * and contains a string array of all of the components that have changed. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 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 |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 4644 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
| 4645 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4646 | * and contains an integer array of uids of all of the components |
| 4647 | * that have changed. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4648 | */ |
| 4649 | public static final String EXTRA_CHANGED_UID_LIST = |
| 4650 | "android.intent.extra.changed_uid_list"; |
| 4651 | |
| 4652 | /** |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 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 | |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 4670 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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 |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 4679 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4680 | * @see #ACTION_CREATE_DOCUMENT |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 4681 | */ |
| 4682 | public static final String EXTRA_LOCAL_ONLY = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4683 | "android.intent.extra.LOCAL_ONLY"; |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 4684 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 4685 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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 |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 4695 | */ |
| 4696 | public static final String EXTRA_ALLOW_MULTIPLE = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4697 | "android.intent.extra.ALLOW_MULTIPLE"; |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 4698 | |
| 4699 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 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 | * |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 4704 | * @hide |
| 4705 | */ |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 4706 | public static final String EXTRA_USER_HANDLE = |
| 4707 | "android.intent.extra.user_handle"; |
Jean-Michel Trivi | 3114ce3 | 2012-06-11 15:03:52 -0700 | [diff] [blame] | 4708 | |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4709 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 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 = |
Alexandra Gherghina | 3315f6b | 2014-09-05 15:48:06 +0100 | [diff] [blame] | 4714 | "android.intent.extra.USER"; |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 4715 | |
| 4716 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4717 | * Extra used in the response from a BroadcastReceiver that handles |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 4718 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is |
| 4719 | * <code>ArrayList<RestrictionEntry></code>. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4720 | */ |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 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"; |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4730 | |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 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 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 4738 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 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 |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 4746 | */ |
| 4747 | public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; |
| 4748 | |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 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. |
Dianne Hackborn | d318e0b | 2013-09-03 14:34:12 -0700 | [diff] [blame] | 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. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 4756 | */ |
| 4757 | public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY |
| 4758 | = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; |
| 4759 | |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 4760 | /** |
Neil Fuller | b7146fe | 2016-11-15 16:52:15 +0000 | [diff] [blame] | 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. |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 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"; |
Neil Fuller | b7146fe | 2016-11-15 16:52:15 +0000 | [diff] [blame] | 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; |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 4776 | |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 4777 | /** {@hide} */ |
| 4778 | public static final String EXTRA_REASON = "android.intent.extra.REASON"; |
| 4779 | |
qingxi | 240c2bb | 2017-04-12 17:31:18 -0700 | [diff] [blame] | 4780 | /** |
| 4781 | * {@hide} |
| 4782 | * This extra will be send together with {@link #ACTION_FACTORY_RESET} |
| 4783 | */ |
Rubin Xu | e8490f1 | 2015-06-25 12:17:48 +0100 | [diff] [blame] | 4784 | public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; |
| 4785 | |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 4786 | /** |
qingxi | 240c2bb | 2017-04-12 17:31:18 -0700 | [diff] [blame] | 4787 | * {@hide} |
| 4788 | * This extra will be set to true when the user choose to wipe the data on eSIM during factory |
| 4789 | * reset for the device with eSIM. This extra will be sent together with |
| 4790 | * {@link #ACTION_FACTORY_RESET} |
| 4791 | */ |
| 4792 | public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; |
| 4793 | |
| 4794 | /** |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 4795 | * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM |
| 4796 | * activation request. |
| 4797 | * TODO: Add information about the structure and response data used with the pending intent. |
| 4798 | * @hide |
| 4799 | */ |
| 4800 | public static final String EXTRA_SIM_ACTIVATION_RESPONSE = |
| 4801 | "android.intent.extra.SIM_ACTIVATION_RESPONSE"; |
| 4802 | |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 4803 | /** |
| 4804 | * Optional index with semantics depending on the intent action. |
Tomasz Mikolajewski | fe02313 | 2016-03-10 17:42:35 +0900 | [diff] [blame] | 4805 | * |
| 4806 | * <p>The value must be an integer greater or equal to 0. |
Garfield Tan | ce1d0e9 | 2017-03-23 10:52:48 -0700 | [diff] [blame] | 4807 | * @see #ACTION_QUICK_VIEW |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 4808 | */ |
Steve McKay | 6eaf3863 | 2015-08-04 10:11:01 -0700 | [diff] [blame] | 4809 | public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; |
| 4810 | |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4811 | /** |
Tomasz Mikolajewski | 17c50da | 2017-02-16 14:38:04 +0900 | [diff] [blame] | 4812 | * Tells the quick viewer to show additional UI actions suitable for the passed Uris, |
| 4813 | * such as opening in other apps, sharing, opening, editing, printing, deleting, |
| 4814 | * casting, etc. |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 4815 | * |
| 4816 | * <p>The value is boolean. By default false. |
Garfield Tan | ce1d0e9 | 2017-03-23 10:52:48 -0700 | [diff] [blame] | 4817 | * @see #ACTION_QUICK_VIEW |
| 4818 | * @removed |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 4819 | */ |
Garfield Tan | ce1d0e9 | 2017-03-23 10:52:48 -0700 | [diff] [blame] | 4820 | @Deprecated |
Tomasz Mikolajewski | 17c50da | 2017-02-16 14:38:04 +0900 | [diff] [blame] | 4821 | public static final String EXTRA_QUICK_VIEW_ADVANCED = |
| 4822 | "android.intent.extra.QUICK_VIEW_ADVANCED"; |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 4823 | |
| 4824 | /** |
Garfield Tan | ce1d0e9 | 2017-03-23 10:52:48 -0700 | [diff] [blame] | 4825 | * An optional extra of {@code String[]} indicating which quick view features should be made |
| 4826 | * available to the user in the quick view UI while handing a |
| 4827 | * {@link Intent#ACTION_QUICK_VIEW} intent. |
| 4828 | * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer. |
| 4829 | * Quick viewer can implement features not listed below. |
| 4830 | * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW}, |
| 4831 | * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD}, |
| 4832 | * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}. |
| 4833 | * <p> |
| 4834 | * Requirements: |
| 4835 | * <li>Quick viewer shouldn't show a feature if the feature is absent in |
| 4836 | * {@link #EXTRA_QUICK_VIEW_FEATURES}. |
| 4837 | * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow |
| 4838 | * internal policies. |
| 4839 | * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a |
| 4840 | * requirement that the feature be shown. Quick viewer may, according to its own policies, |
| 4841 | * disable or hide features. |
| 4842 | * |
| 4843 | * @see #ACTION_QUICK_VIEW |
| 4844 | */ |
| 4845 | public static final String EXTRA_QUICK_VIEW_FEATURES = |
| 4846 | "android.intent.extra.QUICK_VIEW_FEATURES"; |
| 4847 | |
| 4848 | /** |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4849 | * Optional boolean extra indicating whether quiet mode has been switched on or off. |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 4850 | * When a profile goes into quiet mode, all apps in the profile are killed and the |
| 4851 | * profile user is stopped. Widgets originating from the profile are masked, and app |
| 4852 | * launcher icons are grayed out. |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4853 | */ |
| 4854 | public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4855 | |
| 4856 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4857 | * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4858 | * intents to specify the resource type granted. Possible values are |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4859 | * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or |
| 4860 | * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4861 | * |
| 4862 | * @hide |
| 4863 | */ |
| 4864 | public static final String EXTRA_MEDIA_RESOURCE_TYPE = |
| 4865 | "android.intent.extra.MEDIA_RESOURCE_TYPE"; |
| 4866 | |
| 4867 | /** |
Ben Lin | 145b0ca | 2016-10-14 14:23:40 -0700 | [diff] [blame] | 4868 | * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify |
| 4869 | * whether to show the chooser or not when there is only one application available |
| 4870 | * to choose from. |
| 4871 | * |
| 4872 | * @hide |
| 4873 | */ |
| 4874 | public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = |
| 4875 | "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; |
| 4876 | |
| 4877 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4878 | * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4879 | * to represent that a video codec is allowed to use. |
| 4880 | * |
| 4881 | * @hide |
| 4882 | */ |
| 4883 | public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; |
| 4884 | |
| 4885 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4886 | * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4887 | * to represent that a audio codec is allowed to use. |
| 4888 | * |
| 4889 | * @hide |
| 4890 | */ |
| 4891 | public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; |
| 4892 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4893 | // --------------------------------------------------------------------- |
| 4894 | // --------------------------------------------------------------------- |
| 4895 | // Intent flags (see mFlags variable). |
| 4896 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4897 | /** @hide */ |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4898 | @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4899 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, |
| 4900 | FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4901 | @Retention(RetentionPolicy.SOURCE) |
| 4902 | public @interface GrantUriMode {} |
| 4903 | |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4904 | /** @hide */ |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4905 | @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4906 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) |
| 4907 | @Retention(RetentionPolicy.SOURCE) |
| 4908 | public @interface AccessUriMode {} |
| 4909 | |
| 4910 | /** |
| 4911 | * Test if given mode flags specify an access mode, which must be at least |
| 4912 | * read and/or write. |
| 4913 | * |
| 4914 | * @hide |
| 4915 | */ |
| 4916 | public static boolean isAccessUriMode(int modeFlags) { |
| 4917 | return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION |
| 4918 | | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; |
| 4919 | } |
| 4920 | |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4921 | /** @hide */ |
| 4922 | @IntDef(flag = true, prefix = { "FLAG_" }, value = { |
| 4923 | FLAG_GRANT_READ_URI_PERMISSION, |
| 4924 | FLAG_GRANT_WRITE_URI_PERMISSION, |
| 4925 | FLAG_FROM_BACKGROUND, |
| 4926 | FLAG_DEBUG_LOG_RESOLUTION, |
| 4927 | FLAG_EXCLUDE_STOPPED_PACKAGES, |
| 4928 | FLAG_INCLUDE_STOPPED_PACKAGES, |
| 4929 | FLAG_GRANT_PERSISTABLE_URI_PERMISSION, |
| 4930 | FLAG_GRANT_PREFIX_URI_PERMISSION, |
| 4931 | FLAG_DEBUG_TRIAGED_MISSING, |
| 4932 | FLAG_IGNORE_EPHEMERAL, |
| 4933 | FLAG_ACTIVITY_NO_HISTORY, |
| 4934 | FLAG_ACTIVITY_SINGLE_TOP, |
| 4935 | FLAG_ACTIVITY_NEW_TASK, |
| 4936 | FLAG_ACTIVITY_MULTIPLE_TASK, |
| 4937 | FLAG_ACTIVITY_CLEAR_TOP, |
| 4938 | FLAG_ACTIVITY_FORWARD_RESULT, |
| 4939 | FLAG_ACTIVITY_PREVIOUS_IS_TOP, |
| 4940 | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, |
| 4941 | FLAG_ACTIVITY_BROUGHT_TO_FRONT, |
| 4942 | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, |
| 4943 | FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, |
| 4944 | FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, |
| 4945 | FLAG_ACTIVITY_NEW_DOCUMENT, |
| 4946 | FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, |
| 4947 | FLAG_ACTIVITY_NO_USER_ACTION, |
| 4948 | FLAG_ACTIVITY_REORDER_TO_FRONT, |
| 4949 | FLAG_ACTIVITY_NO_ANIMATION, |
| 4950 | FLAG_ACTIVITY_CLEAR_TASK, |
| 4951 | FLAG_ACTIVITY_TASK_ON_HOME, |
| 4952 | FLAG_ACTIVITY_RETAIN_IN_RECENTS, |
| 4953 | FLAG_ACTIVITY_LAUNCH_ADJACENT, |
| 4954 | FLAG_RECEIVER_REGISTERED_ONLY, |
| 4955 | FLAG_RECEIVER_REPLACE_PENDING, |
| 4956 | FLAG_RECEIVER_FOREGROUND, |
| 4957 | FLAG_RECEIVER_NO_ABORT, |
| 4958 | FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, |
| 4959 | FLAG_RECEIVER_BOOT_UPGRADE, |
| 4960 | FLAG_RECEIVER_INCLUDE_BACKGROUND, |
| 4961 | FLAG_RECEIVER_EXCLUDE_BACKGROUND, |
| 4962 | FLAG_RECEIVER_FROM_SHELL, |
| 4963 | FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, |
| 4964 | }) |
| 4965 | @Retention(RetentionPolicy.SOURCE) |
| 4966 | public @interface Flags {} |
| 4967 | |
| 4968 | /** @hide */ |
| 4969 | @IntDef(flag = true, prefix = { "FLAG_" }, value = { |
| 4970 | FLAG_FROM_BACKGROUND, |
| 4971 | FLAG_DEBUG_LOG_RESOLUTION, |
| 4972 | FLAG_EXCLUDE_STOPPED_PACKAGES, |
| 4973 | FLAG_INCLUDE_STOPPED_PACKAGES, |
| 4974 | FLAG_DEBUG_TRIAGED_MISSING, |
| 4975 | FLAG_IGNORE_EPHEMERAL, |
| 4976 | FLAG_ACTIVITY_NO_HISTORY, |
| 4977 | FLAG_ACTIVITY_SINGLE_TOP, |
| 4978 | FLAG_ACTIVITY_NEW_TASK, |
| 4979 | FLAG_ACTIVITY_MULTIPLE_TASK, |
| 4980 | FLAG_ACTIVITY_CLEAR_TOP, |
| 4981 | FLAG_ACTIVITY_FORWARD_RESULT, |
| 4982 | FLAG_ACTIVITY_PREVIOUS_IS_TOP, |
| 4983 | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, |
| 4984 | FLAG_ACTIVITY_BROUGHT_TO_FRONT, |
| 4985 | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, |
| 4986 | FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, |
| 4987 | FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, |
| 4988 | FLAG_ACTIVITY_NEW_DOCUMENT, |
| 4989 | FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, |
| 4990 | FLAG_ACTIVITY_NO_USER_ACTION, |
| 4991 | FLAG_ACTIVITY_REORDER_TO_FRONT, |
| 4992 | FLAG_ACTIVITY_NO_ANIMATION, |
| 4993 | FLAG_ACTIVITY_CLEAR_TASK, |
| 4994 | FLAG_ACTIVITY_TASK_ON_HOME, |
| 4995 | FLAG_ACTIVITY_RETAIN_IN_RECENTS, |
| 4996 | FLAG_ACTIVITY_LAUNCH_ADJACENT, |
| 4997 | FLAG_RECEIVER_REGISTERED_ONLY, |
| 4998 | FLAG_RECEIVER_REPLACE_PENDING, |
| 4999 | FLAG_RECEIVER_FOREGROUND, |
| 5000 | FLAG_RECEIVER_NO_ABORT, |
| 5001 | FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, |
| 5002 | FLAG_RECEIVER_BOOT_UPGRADE, |
| 5003 | FLAG_RECEIVER_INCLUDE_BACKGROUND, |
| 5004 | FLAG_RECEIVER_EXCLUDE_BACKGROUND, |
| 5005 | FLAG_RECEIVER_FROM_SHELL, |
| 5006 | FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, |
| 5007 | }) |
| 5008 | @Retention(RetentionPolicy.SOURCE) |
| 5009 | public @interface MutableFlags {} |
| 5010 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5011 | /** |
| 5012 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 5013 | * perform read operations on the URI in the Intent's data and any URIs |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5014 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 5015 | * all URIs as well as recursive traversals through data or other ClipData |
| 5016 | * in Intent items will be granted; only the grant flags of the top-level |
| 5017 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5018 | */ |
| 5019 | public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; |
| 5020 | /** |
| 5021 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 5022 | * perform write operations on the URI in the Intent's data and any URIs |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5023 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 5024 | * all URIs as well as recursive traversals through data or other ClipData |
| 5025 | * in Intent items will be granted; only the grant flags of the top-level |
| 5026 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5027 | */ |
| 5028 | public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; |
| 5029 | /** |
| 5030 | * Can be set by the caller to indicate that this Intent is coming from |
| 5031 | * a background operation, not from direct user interaction. |
| 5032 | */ |
| 5033 | public static final int FLAG_FROM_BACKGROUND = 0x00000004; |
| 5034 | /** |
| 5035 | * A flag you can enable for debugging: when set, log messages will be |
| 5036 | * printed during the resolution of this intent to show you what has |
| 5037 | * been found to create the final resolved list. |
| 5038 | */ |
| 5039 | public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 5040 | /** |
| 5041 | * If set, this intent will not match any components in packages that |
| 5042 | * are currently stopped. If this is not set, then the default behavior |
| 5043 | * is to include such applications in the result. |
| 5044 | */ |
| 5045 | public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; |
| 5046 | /** |
| 5047 | * If set, this intent will always match any components in packages that |
| 5048 | * are currently stopped. This is the default behavior when |
| 5049 | * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these |
| 5050 | * flags are set, this one wins (it allows overriding of exclude for |
| 5051 | * places where the framework may automatically set the exclude flag). |
| 5052 | */ |
| 5053 | public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5054 | |
| 5055 | /** |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 5056 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 5057 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 5058 | * persisted across device reboots until explicitly revoked with |
| 5059 | * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the |
| 5060 | * grant for possible persisting; the receiving application must call |
| 5061 | * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to |
| 5062 | * actually persist. |
| 5063 | * |
| 5064 | * @see ContentResolver#takePersistableUriPermission(Uri, int) |
| 5065 | * @see ContentResolver#releasePersistableUriPermission(Uri, int) |
| 5066 | * @see ContentResolver#getPersistedUriPermissions() |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 5067 | * @see ContentResolver#getOutgoingPersistedUriPermissions() |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 5068 | */ |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 5069 | public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 5070 | |
| 5071 | /** |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5072 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 5073 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant |
| 5074 | * applies to any URI that is a prefix match against the original granted |
| 5075 | * URI. (Without this flag, the URI must match exactly for access to be |
| 5076 | * granted.) Another URI is considered a prefix match only when scheme, |
| 5077 | * authority, and all path segments defined by the prefix are an exact |
| 5078 | * match. |
| 5079 | */ |
| 5080 | public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; |
| 5081 | |
| 5082 | /** |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 5083 | * Internal flag used to indicate that a system component has done their |
Jeff Sharkey | 2f3e353 | 2015-12-21 14:16:43 -0700 | [diff] [blame] | 5084 | * homework and verified that they correctly handle packages and components |
| 5085 | * that come and go over time. In particular: |
| 5086 | * <ul> |
| 5087 | * <li>Apps installed on external storage, which will appear to be |
| 5088 | * uninstalled while the the device is ejected. |
| 5089 | * <li>Apps with encryption unaware components, which will appear to not |
| 5090 | * exist while the device is locked. |
| 5091 | * </ul> |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 5092 | * |
| 5093 | * @hide |
| 5094 | */ |
Jeff Sharkey | 2f3e353 | 2015-12-21 14:16:43 -0700 | [diff] [blame] | 5095 | public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100; |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 5096 | |
| 5097 | /** |
Todd Kennedy | 8e2d9d1 | 2016-06-28 14:09:55 -0700 | [diff] [blame] | 5098 | * Internal flag used to indicate ephemeral applications should not be |
| 5099 | * considered when resolving the intent. |
| 5100 | * |
| 5101 | * @hide |
| 5102 | */ |
| 5103 | public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200; |
| 5104 | |
| 5105 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 5106 | * If set, the new activity is not kept in the history stack. As soon as |
| 5107 | * the user navigates away from it, the activity is finished. This may also |
| 5108 | * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory |
| 5109 | * noHistory} attribute. |
Ricardo Cervera | 92f6a74 | 2014-04-04 11:17:06 -0700 | [diff] [blame] | 5110 | * |
| 5111 | * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} |
| 5112 | * is never invoked when the current activity starts a new activity which |
| 5113 | * sets a result and finishes. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5114 | */ |
| 5115 | public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; |
| 5116 | /** |
| 5117 | * If set, the activity will not be launched if it is already running |
| 5118 | * at the top of the history stack. |
| 5119 | */ |
| 5120 | public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; |
| 5121 | /** |
| 5122 | * If set, this activity will become the start of a new task on this |
| 5123 | * history stack. A task (from the activity that started it to the |
| 5124 | * next task activity) defines an atomic group of activities that the |
| 5125 | * user can move to. Tasks can be moved to the foreground and background; |
| 5126 | * all of the activities inside of a particular task always remain in |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5127 | * the same order. See |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 5128 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 5129 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5130 | * |
| 5131 | * <p>This flag is generally used by activities that want |
| 5132 | * to present a "launcher" style behavior: they give the user a list of |
| 5133 | * separate things that can be done, which otherwise run completely |
| 5134 | * independently of the activity launching them. |
| 5135 | * |
| 5136 | * <p>When using this flag, if a task is already running for the activity |
| 5137 | * you are now starting, then a new activity will not be started; instead, |
| 5138 | * the current task will simply be brought to the front of the screen with |
| 5139 | * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag |
| 5140 | * to disable this behavior. |
| 5141 | * |
| 5142 | * <p>This flag can not be used when the caller is requesting a result from |
| 5143 | * the activity being launched. |
| 5144 | */ |
| 5145 | public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; |
| 5146 | /** |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5147 | * This flag is used to create a new task and launch an activity into it. |
| 5148 | * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} |
| 5149 | * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would |
| 5150 | * search through existing tasks for ones matching this Intent. Only if no such |
| 5151 | * task is found would a new task be created. When paired with |
| 5152 | * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip |
| 5153 | * the search for a matching task and unconditionally start a new task. |
| 5154 | * |
| 5155 | * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this |
| 5156 | * flag unless you are implementing your own |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5157 | * top-level application launcher.</strong> Used in conjunction with |
| 5158 | * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the |
| 5159 | * behavior of bringing an existing task to the foreground. When set, |
| 5160 | * a new task is <em>always</em> started to host the Activity for the |
| 5161 | * Intent, regardless of whether there is already an existing task running |
| 5162 | * the same thing. |
| 5163 | * |
| 5164 | * <p><strong>Because the default system does not include graphical task management, |
| 5165 | * you should not use this flag unless you provide some way for a user to |
| 5166 | * return back to the tasks you have launched.</strong> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5167 | * |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5168 | * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for |
| 5169 | * creating new document tasks. |
| 5170 | * |
| 5171 | * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or |
Paul Soulos | 628cb74 | 2014-09-19 11:00:52 -0700 | [diff] [blame] | 5172 | * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5173 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 5174 | * <p>See |
| 5175 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 5176 | * Stack</a> for more information about tasks. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5177 | * |
| 5178 | * @see #FLAG_ACTIVITY_NEW_DOCUMENT |
| 5179 | * @see #FLAG_ACTIVITY_NEW_TASK |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5180 | */ |
| 5181 | public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; |
| 5182 | /** |
| 5183 | * If set, and the activity being launched is already running in the |
| 5184 | * current task, then instead of launching a new instance of that activity, |
| 5185 | * all of the other activities on top of it will be closed and this Intent |
| 5186 | * will be delivered to the (now on top) old activity as a new Intent. |
| 5187 | * |
| 5188 | * <p>For example, consider a task consisting of the activities: A, B, C, D. |
| 5189 | * If D calls startActivity() with an Intent that resolves to the component |
| 5190 | * of activity B, then C and D will be finished and B receive the given |
| 5191 | * Intent, resulting in the stack now being: A, B. |
| 5192 | * |
Dianne Hackborn | aa52f9a | 2009-08-25 16:01:15 -0700 | [diff] [blame] | 5193 | * <p>The currently running instance of activity B in the above example will |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5194 | * either receive the new intent you are starting here in its |
| 5195 | * onNewIntent() method, or be itself finished and restarted with the |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5196 | * new intent. If it has declared its launch mode to be "multiple" (the |
Dianne Hackborn | aa52f9a | 2009-08-25 16:01:15 -0700 | [diff] [blame] | 5197 | * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in |
| 5198 | * the same intent, then it will be finished and re-created; for all other |
| 5199 | * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this |
| 5200 | * Intent will be delivered to the current instance's onNewIntent(). |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5201 | * |
| 5202 | * <p>This launch mode can also be used to good effect in conjunction with |
| 5203 | * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity |
| 5204 | * of a task, it will bring any currently running instance of that task |
| 5205 | * to the foreground, and then clear it to its root state. This is |
| 5206 | * especially useful, for example, when launching an activity from the |
| 5207 | * notification manager. |
| 5208 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 5209 | * <p>See |
| 5210 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 5211 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5212 | */ |
| 5213 | public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; |
| 5214 | /** |
| 5215 | * If set and this intent is being used to launch a new activity from an |
| 5216 | * existing one, then the reply target of the existing activity will be |
| 5217 | * transfered to the new activity. This way the new activity can call |
| 5218 | * {@link android.app.Activity#setResult} and have that result sent back to |
| 5219 | * the reply target of the original activity. |
| 5220 | */ |
| 5221 | public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; |
| 5222 | /** |
| 5223 | * If set and this intent is being used to launch a new activity from an |
| 5224 | * existing one, the current activity will not be counted as the top |
| 5225 | * activity for deciding whether the new intent should be delivered to |
| 5226 | * the top instead of starting a new one. The previous activity will |
| 5227 | * be used as the top, with the assumption being that the current activity |
| 5228 | * will finish itself immediately. |
| 5229 | */ |
| 5230 | public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; |
| 5231 | /** |
| 5232 | * If set, the new activity is not kept in the list of recently launched |
| 5233 | * activities. |
| 5234 | */ |
| 5235 | public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; |
| 5236 | /** |
| 5237 | * This flag is not normally set by application code, but set for you by |
| 5238 | * the system as described in the |
| 5239 | * {@link android.R.styleable#AndroidManifestActivity_launchMode |
| 5240 | * launchMode} documentation for the singleTask mode. |
| 5241 | */ |
| 5242 | public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; |
| 5243 | /** |
| 5244 | * If set, and this activity is either being started in a new task or |
| 5245 | * bringing to the top an existing task, then it will be launched as |
| 5246 | * the front door of the task. This will result in the application of |
| 5247 | * any affinities needed to have that task in the proper state (either |
| 5248 | * moving activities to or from it), or simply resetting that task to |
| 5249 | * its initial state if needed. |
| 5250 | */ |
| 5251 | public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; |
| 5252 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 5253 | * This flag is not normally set by application code, but set for you by |
| 5254 | * the system if this activity is being launched from history |
| 5255 | * (longpress home key). |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5256 | */ |
| 5257 | public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 5258 | /** |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 5259 | * @deprecated As of API 21 this performs identically to |
| 5260 | * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 5261 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 5262 | @Deprecated |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 5263 | public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 5264 | /** |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 5265 | * This flag is used to open a document into a new task rooted at the activity launched |
| 5266 | * by this Intent. Through the use of this flag, or its equivalent attribute, |
| 5267 | * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 5268 | * containing different documents will appear in the recent tasks list. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5269 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 5270 | * <p>The use of the activity attribute form of this, |
| 5271 | * {@link android.R.attr#documentLaunchMode}, is |
| 5272 | * preferred over the Intent flag described here. The attribute form allows the |
| 5273 | * Activity to specify multiple document behavior for all launchers of the Activity |
| 5274 | * whereas using this flag requires each Intent that launches the Activity to specify it. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5275 | * |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 5276 | * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for |
| 5277 | * it is kept after the activity is finished is different than the use of |
| 5278 | * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if |
| 5279 | * this flag is being used to create a new recents entry, then by default that entry |
| 5280 | * will be removed once the activity is finished. You can modify this behavior with |
| 5281 | * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. |
| 5282 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 5283 | * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link |
| 5284 | * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the |
| 5285 | * equivalent of the Activity manifest specifying {@link |
| 5286 | * android.R.attr#documentLaunchMode}="intoExisting". When used with |
| 5287 | * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying |
| 5288 | * {@link android.R.attr#documentLaunchMode}="always". |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5289 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 5290 | * Refer to {@link android.R.attr#documentLaunchMode} for more information. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5291 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 5292 | * @see android.R.attr#documentLaunchMode |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5293 | * @see #FLAG_ACTIVITY_MULTIPLE_TASK |
| 5294 | */ |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 5295 | public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 5296 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5297 | * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 5298 | * callback from occurring on the current frontmost activity before it is |
| 5299 | * paused as the newly-started activity is brought to the front. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5300 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 5301 | * <p>Typically, an activity can rely on that callback to indicate that an |
| 5302 | * explicit user action has caused their activity to be moved out of the |
| 5303 | * foreground. The callback marks an appropriate point in the activity's |
| 5304 | * lifecycle for it to dismiss any notifications that it intends to display |
| 5305 | * "until the user has seen them," such as a blinking LED. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5306 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 5307 | * <p>If an activity is ever started via any non-user-driven events such as |
| 5308 | * phone-call receipt or an alarm handler, this flag should be passed to {@link |
| 5309 | * Context#startActivity Context.startActivity}, ensuring that the pausing |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5310 | * activity does not think the user has acknowledged its notification. |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 5311 | */ |
| 5312 | public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5313 | /** |
| 5314 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 5315 | * this flag will cause the launched activity to be brought to the front of its |
| 5316 | * task's history stack if it is already running. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5317 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5318 | * <p>For example, consider a task consisting of four activities: A, B, C, D. |
| 5319 | * If D calls startActivity() with an Intent that resolves to the component |
| 5320 | * of activity B, then B will be brought to the front of the history stack, |
| 5321 | * with this resulting order: A, C, D, B. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5322 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5323 | * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5324 | * specified. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5325 | */ |
| 5326 | public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5327 | /** |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 5328 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 5329 | * this flag will prevent the system from applying an activity transition |
| 5330 | * animation to go to the next activity state. This doesn't mean an |
| 5331 | * animation will never run -- if another activity change happens that doesn't |
| 5332 | * specify this flag before the activity started here is displayed, then |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 5333 | * that transition will be used. This flag can be put to good use |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 5334 | * when you are going to do a series of activity operations but the |
| 5335 | * animation seen by the user shouldn't be driven by the first activity |
| 5336 | * change but rather a later one. |
| 5337 | */ |
| 5338 | public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; |
| 5339 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 5340 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 5341 | * this flag will cause any existing task that would be associated with the |
| 5342 | * activity to be cleared before the activity is started. That is, the activity |
| 5343 | * becomes the new root of an otherwise empty task, and any old activities |
| 5344 | * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 5345 | */ |
| 5346 | public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; |
| 5347 | /** |
| 5348 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 5349 | * this flag will cause a newly launching task to be placed on top of the current |
| 5350 | * home activity task (if there is one). That is, pressing back from the task |
| 5351 | * will always return the user to home even if that was not the last activity they |
| 5352 | * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 5353 | */ |
| 5354 | public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; |
| 5355 | /** |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 5356 | * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will |
| 5357 | * have its entry in recent tasks removed when the user closes it (with back |
Jeff Sharkey | 9f991a2 | 2014-08-13 11:37:41 -0700 | [diff] [blame] | 5358 | * or however else it may finish()). If you would like to instead allow the |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 5359 | * document to be kept in recents so that it can be re-launched, you can use |
Jeff Sharkey | 9f991a2 | 2014-08-13 11:37:41 -0700 | [diff] [blame] | 5360 | * this flag. When set and the task's activity is finished, the recents |
| 5361 | * entry will remain in the interface for the user to re-launch it, like a |
| 5362 | * recents entry for a top-level application. |
| 5363 | * <p> |
| 5364 | * The receiving activity can override this request with |
| 5365 | * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling |
| 5366 | * {@link android.app.Activity#finishAndRemoveTask() |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 5367 | * Activity.finishAndRemoveTask()}. |
Craig Mautner | 2dac056 | 2014-05-06 09:06:44 -0700 | [diff] [blame] | 5368 | */ |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 5369 | public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; |
Craig Mautner | a228ae9 | 2014-07-09 05:44:55 -0700 | [diff] [blame] | 5370 | |
| 5371 | /** |
Wale Ogunwale | 2a25a62 | 2016-01-30 11:27:21 -0800 | [diff] [blame] | 5372 | * This flag is only used in split-screen multi-window mode. The new activity will be displayed |
| 5373 | * adjacent to the one launching it. This can only be used in conjunction with |
Wale Ogunwale | 6bdf257 | 2016-03-11 15:22:38 -0800 | [diff] [blame] | 5374 | * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is |
| 5375 | * required if you want a new instance of an existing activity to be created. |
Filip Gruszczynski | 80e29f1 | 2015-12-14 14:58:30 -0800 | [diff] [blame] | 5376 | */ |
Wale Ogunwale | 2a25a62 | 2016-01-30 11:27:21 -0800 | [diff] [blame] | 5377 | public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; |
Filip Gruszczynski | 80e29f1 | 2015-12-14 14:58:30 -0800 | [diff] [blame] | 5378 | |
| 5379 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5380 | * If set, when sending a broadcast only registered receivers will be |
| 5381 | * called -- no BroadcastReceiver components will be launched. |
| 5382 | */ |
| 5383 | public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5384 | /** |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 5385 | * If set, when sending a broadcast the new broadcast will replace |
| 5386 | * any existing pending broadcast that matches it. Matching is defined |
| 5387 | * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning |
| 5388 | * true for the intents of the two broadcasts. When a match is found, |
| 5389 | * the new broadcast (and receivers associated with it) will replace the |
| 5390 | * existing one in the pending broadcast list, remaining at the same |
| 5391 | * position in the list. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5392 | * |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 5393 | * <p>This flag is most typically used with sticky broadcasts, which |
| 5394 | * only care about delivering the most recent values of the broadcast |
| 5395 | * to their receivers. |
| 5396 | */ |
| 5397 | public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; |
| 5398 | /** |
Christopher Tate | f46723b | 2012-01-26 14:19:24 -0800 | [diff] [blame] | 5399 | * If set, when sending a broadcast the recipient is allowed to run at |
| 5400 | * foreground priority, with a shorter timeout interval. During normal |
| 5401 | * broadcasts the receivers are not automatically hoisted out of the |
| 5402 | * background priority class. |
| 5403 | */ |
| 5404 | public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; |
| 5405 | /** |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 5406 | * If this is an ordered broadcast, don't allow receivers to abort the broadcast. |
| 5407 | * They can still propagate results through to later receivers, but they can not prevent |
| 5408 | * later receivers from seeing the broadcast. |
| 5409 | */ |
| 5410 | public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; |
| 5411 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5412 | * If set, when sending a broadcast <i>before boot has completed</i> only |
| 5413 | * registered receivers will be called -- no BroadcastReceiver components |
| 5414 | * will be launched. Sticky intent state will be recorded properly even |
| 5415 | * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} |
| 5416 | * is specified in the broadcast intent, this flag is unnecessary. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5417 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5418 | * <p>This flag is only for use by system sevices as a convenience to |
| 5419 | * avoid having to implement a more complex mechanism around detection |
| 5420 | * of boot completion. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5421 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5422 | * @hide |
| 5423 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 5424 | public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 5425 | /** |
| 5426 | * Set when this broadcast is for a boot upgrade, a special mode that |
| 5427 | * allows the broadcast to be sent before the system is ready and launches |
| 5428 | * the app process with no providers running in it. |
| 5429 | * @hide |
| 5430 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 5431 | public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; |
Dianne Hackborn | 6ac42ae | 2015-12-08 17:22:10 -0800 | [diff] [blame] | 5432 | /** |
| 5433 | * If set, the broadcast will always go to manifest receivers in background (cached |
| 5434 | * or not running) apps, regardless of whether that would be done by default. By |
| 5435 | * default they will only receive broadcasts if the broadcast has specified an |
| 5436 | * explicit component or package name. |
Christopher Tate | bdc3941 | 2017-01-23 12:21:13 -0800 | [diff] [blame] | 5437 | * |
| 5438 | * NOTE: dumpstate uses this flag numerically, so when its value is changed |
| 5439 | * the broadcast code there must also be changed to match. |
| 5440 | * |
Dianne Hackborn | 6ac42ae | 2015-12-08 17:22:10 -0800 | [diff] [blame] | 5441 | * @hide |
| 5442 | */ |
| 5443 | public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; |
| 5444 | /** |
| 5445 | * If set, the broadcast will never go to manifest receivers in background (cached |
| 5446 | * or not running) apps, regardless of whether that would be done by default. By |
| 5447 | * default they will receive broadcasts if the broadcast has specified an |
| 5448 | * explicit component or package name. |
| 5449 | * @hide |
| 5450 | */ |
| 5451 | public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 5452 | /** |
| 5453 | * If set, this broadcast is being sent from the shell. |
| 5454 | * @hide |
| 5455 | */ |
| 5456 | public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5457 | |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 5458 | /** |
Chad Brubaker | b7e34d5 | 2017-02-22 12:36:06 -0800 | [diff] [blame] | 5459 | * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps |
| 5460 | * will not receive broadcasts. |
| 5461 | * |
| 5462 | * <em>This flag has no effect when used by an Instant App.</em> |
| 5463 | */ |
| 5464 | public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000; |
| 5465 | |
| 5466 | /** |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 5467 | * @hide Flags that can't be changed with PendingIntent. |
| 5468 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5469 | public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION |
| 5470 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 5471 | | FLAG_GRANT_PREFIX_URI_PERMISSION; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5472 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5473 | // --------------------------------------------------------------------- |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5474 | // --------------------------------------------------------------------- |
| 5475 | // toUri() and parseUri() options. |
| 5476 | |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5477 | /** @hide */ |
| 5478 | @IntDef(flag = true, prefix = { "URI_" }, value = { |
| 5479 | URI_ALLOW_UNSAFE, |
| 5480 | URI_ANDROID_APP_SCHEME, |
| 5481 | URI_INTENT_SCHEME, |
| 5482 | }) |
| 5483 | @Retention(RetentionPolicy.SOURCE) |
| 5484 | public @interface UriFlags {} |
| 5485 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5486 | /** |
| 5487 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 5488 | * always has the "intent:" scheme. This syntax can be used when you want |
| 5489 | * to later disambiguate between URIs that are intended to describe an |
| 5490 | * Intent vs. all others that should be treated as raw URIs. When used |
| 5491 | * with {@link #parseUri}, any other scheme will result in a generic |
| 5492 | * VIEW action for that raw URI. |
| 5493 | */ |
| 5494 | public static final int URI_INTENT_SCHEME = 1<<0; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5495 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5496 | /** |
| 5497 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 5498 | * always has the "android-app:" scheme. This is a variation of |
| 5499 | * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an |
| 5500 | * http/https URI being delivered to a specific package name. The format |
| 5501 | * is: |
| 5502 | * |
| 5503 | * <pre class="prettyprint"> |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 5504 | * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5505 | * |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 5506 | * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, |
| 5507 | * you must also include a scheme; including a path also requires both a host and a scheme. |
| 5508 | * The final #Intent; fragment can be used without a scheme, host, or path. |
| 5509 | * Note that this can not be |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5510 | * used with intents that have a {@link #setSelector}, since the base intent |
| 5511 | * will always have an explicit package name.</p> |
| 5512 | * |
| 5513 | * <p>Some examples of how this scheme maps to Intent objects:</p> |
| 5514 | * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> |
| 5515 | * <colgroup align="left" /> |
| 5516 | * <colgroup align="left" /> |
| 5517 | * <thead> |
| 5518 | * <tr><th>URI</th> <th>Intent</th></tr> |
| 5519 | * </thead> |
| 5520 | * |
| 5521 | * <tbody> |
| 5522 | * <tr><td><code>android-app://com.example.app</code></td> |
| 5523 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5524 | * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> |
| 5525 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5526 | * </table></td> |
| 5527 | * </tr> |
| 5528 | * <tr><td><code>android-app://com.example.app/http/example.com</code></td> |
| 5529 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5530 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 5531 | * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> |
| 5532 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5533 | * </table></td> |
| 5534 | * </tr> |
| 5535 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> |
| 5536 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5537 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 5538 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 5539 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5540 | * </table></td> |
| 5541 | * </tr> |
| 5542 | * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 5543 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5544 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 5545 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5546 | * </table></td> |
| 5547 | * </tr> |
| 5548 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 5549 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5550 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 5551 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 5552 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5553 | * </table></td> |
| 5554 | * </tr> |
| 5555 | * <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> |
| 5556 | * <td><table border="" style="margin:0" > |
| 5557 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 5558 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5559 | * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> |
| 5560 | * </table></td> |
| 5561 | * </tr> |
| 5562 | * </tbody> |
| 5563 | * </table> |
| 5564 | */ |
| 5565 | public static final int URI_ANDROID_APP_SCHEME = 1<<1; |
| 5566 | |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5567 | /** |
| 5568 | * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing |
| 5569 | * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, |
| 5570 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, |
| 5571 | * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the |
| 5572 | * generated Intent can not cause unexpected data access to happen. |
| 5573 | * |
| 5574 | * <p>If you do not trust the source of the URI being parsed, you should still do further |
| 5575 | * processing to protect yourself from it. In particular, when using it to start an |
| 5576 | * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities |
| 5577 | * that can handle it.</p> |
| 5578 | */ |
| 5579 | public static final int URI_ALLOW_UNSAFE = 1<<2; |
| 5580 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5581 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5582 | |
| 5583 | private String mAction; |
| 5584 | private Uri mData; |
| 5585 | private String mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5586 | private String mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5587 | private ComponentName mComponent; |
| 5588 | private int mFlags; |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 5589 | private ArraySet<String> mCategories; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5590 | private Bundle mExtras; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5591 | private Rect mSourceBounds; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5592 | private Intent mSelector; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5593 | private ClipData mClipData; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 5594 | private int mContentUserHint = UserHandle.USER_CURRENT; |
Todd Kennedy | b3b43130 | 2017-03-20 16:05:48 -0700 | [diff] [blame] | 5595 | /** Token to track instant app launches. Local only; do not copy cross-process. */ |
| 5596 | private String mLaunchToken; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5597 | |
| 5598 | // --------------------------------------------------------------------- |
| 5599 | |
Makoto Onuki | 97f82f2 | 2017-05-31 16:20:21 -0700 | [diff] [blame] | 5600 | private static final int COPY_MODE_ALL = 0; |
| 5601 | private static final int COPY_MODE_FILTER = 1; |
| 5602 | private static final int COPY_MODE_HISTORY = 2; |
| 5603 | |
| 5604 | /** @hide */ |
| 5605 | @IntDef(value = {COPY_MODE_ALL, COPY_MODE_FILTER, COPY_MODE_HISTORY}) |
| 5606 | @Retention(RetentionPolicy.SOURCE) |
| 5607 | public @interface CopyMode {} |
| 5608 | |
| 5609 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5610 | /** |
| 5611 | * Create an empty intent. |
| 5612 | */ |
| 5613 | public Intent() { |
| 5614 | } |
| 5615 | |
| 5616 | /** |
| 5617 | * Copy constructor. |
| 5618 | */ |
| 5619 | public Intent(Intent o) { |
Makoto Onuki | 97f82f2 | 2017-05-31 16:20:21 -0700 | [diff] [blame] | 5620 | this(o, COPY_MODE_ALL); |
| 5621 | } |
| 5622 | |
| 5623 | private Intent(Intent o, @CopyMode int copyMode) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5624 | this.mAction = o.mAction; |
| 5625 | this.mData = o.mData; |
| 5626 | this.mType = o.mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5627 | this.mPackage = o.mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5628 | this.mComponent = o.mComponent; |
Makoto Onuki | 97f82f2 | 2017-05-31 16:20:21 -0700 | [diff] [blame] | 5629 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5630 | if (o.mCategories != null) { |
Makoto Onuki | 97f82f2 | 2017-05-31 16:20:21 -0700 | [diff] [blame] | 5631 | this.mCategories = new ArraySet<>(o.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5632 | } |
Makoto Onuki | 97f82f2 | 2017-05-31 16:20:21 -0700 | [diff] [blame] | 5633 | |
| 5634 | if (copyMode != COPY_MODE_FILTER) { |
| 5635 | this.mFlags = o.mFlags; |
| 5636 | this.mContentUserHint = o.mContentUserHint; |
| 5637 | this.mLaunchToken = o.mLaunchToken; |
| 5638 | if (o.mSourceBounds != null) { |
| 5639 | this.mSourceBounds = new Rect(o.mSourceBounds); |
| 5640 | } |
| 5641 | if (o.mSelector != null) { |
| 5642 | this.mSelector = new Intent(o.mSelector); |
| 5643 | } |
| 5644 | |
| 5645 | if (copyMode != COPY_MODE_HISTORY) { |
| 5646 | if (o.mExtras != null) { |
| 5647 | this.mExtras = new Bundle(o.mExtras); |
| 5648 | } |
| 5649 | if (o.mClipData != null) { |
| 5650 | this.mClipData = new ClipData(o.mClipData); |
| 5651 | } |
| 5652 | } else { |
| 5653 | if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) { |
| 5654 | this.mExtras = Bundle.STRIPPED; |
| 5655 | } |
| 5656 | |
| 5657 | // Also set "stripped" clip data when we ever log mClipData in the (broadcast) |
| 5658 | // history. |
| 5659 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5660 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5661 | } |
| 5662 | |
| 5663 | @Override |
| 5664 | public Object clone() { |
| 5665 | return new Intent(this); |
| 5666 | } |
| 5667 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5668 | /** |
| 5669 | * Make a clone of only the parts of the Intent that are relevant for |
| 5670 | * filter matching: the action, data, type, component, and categories. |
| 5671 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5672 | public @NonNull Intent cloneFilter() { |
Makoto Onuki | 97f82f2 | 2017-05-31 16:20:21 -0700 | [diff] [blame] | 5673 | return new Intent(this, COPY_MODE_FILTER); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5674 | } |
| 5675 | |
| 5676 | /** |
| 5677 | * Create an intent with a given action. All other fields (data, type, |
| 5678 | * class) are null. Note that the action <em>must</em> be in a |
| 5679 | * namespace because Intents are used globally in the system -- for |
| 5680 | * example the system VIEW action is android.intent.action.VIEW; an |
| 5681 | * application's custom action would be something like |
| 5682 | * com.google.app.myapp.CUSTOM_ACTION. |
| 5683 | * |
| 5684 | * @param action The Intent action, such as ACTION_VIEW. |
| 5685 | */ |
| 5686 | public Intent(String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5687 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5688 | } |
| 5689 | |
| 5690 | /** |
| 5691 | * Create an intent with a given action and for a given data url. Note |
| 5692 | * that the action <em>must</em> be in a namespace because Intents are |
| 5693 | * used globally in the system -- for example the system VIEW action is |
| 5694 | * android.intent.action.VIEW; an application's custom action would be |
| 5695 | * something like com.google.app.myapp.CUSTOM_ACTION. |
| 5696 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 5697 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 5698 | * case-sensitive, unlike the formal RFC. As a result, |
| 5699 | * you should always ensure that you write your Uri with these elements |
| 5700 | * using lower case letters, and normalize any Uris you receive from |
| 5701 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 5702 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5703 | * @param action The Intent action, such as ACTION_VIEW. |
| 5704 | * @param uri The Intent data URI. |
| 5705 | */ |
| 5706 | public Intent(String action, Uri uri) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5707 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5708 | mData = uri; |
| 5709 | } |
| 5710 | |
| 5711 | /** |
| 5712 | * Create an intent for a specific component. All other fields (action, data, |
| 5713 | * type, class) are null, though they can be modified later with explicit |
| 5714 | * calls. This provides a convenient way to create an intent that is |
| 5715 | * intended to execute a hard-coded class name, rather than relying on the |
| 5716 | * system to find an appropriate class for you; see {@link #setComponent} |
| 5717 | * for more information on the repercussions of this. |
| 5718 | * |
| 5719 | * @param packageContext A Context of the application package implementing |
| 5720 | * this class. |
| 5721 | * @param cls The component class that is to be used for the intent. |
| 5722 | * |
| 5723 | * @see #setClass |
| 5724 | * @see #setComponent |
| 5725 | * @see #Intent(String, android.net.Uri , Context, Class) |
| 5726 | */ |
| 5727 | public Intent(Context packageContext, Class<?> cls) { |
| 5728 | mComponent = new ComponentName(packageContext, cls); |
| 5729 | } |
| 5730 | |
| 5731 | /** |
| 5732 | * Create an intent for a specific component with a specified action and data. |
Craig Mautner | 2dac056 | 2014-05-06 09:06:44 -0700 | [diff] [blame] | 5733 | * This is equivalent to using {@link #Intent(String, android.net.Uri)} to |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5734 | * construct the Intent and then calling {@link #setClass} to set its |
| 5735 | * class. |
| 5736 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 5737 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 5738 | * case-sensitive, unlike the formal RFC. As a result, |
| 5739 | * you should always ensure that you write your Uri with these elements |
| 5740 | * using lower case letters, and normalize any Uris you receive from |
| 5741 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 5742 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5743 | * @param action The Intent action, such as ACTION_VIEW. |
| 5744 | * @param uri The Intent data URI. |
| 5745 | * @param packageContext A Context of the application package implementing |
| 5746 | * this class. |
| 5747 | * @param cls The component class that is to be used for the intent. |
| 5748 | * |
| 5749 | * @see #Intent(String, android.net.Uri) |
| 5750 | * @see #Intent(Context, Class) |
| 5751 | * @see #setClass |
| 5752 | * @see #setComponent |
| 5753 | */ |
| 5754 | public Intent(String action, Uri uri, |
| 5755 | Context packageContext, Class<?> cls) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5756 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5757 | mData = uri; |
| 5758 | mComponent = new ComponentName(packageContext, cls); |
| 5759 | } |
| 5760 | |
| 5761 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 5762 | * Create an intent to launch the main (root) activity of a task. This |
| 5763 | * is the Intent that is started when the application's is launched from |
| 5764 | * Home. For anything else that wants to launch an application in the |
| 5765 | * same way, it is important that they use an Intent structured the same |
| 5766 | * way, and can use this function to ensure this is the case. |
| 5767 | * |
| 5768 | * <p>The returned Intent has the given Activity component as its explicit |
| 5769 | * component, {@link #ACTION_MAIN} as its action, and includes the |
| 5770 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 5771 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 5772 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 5773 | * |
| 5774 | * @param mainActivity The main activity component that this Intent will |
| 5775 | * launch. |
| 5776 | * @return Returns a newly created Intent that can be used to launch the |
| 5777 | * activity as a main application entry. |
| 5778 | * |
| 5779 | * @see #setClass |
| 5780 | * @see #setComponent |
| 5781 | */ |
| 5782 | public static Intent makeMainActivity(ComponentName mainActivity) { |
| 5783 | Intent intent = new Intent(ACTION_MAIN); |
| 5784 | intent.setComponent(mainActivity); |
| 5785 | intent.addCategory(CATEGORY_LAUNCHER); |
| 5786 | return intent; |
| 5787 | } |
| 5788 | |
| 5789 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5790 | * Make an Intent for the main activity of an application, without |
| 5791 | * specifying a specific activity to run but giving a selector to find |
| 5792 | * the activity. This results in a final Intent that is structured |
| 5793 | * the same as when the application is launched from |
| 5794 | * Home. For anything else that wants to launch an application in the |
| 5795 | * same way, it is important that they use an Intent structured the same |
| 5796 | * way, and can use this function to ensure this is the case. |
| 5797 | * |
| 5798 | * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the |
| 5799 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 5800 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 5801 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 5802 | * |
| 5803 | * @param selectorAction The action name of the Intent's selector. |
| 5804 | * @param selectorCategory The name of a category to add to the Intent's |
| 5805 | * selector. |
| 5806 | * @return Returns a newly created Intent that can be used to launch the |
| 5807 | * activity as a main application entry. |
| 5808 | * |
| 5809 | * @see #setSelector(Intent) |
| 5810 | */ |
| 5811 | public static Intent makeMainSelectorActivity(String selectorAction, |
| 5812 | String selectorCategory) { |
| 5813 | Intent intent = new Intent(ACTION_MAIN); |
| 5814 | intent.addCategory(CATEGORY_LAUNCHER); |
| 5815 | Intent selector = new Intent(); |
| 5816 | selector.setAction(selectorAction); |
| 5817 | selector.addCategory(selectorCategory); |
| 5818 | intent.setSelector(selector); |
| 5819 | return intent; |
| 5820 | } |
| 5821 | |
| 5822 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 5823 | * Make an Intent that can be used to re-launch an application's task |
| 5824 | * in its base state. This is like {@link #makeMainActivity(ComponentName)}, |
| 5825 | * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and |
| 5826 | * {@link #FLAG_ACTIVITY_CLEAR_TASK}. |
| 5827 | * |
| 5828 | * @param mainActivity The activity component that is the root of the |
| 5829 | * task; this is the activity that has been published in the application's |
| 5830 | * manifest as the main launcher icon. |
| 5831 | * |
| 5832 | * @return Returns a newly created Intent that can be used to relaunch the |
| 5833 | * activity's task in its root state. |
| 5834 | */ |
| 5835 | public static Intent makeRestartActivityTask(ComponentName mainActivity) { |
| 5836 | Intent intent = makeMainActivity(mainActivity); |
| 5837 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 5838 | | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 5839 | return intent; |
| 5840 | } |
| 5841 | |
| 5842 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5843 | * Call {@link #parseUri} with 0 flags. |
| 5844 | * @deprecated Use {@link #parseUri} instead. |
| 5845 | */ |
| 5846 | @Deprecated |
| 5847 | public static Intent getIntent(String uri) throws URISyntaxException { |
| 5848 | return parseUri(uri, 0); |
| 5849 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5850 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5851 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5852 | * Create an intent from a URI. This URI may encode the action, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5853 | * category, and other intent fields, if it was returned by |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 5854 | * {@link #toUri}. If the Intent was not generate by toUri(), its data |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5855 | * will be the entire URI and its action will be ACTION_VIEW. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5856 | * |
| 5857 | * <p>The URI given here must not be relative -- that is, it must include |
| 5858 | * the scheme and full path. |
| 5859 | * |
| 5860 | * @param uri The URI to turn into an Intent. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5861 | * @param flags Additional processing flags. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5862 | * |
| 5863 | * @return Intent The newly created Intent object. |
| 5864 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5865 | * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax |
| 5866 | * it bad (as parsed by the Uri class) or the Intent data within the |
| 5867 | * URI is invalid. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5868 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5869 | * @see #toUri |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5870 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5871 | public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5872 | int i = 0; |
| 5873 | try { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5874 | final boolean androidApp = uri.startsWith("android-app:"); |
| 5875 | |
| 5876 | // Validate intent scheme if requested. |
| 5877 | if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { |
| 5878 | if (!uri.startsWith("intent:") && !androidApp) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5879 | Intent intent = new Intent(ACTION_VIEW); |
| 5880 | try { |
| 5881 | intent.setData(Uri.parse(uri)); |
| 5882 | } catch (IllegalArgumentException e) { |
| 5883 | throw new URISyntaxException(uri, e.getMessage()); |
| 5884 | } |
| 5885 | return intent; |
| 5886 | } |
| 5887 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5888 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5889 | i = uri.lastIndexOf("#"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5890 | // simple case |
| 5891 | if (i == -1) { |
| 5892 | if (!androidApp) { |
| 5893 | return new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 5894 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5895 | |
| 5896 | // old format Intent URI |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5897 | } else if (!uri.startsWith("#Intent;", i)) { |
| 5898 | if (!androidApp) { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5899 | return getIntentOld(uri, flags); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5900 | } else { |
| 5901 | i = -1; |
| 5902 | } |
| 5903 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5904 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5905 | // new format |
| 5906 | Intent intent = new Intent(ACTION_VIEW); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5907 | Intent baseIntent = intent; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5908 | boolean explicitAction = false; |
| 5909 | boolean inSelector = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5910 | |
| 5911 | // fetch data part, if present |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5912 | String scheme = null; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5913 | String data; |
| 5914 | if (i >= 0) { |
| 5915 | data = uri.substring(0, i); |
| 5916 | i += 8; // length of "#Intent;" |
| 5917 | } else { |
| 5918 | data = uri; |
| 5919 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5920 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5921 | // loop over contents of Intent, all name=value; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5922 | while (i >= 0 && !uri.startsWith("end", i)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5923 | int eq = uri.indexOf('=', i); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5924 | if (eq < 0) eq = i-1; |
| 5925 | int semi = uri.indexOf(';', i); |
| 5926 | String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : ""; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5927 | |
| 5928 | // action |
| 5929 | if (uri.startsWith("action=", i)) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5930 | intent.setAction(value); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5931 | if (!inSelector) { |
| 5932 | explicitAction = true; |
| 5933 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5934 | } |
| 5935 | |
| 5936 | // categories |
| 5937 | else if (uri.startsWith("category=", i)) { |
| 5938 | intent.addCategory(value); |
| 5939 | } |
| 5940 | |
| 5941 | // type |
| 5942 | else if (uri.startsWith("type=", i)) { |
| 5943 | intent.mType = value; |
| 5944 | } |
| 5945 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5946 | // launch flags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5947 | else if (uri.startsWith("launchFlags=", i)) { |
| 5948 | intent.mFlags = Integer.decode(value).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5949 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 5950 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 5951 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5952 | } |
| 5953 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5954 | // package |
| 5955 | else if (uri.startsWith("package=", i)) { |
| 5956 | intent.mPackage = value; |
| 5957 | } |
| 5958 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5959 | // component |
| 5960 | else if (uri.startsWith("component=", i)) { |
| 5961 | intent.mComponent = ComponentName.unflattenFromString(value); |
| 5962 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5963 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5964 | // scheme |
| 5965 | else if (uri.startsWith("scheme=", i)) { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5966 | if (inSelector) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 5967 | intent.mData = Uri.parse(value + ":"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5968 | } else { |
| 5969 | scheme = value; |
| 5970 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5971 | } |
| 5972 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5973 | // source bounds |
| 5974 | else if (uri.startsWith("sourceBounds=", i)) { |
| 5975 | intent.mSourceBounds = Rect.unflattenFromString(value); |
| 5976 | } |
| 5977 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5978 | // selector |
| 5979 | else if (semi == (i+3) && uri.startsWith("SEL", i)) { |
| 5980 | intent = new Intent(); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5981 | inSelector = true; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5982 | } |
| 5983 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5984 | // extra |
| 5985 | else { |
| 5986 | String key = Uri.decode(uri.substring(i + 2, eq)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5987 | // create Bundle if it doesn't already exist |
| 5988 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
| 5989 | Bundle b = intent.mExtras; |
| 5990 | // add EXTRA |
| 5991 | if (uri.startsWith("S.", i)) b.putString(key, value); |
| 5992 | else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); |
| 5993 | else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); |
| 5994 | else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); |
| 5995 | else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); |
| 5996 | else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); |
| 5997 | else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); |
| 5998 | else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); |
| 5999 | else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); |
| 6000 | else throw new URISyntaxException(uri, "unknown EXTRA type", i); |
| 6001 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6002 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6003 | // move to the next item |
| 6004 | i = semi + 1; |
| 6005 | } |
| 6006 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 6007 | if (inSelector) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6008 | // The Intent had a selector; fix it up. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 6009 | if (baseIntent.mPackage == null) { |
| 6010 | baseIntent.setSelector(intent); |
| 6011 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6012 | intent = baseIntent; |
| 6013 | } |
| 6014 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 6015 | if (data != null) { |
| 6016 | if (data.startsWith("intent:")) { |
| 6017 | data = data.substring(7); |
| 6018 | if (scheme != null) { |
| 6019 | data = scheme + ':' + data; |
| 6020 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 6021 | } else if (data.startsWith("android-app:")) { |
| 6022 | if (data.charAt(12) == '/' && data.charAt(13) == '/') { |
| 6023 | // Correctly formed android-app, first part is package name. |
| 6024 | int end = data.indexOf('/', 14); |
| 6025 | if (end < 0) { |
| 6026 | // All we have is a package name. |
| 6027 | intent.mPackage = data.substring(14); |
| 6028 | if (!explicitAction) { |
| 6029 | intent.setAction(ACTION_MAIN); |
| 6030 | } |
| 6031 | data = ""; |
| 6032 | } else { |
| 6033 | // Target the Intent at the given package name always. |
| 6034 | String authority = null; |
| 6035 | intent.mPackage = data.substring(14, end); |
| 6036 | int newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 6037 | if ((end+1) < data.length()) { |
| 6038 | if ((newEnd=data.indexOf('/', end+1)) >= 0) { |
| 6039 | // Found a scheme, remember it. |
| 6040 | scheme = data.substring(end+1, newEnd); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 6041 | end = newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 6042 | if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { |
| 6043 | // Found a authority, remember it. |
| 6044 | authority = data.substring(end+1, newEnd); |
| 6045 | end = newEnd; |
| 6046 | } |
| 6047 | } else { |
| 6048 | // All we have is a scheme. |
| 6049 | scheme = data.substring(end+1); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 6050 | } |
| 6051 | } |
| 6052 | if (scheme == null) { |
| 6053 | // If there was no scheme, then this just targets the package. |
| 6054 | if (!explicitAction) { |
| 6055 | intent.setAction(ACTION_MAIN); |
| 6056 | } |
| 6057 | data = ""; |
| 6058 | } else if (authority == null) { |
| 6059 | data = scheme + ":"; |
| 6060 | } else { |
| 6061 | data = scheme + "://" + authority + data.substring(end); |
| 6062 | } |
| 6063 | } |
| 6064 | } else { |
| 6065 | data = ""; |
| 6066 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 6067 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 6068 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 6069 | if (data.length() > 0) { |
| 6070 | try { |
| 6071 | intent.mData = Uri.parse(data); |
| 6072 | } catch (IllegalArgumentException e) { |
| 6073 | throw new URISyntaxException(uri, e.getMessage()); |
| 6074 | } |
| 6075 | } |
| 6076 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 6077 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6078 | return intent; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6079 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6080 | } catch (IndexOutOfBoundsException e) { |
| 6081 | throw new URISyntaxException(uri, "illegal Intent URI format", i); |
| 6082 | } |
| 6083 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6084 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6085 | public static Intent getIntentOld(String uri) throws URISyntaxException { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 6086 | return getIntentOld(uri, 0); |
| 6087 | } |
| 6088 | |
| 6089 | private static Intent getIntentOld(String uri, int flags) throws URISyntaxException { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6090 | Intent intent; |
| 6091 | |
| 6092 | int i = uri.lastIndexOf('#'); |
| 6093 | if (i >= 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6094 | String action = null; |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6095 | final int intentFragmentStart = i; |
| 6096 | boolean isIntentFragment = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6097 | |
| 6098 | i++; |
| 6099 | |
| 6100 | if (uri.regionMatches(i, "action(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6101 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6102 | i += 7; |
| 6103 | int j = uri.indexOf(')', i); |
| 6104 | action = uri.substring(i, j); |
| 6105 | i = j + 1; |
| 6106 | } |
| 6107 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6108 | intent = new Intent(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6109 | |
| 6110 | if (uri.regionMatches(i, "categories(", 0, 11)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6111 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6112 | i += 11; |
| 6113 | int j = uri.indexOf(')', i); |
| 6114 | while (i < j) { |
| 6115 | int sep = uri.indexOf('!', i); |
Alan Viverette | 0adf32b | 2014-09-18 12:53:16 -0700 | [diff] [blame] | 6116 | if (sep < 0 || sep > j) sep = j; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6117 | if (i < sep) { |
| 6118 | intent.addCategory(uri.substring(i, sep)); |
| 6119 | } |
| 6120 | i = sep + 1; |
| 6121 | } |
| 6122 | i = j + 1; |
| 6123 | } |
| 6124 | |
| 6125 | if (uri.regionMatches(i, "type(", 0, 5)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6126 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6127 | i += 5; |
| 6128 | int j = uri.indexOf(')', i); |
| 6129 | intent.mType = uri.substring(i, j); |
| 6130 | i = j + 1; |
| 6131 | } |
| 6132 | |
| 6133 | if (uri.regionMatches(i, "launchFlags(", 0, 12)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6134 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6135 | i += 12; |
| 6136 | int j = uri.indexOf(')', i); |
| 6137 | intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 6138 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 6139 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 6140 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6141 | i = j + 1; |
| 6142 | } |
| 6143 | |
| 6144 | if (uri.regionMatches(i, "component(", 0, 10)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6145 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6146 | i += 10; |
| 6147 | int j = uri.indexOf(')', i); |
| 6148 | int sep = uri.indexOf('!', i); |
| 6149 | if (sep >= 0 && sep < j) { |
| 6150 | String pkg = uri.substring(i, sep); |
| 6151 | String cls = uri.substring(sep + 1, j); |
| 6152 | intent.mComponent = new ComponentName(pkg, cls); |
| 6153 | } |
| 6154 | i = j + 1; |
| 6155 | } |
| 6156 | |
| 6157 | if (uri.regionMatches(i, "extras(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6158 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6159 | i += 7; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6160 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6161 | final int closeParen = uri.indexOf(')', i); |
| 6162 | if (closeParen == -1) throw new URISyntaxException(uri, |
| 6163 | "EXTRA missing trailing ')'", i); |
| 6164 | |
| 6165 | while (i < closeParen) { |
| 6166 | // fetch the key value |
| 6167 | int j = uri.indexOf('=', i); |
| 6168 | if (j <= i + 1 || i >= closeParen) { |
| 6169 | throw new URISyntaxException(uri, "EXTRA missing '='", i); |
| 6170 | } |
| 6171 | char type = uri.charAt(i); |
| 6172 | i++; |
| 6173 | String key = uri.substring(i, j); |
| 6174 | i = j + 1; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6175 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6176 | // get type-value |
| 6177 | j = uri.indexOf('!', i); |
| 6178 | if (j == -1 || j >= closeParen) j = closeParen; |
| 6179 | if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 6180 | String value = uri.substring(i, j); |
| 6181 | i = j; |
| 6182 | |
| 6183 | // create Bundle if it doesn't already exist |
| 6184 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6185 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6186 | // add item to bundle |
| 6187 | try { |
| 6188 | switch (type) { |
| 6189 | case 'S': |
| 6190 | intent.mExtras.putString(key, Uri.decode(value)); |
| 6191 | break; |
| 6192 | case 'B': |
| 6193 | intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); |
| 6194 | break; |
| 6195 | case 'b': |
| 6196 | intent.mExtras.putByte(key, Byte.parseByte(value)); |
| 6197 | break; |
| 6198 | case 'c': |
| 6199 | intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); |
| 6200 | break; |
| 6201 | case 'd': |
| 6202 | intent.mExtras.putDouble(key, Double.parseDouble(value)); |
| 6203 | break; |
| 6204 | case 'f': |
| 6205 | intent.mExtras.putFloat(key, Float.parseFloat(value)); |
| 6206 | break; |
| 6207 | case 'i': |
| 6208 | intent.mExtras.putInt(key, Integer.parseInt(value)); |
| 6209 | break; |
| 6210 | case 'l': |
| 6211 | intent.mExtras.putLong(key, Long.parseLong(value)); |
| 6212 | break; |
| 6213 | case 's': |
| 6214 | intent.mExtras.putShort(key, Short.parseShort(value)); |
| 6215 | break; |
| 6216 | default: |
| 6217 | throw new URISyntaxException(uri, "EXTRA has unknown type", i); |
| 6218 | } |
| 6219 | } catch (NumberFormatException e) { |
| 6220 | throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); |
| 6221 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6222 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6223 | char ch = uri.charAt(i); |
| 6224 | if (ch == ')') break; |
| 6225 | if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 6226 | i++; |
| 6227 | } |
| 6228 | } |
| 6229 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 6230 | if (isIntentFragment) { |
| 6231 | intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); |
| 6232 | } else { |
| 6233 | intent.mData = Uri.parse(uri); |
| 6234 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 6235 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6236 | if (intent.mAction == null) { |
| 6237 | // By default, if no action is specified, then use VIEW. |
| 6238 | intent.mAction = ACTION_VIEW; |
| 6239 | } |
| 6240 | |
| 6241 | } else { |
| 6242 | intent = new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 6243 | } |
| 6244 | |
| 6245 | return intent; |
| 6246 | } |
| 6247 | |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6248 | /** @hide */ |
| 6249 | public interface CommandOptionHandler { |
| 6250 | boolean handleOption(String opt, ShellCommand cmd); |
| 6251 | } |
| 6252 | |
| 6253 | /** @hide */ |
| 6254 | public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) |
| 6255 | throws URISyntaxException { |
| 6256 | Intent intent = new Intent(); |
| 6257 | Intent baseIntent = intent; |
| 6258 | boolean hasIntentInfo = false; |
| 6259 | |
| 6260 | Uri data = null; |
| 6261 | String type = null; |
| 6262 | |
| 6263 | String opt; |
| 6264 | while ((opt=cmd.getNextOption()) != null) { |
| 6265 | switch (opt) { |
| 6266 | case "-a": |
| 6267 | intent.setAction(cmd.getNextArgRequired()); |
| 6268 | if (intent == baseIntent) { |
| 6269 | hasIntentInfo = true; |
| 6270 | } |
| 6271 | break; |
| 6272 | case "-d": |
| 6273 | data = Uri.parse(cmd.getNextArgRequired()); |
| 6274 | if (intent == baseIntent) { |
| 6275 | hasIntentInfo = true; |
| 6276 | } |
| 6277 | break; |
| 6278 | case "-t": |
| 6279 | type = cmd.getNextArgRequired(); |
| 6280 | if (intent == baseIntent) { |
| 6281 | hasIntentInfo = true; |
| 6282 | } |
| 6283 | break; |
| 6284 | case "-c": |
| 6285 | intent.addCategory(cmd.getNextArgRequired()); |
| 6286 | if (intent == baseIntent) { |
| 6287 | hasIntentInfo = true; |
| 6288 | } |
| 6289 | break; |
| 6290 | case "-e": |
| 6291 | case "--es": { |
| 6292 | String key = cmd.getNextArgRequired(); |
| 6293 | String value = cmd.getNextArgRequired(); |
| 6294 | intent.putExtra(key, value); |
| 6295 | } |
| 6296 | break; |
| 6297 | case "--esn": { |
| 6298 | String key = cmd.getNextArgRequired(); |
| 6299 | intent.putExtra(key, (String) null); |
| 6300 | } |
| 6301 | break; |
| 6302 | case "--ei": { |
| 6303 | String key = cmd.getNextArgRequired(); |
| 6304 | String value = cmd.getNextArgRequired(); |
| 6305 | intent.putExtra(key, Integer.decode(value)); |
| 6306 | } |
| 6307 | break; |
| 6308 | case "--eu": { |
| 6309 | String key = cmd.getNextArgRequired(); |
| 6310 | String value = cmd.getNextArgRequired(); |
| 6311 | intent.putExtra(key, Uri.parse(value)); |
| 6312 | } |
| 6313 | break; |
| 6314 | case "--ecn": { |
| 6315 | String key = cmd.getNextArgRequired(); |
| 6316 | String value = cmd.getNextArgRequired(); |
| 6317 | ComponentName cn = ComponentName.unflattenFromString(value); |
| 6318 | if (cn == null) |
| 6319 | throw new IllegalArgumentException("Bad component name: " + value); |
| 6320 | intent.putExtra(key, cn); |
| 6321 | } |
| 6322 | break; |
| 6323 | case "--eia": { |
| 6324 | String key = cmd.getNextArgRequired(); |
| 6325 | String value = cmd.getNextArgRequired(); |
| 6326 | String[] strings = value.split(","); |
| 6327 | int[] list = new int[strings.length]; |
| 6328 | for (int i = 0; i < strings.length; i++) { |
| 6329 | list[i] = Integer.decode(strings[i]); |
| 6330 | } |
| 6331 | intent.putExtra(key, list); |
| 6332 | } |
| 6333 | break; |
| 6334 | case "--eial": { |
| 6335 | String key = cmd.getNextArgRequired(); |
| 6336 | String value = cmd.getNextArgRequired(); |
| 6337 | String[] strings = value.split(","); |
| 6338 | ArrayList<Integer> list = new ArrayList<>(strings.length); |
| 6339 | for (int i = 0; i < strings.length; i++) { |
| 6340 | list.add(Integer.decode(strings[i])); |
| 6341 | } |
| 6342 | intent.putExtra(key, list); |
| 6343 | } |
| 6344 | break; |
| 6345 | case "--el": { |
| 6346 | String key = cmd.getNextArgRequired(); |
| 6347 | String value = cmd.getNextArgRequired(); |
| 6348 | intent.putExtra(key, Long.valueOf(value)); |
| 6349 | } |
| 6350 | break; |
| 6351 | case "--ela": { |
| 6352 | String key = cmd.getNextArgRequired(); |
| 6353 | String value = cmd.getNextArgRequired(); |
| 6354 | String[] strings = value.split(","); |
| 6355 | long[] list = new long[strings.length]; |
| 6356 | for (int i = 0; i < strings.length; i++) { |
| 6357 | list[i] = Long.valueOf(strings[i]); |
| 6358 | } |
| 6359 | intent.putExtra(key, list); |
| 6360 | hasIntentInfo = true; |
| 6361 | } |
| 6362 | break; |
| 6363 | case "--elal": { |
| 6364 | String key = cmd.getNextArgRequired(); |
| 6365 | String value = cmd.getNextArgRequired(); |
| 6366 | String[] strings = value.split(","); |
| 6367 | ArrayList<Long> list = new ArrayList<>(strings.length); |
| 6368 | for (int i = 0; i < strings.length; i++) { |
| 6369 | list.add(Long.valueOf(strings[i])); |
| 6370 | } |
| 6371 | intent.putExtra(key, list); |
| 6372 | hasIntentInfo = true; |
| 6373 | } |
| 6374 | break; |
| 6375 | case "--ef": { |
| 6376 | String key = cmd.getNextArgRequired(); |
| 6377 | String value = cmd.getNextArgRequired(); |
| 6378 | intent.putExtra(key, Float.valueOf(value)); |
| 6379 | hasIntentInfo = true; |
| 6380 | } |
| 6381 | break; |
| 6382 | case "--efa": { |
| 6383 | String key = cmd.getNextArgRequired(); |
| 6384 | String value = cmd.getNextArgRequired(); |
| 6385 | String[] strings = value.split(","); |
| 6386 | float[] list = new float[strings.length]; |
| 6387 | for (int i = 0; i < strings.length; i++) { |
| 6388 | list[i] = Float.valueOf(strings[i]); |
| 6389 | } |
| 6390 | intent.putExtra(key, list); |
| 6391 | hasIntentInfo = true; |
| 6392 | } |
| 6393 | break; |
| 6394 | case "--efal": { |
| 6395 | String key = cmd.getNextArgRequired(); |
| 6396 | String value = cmd.getNextArgRequired(); |
| 6397 | String[] strings = value.split(","); |
| 6398 | ArrayList<Float> list = new ArrayList<>(strings.length); |
| 6399 | for (int i = 0; i < strings.length; i++) { |
| 6400 | list.add(Float.valueOf(strings[i])); |
| 6401 | } |
| 6402 | intent.putExtra(key, list); |
| 6403 | hasIntentInfo = true; |
| 6404 | } |
| 6405 | break; |
| 6406 | case "--esa": { |
| 6407 | String key = cmd.getNextArgRequired(); |
| 6408 | String value = cmd.getNextArgRequired(); |
| 6409 | // Split on commas unless they are preceeded by an escape. |
| 6410 | // The escape character must be escaped for the string and |
| 6411 | // again for the regex, thus four escape characters become one. |
| 6412 | String[] strings = value.split("(?<!\\\\),"); |
| 6413 | intent.putExtra(key, strings); |
| 6414 | hasIntentInfo = true; |
| 6415 | } |
| 6416 | break; |
| 6417 | case "--esal": { |
| 6418 | String key = cmd.getNextArgRequired(); |
| 6419 | String value = cmd.getNextArgRequired(); |
| 6420 | // Split on commas unless they are preceeded by an escape. |
| 6421 | // The escape character must be escaped for the string and |
| 6422 | // again for the regex, thus four escape characters become one. |
| 6423 | String[] strings = value.split("(?<!\\\\),"); |
| 6424 | ArrayList<String> list = new ArrayList<>(strings.length); |
| 6425 | for (int i = 0; i < strings.length; i++) { |
| 6426 | list.add(strings[i]); |
| 6427 | } |
| 6428 | intent.putExtra(key, list); |
| 6429 | hasIntentInfo = true; |
| 6430 | } |
| 6431 | break; |
| 6432 | case "--ez": { |
| 6433 | String key = cmd.getNextArgRequired(); |
| 6434 | String value = cmd.getNextArgRequired().toLowerCase(); |
| 6435 | // Boolean.valueOf() results in false for anything that is not "true", which is |
| 6436 | // error-prone in shell commands |
| 6437 | boolean arg; |
| 6438 | if ("true".equals(value) || "t".equals(value)) { |
| 6439 | arg = true; |
| 6440 | } else if ("false".equals(value) || "f".equals(value)) { |
| 6441 | arg = false; |
| 6442 | } else { |
| 6443 | try { |
| 6444 | arg = Integer.decode(value) != 0; |
| 6445 | } catch (NumberFormatException ex) { |
| 6446 | throw new IllegalArgumentException("Invalid boolean value: " + value); |
| 6447 | } |
| 6448 | } |
| 6449 | |
| 6450 | intent.putExtra(key, arg); |
| 6451 | } |
| 6452 | break; |
| 6453 | case "-n": { |
| 6454 | String str = cmd.getNextArgRequired(); |
| 6455 | ComponentName cn = ComponentName.unflattenFromString(str); |
| 6456 | if (cn == null) |
| 6457 | throw new IllegalArgumentException("Bad component name: " + str); |
| 6458 | intent.setComponent(cn); |
| 6459 | if (intent == baseIntent) { |
| 6460 | hasIntentInfo = true; |
| 6461 | } |
| 6462 | } |
| 6463 | break; |
| 6464 | case "-p": { |
| 6465 | String str = cmd.getNextArgRequired(); |
| 6466 | intent.setPackage(str); |
| 6467 | if (intent == baseIntent) { |
| 6468 | hasIntentInfo = true; |
| 6469 | } |
| 6470 | } |
| 6471 | break; |
| 6472 | case "-f": |
| 6473 | String str = cmd.getNextArgRequired(); |
| 6474 | intent.setFlags(Integer.decode(str).intValue()); |
| 6475 | break; |
| 6476 | case "--grant-read-uri-permission": |
| 6477 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 6478 | break; |
| 6479 | case "--grant-write-uri-permission": |
| 6480 | intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
| 6481 | break; |
| 6482 | case "--grant-persistable-uri-permission": |
| 6483 | intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); |
| 6484 | break; |
| 6485 | case "--grant-prefix-uri-permission": |
| 6486 | intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); |
| 6487 | break; |
| 6488 | case "--exclude-stopped-packages": |
| 6489 | intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); |
| 6490 | break; |
| 6491 | case "--include-stopped-packages": |
| 6492 | intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| 6493 | break; |
| 6494 | case "--debug-log-resolution": |
| 6495 | intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); |
| 6496 | break; |
| 6497 | case "--activity-brought-to-front": |
| 6498 | intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); |
| 6499 | break; |
| 6500 | case "--activity-clear-top": |
| 6501 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 6502 | break; |
| 6503 | case "--activity-clear-when-task-reset": |
| 6504 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); |
| 6505 | break; |
| 6506 | case "--activity-exclude-from-recents": |
| 6507 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 6508 | break; |
| 6509 | case "--activity-launched-from-history": |
| 6510 | intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); |
| 6511 | break; |
| 6512 | case "--activity-multiple-task": |
| 6513 | intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); |
| 6514 | break; |
| 6515 | case "--activity-no-animation": |
| 6516 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); |
| 6517 | break; |
| 6518 | case "--activity-no-history": |
| 6519 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); |
| 6520 | break; |
| 6521 | case "--activity-no-user-action": |
| 6522 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); |
| 6523 | break; |
| 6524 | case "--activity-previous-is-top": |
| 6525 | intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); |
| 6526 | break; |
| 6527 | case "--activity-reorder-to-front": |
| 6528 | intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); |
| 6529 | break; |
| 6530 | case "--activity-reset-task-if-needed": |
| 6531 | intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 6532 | break; |
| 6533 | case "--activity-single-top": |
| 6534 | intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); |
| 6535 | break; |
| 6536 | case "--activity-clear-task": |
| 6537 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 6538 | break; |
| 6539 | case "--activity-task-on-home": |
| 6540 | intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); |
| 6541 | break; |
| 6542 | case "--receiver-registered-only": |
| 6543 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); |
| 6544 | break; |
| 6545 | case "--receiver-replace-pending": |
| 6546 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| 6547 | break; |
Felipe Leme | 3cb48cd | 2016-01-27 08:39:09 -0800 | [diff] [blame] | 6548 | case "--receiver-foreground": |
| 6549 | intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); |
| 6550 | break; |
Dianne Hackborn | 797772b1 | 2017-02-08 16:33:43 -0800 | [diff] [blame] | 6551 | case "--receiver-no-abort": |
| 6552 | intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); |
| 6553 | break; |
| 6554 | case "--receiver-include-background": |
| 6555 | intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); |
| 6556 | break; |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6557 | case "--selector": |
| 6558 | intent.setDataAndType(data, type); |
| 6559 | intent = new Intent(); |
| 6560 | break; |
| 6561 | default: |
| 6562 | if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { |
| 6563 | // Okay, caller handled this option. |
| 6564 | } else { |
| 6565 | throw new IllegalArgumentException("Unknown option: " + opt); |
| 6566 | } |
| 6567 | break; |
| 6568 | } |
| 6569 | } |
| 6570 | intent.setDataAndType(data, type); |
| 6571 | |
| 6572 | final boolean hasSelector = intent != baseIntent; |
| 6573 | if (hasSelector) { |
| 6574 | // A selector was specified; fix up. |
| 6575 | baseIntent.setSelector(intent); |
| 6576 | intent = baseIntent; |
| 6577 | } |
| 6578 | |
| 6579 | String arg = cmd.getNextArg(); |
| 6580 | baseIntent = null; |
| 6581 | if (arg == null) { |
| 6582 | if (hasSelector) { |
| 6583 | // If a selector has been specified, and no arguments |
| 6584 | // have been supplied for the main Intent, then we can |
| 6585 | // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't |
| 6586 | // need to have a component name specified yet, the |
| 6587 | // selector will take care of that. |
| 6588 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 6589 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 6590 | } |
| 6591 | } else if (arg.indexOf(':') >= 0) { |
| 6592 | // The argument is a URI. Fully parse it, and use that result |
| 6593 | // to fill in any data not specified so far. |
| 6594 | baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME |
| 6595 | | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); |
| 6596 | } else if (arg.indexOf('/') >= 0) { |
| 6597 | // The argument is a component name. Build an Intent to launch |
| 6598 | // it. |
| 6599 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 6600 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 6601 | baseIntent.setComponent(ComponentName.unflattenFromString(arg)); |
| 6602 | } else { |
| 6603 | // Assume the argument is a package name. |
| 6604 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 6605 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 6606 | baseIntent.setPackage(arg); |
| 6607 | } |
| 6608 | if (baseIntent != null) { |
| 6609 | Bundle extras = intent.getExtras(); |
| 6610 | intent.replaceExtras((Bundle)null); |
| 6611 | Bundle uriExtras = baseIntent.getExtras(); |
| 6612 | baseIntent.replaceExtras((Bundle)null); |
| 6613 | if (intent.getAction() != null && baseIntent.getCategories() != null) { |
| 6614 | HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); |
| 6615 | for (String c : cats) { |
| 6616 | baseIntent.removeCategory(c); |
| 6617 | } |
| 6618 | } |
| 6619 | intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); |
| 6620 | if (extras == null) { |
| 6621 | extras = uriExtras; |
| 6622 | } else if (uriExtras != null) { |
| 6623 | uriExtras.putAll(extras); |
| 6624 | extras = uriExtras; |
| 6625 | } |
| 6626 | intent.replaceExtras(extras); |
| 6627 | hasIntentInfo = true; |
| 6628 | } |
| 6629 | |
| 6630 | if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); |
| 6631 | return intent; |
| 6632 | } |
| 6633 | |
| 6634 | /** @hide */ |
| 6635 | public static void printIntentArgsHelp(PrintWriter pw, String prefix) { |
| 6636 | final String[] lines = new String[] { |
| 6637 | "<INTENT> specifications include these flags and arguments:", |
| 6638 | " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]", |
| 6639 | " [-c <CATEGORY> [-c <CATEGORY>] ...]", |
| 6640 | " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", |
| 6641 | " [--esn <EXTRA_KEY> ...]", |
| 6642 | " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", |
| 6643 | " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", |
| 6644 | " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", |
| 6645 | " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", |
| 6646 | " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", |
| 6647 | " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", |
| 6648 | " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", |
| 6649 | " (mutiple extras passed as Integer[])", |
| 6650 | " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", |
| 6651 | " (mutiple extras passed as List<Integer>)", |
| 6652 | " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", |
| 6653 | " (mutiple extras passed as Long[])", |
| 6654 | " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", |
| 6655 | " (mutiple extras passed as List<Long>)", |
| 6656 | " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", |
| 6657 | " (mutiple extras passed as Float[])", |
| 6658 | " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", |
| 6659 | " (mutiple extras passed as List<Float>)", |
| 6660 | " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", |
| 6661 | " (mutiple extras passed as String[]; to embed a comma into a string,", |
| 6662 | " escape it using \"\\,\")", |
| 6663 | " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", |
| 6664 | " (mutiple extras passed as List<String>; to embed a comma into a string,", |
| 6665 | " escape it using \"\\,\")", |
Felipe Leme | 545569d | 2016-01-11 16:27:58 -0800 | [diff] [blame] | 6666 | " [-f <FLAG>]", |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6667 | " [--grant-read-uri-permission] [--grant-write-uri-permission]", |
| 6668 | " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", |
| 6669 | " [--debug-log-resolution] [--exclude-stopped-packages]", |
| 6670 | " [--include-stopped-packages]", |
| 6671 | " [--activity-brought-to-front] [--activity-clear-top]", |
| 6672 | " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", |
| 6673 | " [--activity-launched-from-history] [--activity-multiple-task]", |
| 6674 | " [--activity-no-animation] [--activity-no-history]", |
| 6675 | " [--activity-no-user-action] [--activity-previous-is-top]", |
| 6676 | " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", |
| 6677 | " [--activity-single-top] [--activity-clear-task]", |
| 6678 | " [--activity-task-on-home]", |
| 6679 | " [--receiver-registered-only] [--receiver-replace-pending]", |
Dianne Hackborn | 797772b1 | 2017-02-08 16:33:43 -0800 | [diff] [blame] | 6680 | " [--receiver-foreground] [--receiver-no-abort]", |
| 6681 | " [--receiver-include-background]", |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6682 | " [--selector]", |
| 6683 | " [<URI> | <PACKAGE> | <COMPONENT>]" |
| 6684 | }; |
| 6685 | for (String line : lines) { |
| 6686 | pw.print(prefix); |
| 6687 | pw.println(line); |
| 6688 | } |
| 6689 | } |
| 6690 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6691 | /** |
| 6692 | * Retrieve the general action to be performed, such as |
| 6693 | * {@link #ACTION_VIEW}. The action describes the general way the rest of |
| 6694 | * the information in the intent should be interpreted -- most importantly, |
| 6695 | * what to do with the data returned by {@link #getData}. |
| 6696 | * |
| 6697 | * @return The action of this intent or null if none is specified. |
| 6698 | * |
| 6699 | * @see #setAction |
| 6700 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6701 | public @Nullable String getAction() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6702 | return mAction; |
| 6703 | } |
| 6704 | |
| 6705 | /** |
| 6706 | * Retrieve data this intent is operating on. This URI specifies the name |
| 6707 | * of the data; often it uses the content: scheme, specifying data in a |
| 6708 | * content provider. Other schemes may be handled by specific activities, |
| 6709 | * such as http: by the web browser. |
| 6710 | * |
| 6711 | * @return The URI of the data this intent is targeting or null. |
| 6712 | * |
| 6713 | * @see #getScheme |
| 6714 | * @see #setData |
| 6715 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6716 | public @Nullable Uri getData() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6717 | return mData; |
| 6718 | } |
| 6719 | |
| 6720 | /** |
| 6721 | * The same as {@link #getData()}, but returns the URI as an encoded |
| 6722 | * String. |
| 6723 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6724 | public @Nullable String getDataString() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6725 | return mData != null ? mData.toString() : null; |
| 6726 | } |
| 6727 | |
| 6728 | /** |
| 6729 | * Return the scheme portion of the intent's data. If the data is null or |
| 6730 | * does not include a scheme, null is returned. Otherwise, the scheme |
| 6731 | * prefix without the final ':' is returned, i.e. "http". |
| 6732 | * |
| 6733 | * <p>This is the same as calling getData().getScheme() (and checking for |
| 6734 | * null data). |
| 6735 | * |
| 6736 | * @return The scheme of this intent. |
| 6737 | * |
| 6738 | * @see #getData |
| 6739 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6740 | public @Nullable String getScheme() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6741 | return mData != null ? mData.getScheme() : null; |
| 6742 | } |
| 6743 | |
| 6744 | /** |
| 6745 | * Retrieve any explicit MIME type included in the intent. This is usually |
| 6746 | * null, as the type is determined by the intent data. |
| 6747 | * |
| 6748 | * @return If a type was manually set, it is returned; else null is |
| 6749 | * returned. |
| 6750 | * |
| 6751 | * @see #resolveType(ContentResolver) |
| 6752 | * @see #setType |
| 6753 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6754 | public @Nullable String getType() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6755 | return mType; |
| 6756 | } |
| 6757 | |
| 6758 | /** |
| 6759 | * Return the MIME data type of this intent. If the type field is |
| 6760 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 6761 | * the type of that data is returned. If neither fields are set, a null is |
| 6762 | * returned. |
| 6763 | * |
| 6764 | * @return The MIME type of this intent. |
| 6765 | * |
| 6766 | * @see #getType |
| 6767 | * @see #resolveType(ContentResolver) |
| 6768 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6769 | public @Nullable String resolveType(@NonNull Context context) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6770 | return resolveType(context.getContentResolver()); |
| 6771 | } |
| 6772 | |
| 6773 | /** |
| 6774 | * Return the MIME data type of this intent. If the type field is |
| 6775 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 6776 | * the type of that data is returned. If neither fields are set, a null is |
| 6777 | * returned. |
| 6778 | * |
| 6779 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 6780 | * type of the intent's data. |
| 6781 | * |
| 6782 | * @return The MIME type of this intent. |
| 6783 | * |
| 6784 | * @see #getType |
| 6785 | * @see #resolveType(Context) |
| 6786 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6787 | public @Nullable String resolveType(@NonNull ContentResolver resolver) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6788 | if (mType != null) { |
| 6789 | return mType; |
| 6790 | } |
| 6791 | if (mData != null) { |
| 6792 | if ("content".equals(mData.getScheme())) { |
| 6793 | return resolver.getType(mData); |
| 6794 | } |
| 6795 | } |
| 6796 | return null; |
| 6797 | } |
| 6798 | |
| 6799 | /** |
| 6800 | * Return the MIME data type of this intent, only if it will be needed for |
| 6801 | * intent resolution. This is not generally useful for application code; |
| 6802 | * it is used by the frameworks for communicating with back-end system |
| 6803 | * services. |
| 6804 | * |
| 6805 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 6806 | * type of the intent's data. |
| 6807 | * |
| 6808 | * @return The MIME type of this intent, or null if it is unknown or not |
| 6809 | * needed. |
| 6810 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6811 | public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6812 | if (mComponent != null) { |
| 6813 | return mType; |
| 6814 | } |
| 6815 | return resolveType(resolver); |
| 6816 | } |
| 6817 | |
| 6818 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 6819 | * Check if a category exists in the intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6820 | * |
| 6821 | * @param category The category to check. |
| 6822 | * |
| 6823 | * @return boolean True if the intent contains the category, else false. |
| 6824 | * |
| 6825 | * @see #getCategories |
| 6826 | * @see #addCategory |
| 6827 | */ |
| 6828 | public boolean hasCategory(String category) { |
| 6829 | return mCategories != null && mCategories.contains(category); |
| 6830 | } |
| 6831 | |
| 6832 | /** |
| 6833 | * Return the set of all categories in the intent. If there are no categories, |
| 6834 | * returns NULL. |
| 6835 | * |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6836 | * @return The set of categories you can examine. Do not modify! |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6837 | * |
| 6838 | * @see #hasCategory |
| 6839 | * @see #addCategory |
| 6840 | */ |
| 6841 | public Set<String> getCategories() { |
| 6842 | return mCategories; |
| 6843 | } |
| 6844 | |
| 6845 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6846 | * Return the specific selector associated with this Intent. If there is |
| 6847 | * none, returns null. See {@link #setSelector} for more information. |
| 6848 | * |
| 6849 | * @see #setSelector |
| 6850 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6851 | public @Nullable Intent getSelector() { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6852 | return mSelector; |
| 6853 | } |
| 6854 | |
| 6855 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6856 | * Return the {@link ClipData} associated with this Intent. If there is |
| 6857 | * none, returns null. See {@link #setClipData} for more information. |
| 6858 | * |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 6859 | * @see #setClipData |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6860 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6861 | public @Nullable ClipData getClipData() { |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6862 | return mClipData; |
| 6863 | } |
| 6864 | |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 6865 | /** @hide */ |
| 6866 | public int getContentUserHint() { |
| 6867 | return mContentUserHint; |
| 6868 | } |
| 6869 | |
Todd Kennedy | b3b43130 | 2017-03-20 16:05:48 -0700 | [diff] [blame] | 6870 | /** @hide */ |
| 6871 | public String getLaunchToken() { |
| 6872 | return mLaunchToken; |
| 6873 | } |
| 6874 | |
| 6875 | /** @hide */ |
| 6876 | public void setLaunchToken(String launchToken) { |
| 6877 | mLaunchToken = launchToken; |
| 6878 | } |
| 6879 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6880 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6881 | * Sets the ClassLoader that will be used when unmarshalling |
| 6882 | * any Parcelable values from the extras of this Intent. |
| 6883 | * |
| 6884 | * @param loader a ClassLoader, or null to use the default loader |
| 6885 | * at the time of unmarshalling. |
| 6886 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 6887 | public void setExtrasClassLoader(@Nullable ClassLoader loader) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6888 | if (mExtras != null) { |
| 6889 | mExtras.setClassLoader(loader); |
| 6890 | } |
| 6891 | } |
| 6892 | |
| 6893 | /** |
| 6894 | * Returns true if an extra value is associated with the given name. |
| 6895 | * @param name the extra's name |
| 6896 | * @return true if the given extra is present. |
| 6897 | */ |
| 6898 | public boolean hasExtra(String name) { |
| 6899 | return mExtras != null && mExtras.containsKey(name); |
| 6900 | } |
| 6901 | |
| 6902 | /** |
| 6903 | * Returns true if the Intent's extras contain a parcelled file descriptor. |
| 6904 | * @return true if the Intent contains a parcelled file descriptor. |
| 6905 | */ |
| 6906 | public boolean hasFileDescriptors() { |
| 6907 | return mExtras != null && mExtras.hasFileDescriptors(); |
| 6908 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6909 | |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 6910 | /** {@hide} */ |
Dianne Hackborn | 9ecebbf | 2011-09-28 23:19:47 -0400 | [diff] [blame] | 6911 | public void setAllowFds(boolean allowFds) { |
| 6912 | if (mExtras != null) { |
| 6913 | mExtras.setAllowFds(allowFds); |
| 6914 | } |
| 6915 | } |
| 6916 | |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 6917 | /** {@hide} */ |
| 6918 | public void setDefusable(boolean defusable) { |
| 6919 | if (mExtras != null) { |
| 6920 | mExtras.setDefusable(defusable); |
| 6921 | } |
| 6922 | } |
| 6923 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6924 | /** |
| 6925 | * Retrieve extended data from the intent. |
| 6926 | * |
| 6927 | * @param name The name of the desired item. |
| 6928 | * |
| 6929 | * @return the value of an item that previously added with putExtra() |
| 6930 | * or null if none was found. |
| 6931 | * |
| 6932 | * @deprecated |
| 6933 | * @hide |
| 6934 | */ |
| 6935 | @Deprecated |
| 6936 | public Object getExtra(String name) { |
| 6937 | return getExtra(name, null); |
| 6938 | } |
| 6939 | |
| 6940 | /** |
| 6941 | * Retrieve extended data from the intent. |
| 6942 | * |
| 6943 | * @param name The name of the desired item. |
| 6944 | * @param defaultValue the value to be returned if no value of the desired |
| 6945 | * type is stored with the given name. |
| 6946 | * |
| 6947 | * @return the value of an item that previously added with putExtra() |
| 6948 | * or the default value if none was found. |
| 6949 | * |
| 6950 | * @see #putExtra(String, boolean) |
| 6951 | */ |
| 6952 | public boolean getBooleanExtra(String name, boolean defaultValue) { |
| 6953 | return mExtras == null ? defaultValue : |
| 6954 | mExtras.getBoolean(name, defaultValue); |
| 6955 | } |
| 6956 | |
| 6957 | /** |
| 6958 | * Retrieve extended data from the intent. |
| 6959 | * |
| 6960 | * @param name The name of the desired item. |
| 6961 | * @param defaultValue the value to be returned if no value of the desired |
| 6962 | * type is stored with the given name. |
| 6963 | * |
| 6964 | * @return the value of an item that previously added with putExtra() |
| 6965 | * or the default value if none was found. |
| 6966 | * |
| 6967 | * @see #putExtra(String, byte) |
| 6968 | */ |
| 6969 | public byte getByteExtra(String name, byte defaultValue) { |
| 6970 | return mExtras == null ? defaultValue : |
| 6971 | mExtras.getByte(name, defaultValue); |
| 6972 | } |
| 6973 | |
| 6974 | /** |
| 6975 | * Retrieve extended data from the intent. |
| 6976 | * |
| 6977 | * @param name The name of the desired item. |
| 6978 | * @param defaultValue the value to be returned if no value of the desired |
| 6979 | * type is stored with the given name. |
| 6980 | * |
| 6981 | * @return the value of an item that previously added with putExtra() |
| 6982 | * or the default value if none was found. |
| 6983 | * |
| 6984 | * @see #putExtra(String, short) |
| 6985 | */ |
| 6986 | public short getShortExtra(String name, short defaultValue) { |
| 6987 | return mExtras == null ? defaultValue : |
| 6988 | mExtras.getShort(name, defaultValue); |
| 6989 | } |
| 6990 | |
| 6991 | /** |
| 6992 | * Retrieve extended data from the intent. |
| 6993 | * |
| 6994 | * @param name The name of the desired item. |
| 6995 | * @param defaultValue the value to be returned if no value of the desired |
| 6996 | * type is stored with the given name. |
| 6997 | * |
| 6998 | * @return the value of an item that previously added with putExtra() |
| 6999 | * or the default value if none was found. |
| 7000 | * |
| 7001 | * @see #putExtra(String, char) |
| 7002 | */ |
| 7003 | public char getCharExtra(String name, char defaultValue) { |
| 7004 | return mExtras == null ? defaultValue : |
| 7005 | mExtras.getChar(name, defaultValue); |
| 7006 | } |
| 7007 | |
| 7008 | /** |
| 7009 | * Retrieve extended data from the intent. |
| 7010 | * |
| 7011 | * @param name The name of the desired item. |
| 7012 | * @param defaultValue the value to be returned if no value of the desired |
| 7013 | * type is stored with the given name. |
| 7014 | * |
| 7015 | * @return the value of an item that previously added with putExtra() |
| 7016 | * or the default value if none was found. |
| 7017 | * |
| 7018 | * @see #putExtra(String, int) |
| 7019 | */ |
| 7020 | public int getIntExtra(String name, int defaultValue) { |
| 7021 | return mExtras == null ? defaultValue : |
| 7022 | mExtras.getInt(name, defaultValue); |
| 7023 | } |
| 7024 | |
| 7025 | /** |
| 7026 | * Retrieve extended data from the intent. |
| 7027 | * |
| 7028 | * @param name The name of the desired item. |
| 7029 | * @param defaultValue the value to be returned if no value of the desired |
| 7030 | * type is stored with the given name. |
| 7031 | * |
| 7032 | * @return the value of an item that previously added with putExtra() |
| 7033 | * or the default value if none was found. |
| 7034 | * |
| 7035 | * @see #putExtra(String, long) |
| 7036 | */ |
| 7037 | public long getLongExtra(String name, long defaultValue) { |
| 7038 | return mExtras == null ? defaultValue : |
| 7039 | mExtras.getLong(name, defaultValue); |
| 7040 | } |
| 7041 | |
| 7042 | /** |
| 7043 | * Retrieve extended data from the intent. |
| 7044 | * |
| 7045 | * @param name The name of the desired item. |
| 7046 | * @param defaultValue the value to be returned if no value of the desired |
| 7047 | * type is stored with the given name. |
| 7048 | * |
| 7049 | * @return the value of an item that previously added with putExtra(), |
| 7050 | * or the default value if no such item is present |
| 7051 | * |
| 7052 | * @see #putExtra(String, float) |
| 7053 | */ |
| 7054 | public float getFloatExtra(String name, float defaultValue) { |
| 7055 | return mExtras == null ? defaultValue : |
| 7056 | mExtras.getFloat(name, defaultValue); |
| 7057 | } |
| 7058 | |
| 7059 | /** |
| 7060 | * Retrieve extended data from the intent. |
| 7061 | * |
| 7062 | * @param name The name of the desired item. |
| 7063 | * @param defaultValue the value to be returned if no value of the desired |
| 7064 | * type is stored with the given name. |
| 7065 | * |
| 7066 | * @return the value of an item that previously added with putExtra() |
| 7067 | * or the default value if none was found. |
| 7068 | * |
| 7069 | * @see #putExtra(String, double) |
| 7070 | */ |
| 7071 | public double getDoubleExtra(String name, double defaultValue) { |
| 7072 | return mExtras == null ? defaultValue : |
| 7073 | mExtras.getDouble(name, defaultValue); |
| 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 String value was found. |
| 7083 | * |
| 7084 | * @see #putExtra(String, String) |
| 7085 | */ |
| 7086 | public String getStringExtra(String name) { |
| 7087 | return mExtras == null ? null : mExtras.getString(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 CharSequence value was found. |
| 7097 | * |
| 7098 | * @see #putExtra(String, CharSequence) |
| 7099 | */ |
| 7100 | public CharSequence getCharSequenceExtra(String name) { |
| 7101 | return mExtras == null ? null : mExtras.getCharSequence(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 Parcelable value was found. |
| 7111 | * |
| 7112 | * @see #putExtra(String, Parcelable) |
| 7113 | */ |
| 7114 | public <T extends Parcelable> T getParcelableExtra(String name) { |
| 7115 | return mExtras == null ? null : mExtras.<T>getParcelable(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 Parcelable[] value was found. |
| 7125 | * |
| 7126 | * @see #putExtra(String, Parcelable[]) |
| 7127 | */ |
| 7128 | public Parcelable[] getParcelableArrayExtra(String name) { |
| 7129 | return mExtras == null ? null : mExtras.getParcelableArray(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 ArrayList<Parcelable> value was found. |
| 7139 | * |
| 7140 | * @see #putParcelableArrayListExtra(String, ArrayList) |
| 7141 | */ |
| 7142 | public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { |
| 7143 | return mExtras == null ? null : mExtras.<T>getParcelableArrayList(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 Serializable value was found. |
| 7153 | * |
| 7154 | * @see #putExtra(String, Serializable) |
| 7155 | */ |
| 7156 | public Serializable getSerializableExtra(String name) { |
| 7157 | return mExtras == null ? null : mExtras.getSerializable(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 ArrayList<Integer> value was found. |
| 7167 | * |
| 7168 | * @see #putIntegerArrayListExtra(String, ArrayList) |
| 7169 | */ |
| 7170 | public ArrayList<Integer> getIntegerArrayListExtra(String name) { |
| 7171 | return mExtras == null ? null : mExtras.getIntegerArrayList(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 ArrayList<String> value was found. |
| 7181 | * |
| 7182 | * @see #putStringArrayListExtra(String, ArrayList) |
| 7183 | */ |
| 7184 | public ArrayList<String> getStringArrayListExtra(String name) { |
| 7185 | return mExtras == null ? null : mExtras.getStringArrayList(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() |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 7194 | * or null if no ArrayList<CharSequence> value was found. |
| 7195 | * |
| 7196 | * @see #putCharSequenceArrayListExtra(String, ArrayList) |
| 7197 | */ |
| 7198 | public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { |
| 7199 | return mExtras == null ? null : mExtras.getCharSequenceArrayList(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() |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7208 | * or null if no boolean array value was found. |
| 7209 | * |
| 7210 | * @see #putExtra(String, boolean[]) |
| 7211 | */ |
| 7212 | public boolean[] getBooleanArrayExtra(String name) { |
| 7213 | return mExtras == null ? null : mExtras.getBooleanArray(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 byte array value was found. |
| 7223 | * |
| 7224 | * @see #putExtra(String, byte[]) |
| 7225 | */ |
| 7226 | public byte[] getByteArrayExtra(String name) { |
| 7227 | return mExtras == null ? null : mExtras.getByteArray(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 short array value was found. |
| 7237 | * |
| 7238 | * @see #putExtra(String, short[]) |
| 7239 | */ |
| 7240 | public short[] getShortArrayExtra(String name) { |
| 7241 | return mExtras == null ? null : mExtras.getShortArray(name); |
| 7242 | } |
| 7243 | |
| 7244 | /** |
| 7245 | * Retrieve extended data from the intent. |
| 7246 | * |
| 7247 | * @param name The name of the desired item. |
| 7248 | * |
| 7249 | * @return the value of an item that previously added with putExtra() |
| 7250 | * or null if no char array value was found. |
| 7251 | * |
| 7252 | * @see #putExtra(String, char[]) |
| 7253 | */ |
| 7254 | public char[] getCharArrayExtra(String name) { |
| 7255 | return mExtras == null ? null : mExtras.getCharArray(name); |
| 7256 | } |
| 7257 | |
| 7258 | /** |
| 7259 | * Retrieve extended data from the intent. |
| 7260 | * |
| 7261 | * @param name The name of the desired item. |
| 7262 | * |
| 7263 | * @return the value of an item that previously added with putExtra() |
| 7264 | * or null if no int array value was found. |
| 7265 | * |
| 7266 | * @see #putExtra(String, int[]) |
| 7267 | */ |
| 7268 | public int[] getIntArrayExtra(String name) { |
| 7269 | return mExtras == null ? null : mExtras.getIntArray(name); |
| 7270 | } |
| 7271 | |
| 7272 | /** |
| 7273 | * Retrieve extended data from the intent. |
| 7274 | * |
| 7275 | * @param name The name of the desired item. |
| 7276 | * |
| 7277 | * @return the value of an item that previously added with putExtra() |
| 7278 | * or null if no long array value was found. |
| 7279 | * |
| 7280 | * @see #putExtra(String, long[]) |
| 7281 | */ |
| 7282 | public long[] getLongArrayExtra(String name) { |
| 7283 | return mExtras == null ? null : mExtras.getLongArray(name); |
| 7284 | } |
| 7285 | |
| 7286 | /** |
| 7287 | * Retrieve extended data from the intent. |
| 7288 | * |
| 7289 | * @param name The name of the desired item. |
| 7290 | * |
| 7291 | * @return the value of an item that previously added with putExtra() |
| 7292 | * or null if no float array value was found. |
| 7293 | * |
| 7294 | * @see #putExtra(String, float[]) |
| 7295 | */ |
| 7296 | public float[] getFloatArrayExtra(String name) { |
| 7297 | return mExtras == null ? null : mExtras.getFloatArray(name); |
| 7298 | } |
| 7299 | |
| 7300 | /** |
| 7301 | * Retrieve extended data from the intent. |
| 7302 | * |
| 7303 | * @param name The name of the desired item. |
| 7304 | * |
| 7305 | * @return the value of an item that previously added with putExtra() |
| 7306 | * or null if no double array value was found. |
| 7307 | * |
| 7308 | * @see #putExtra(String, double[]) |
| 7309 | */ |
| 7310 | public double[] getDoubleArrayExtra(String name) { |
| 7311 | return mExtras == null ? null : mExtras.getDoubleArray(name); |
| 7312 | } |
| 7313 | |
| 7314 | /** |
| 7315 | * Retrieve extended data from the intent. |
| 7316 | * |
| 7317 | * @param name The name of the desired item. |
| 7318 | * |
| 7319 | * @return the value of an item that previously added with putExtra() |
| 7320 | * or null if no String array value was found. |
| 7321 | * |
| 7322 | * @see #putExtra(String, String[]) |
| 7323 | */ |
| 7324 | public String[] getStringArrayExtra(String name) { |
| 7325 | return mExtras == null ? null : mExtras.getStringArray(name); |
| 7326 | } |
| 7327 | |
| 7328 | /** |
| 7329 | * Retrieve extended data from the intent. |
| 7330 | * |
| 7331 | * @param name The name of the desired item. |
| 7332 | * |
| 7333 | * @return the value of an item that previously added with putExtra() |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 7334 | * or null if no CharSequence array value was found. |
| 7335 | * |
| 7336 | * @see #putExtra(String, CharSequence[]) |
| 7337 | */ |
| 7338 | public CharSequence[] getCharSequenceArrayExtra(String name) { |
| 7339 | return mExtras == null ? null : mExtras.getCharSequenceArray(name); |
| 7340 | } |
| 7341 | |
| 7342 | /** |
| 7343 | * Retrieve extended data from the intent. |
| 7344 | * |
| 7345 | * @param name The name of the desired item. |
| 7346 | * |
| 7347 | * @return the value of an item that previously added with putExtra() |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7348 | * or null if no Bundle value was found. |
| 7349 | * |
| 7350 | * @see #putExtra(String, Bundle) |
| 7351 | */ |
| 7352 | public Bundle getBundleExtra(String name) { |
| 7353 | return mExtras == null ? null : mExtras.getBundle(name); |
| 7354 | } |
| 7355 | |
| 7356 | /** |
| 7357 | * Retrieve extended data from the intent. |
| 7358 | * |
| 7359 | * @param name The name of the desired item. |
| 7360 | * |
| 7361 | * @return the value of an item that previously added with putExtra() |
| 7362 | * or null if no IBinder value was found. |
| 7363 | * |
| 7364 | * @see #putExtra(String, IBinder) |
| 7365 | * |
| 7366 | * @deprecated |
| 7367 | * @hide |
| 7368 | */ |
| 7369 | @Deprecated |
| 7370 | public IBinder getIBinderExtra(String name) { |
| 7371 | return mExtras == null ? null : mExtras.getIBinder(name); |
| 7372 | } |
| 7373 | |
| 7374 | /** |
| 7375 | * Retrieve extended data from the intent. |
| 7376 | * |
| 7377 | * @param name The name of the desired item. |
| 7378 | * @param defaultValue The default value to return in case no item is |
| 7379 | * associated with the key 'name' |
| 7380 | * |
| 7381 | * @return the value of an item that previously added with putExtra() |
| 7382 | * or defaultValue if none was found. |
| 7383 | * |
| 7384 | * @see #putExtra |
| 7385 | * |
| 7386 | * @deprecated |
| 7387 | * @hide |
| 7388 | */ |
| 7389 | @Deprecated |
| 7390 | public Object getExtra(String name, Object defaultValue) { |
| 7391 | Object result = defaultValue; |
| 7392 | if (mExtras != null) { |
| 7393 | Object result2 = mExtras.get(name); |
| 7394 | if (result2 != null) { |
| 7395 | result = result2; |
| 7396 | } |
| 7397 | } |
| 7398 | |
| 7399 | return result; |
| 7400 | } |
| 7401 | |
| 7402 | /** |
| 7403 | * Retrieves a map of extended data from the intent. |
| 7404 | * |
| 7405 | * @return the map of all extras previously added with putExtra(), |
| 7406 | * or null if none have been added. |
| 7407 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7408 | public @Nullable Bundle getExtras() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7409 | return (mExtras != null) |
| 7410 | ? new Bundle(mExtras) |
| 7411 | : null; |
| 7412 | } |
| 7413 | |
| 7414 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 7415 | * Filter extras to only basic types. |
| 7416 | * @hide |
| 7417 | */ |
| 7418 | public void removeUnsafeExtras() { |
| 7419 | if (mExtras != null) { |
Dianne Hackborn | 851ec49 | 2016-10-12 17:20:07 -0700 | [diff] [blame] | 7420 | mExtras = mExtras.filterValues(); |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 7421 | } |
| 7422 | } |
| 7423 | |
| 7424 | /** |
Makoto Onuki | 97f82f2 | 2017-05-31 16:20:21 -0700 | [diff] [blame] | 7425 | * @return Whether {@link #maybeStripForHistory} will return an lightened intent or |
| 7426 | * return itself as-is. |
| 7427 | * @hide |
| 7428 | */ |
| 7429 | public boolean canStripForHistory() { |
| 7430 | return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null); |
| 7431 | } |
| 7432 | |
| 7433 | /** |
| 7434 | * Call it when the system needs to keep an intent for logging purposes to remove fields |
| 7435 | * that are not needed for logging. |
| 7436 | * @hide |
| 7437 | */ |
| 7438 | public Intent maybeStripForHistory() { |
| 7439 | // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras? |
| 7440 | |
| 7441 | if (!canStripForHistory()) { |
| 7442 | return this; |
| 7443 | } |
| 7444 | return new Intent(this, COPY_MODE_HISTORY); |
| 7445 | } |
| 7446 | |
| 7447 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7448 | * Retrieve any special flags associated with this intent. You will |
| 7449 | * normally just set them with {@link #setFlags} and let the system |
| 7450 | * take the appropriate action with them. |
| 7451 | * |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7452 | * @return The currently set flags. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7453 | * @see #setFlags |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7454 | * @see #addFlags |
| 7455 | * @see #removeFlags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7456 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7457 | public @Flags int getFlags() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7458 | return mFlags; |
| 7459 | } |
| 7460 | |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 7461 | /** @hide */ |
| 7462 | public boolean isExcludingStopped() { |
| 7463 | return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) |
| 7464 | == FLAG_EXCLUDE_STOPPED_PACKAGES; |
| 7465 | } |
| 7466 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7467 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7468 | * Retrieve the application package name this Intent is limited to. When |
| 7469 | * resolving an Intent, if non-null this limits the resolution to only |
| 7470 | * components in the given application package. |
| 7471 | * |
| 7472 | * @return The name of the application package for the Intent. |
| 7473 | * |
| 7474 | * @see #resolveActivity |
| 7475 | * @see #setPackage |
| 7476 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7477 | public @Nullable String getPackage() { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7478 | return mPackage; |
| 7479 | } |
| 7480 | |
| 7481 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7482 | * Retrieve the concrete component associated with the intent. When receiving |
| 7483 | * an intent, this is the component that was found to best handle it (that is, |
| 7484 | * yourself) and will always be non-null; in all other cases it will be |
| 7485 | * null unless explicitly set. |
| 7486 | * |
| 7487 | * @return The name of the application component to handle the intent. |
| 7488 | * |
| 7489 | * @see #resolveActivity |
| 7490 | * @see #setComponent |
| 7491 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7492 | public @Nullable ComponentName getComponent() { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7493 | return mComponent; |
| 7494 | } |
| 7495 | |
| 7496 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7497 | * Get the bounds of the sender of this intent, in screen coordinates. This can be |
| 7498 | * used as a hint to the receiver for animations and the like. Null means that there |
| 7499 | * is no source bounds. |
| 7500 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7501 | public @Nullable Rect getSourceBounds() { |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7502 | return mSourceBounds; |
| 7503 | } |
| 7504 | |
| 7505 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7506 | * Return the Activity component that should be used to handle this intent. |
| 7507 | * The appropriate component is determined based on the information in the |
| 7508 | * intent, evaluated as follows: |
| 7509 | * |
| 7510 | * <p>If {@link #getComponent} returns an explicit class, that is returned |
| 7511 | * without any further consideration. |
| 7512 | * |
| 7513 | * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent |
| 7514 | * category to be considered. |
| 7515 | * |
| 7516 | * <p>If {@link #getAction} is non-NULL, the activity must handle this |
| 7517 | * action. |
| 7518 | * |
| 7519 | * <p>If {@link #resolveType} returns non-NULL, the activity must handle |
| 7520 | * this type. |
| 7521 | * |
| 7522 | * <p>If {@link #addCategory} has added any categories, the activity must |
| 7523 | * handle ALL of the categories specified. |
| 7524 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7525 | * <p>If {@link #getPackage} is non-NULL, only activity components in |
| 7526 | * that application package will be considered. |
| 7527 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7528 | * <p>If there are no activities that satisfy all of these conditions, a |
| 7529 | * null string is returned. |
| 7530 | * |
| 7531 | * <p>If multiple activities are found to satisfy the intent, the one with |
| 7532 | * the highest priority will be used. If there are multiple activities |
| 7533 | * with the same priority, the system will either pick the best activity |
| 7534 | * based on user preference, or resolve to a system class that will allow |
| 7535 | * the user to pick an activity and forward from there. |
| 7536 | * |
| 7537 | * <p>This method is implemented simply by calling |
| 7538 | * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter |
| 7539 | * true.</p> |
| 7540 | * <p> This API is called for you as part of starting an activity from an |
| 7541 | * intent. You do not normally need to call it yourself.</p> |
| 7542 | * |
| 7543 | * @param pm The package manager with which to resolve the Intent. |
| 7544 | * |
| 7545 | * @return Name of the component implementing an activity that can |
| 7546 | * display the intent. |
| 7547 | * |
| 7548 | * @see #setComponent |
| 7549 | * @see #getComponent |
| 7550 | * @see #resolveActivityInfo |
| 7551 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7552 | public ComponentName resolveActivity(@NonNull PackageManager pm) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7553 | if (mComponent != null) { |
| 7554 | return mComponent; |
| 7555 | } |
| 7556 | |
| 7557 | ResolveInfo info = pm.resolveActivity( |
| 7558 | this, PackageManager.MATCH_DEFAULT_ONLY); |
| 7559 | if (info != null) { |
| 7560 | return new ComponentName( |
| 7561 | info.activityInfo.applicationInfo.packageName, |
| 7562 | info.activityInfo.name); |
| 7563 | } |
| 7564 | |
| 7565 | return null; |
| 7566 | } |
| 7567 | |
| 7568 | /** |
| 7569 | * Resolve the Intent into an {@link ActivityInfo} |
| 7570 | * describing the activity that should execute the intent. Resolution |
| 7571 | * follows the same rules as described for {@link #resolveActivity}, but |
| 7572 | * you get back the completely information about the resolved activity |
| 7573 | * instead of just its class name. |
| 7574 | * |
| 7575 | * @param pm The package manager with which to resolve the Intent. |
| 7576 | * @param flags Addition information to retrieve as per |
| 7577 | * {@link PackageManager#getActivityInfo(ComponentName, int) |
| 7578 | * PackageManager.getActivityInfo()}. |
| 7579 | * |
| 7580 | * @return PackageManager.ActivityInfo |
| 7581 | * |
| 7582 | * @see #resolveActivity |
| 7583 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7584 | public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm, |
| 7585 | @PackageManager.ComponentInfoFlags int flags) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7586 | ActivityInfo ai = null; |
| 7587 | if (mComponent != null) { |
| 7588 | try { |
| 7589 | ai = pm.getActivityInfo(mComponent, flags); |
| 7590 | } catch (PackageManager.NameNotFoundException e) { |
| 7591 | // ignore |
| 7592 | } |
| 7593 | } else { |
| 7594 | ResolveInfo info = pm.resolveActivity( |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 7595 | this, PackageManager.MATCH_DEFAULT_ONLY | flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7596 | if (info != null) { |
| 7597 | ai = info.activityInfo; |
| 7598 | } |
| 7599 | } |
| 7600 | |
| 7601 | return ai; |
| 7602 | } |
| 7603 | |
| 7604 | /** |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 7605 | * Special function for use by the system to resolve service |
| 7606 | * intents to system apps. Throws an exception if there are |
| 7607 | * multiple potential matches to the Intent. Returns null if |
| 7608 | * there are no matches. |
| 7609 | * @hide |
| 7610 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7611 | public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm, |
| 7612 | @PackageManager.ComponentInfoFlags int flags) { |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 7613 | if (mComponent != null) { |
| 7614 | return mComponent; |
| 7615 | } |
| 7616 | |
| 7617 | List<ResolveInfo> results = pm.queryIntentServices(this, flags); |
| 7618 | if (results == null) { |
| 7619 | return null; |
| 7620 | } |
| 7621 | ComponentName comp = null; |
| 7622 | for (int i=0; i<results.size(); i++) { |
| 7623 | ResolveInfo ri = results.get(i); |
| 7624 | if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { |
| 7625 | continue; |
| 7626 | } |
| 7627 | ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, |
| 7628 | ri.serviceInfo.name); |
| 7629 | if (comp != null) { |
| 7630 | throw new IllegalStateException("Multiple system services handle " + this |
| 7631 | + ": " + comp + ", " + foundComp); |
| 7632 | } |
| 7633 | comp = foundComp; |
| 7634 | } |
| 7635 | return comp; |
| 7636 | } |
| 7637 | |
| 7638 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7639 | * Set the general action to be performed. |
| 7640 | * |
| 7641 | * @param action An action name, such as ACTION_VIEW. Application-specific |
| 7642 | * actions should be prefixed with the vendor's package name. |
| 7643 | * |
| 7644 | * @return Returns the same Intent object, for chaining multiple calls |
| 7645 | * into a single statement. |
| 7646 | * |
| 7647 | * @see #getAction |
| 7648 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7649 | public @NonNull Intent setAction(@Nullable String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 7650 | mAction = action != null ? action.intern() : null; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7651 | return this; |
| 7652 | } |
| 7653 | |
| 7654 | /** |
| 7655 | * Set the data this intent is operating on. This method automatically |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7656 | * clears any type that was previously set by {@link #setType} or |
| 7657 | * {@link #setTypeAndNormalize}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7658 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7659 | * <p><em>Note: scheme matching in the Android framework is |
| 7660 | * case-sensitive, unlike the formal RFC. As a result, |
| 7661 | * you should always write your Uri with a lower case scheme, |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7662 | * or use {@link Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7663 | * {@link #setDataAndNormalize} |
| 7664 | * to ensure that the scheme is converted to lower case.</em> |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7665 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7666 | * @param data The Uri of the data this intent is now targeting. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7667 | * |
| 7668 | * @return Returns the same Intent object, for chaining multiple calls |
| 7669 | * into a single statement. |
| 7670 | * |
| 7671 | * @see #getData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7672 | * @see #setDataAndNormalize |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 7673 | * @see android.net.Uri#normalizeScheme() |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7674 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7675 | public @NonNull Intent setData(@Nullable Uri data) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7676 | mData = data; |
| 7677 | mType = null; |
| 7678 | return this; |
| 7679 | } |
| 7680 | |
| 7681 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7682 | * Normalize and set the data this intent is operating on. |
| 7683 | * |
| 7684 | * <p>This method automatically clears any type that was |
| 7685 | * previously set (for example, by {@link #setType}). |
| 7686 | * |
| 7687 | * <p>The data Uri is normalized using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7688 | * {@link android.net.Uri#normalizeScheme} before it is set, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7689 | * so really this is just a convenience method for |
| 7690 | * <pre> |
| 7691 | * setData(data.normalize()) |
| 7692 | * </pre> |
| 7693 | * |
| 7694 | * @param data The Uri of the data this intent is now targeting. |
| 7695 | * |
| 7696 | * @return Returns the same Intent object, for chaining multiple calls |
| 7697 | * into a single statement. |
| 7698 | * |
| 7699 | * @see #getData |
| 7700 | * @see #setType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7701 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7702 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7703 | public @NonNull Intent setDataAndNormalize(@NonNull Uri data) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7704 | return setData(data.normalizeScheme()); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7705 | } |
| 7706 | |
| 7707 | /** |
| 7708 | * Set an explicit MIME data type. |
| 7709 | * |
| 7710 | * <p>This is used to create intents that only specify a type and not data, |
| 7711 | * for example to indicate the type of data to return. |
| 7712 | * |
| 7713 | * <p>This method automatically clears any data that was |
| 7714 | * previously set (for example by {@link #setData}). |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 7715 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7716 | * <p><em>Note: MIME type matching in the Android framework is |
| 7717 | * case-sensitive, unlike formal RFC MIME types. As a result, |
| 7718 | * you should always write your MIME types with lower case letters, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7719 | * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} |
| 7720 | * to ensure that it is converted to lower case.</em> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7721 | * |
| 7722 | * @param type The MIME type of the data being handled by this intent. |
| 7723 | * |
| 7724 | * @return Returns the same Intent object, for chaining multiple calls |
| 7725 | * into a single statement. |
| 7726 | * |
| 7727 | * @see #getType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7728 | * @see #setTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7729 | * @see #setDataAndType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7730 | * @see #normalizeMimeType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7731 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7732 | public @NonNull Intent setType(@Nullable String type) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7733 | mData = null; |
| 7734 | mType = type; |
| 7735 | return this; |
| 7736 | } |
| 7737 | |
| 7738 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7739 | * Normalize and set an explicit MIME data type. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7740 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7741 | * <p>This is used to create intents that only specify a type and not data, |
| 7742 | * for example to indicate the type of data to return. |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7743 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7744 | * <p>This method automatically clears any data that was |
| 7745 | * previously set (for example by {@link #setData}). |
| 7746 | * |
| 7747 | * <p>The MIME type is normalized using |
| 7748 | * {@link #normalizeMimeType} before it is set, |
| 7749 | * so really this is just a convenience method for |
| 7750 | * <pre> |
| 7751 | * setType(Intent.normalizeMimeType(type)) |
| 7752 | * </pre> |
| 7753 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7754 | * @param type The MIME type of the data being handled by this intent. |
| 7755 | * |
| 7756 | * @return Returns the same Intent object, for chaining multiple calls |
| 7757 | * into a single statement. |
| 7758 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7759 | * @see #getType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7760 | * @see #setData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7761 | * @see #normalizeMimeType |
| 7762 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7763 | public @NonNull Intent setTypeAndNormalize(@Nullable String type) { |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7764 | return setType(normalizeMimeType(type)); |
| 7765 | } |
| 7766 | |
| 7767 | /** |
| 7768 | * (Usually optional) Set the data for the intent along with an explicit |
| 7769 | * MIME data type. This method should very rarely be used -- it allows you |
| 7770 | * to override the MIME type that would ordinarily be inferred from the |
| 7771 | * data with your own type given here. |
| 7772 | * |
| 7773 | * <p><em>Note: MIME type and Uri scheme matching in the |
| 7774 | * Android framework is case-sensitive, unlike the formal RFC definitions. |
| 7775 | * As a result, you should always write these elements with lower case letters, |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7776 | * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7777 | * {@link #setDataAndTypeAndNormalize} |
| 7778 | * to ensure that they are converted to lower case.</em> |
| 7779 | * |
| 7780 | * @param data The Uri of the data this intent is now targeting. |
| 7781 | * @param type The MIME type of the data being handled by this intent. |
| 7782 | * |
| 7783 | * @return Returns the same Intent object, for chaining multiple calls |
| 7784 | * into a single statement. |
| 7785 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7786 | * @see #setType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7787 | * @see #setData |
| 7788 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7789 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7790 | * @see #setDataAndTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7791 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7792 | public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7793 | mData = data; |
| 7794 | mType = type; |
| 7795 | return this; |
| 7796 | } |
| 7797 | |
| 7798 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7799 | * (Usually optional) Normalize and set both the data Uri and an explicit |
| 7800 | * MIME data type. This method should very rarely be used -- it allows you |
| 7801 | * to override the MIME type that would ordinarily be inferred from the |
| 7802 | * data with your own type given here. |
| 7803 | * |
| 7804 | * <p>The data Uri and the MIME type are normalize using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7805 | * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7806 | * before they are set, so really this is just a convenience method for |
| 7807 | * <pre> |
| 7808 | * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) |
| 7809 | * </pre> |
| 7810 | * |
| 7811 | * @param data The Uri of the data this intent is now targeting. |
| 7812 | * @param type The MIME type of the data being handled by this intent. |
| 7813 | * |
| 7814 | * @return Returns the same Intent object, for chaining multiple calls |
| 7815 | * into a single statement. |
| 7816 | * |
| 7817 | * @see #setType |
| 7818 | * @see #setData |
| 7819 | * @see #setDataAndType |
| 7820 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7821 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7822 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7823 | public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7824 | return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7825 | } |
| 7826 | |
| 7827 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7828 | * Add a new category to the intent. Categories provide additional detail |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 7829 | * about the action the intent performs. When resolving an intent, only |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7830 | * activities that provide <em>all</em> of the requested categories will be |
| 7831 | * used. |
| 7832 | * |
| 7833 | * @param category The desired category. This can be either one of the |
| 7834 | * predefined Intent categories, or a custom category in your own |
| 7835 | * namespace. |
| 7836 | * |
| 7837 | * @return Returns the same Intent object, for chaining multiple calls |
| 7838 | * into a single statement. |
| 7839 | * |
| 7840 | * @see #hasCategory |
| 7841 | * @see #removeCategory |
| 7842 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7843 | public @NonNull Intent addCategory(String category) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7844 | if (mCategories == null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7845 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7846 | } |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 7847 | mCategories.add(category.intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7848 | return this; |
| 7849 | } |
| 7850 | |
| 7851 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 7852 | * Remove a category from an intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7853 | * |
| 7854 | * @param category The category to remove. |
| 7855 | * |
| 7856 | * @see #addCategory |
| 7857 | */ |
| 7858 | public void removeCategory(String category) { |
| 7859 | if (mCategories != null) { |
| 7860 | mCategories.remove(category); |
| 7861 | if (mCategories.size() == 0) { |
| 7862 | mCategories = null; |
| 7863 | } |
| 7864 | } |
| 7865 | } |
| 7866 | |
| 7867 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7868 | * Set a selector for this Intent. This is a modification to the kinds of |
| 7869 | * things the Intent will match. If the selector is set, it will be used |
| 7870 | * when trying to find entities that can handle the Intent, instead of the |
| 7871 | * main contents of the Intent. This allows you build an Intent containing |
| 7872 | * a generic protocol while targeting it more specifically. |
| 7873 | * |
| 7874 | * <p>An example of where this may be used is with things like |
| 7875 | * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an |
| 7876 | * Intent that will launch the Browser application. However, the correct |
| 7877 | * main entry point of an application is actually {@link #ACTION_MAIN} |
| 7878 | * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} |
| 7879 | * used to specify the actual Activity to launch. If you launch the browser |
| 7880 | * with something different, undesired behavior may happen if the user has |
| 7881 | * previously or later launches it the normal way, since they do not match. |
| 7882 | * Instead, you can build an Intent with the MAIN action (but no ComponentName |
| 7883 | * yet specified) and set a selector with {@link #ACTION_MAIN} and |
| 7884 | * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. |
| 7885 | * |
| 7886 | * <p>Setting a selector does not impact the behavior of |
| 7887 | * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the |
| 7888 | * desired behavior of a selector -- it does not impact the base meaning |
| 7889 | * of the Intent, just what kinds of things will be matched against it |
| 7890 | * when determining who can handle it.</p> |
| 7891 | * |
| 7892 | * <p>You can not use both a selector and {@link #setPackage(String)} on |
| 7893 | * the same base Intent.</p> |
| 7894 | * |
| 7895 | * @param selector The desired selector Intent; set to null to not use |
| 7896 | * a special selector. |
| 7897 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7898 | public void setSelector(@Nullable Intent selector) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7899 | if (selector == this) { |
| 7900 | throw new IllegalArgumentException( |
| 7901 | "Intent being set as a selector of itself"); |
| 7902 | } |
| 7903 | if (selector != null && mPackage != null) { |
| 7904 | throw new IllegalArgumentException( |
| 7905 | "Can't set selector when package name is already set"); |
| 7906 | } |
| 7907 | mSelector = selector; |
| 7908 | } |
| 7909 | |
| 7910 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7911 | * Set a {@link ClipData} associated with this Intent. This replaces any |
| 7912 | * previously set ClipData. |
| 7913 | * |
| 7914 | * <p>The ClipData in an intent is not used for Intent matching or other |
| 7915 | * such operations. Semantically it is like extras, used to transmit |
| 7916 | * additional data with the Intent. The main feature of using this over |
| 7917 | * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} |
| 7918 | * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI |
| 7919 | * items included in the clip data. This is useful, in particular, if |
| 7920 | * you want to transmit an Intent containing multiple <code>content:</code> |
| 7921 | * URIs for which the recipient may not have global permission to access the |
| 7922 | * content provider. |
| 7923 | * |
| 7924 | * <p>If the ClipData contains items that are themselves Intents, any |
| 7925 | * grant flags in those Intents will be ignored. Only the top-level flags |
| 7926 | * of the main Intent are respected, and will be applied to all Uri or |
| 7927 | * Intent items in the clip (or sub-items of the clip). |
| 7928 | * |
| 7929 | * <p>The MIME type, label, and icon in the ClipData object are not |
| 7930 | * directly used by Intent. Applications should generally rely on the |
| 7931 | * MIME type of the Intent itself, not what it may find in the ClipData. |
| 7932 | * A common practice is to construct a ClipData for use with an Intent |
John Spurlock | 3390018 | 2014-01-02 11:04:18 -0500 | [diff] [blame] | 7933 | * with a MIME type of "*/*". |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7934 | * |
| 7935 | * @param clip The new clip to set. May be null to clear the current clip. |
| 7936 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7937 | public void setClipData(@Nullable ClipData clip) { |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7938 | mClipData = clip; |
| 7939 | } |
| 7940 | |
| 7941 | /** |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7942 | * This is NOT a secure mechanism to identify the user who sent the intent. |
| 7943 | * When the intent is sent to a different user, it is used to fix uris by adding the userId |
| 7944 | * who sent the intent. |
| 7945 | * @hide |
| 7946 | */ |
Nicolas Prevot | 107f7b7 | 2015-07-01 16:31:48 +0100 | [diff] [blame] | 7947 | public void prepareToLeaveUser(int userId) { |
| 7948 | // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. |
| 7949 | // We want mContentUserHint to refer to the original user, so don't do anything. |
| 7950 | if (mContentUserHint == UserHandle.USER_CURRENT) { |
| 7951 | mContentUserHint = userId; |
| 7952 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7953 | } |
| 7954 | |
| 7955 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7956 | * Add extended data to the intent. The name must include a package |
| 7957 | * prefix, for example the app com.android.contacts would use names |
| 7958 | * like "com.android.contacts.ShowAll". |
| 7959 | * |
| 7960 | * @param name The name of the extra data, with package prefix. |
| 7961 | * @param value The boolean data value. |
| 7962 | * |
| 7963 | * @return Returns the same Intent object, for chaining multiple calls |
| 7964 | * into a single statement. |
| 7965 | * |
| 7966 | * @see #putExtras |
| 7967 | * @see #removeExtra |
| 7968 | * @see #getBooleanExtra(String, boolean) |
| 7969 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7970 | public @NonNull Intent putExtra(String name, boolean value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7971 | if (mExtras == null) { |
| 7972 | mExtras = new Bundle(); |
| 7973 | } |
| 7974 | mExtras.putBoolean(name, value); |
| 7975 | return this; |
| 7976 | } |
| 7977 | |
| 7978 | /** |
| 7979 | * Add extended data to the intent. The name must include a package |
| 7980 | * prefix, for example the app com.android.contacts would use names |
| 7981 | * like "com.android.contacts.ShowAll". |
| 7982 | * |
| 7983 | * @param name The name of the extra data, with package prefix. |
| 7984 | * @param value The byte data value. |
| 7985 | * |
| 7986 | * @return Returns the same Intent object, for chaining multiple calls |
| 7987 | * into a single statement. |
| 7988 | * |
| 7989 | * @see #putExtras |
| 7990 | * @see #removeExtra |
| 7991 | * @see #getByteExtra(String, byte) |
| 7992 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 7993 | public @NonNull Intent putExtra(String name, byte value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7994 | if (mExtras == null) { |
| 7995 | mExtras = new Bundle(); |
| 7996 | } |
| 7997 | mExtras.putByte(name, value); |
| 7998 | return this; |
| 7999 | } |
| 8000 | |
| 8001 | /** |
| 8002 | * Add extended data to the intent. The name must include a package |
| 8003 | * prefix, for example the app com.android.contacts would use names |
| 8004 | * like "com.android.contacts.ShowAll". |
| 8005 | * |
| 8006 | * @param name The name of the extra data, with package prefix. |
| 8007 | * @param value The char data value. |
| 8008 | * |
| 8009 | * @return Returns the same Intent object, for chaining multiple calls |
| 8010 | * into a single statement. |
| 8011 | * |
| 8012 | * @see #putExtras |
| 8013 | * @see #removeExtra |
| 8014 | * @see #getCharExtra(String, char) |
| 8015 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8016 | public @NonNull Intent putExtra(String name, char value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8017 | if (mExtras == null) { |
| 8018 | mExtras = new Bundle(); |
| 8019 | } |
| 8020 | mExtras.putChar(name, value); |
| 8021 | return this; |
| 8022 | } |
| 8023 | |
| 8024 | /** |
| 8025 | * Add extended data to the intent. The name must include a package |
| 8026 | * prefix, for example the app com.android.contacts would use names |
| 8027 | * like "com.android.contacts.ShowAll". |
| 8028 | * |
| 8029 | * @param name The name of the extra data, with package prefix. |
| 8030 | * @param value The short data value. |
| 8031 | * |
| 8032 | * @return Returns the same Intent object, for chaining multiple calls |
| 8033 | * into a single statement. |
| 8034 | * |
| 8035 | * @see #putExtras |
| 8036 | * @see #removeExtra |
| 8037 | * @see #getShortExtra(String, short) |
| 8038 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8039 | public @NonNull Intent putExtra(String name, short value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8040 | if (mExtras == null) { |
| 8041 | mExtras = new Bundle(); |
| 8042 | } |
| 8043 | mExtras.putShort(name, value); |
| 8044 | return this; |
| 8045 | } |
| 8046 | |
| 8047 | /** |
| 8048 | * Add extended data to the intent. The name must include a package |
| 8049 | * prefix, for example the app com.android.contacts would use names |
| 8050 | * like "com.android.contacts.ShowAll". |
| 8051 | * |
| 8052 | * @param name The name of the extra data, with package prefix. |
| 8053 | * @param value The integer data value. |
| 8054 | * |
| 8055 | * @return Returns the same Intent object, for chaining multiple calls |
| 8056 | * into a single statement. |
| 8057 | * |
| 8058 | * @see #putExtras |
| 8059 | * @see #removeExtra |
| 8060 | * @see #getIntExtra(String, int) |
| 8061 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8062 | public @NonNull Intent putExtra(String name, int value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8063 | if (mExtras == null) { |
| 8064 | mExtras = new Bundle(); |
| 8065 | } |
| 8066 | mExtras.putInt(name, value); |
| 8067 | return this; |
| 8068 | } |
| 8069 | |
| 8070 | /** |
| 8071 | * Add extended data to the intent. The name must include a package |
| 8072 | * prefix, for example the app com.android.contacts would use names |
| 8073 | * like "com.android.contacts.ShowAll". |
| 8074 | * |
| 8075 | * @param name The name of the extra data, with package prefix. |
| 8076 | * @param value The long data value. |
| 8077 | * |
| 8078 | * @return Returns the same Intent object, for chaining multiple calls |
| 8079 | * into a single statement. |
| 8080 | * |
| 8081 | * @see #putExtras |
| 8082 | * @see #removeExtra |
| 8083 | * @see #getLongExtra(String, long) |
| 8084 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8085 | public @NonNull Intent putExtra(String name, long value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8086 | if (mExtras == null) { |
| 8087 | mExtras = new Bundle(); |
| 8088 | } |
| 8089 | mExtras.putLong(name, value); |
| 8090 | return this; |
| 8091 | } |
| 8092 | |
| 8093 | /** |
| 8094 | * Add extended data to the intent. The name must include a package |
| 8095 | * prefix, for example the app com.android.contacts would use names |
| 8096 | * like "com.android.contacts.ShowAll". |
| 8097 | * |
| 8098 | * @param name The name of the extra data, with package prefix. |
| 8099 | * @param value The float data value. |
| 8100 | * |
| 8101 | * @return Returns the same Intent object, for chaining multiple calls |
| 8102 | * into a single statement. |
| 8103 | * |
| 8104 | * @see #putExtras |
| 8105 | * @see #removeExtra |
| 8106 | * @see #getFloatExtra(String, float) |
| 8107 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8108 | public @NonNull Intent putExtra(String name, float value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8109 | if (mExtras == null) { |
| 8110 | mExtras = new Bundle(); |
| 8111 | } |
| 8112 | mExtras.putFloat(name, value); |
| 8113 | return this; |
| 8114 | } |
| 8115 | |
| 8116 | /** |
| 8117 | * Add extended data to the intent. The name must include a package |
| 8118 | * prefix, for example the app com.android.contacts would use names |
| 8119 | * like "com.android.contacts.ShowAll". |
| 8120 | * |
| 8121 | * @param name The name of the extra data, with package prefix. |
| 8122 | * @param value The double data value. |
| 8123 | * |
| 8124 | * @return Returns the same Intent object, for chaining multiple calls |
| 8125 | * into a single statement. |
| 8126 | * |
| 8127 | * @see #putExtras |
| 8128 | * @see #removeExtra |
| 8129 | * @see #getDoubleExtra(String, double) |
| 8130 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8131 | public @NonNull Intent putExtra(String name, double value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8132 | if (mExtras == null) { |
| 8133 | mExtras = new Bundle(); |
| 8134 | } |
| 8135 | mExtras.putDouble(name, value); |
| 8136 | return this; |
| 8137 | } |
| 8138 | |
| 8139 | /** |
| 8140 | * Add extended data to the intent. The name must include a package |
| 8141 | * prefix, for example the app com.android.contacts would use names |
| 8142 | * like "com.android.contacts.ShowAll". |
| 8143 | * |
| 8144 | * @param name The name of the extra data, with package prefix. |
| 8145 | * @param value The String data value. |
| 8146 | * |
| 8147 | * @return Returns the same Intent object, for chaining multiple calls |
| 8148 | * into a single statement. |
| 8149 | * |
| 8150 | * @see #putExtras |
| 8151 | * @see #removeExtra |
| 8152 | * @see #getStringExtra(String) |
| 8153 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8154 | public @NonNull Intent putExtra(String name, String value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8155 | if (mExtras == null) { |
| 8156 | mExtras = new Bundle(); |
| 8157 | } |
| 8158 | mExtras.putString(name, value); |
| 8159 | return this; |
| 8160 | } |
| 8161 | |
| 8162 | /** |
| 8163 | * Add extended data to the intent. The name must include a package |
| 8164 | * prefix, for example the app com.android.contacts would use names |
| 8165 | * like "com.android.contacts.ShowAll". |
| 8166 | * |
| 8167 | * @param name The name of the extra data, with package prefix. |
| 8168 | * @param value The CharSequence data value. |
| 8169 | * |
| 8170 | * @return Returns the same Intent object, for chaining multiple calls |
| 8171 | * into a single statement. |
| 8172 | * |
| 8173 | * @see #putExtras |
| 8174 | * @see #removeExtra |
| 8175 | * @see #getCharSequenceExtra(String) |
| 8176 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8177 | public @NonNull Intent putExtra(String name, CharSequence value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8178 | if (mExtras == null) { |
| 8179 | mExtras = new Bundle(); |
| 8180 | } |
| 8181 | mExtras.putCharSequence(name, value); |
| 8182 | return this; |
| 8183 | } |
| 8184 | |
| 8185 | /** |
| 8186 | * Add extended data to the intent. The name must include a package |
| 8187 | * prefix, for example the app com.android.contacts would use names |
| 8188 | * like "com.android.contacts.ShowAll". |
| 8189 | * |
| 8190 | * @param name The name of the extra data, with package prefix. |
| 8191 | * @param value The Parcelable data value. |
| 8192 | * |
| 8193 | * @return Returns the same Intent object, for chaining multiple calls |
| 8194 | * into a single statement. |
| 8195 | * |
| 8196 | * @see #putExtras |
| 8197 | * @see #removeExtra |
| 8198 | * @see #getParcelableExtra(String) |
| 8199 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8200 | public @NonNull Intent putExtra(String name, Parcelable value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8201 | if (mExtras == null) { |
| 8202 | mExtras = new Bundle(); |
| 8203 | } |
| 8204 | mExtras.putParcelable(name, value); |
| 8205 | return this; |
| 8206 | } |
| 8207 | |
| 8208 | /** |
| 8209 | * Add extended data to the intent. The name must include a package |
| 8210 | * prefix, for example the app com.android.contacts would use names |
| 8211 | * like "com.android.contacts.ShowAll". |
| 8212 | * |
| 8213 | * @param name The name of the extra data, with package prefix. |
| 8214 | * @param value The Parcelable[] data value. |
| 8215 | * |
| 8216 | * @return Returns the same Intent object, for chaining multiple calls |
| 8217 | * into a single statement. |
| 8218 | * |
| 8219 | * @see #putExtras |
| 8220 | * @see #removeExtra |
| 8221 | * @see #getParcelableArrayExtra(String) |
| 8222 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8223 | public @NonNull Intent putExtra(String name, Parcelable[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8224 | if (mExtras == null) { |
| 8225 | mExtras = new Bundle(); |
| 8226 | } |
| 8227 | mExtras.putParcelableArray(name, value); |
| 8228 | return this; |
| 8229 | } |
| 8230 | |
| 8231 | /** |
| 8232 | * Add extended data to the intent. The name must include a package |
| 8233 | * prefix, for example the app com.android.contacts would use names |
| 8234 | * like "com.android.contacts.ShowAll". |
| 8235 | * |
| 8236 | * @param name The name of the extra data, with package prefix. |
| 8237 | * @param value The ArrayList<Parcelable> data value. |
| 8238 | * |
| 8239 | * @return Returns the same Intent object, for chaining multiple calls |
| 8240 | * into a single statement. |
| 8241 | * |
| 8242 | * @see #putExtras |
| 8243 | * @see #removeExtra |
| 8244 | * @see #getParcelableArrayListExtra(String) |
| 8245 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8246 | public @NonNull Intent putParcelableArrayListExtra(String name, |
| 8247 | ArrayList<? extends Parcelable> value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8248 | if (mExtras == null) { |
| 8249 | mExtras = new Bundle(); |
| 8250 | } |
| 8251 | mExtras.putParcelableArrayList(name, value); |
| 8252 | return this; |
| 8253 | } |
| 8254 | |
| 8255 | /** |
| 8256 | * Add extended data to the intent. The name must include a package |
| 8257 | * prefix, for example the app com.android.contacts would use names |
| 8258 | * like "com.android.contacts.ShowAll". |
| 8259 | * |
| 8260 | * @param name The name of the extra data, with package prefix. |
| 8261 | * @param value The ArrayList<Integer> data value. |
| 8262 | * |
| 8263 | * @return Returns the same Intent object, for chaining multiple calls |
| 8264 | * into a single statement. |
| 8265 | * |
| 8266 | * @see #putExtras |
| 8267 | * @see #removeExtra |
| 8268 | * @see #getIntegerArrayListExtra(String) |
| 8269 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8270 | public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8271 | if (mExtras == null) { |
| 8272 | mExtras = new Bundle(); |
| 8273 | } |
| 8274 | mExtras.putIntegerArrayList(name, value); |
| 8275 | return this; |
| 8276 | } |
| 8277 | |
| 8278 | /** |
| 8279 | * Add extended data to the intent. The name must include a package |
| 8280 | * prefix, for example the app com.android.contacts would use names |
| 8281 | * like "com.android.contacts.ShowAll". |
| 8282 | * |
| 8283 | * @param name The name of the extra data, with package prefix. |
| 8284 | * @param value The ArrayList<String> data value. |
| 8285 | * |
| 8286 | * @return Returns the same Intent object, for chaining multiple calls |
| 8287 | * into a single statement. |
| 8288 | * |
| 8289 | * @see #putExtras |
| 8290 | * @see #removeExtra |
| 8291 | * @see #getStringArrayListExtra(String) |
| 8292 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8293 | public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8294 | if (mExtras == null) { |
| 8295 | mExtras = new Bundle(); |
| 8296 | } |
| 8297 | mExtras.putStringArrayList(name, value); |
| 8298 | return this; |
| 8299 | } |
| 8300 | |
| 8301 | /** |
| 8302 | * Add extended data to the intent. The name must include a package |
| 8303 | * prefix, for example the app com.android.contacts would use names |
| 8304 | * like "com.android.contacts.ShowAll". |
| 8305 | * |
| 8306 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 8307 | * @param value The ArrayList<CharSequence> data value. |
| 8308 | * |
| 8309 | * @return Returns the same Intent object, for chaining multiple calls |
| 8310 | * into a single statement. |
| 8311 | * |
| 8312 | * @see #putExtras |
| 8313 | * @see #removeExtra |
| 8314 | * @see #getCharSequenceArrayListExtra(String) |
| 8315 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8316 | public @NonNull Intent putCharSequenceArrayListExtra(String name, |
| 8317 | ArrayList<CharSequence> value) { |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 8318 | if (mExtras == null) { |
| 8319 | mExtras = new Bundle(); |
| 8320 | } |
| 8321 | mExtras.putCharSequenceArrayList(name, value); |
| 8322 | return this; |
| 8323 | } |
| 8324 | |
| 8325 | /** |
| 8326 | * Add extended data to the intent. The name must include a package |
| 8327 | * prefix, for example the app com.android.contacts would use names |
| 8328 | * like "com.android.contacts.ShowAll". |
| 8329 | * |
| 8330 | * @param name The name of the extra data, with package prefix. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8331 | * @param value The Serializable data value. |
| 8332 | * |
| 8333 | * @return Returns the same Intent object, for chaining multiple calls |
| 8334 | * into a single statement. |
| 8335 | * |
| 8336 | * @see #putExtras |
| 8337 | * @see #removeExtra |
| 8338 | * @see #getSerializableExtra(String) |
| 8339 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8340 | public @NonNull Intent putExtra(String name, Serializable value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8341 | if (mExtras == null) { |
| 8342 | mExtras = new Bundle(); |
| 8343 | } |
| 8344 | mExtras.putSerializable(name, value); |
| 8345 | return this; |
| 8346 | } |
| 8347 | |
| 8348 | /** |
| 8349 | * Add extended data to the intent. The name must include a package |
| 8350 | * prefix, for example the app com.android.contacts would use names |
| 8351 | * like "com.android.contacts.ShowAll". |
| 8352 | * |
| 8353 | * @param name The name of the extra data, with package prefix. |
| 8354 | * @param value The boolean array data value. |
| 8355 | * |
| 8356 | * @return Returns the same Intent object, for chaining multiple calls |
| 8357 | * into a single statement. |
| 8358 | * |
| 8359 | * @see #putExtras |
| 8360 | * @see #removeExtra |
| 8361 | * @see #getBooleanArrayExtra(String) |
| 8362 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8363 | public @NonNull Intent putExtra(String name, boolean[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8364 | if (mExtras == null) { |
| 8365 | mExtras = new Bundle(); |
| 8366 | } |
| 8367 | mExtras.putBooleanArray(name, value); |
| 8368 | return this; |
| 8369 | } |
| 8370 | |
| 8371 | /** |
| 8372 | * Add extended data to the intent. The name must include a package |
| 8373 | * prefix, for example the app com.android.contacts would use names |
| 8374 | * like "com.android.contacts.ShowAll". |
| 8375 | * |
| 8376 | * @param name The name of the extra data, with package prefix. |
| 8377 | * @param value The byte array data value. |
| 8378 | * |
| 8379 | * @return Returns the same Intent object, for chaining multiple calls |
| 8380 | * into a single statement. |
| 8381 | * |
| 8382 | * @see #putExtras |
| 8383 | * @see #removeExtra |
| 8384 | * @see #getByteArrayExtra(String) |
| 8385 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8386 | public @NonNull Intent putExtra(String name, byte[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8387 | if (mExtras == null) { |
| 8388 | mExtras = new Bundle(); |
| 8389 | } |
| 8390 | mExtras.putByteArray(name, value); |
| 8391 | return this; |
| 8392 | } |
| 8393 | |
| 8394 | /** |
| 8395 | * Add extended data to the intent. The name must include a package |
| 8396 | * prefix, for example the app com.android.contacts would use names |
| 8397 | * like "com.android.contacts.ShowAll". |
| 8398 | * |
| 8399 | * @param name The name of the extra data, with package prefix. |
| 8400 | * @param value The short array data value. |
| 8401 | * |
| 8402 | * @return Returns the same Intent object, for chaining multiple calls |
| 8403 | * into a single statement. |
| 8404 | * |
| 8405 | * @see #putExtras |
| 8406 | * @see #removeExtra |
| 8407 | * @see #getShortArrayExtra(String) |
| 8408 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8409 | public @NonNull Intent putExtra(String name, short[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8410 | if (mExtras == null) { |
| 8411 | mExtras = new Bundle(); |
| 8412 | } |
| 8413 | mExtras.putShortArray(name, value); |
| 8414 | return this; |
| 8415 | } |
| 8416 | |
| 8417 | /** |
| 8418 | * Add extended data to the intent. The name must include a package |
| 8419 | * prefix, for example the app com.android.contacts would use names |
| 8420 | * like "com.android.contacts.ShowAll". |
| 8421 | * |
| 8422 | * @param name The name of the extra data, with package prefix. |
| 8423 | * @param value The char array data value. |
| 8424 | * |
| 8425 | * @return Returns the same Intent object, for chaining multiple calls |
| 8426 | * into a single statement. |
| 8427 | * |
| 8428 | * @see #putExtras |
| 8429 | * @see #removeExtra |
| 8430 | * @see #getCharArrayExtra(String) |
| 8431 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8432 | public @NonNull Intent putExtra(String name, char[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8433 | if (mExtras == null) { |
| 8434 | mExtras = new Bundle(); |
| 8435 | } |
| 8436 | mExtras.putCharArray(name, value); |
| 8437 | return this; |
| 8438 | } |
| 8439 | |
| 8440 | /** |
| 8441 | * Add extended data to the intent. The name must include a package |
| 8442 | * prefix, for example the app com.android.contacts would use names |
| 8443 | * like "com.android.contacts.ShowAll". |
| 8444 | * |
| 8445 | * @param name The name of the extra data, with package prefix. |
| 8446 | * @param value The int array data value. |
| 8447 | * |
| 8448 | * @return Returns the same Intent object, for chaining multiple calls |
| 8449 | * into a single statement. |
| 8450 | * |
| 8451 | * @see #putExtras |
| 8452 | * @see #removeExtra |
| 8453 | * @see #getIntArrayExtra(String) |
| 8454 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8455 | public @NonNull Intent putExtra(String name, int[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8456 | if (mExtras == null) { |
| 8457 | mExtras = new Bundle(); |
| 8458 | } |
| 8459 | mExtras.putIntArray(name, value); |
| 8460 | return this; |
| 8461 | } |
| 8462 | |
| 8463 | /** |
| 8464 | * Add extended data to the intent. The name must include a package |
| 8465 | * prefix, for example the app com.android.contacts would use names |
| 8466 | * like "com.android.contacts.ShowAll". |
| 8467 | * |
| 8468 | * @param name The name of the extra data, with package prefix. |
| 8469 | * @param value The byte array data value. |
| 8470 | * |
| 8471 | * @return Returns the same Intent object, for chaining multiple calls |
| 8472 | * into a single statement. |
| 8473 | * |
| 8474 | * @see #putExtras |
| 8475 | * @see #removeExtra |
| 8476 | * @see #getLongArrayExtra(String) |
| 8477 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8478 | public @NonNull Intent putExtra(String name, long[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8479 | if (mExtras == null) { |
| 8480 | mExtras = new Bundle(); |
| 8481 | } |
| 8482 | mExtras.putLongArray(name, value); |
| 8483 | return this; |
| 8484 | } |
| 8485 | |
| 8486 | /** |
| 8487 | * Add extended data to the intent. The name must include a package |
| 8488 | * prefix, for example the app com.android.contacts would use names |
| 8489 | * like "com.android.contacts.ShowAll". |
| 8490 | * |
| 8491 | * @param name The name of the extra data, with package prefix. |
| 8492 | * @param value The float array data value. |
| 8493 | * |
| 8494 | * @return Returns the same Intent object, for chaining multiple calls |
| 8495 | * into a single statement. |
| 8496 | * |
| 8497 | * @see #putExtras |
| 8498 | * @see #removeExtra |
| 8499 | * @see #getFloatArrayExtra(String) |
| 8500 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8501 | public @NonNull Intent putExtra(String name, float[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8502 | if (mExtras == null) { |
| 8503 | mExtras = new Bundle(); |
| 8504 | } |
| 8505 | mExtras.putFloatArray(name, value); |
| 8506 | return this; |
| 8507 | } |
| 8508 | |
| 8509 | /** |
| 8510 | * Add extended data to the intent. The name must include a package |
| 8511 | * prefix, for example the app com.android.contacts would use names |
| 8512 | * like "com.android.contacts.ShowAll". |
| 8513 | * |
| 8514 | * @param name The name of the extra data, with package prefix. |
| 8515 | * @param value The double array data value. |
| 8516 | * |
| 8517 | * @return Returns the same Intent object, for chaining multiple calls |
| 8518 | * into a single statement. |
| 8519 | * |
| 8520 | * @see #putExtras |
| 8521 | * @see #removeExtra |
| 8522 | * @see #getDoubleArrayExtra(String) |
| 8523 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8524 | public @NonNull Intent putExtra(String name, double[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8525 | if (mExtras == null) { |
| 8526 | mExtras = new Bundle(); |
| 8527 | } |
| 8528 | mExtras.putDoubleArray(name, value); |
| 8529 | return this; |
| 8530 | } |
| 8531 | |
| 8532 | /** |
| 8533 | * Add extended data to the intent. The name must include a package |
| 8534 | * prefix, for example the app com.android.contacts would use names |
| 8535 | * like "com.android.contacts.ShowAll". |
| 8536 | * |
| 8537 | * @param name The name of the extra data, with package prefix. |
| 8538 | * @param value The String array data value. |
| 8539 | * |
| 8540 | * @return Returns the same Intent object, for chaining multiple calls |
| 8541 | * into a single statement. |
| 8542 | * |
| 8543 | * @see #putExtras |
| 8544 | * @see #removeExtra |
| 8545 | * @see #getStringArrayExtra(String) |
| 8546 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8547 | public @NonNull Intent putExtra(String name, String[] value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8548 | if (mExtras == null) { |
| 8549 | mExtras = new Bundle(); |
| 8550 | } |
| 8551 | mExtras.putStringArray(name, value); |
| 8552 | return this; |
| 8553 | } |
| 8554 | |
| 8555 | /** |
| 8556 | * Add extended data to the intent. The name must include a package |
| 8557 | * prefix, for example the app com.android.contacts would use names |
| 8558 | * like "com.android.contacts.ShowAll". |
| 8559 | * |
| 8560 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 8561 | * @param value The CharSequence array data value. |
| 8562 | * |
| 8563 | * @return Returns the same Intent object, for chaining multiple calls |
| 8564 | * into a single statement. |
| 8565 | * |
| 8566 | * @see #putExtras |
| 8567 | * @see #removeExtra |
| 8568 | * @see #getCharSequenceArrayExtra(String) |
| 8569 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8570 | public @NonNull Intent putExtra(String name, CharSequence[] value) { |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 8571 | if (mExtras == null) { |
| 8572 | mExtras = new Bundle(); |
| 8573 | } |
| 8574 | mExtras.putCharSequenceArray(name, value); |
| 8575 | return this; |
| 8576 | } |
| 8577 | |
| 8578 | /** |
| 8579 | * Add extended data to the intent. The name must include a package |
| 8580 | * prefix, for example the app com.android.contacts would use names |
| 8581 | * like "com.android.contacts.ShowAll". |
| 8582 | * |
| 8583 | * @param name The name of the extra data, with package prefix. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8584 | * @param value The Bundle data value. |
| 8585 | * |
| 8586 | * @return Returns the same Intent object, for chaining multiple calls |
| 8587 | * into a single statement. |
| 8588 | * |
| 8589 | * @see #putExtras |
| 8590 | * @see #removeExtra |
| 8591 | * @see #getBundleExtra(String) |
| 8592 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8593 | public @NonNull Intent putExtra(String name, Bundle value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8594 | if (mExtras == null) { |
| 8595 | mExtras = new Bundle(); |
| 8596 | } |
| 8597 | mExtras.putBundle(name, value); |
| 8598 | return this; |
| 8599 | } |
| 8600 | |
| 8601 | /** |
| 8602 | * Add extended data to the intent. The name must include a package |
| 8603 | * prefix, for example the app com.android.contacts would use names |
| 8604 | * like "com.android.contacts.ShowAll". |
| 8605 | * |
| 8606 | * @param name The name of the extra data, with package prefix. |
| 8607 | * @param value The IBinder data value. |
| 8608 | * |
| 8609 | * @return Returns the same Intent object, for chaining multiple calls |
| 8610 | * into a single statement. |
| 8611 | * |
| 8612 | * @see #putExtras |
| 8613 | * @see #removeExtra |
| 8614 | * @see #getIBinderExtra(String) |
| 8615 | * |
| 8616 | * @deprecated |
| 8617 | * @hide |
| 8618 | */ |
| 8619 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8620 | public @NonNull Intent putExtra(String name, IBinder value) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8621 | if (mExtras == null) { |
| 8622 | mExtras = new Bundle(); |
| 8623 | } |
| 8624 | mExtras.putIBinder(name, value); |
| 8625 | return this; |
| 8626 | } |
| 8627 | |
| 8628 | /** |
| 8629 | * Copy all extras in 'src' in to this intent. |
| 8630 | * |
| 8631 | * @param src Contains the extras to copy. |
| 8632 | * |
| 8633 | * @see #putExtra |
| 8634 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8635 | public @NonNull Intent putExtras(@NonNull Intent src) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8636 | if (src.mExtras != null) { |
| 8637 | if (mExtras == null) { |
| 8638 | mExtras = new Bundle(src.mExtras); |
| 8639 | } else { |
| 8640 | mExtras.putAll(src.mExtras); |
| 8641 | } |
| 8642 | } |
| 8643 | return this; |
| 8644 | } |
| 8645 | |
| 8646 | /** |
| 8647 | * Add a set of extended data to the intent. The keys must include a package |
| 8648 | * prefix, for example the app com.android.contacts would use names |
| 8649 | * like "com.android.contacts.ShowAll". |
| 8650 | * |
| 8651 | * @param extras The Bundle of extras to add to this intent. |
| 8652 | * |
| 8653 | * @see #putExtra |
| 8654 | * @see #removeExtra |
| 8655 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8656 | public @NonNull Intent putExtras(@NonNull Bundle extras) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8657 | if (mExtras == null) { |
| 8658 | mExtras = new Bundle(); |
| 8659 | } |
| 8660 | mExtras.putAll(extras); |
| 8661 | return this; |
| 8662 | } |
| 8663 | |
| 8664 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8665 | * Completely replace the extras in the Intent with the extras in the |
| 8666 | * given Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8667 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8668 | * @param src The exact extras contained in this Intent are copied |
| 8669 | * into the target intent, replacing any that were previously there. |
| 8670 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8671 | public @NonNull Intent replaceExtras(@NonNull Intent src) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8672 | mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; |
| 8673 | return this; |
| 8674 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8675 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8676 | /** |
| 8677 | * Completely replace the extras in the Intent with the given Bundle of |
| 8678 | * extras. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8679 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8680 | * @param extras The new set of extras in the Intent, or null to erase |
| 8681 | * all extras. |
| 8682 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8683 | public @NonNull Intent replaceExtras(@NonNull Bundle extras) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8684 | mExtras = extras != null ? new Bundle(extras) : null; |
| 8685 | return this; |
| 8686 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8687 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8688 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8689 | * Remove extended data from the intent. |
| 8690 | * |
| 8691 | * @see #putExtra |
| 8692 | */ |
| 8693 | public void removeExtra(String name) { |
| 8694 | if (mExtras != null) { |
| 8695 | mExtras.remove(name); |
| 8696 | if (mExtras.size() == 0) { |
| 8697 | mExtras = null; |
| 8698 | } |
| 8699 | } |
| 8700 | } |
| 8701 | |
| 8702 | /** |
| 8703 | * Set special flags controlling how this intent is handled. Most values |
| 8704 | * here depend on the type of component being executed by the Intent, |
| 8705 | * specifically the FLAG_ACTIVITY_* flags are all for use with |
| 8706 | * {@link Context#startActivity Context.startActivity()} and the |
| 8707 | * FLAG_RECEIVER_* flags are all for use with |
| 8708 | * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. |
| 8709 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 8710 | * <p>See the |
| 8711 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 8712 | * Stack</a> documentation for important information on how some of these options impact |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8713 | * the behavior of your application. |
| 8714 | * |
| 8715 | * @param flags The desired flags. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8716 | * @return Returns the same Intent object, for chaining multiple calls |
| 8717 | * into a single statement. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8718 | * @see #getFlags |
| 8719 | * @see #addFlags |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8720 | * @see #removeFlags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8721 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8722 | public @NonNull Intent setFlags(@Flags int flags) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8723 | mFlags = flags; |
| 8724 | return this; |
| 8725 | } |
| 8726 | |
| 8727 | /** |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8728 | * Add additional flags to the intent (or with existing flags value). |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8729 | * |
| 8730 | * @param flags The new flags to set. |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8731 | * @return Returns the same Intent object, for chaining multiple calls into |
| 8732 | * a single statement. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8733 | * @see #setFlags |
| 8734 | * @see #getFlags |
| 8735 | * @see #removeFlags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8736 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8737 | public @NonNull Intent addFlags(@Flags int flags) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8738 | mFlags |= flags; |
| 8739 | return this; |
| 8740 | } |
| 8741 | |
| 8742 | /** |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8743 | * Remove these flags from the intent. |
| 8744 | * |
| 8745 | * @param flags The flags to remove. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8746 | * @see #setFlags |
| 8747 | * @see #getFlags |
| 8748 | * @see #addFlags |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8749 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8750 | public void removeFlags(@Flags int flags) { |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8751 | mFlags &= ~flags; |
| 8752 | } |
| 8753 | |
| 8754 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8755 | * (Usually optional) Set an explicit application package name that limits |
| 8756 | * the components this Intent will resolve to. If left to the default |
| 8757 | * value of null, all components in all applications will considered. |
| 8758 | * If non-null, the Intent can only match the components in the given |
| 8759 | * application package. |
| 8760 | * |
| 8761 | * @param packageName The name of the application package to handle the |
| 8762 | * intent, or null to allow any application package. |
| 8763 | * |
| 8764 | * @return Returns the same Intent object, for chaining multiple calls |
| 8765 | * into a single statement. |
| 8766 | * |
| 8767 | * @see #getPackage |
| 8768 | * @see #resolveActivity |
| 8769 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8770 | public @NonNull Intent setPackage(@Nullable String packageName) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8771 | if (packageName != null && mSelector != null) { |
| 8772 | throw new IllegalArgumentException( |
| 8773 | "Can't set package name when selector is already set"); |
| 8774 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8775 | mPackage = packageName; |
| 8776 | return this; |
| 8777 | } |
| 8778 | |
| 8779 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8780 | * (Usually optional) Explicitly set the component to handle the intent. |
| 8781 | * If left with the default value of null, the system will determine the |
| 8782 | * appropriate class to use based on the other fields (action, data, |
| 8783 | * type, categories) in the Intent. If this class is defined, the |
| 8784 | * specified class will always be used regardless of the other fields. You |
| 8785 | * should only set this value when you know you absolutely want a specific |
| 8786 | * class to be used; otherwise it is better to let the system find the |
| 8787 | * appropriate class so that you will respect the installed applications |
| 8788 | * and user preferences. |
| 8789 | * |
| 8790 | * @param component The name of the application component to handle the |
| 8791 | * intent, or null to let the system find one for you. |
| 8792 | * |
| 8793 | * @return Returns the same Intent object, for chaining multiple calls |
| 8794 | * into a single statement. |
| 8795 | * |
| 8796 | * @see #setClass |
| 8797 | * @see #setClassName(Context, String) |
| 8798 | * @see #setClassName(String, String) |
| 8799 | * @see #getComponent |
| 8800 | * @see #resolveActivity |
| 8801 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8802 | public @NonNull Intent setComponent(@Nullable ComponentName component) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8803 | mComponent = component; |
| 8804 | return this; |
| 8805 | } |
| 8806 | |
| 8807 | /** |
| 8808 | * Convenience for calling {@link #setComponent} with an |
| 8809 | * explicit class name. |
| 8810 | * |
| 8811 | * @param packageContext A Context of the application package implementing |
| 8812 | * this class. |
| 8813 | * @param className The name of a class inside of the application package |
| 8814 | * that will be used as the component for this Intent. |
| 8815 | * |
| 8816 | * @return Returns the same Intent object, for chaining multiple calls |
| 8817 | * into a single statement. |
| 8818 | * |
| 8819 | * @see #setComponent |
| 8820 | * @see #setClass |
| 8821 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8822 | public @NonNull Intent setClassName(@NonNull Context packageContext, |
| 8823 | @NonNull String className) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8824 | mComponent = new ComponentName(packageContext, className); |
| 8825 | return this; |
| 8826 | } |
| 8827 | |
| 8828 | /** |
| 8829 | * Convenience for calling {@link #setComponent} with an |
| 8830 | * explicit application package name and class name. |
| 8831 | * |
| 8832 | * @param packageName The name of the package implementing the desired |
| 8833 | * component. |
| 8834 | * @param className The name of a class inside of the application package |
| 8835 | * that will be used as the component for this Intent. |
| 8836 | * |
| 8837 | * @return Returns the same Intent object, for chaining multiple calls |
| 8838 | * into a single statement. |
| 8839 | * |
| 8840 | * @see #setComponent |
| 8841 | * @see #setClass |
| 8842 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8843 | public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8844 | mComponent = new ComponentName(packageName, className); |
| 8845 | return this; |
| 8846 | } |
| 8847 | |
| 8848 | /** |
| 8849 | * Convenience for calling {@link #setComponent(ComponentName)} with the |
| 8850 | * name returned by a {@link Class} object. |
| 8851 | * |
| 8852 | * @param packageContext A Context of the application package implementing |
| 8853 | * this class. |
| 8854 | * @param cls The class name to set, equivalent to |
| 8855 | * <code>setClassName(context, cls.getName())</code>. |
| 8856 | * |
| 8857 | * @return Returns the same Intent object, for chaining multiple calls |
| 8858 | * into a single statement. |
| 8859 | * |
| 8860 | * @see #setComponent |
| 8861 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8862 | public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8863 | mComponent = new ComponentName(packageContext, cls); |
| 8864 | return this; |
| 8865 | } |
| 8866 | |
| 8867 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8868 | * Set the bounds of the sender of this intent, in screen coordinates. This can be |
| 8869 | * used as a hint to the receiver for animations and the like. Null means that there |
| 8870 | * is no source bounds. |
| 8871 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8872 | public void setSourceBounds(@Nullable Rect r) { |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8873 | if (r != null) { |
| 8874 | mSourceBounds = new Rect(r); |
| 8875 | } else { |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 8876 | mSourceBounds = null; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8877 | } |
| 8878 | } |
| 8879 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8880 | /** @hide */ |
| 8881 | @IntDef(flag = true, |
| 8882 | value = { |
| 8883 | FILL_IN_ACTION, |
| 8884 | FILL_IN_DATA, |
| 8885 | FILL_IN_CATEGORIES, |
| 8886 | FILL_IN_COMPONENT, |
| 8887 | FILL_IN_PACKAGE, |
| 8888 | FILL_IN_SOURCE_BOUNDS, |
| 8889 | FILL_IN_SELECTOR, |
| 8890 | FILL_IN_CLIP_DATA |
| 8891 | }) |
| 8892 | @Retention(RetentionPolicy.SOURCE) |
| 8893 | public @interface FillInFlags {} |
| 8894 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8895 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8896 | * Use with {@link #fillIn} to allow the current action value to be |
| 8897 | * overwritten, even if it is already set. |
| 8898 | */ |
| 8899 | public static final int FILL_IN_ACTION = 1<<0; |
| 8900 | |
| 8901 | /** |
| 8902 | * Use with {@link #fillIn} to allow the current data or type value |
| 8903 | * overwritten, even if it is already set. |
| 8904 | */ |
| 8905 | public static final int FILL_IN_DATA = 1<<1; |
| 8906 | |
| 8907 | /** |
| 8908 | * Use with {@link #fillIn} to allow the current categories to be |
| 8909 | * overwritten, even if they are already set. |
| 8910 | */ |
| 8911 | public static final int FILL_IN_CATEGORIES = 1<<2; |
| 8912 | |
| 8913 | /** |
| 8914 | * Use with {@link #fillIn} to allow the current component value to be |
| 8915 | * overwritten, even if it is already set. |
| 8916 | */ |
| 8917 | public static final int FILL_IN_COMPONENT = 1<<3; |
| 8918 | |
| 8919 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8920 | * Use with {@link #fillIn} to allow the current package value to be |
| 8921 | * overwritten, even if it is already set. |
| 8922 | */ |
| 8923 | public static final int FILL_IN_PACKAGE = 1<<4; |
| 8924 | |
| 8925 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8926 | * Use with {@link #fillIn} to allow the current bounds rectangle to be |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8927 | * overwritten, even if it is already set. |
| 8928 | */ |
| 8929 | public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; |
| 8930 | |
| 8931 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8932 | * Use with {@link #fillIn} to allow the current selector to be |
| 8933 | * overwritten, even if it is already set. |
| 8934 | */ |
| 8935 | public static final int FILL_IN_SELECTOR = 1<<6; |
| 8936 | |
| 8937 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8938 | * Use with {@link #fillIn} to allow the current ClipData to be |
| 8939 | * overwritten, even if it is already set. |
| 8940 | */ |
| 8941 | public static final int FILL_IN_CLIP_DATA = 1<<7; |
| 8942 | |
| 8943 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8944 | * Copy the contents of <var>other</var> in to this object, but only |
| 8945 | * where fields are not defined by this object. For purposes of a field |
| 8946 | * being defined, the following pieces of data in the Intent are |
| 8947 | * considered to be separate fields: |
| 8948 | * |
| 8949 | * <ul> |
| 8950 | * <li> action, as set by {@link #setAction}. |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 8951 | * <li> data Uri and MIME type, as set by {@link #setData(Uri)}, |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8952 | * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. |
| 8953 | * <li> categories, as set by {@link #addCategory}. |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8954 | * <li> package, as set by {@link #setPackage}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8955 | * <li> component, as set by {@link #setComponent(ComponentName)} or |
| 8956 | * related methods. |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8957 | * <li> source bounds, as set by {@link #setSourceBounds}. |
| 8958 | * <li> selector, as set by {@link #setSelector(Intent)}. |
| 8959 | * <li> clip data, as set by {@link #setClipData(ClipData)}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8960 | * <li> each top-level name in the associated extras. |
| 8961 | * </ul> |
| 8962 | * |
| 8963 | * <p>In addition, you can use the {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8964 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8965 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
| 8966 | * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override |
| 8967 | * the restriction where the corresponding field will not be replaced if |
| 8968 | * it is already set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8969 | * |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8970 | * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} |
| 8971 | * is explicitly specified. The selector will only be copied if |
| 8972 | * {@link #FILL_IN_SELECTOR} is explicitly specified. |
Brett Chabot | 3e39175 | 2009-07-21 16:07:23 -0700 | [diff] [blame] | 8973 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8974 | * <p>For example, consider Intent A with {data="foo", categories="bar"} |
| 8975 | * and Intent B with {action="gotit", data-type="some/thing", |
| 8976 | * categories="one","two"}. |
| 8977 | * |
| 8978 | * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now |
| 8979 | * containing: {action="gotit", data-type="some/thing", |
| 8980 | * categories="bar"}. |
| 8981 | * |
| 8982 | * @param other Another Intent whose values are to be used to fill in |
| 8983 | * the current one. |
| 8984 | * @param flags Options to control which fields can be filled in. |
| 8985 | * |
| 8986 | * @return Returns a bit mask of {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8987 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8988 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 8989 | * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8990 | * changed. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8991 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8992 | @FillInFlags |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 8993 | public int fillIn(@NonNull Intent other, @FillInFlags int flags) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8994 | int changes = 0; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8995 | boolean mayHaveCopiedUris = false; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8996 | if (other.mAction != null |
| 8997 | && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8998 | mAction = other.mAction; |
| 8999 | changes |= FILL_IN_ACTION; |
| 9000 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9001 | if ((other.mData != null || other.mType != null) |
| 9002 | && ((mData == null && mType == null) |
| 9003 | || (flags&FILL_IN_DATA) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9004 | mData = other.mData; |
| 9005 | mType = other.mType; |
| 9006 | changes |= FILL_IN_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9007 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9008 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9009 | if (other.mCategories != null |
| 9010 | && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9011 | if (other.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 9012 | mCategories = new ArraySet<String>(other.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9013 | } |
| 9014 | changes |= FILL_IN_CATEGORIES; |
| 9015 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9016 | if (other.mPackage != null |
| 9017 | && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9018 | // Only do this if mSelector is not set. |
| 9019 | if (mSelector == null) { |
| 9020 | mPackage = other.mPackage; |
| 9021 | changes |= FILL_IN_PACKAGE; |
| 9022 | } |
| 9023 | } |
| 9024 | // Selector is special: it can only be set if explicitly allowed, |
| 9025 | // for the same reason as the component name. |
| 9026 | if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { |
| 9027 | if (mPackage == null) { |
| 9028 | mSelector = new Intent(other.mSelector); |
| 9029 | mPackage = null; |
| 9030 | changes |= FILL_IN_SELECTOR; |
| 9031 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9032 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9033 | if (other.mClipData != null |
| 9034 | && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { |
| 9035 | mClipData = other.mClipData; |
| 9036 | changes |= FILL_IN_CLIP_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9037 | mayHaveCopiedUris = true; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9038 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9039 | // Component is special: it can -only- be set if explicitly allowed, |
| 9040 | // since otherwise the sender could force the intent somewhere the |
| 9041 | // originator didn't intend. |
| 9042 | if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9043 | mComponent = other.mComponent; |
| 9044 | changes |= FILL_IN_COMPONENT; |
| 9045 | } |
| 9046 | mFlags |= other.mFlags; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 9047 | if (other.mSourceBounds != null |
| 9048 | && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { |
| 9049 | mSourceBounds = new Rect(other.mSourceBounds); |
| 9050 | changes |= FILL_IN_SOURCE_BOUNDS; |
| 9051 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9052 | if (mExtras == null) { |
| 9053 | if (other.mExtras != null) { |
| 9054 | mExtras = new Bundle(other.mExtras); |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9055 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9056 | } |
| 9057 | } else if (other.mExtras != null) { |
| 9058 | try { |
| 9059 | Bundle newb = new Bundle(other.mExtras); |
| 9060 | newb.putAll(mExtras); |
| 9061 | mExtras = newb; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9062 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9063 | } catch (RuntimeException e) { |
| 9064 | // Modifying the extras can cause us to unparcel the contents |
| 9065 | // of the bundle, and if we do this in the system process that |
| 9066 | // may fail. We really should handle this (i.e., the Bundle |
| 9067 | // impl shouldn't be on top of a plain map), but for now just |
| 9068 | // ignore it and keep the original contents. :( |
| 9069 | Log.w("Intent", "Failure filling in extras", e); |
| 9070 | } |
| 9071 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9072 | if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT |
| 9073 | && other.mContentUserHint != UserHandle.USER_CURRENT) { |
| 9074 | mContentUserHint = other.mContentUserHint; |
| 9075 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9076 | return changes; |
| 9077 | } |
| 9078 | |
| 9079 | /** |
| 9080 | * Wrapper class holding an Intent and implementing comparisons on it for |
| 9081 | * the purpose of filtering. The class implements its |
| 9082 | * {@link #equals equals()} and {@link #hashCode hashCode()} methods as |
| 9083 | * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and |
| 9084 | * {@link android.content.Intent#filterHashCode()} filterHashCode()} |
| 9085 | * on the wrapped Intent. |
| 9086 | */ |
| 9087 | public static final class FilterComparison { |
| 9088 | private final Intent mIntent; |
| 9089 | private final int mHashCode; |
| 9090 | |
| 9091 | public FilterComparison(Intent intent) { |
| 9092 | mIntent = intent; |
| 9093 | mHashCode = intent.filterHashCode(); |
| 9094 | } |
| 9095 | |
| 9096 | /** |
| 9097 | * Return the Intent that this FilterComparison represents. |
| 9098 | * @return Returns the Intent held by the FilterComparison. Do |
| 9099 | * not modify! |
| 9100 | */ |
| 9101 | public Intent getIntent() { |
| 9102 | return mIntent; |
| 9103 | } |
| 9104 | |
| 9105 | @Override |
| 9106 | public boolean equals(Object obj) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 9107 | if (obj instanceof FilterComparison) { |
| 9108 | Intent other = ((FilterComparison)obj).mIntent; |
| 9109 | return mIntent.filterEquals(other); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9110 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 9111 | return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9112 | } |
| 9113 | |
| 9114 | @Override |
| 9115 | public int hashCode() { |
| 9116 | return mHashCode; |
| 9117 | } |
| 9118 | } |
| 9119 | |
| 9120 | /** |
| 9121 | * Determine if two intents are the same for the purposes of intent |
| 9122 | * resolution (filtering). That is, if their action, data, type, |
| 9123 | * class, and categories are the same. This does <em>not</em> compare |
| 9124 | * any extra data included in the intents. |
| 9125 | * |
| 9126 | * @param other The other Intent to compare against. |
| 9127 | * |
| 9128 | * @return Returns true if action, data, type, class, and categories |
| 9129 | * are the same. |
| 9130 | */ |
| 9131 | public boolean filterEquals(Intent other) { |
| 9132 | if (other == null) { |
| 9133 | return false; |
| 9134 | } |
Christopher Tate | 63d9ae1 | 2014-06-19 19:07:26 -0700 | [diff] [blame] | 9135 | if (!Objects.equals(this.mAction, other.mAction)) return false; |
| 9136 | if (!Objects.equals(this.mData, other.mData)) return false; |
| 9137 | if (!Objects.equals(this.mType, other.mType)) return false; |
| 9138 | if (!Objects.equals(this.mPackage, other.mPackage)) return false; |
| 9139 | if (!Objects.equals(this.mComponent, other.mComponent)) return false; |
| 9140 | if (!Objects.equals(this.mCategories, other.mCategories)) return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9141 | |
| 9142 | return true; |
| 9143 | } |
| 9144 | |
| 9145 | /** |
| 9146 | * Generate hash code that matches semantics of filterEquals(). |
| 9147 | * |
| 9148 | * @return Returns the hash value of the action, data, type, class, and |
| 9149 | * categories. |
| 9150 | * |
| 9151 | * @see #filterEquals |
| 9152 | */ |
| 9153 | public int filterHashCode() { |
| 9154 | int code = 0; |
| 9155 | if (mAction != null) { |
| 9156 | code += mAction.hashCode(); |
| 9157 | } |
| 9158 | if (mData != null) { |
| 9159 | code += mData.hashCode(); |
| 9160 | } |
| 9161 | if (mType != null) { |
| 9162 | code += mType.hashCode(); |
| 9163 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9164 | if (mPackage != null) { |
| 9165 | code += mPackage.hashCode(); |
| 9166 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9167 | if (mComponent != null) { |
| 9168 | code += mComponent.hashCode(); |
| 9169 | } |
| 9170 | if (mCategories != null) { |
| 9171 | code += mCategories.hashCode(); |
| 9172 | } |
| 9173 | return code; |
| 9174 | } |
| 9175 | |
| 9176 | @Override |
| 9177 | public String toString() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 9178 | StringBuilder b = new StringBuilder(128); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9179 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9180 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9181 | toShortString(b, true, true, true, false); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9182 | b.append(" }"); |
| 9183 | |
| 9184 | return b.toString(); |
| 9185 | } |
| 9186 | |
| 9187 | /** @hide */ |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 9188 | public String toInsecureString() { |
| 9189 | StringBuilder b = new StringBuilder(128); |
| 9190 | |
| 9191 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9192 | toShortString(b, false, true, true, false); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 9193 | b.append(" }"); |
| 9194 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9195 | return b.toString(); |
| 9196 | } |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 9197 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9198 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9199 | public String toInsecureStringWithClip() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 9200 | StringBuilder b = new StringBuilder(128); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9201 | |
| 9202 | b.append("Intent { "); |
| 9203 | toShortString(b, false, true, true, true); |
| 9204 | b.append(" }"); |
| 9205 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 9206 | return b.toString(); |
| 9207 | } |
| 9208 | |
| 9209 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9210 | public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { |
| 9211 | StringBuilder b = new StringBuilder(128); |
| 9212 | toShortString(b, secure, comp, extras, clip); |
| 9213 | return b.toString(); |
| 9214 | } |
| 9215 | |
| 9216 | /** @hide */ |
| 9217 | public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, |
| 9218 | boolean clip) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9219 | boolean first = true; |
| 9220 | if (mAction != null) { |
| 9221 | b.append("act=").append(mAction); |
| 9222 | first = false; |
| 9223 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9224 | if (mCategories != null) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9225 | if (!first) { |
| 9226 | b.append(' '); |
| 9227 | } |
| 9228 | first = false; |
| 9229 | b.append("cat=["); |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 9230 | for (int i=0; i<mCategories.size(); i++) { |
| 9231 | if (i > 0) b.append(','); |
| 9232 | b.append(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9233 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9234 | b.append("]"); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9235 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9236 | if (mData != null) { |
| 9237 | if (!first) { |
| 9238 | b.append(' '); |
| 9239 | } |
| 9240 | first = false; |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 9241 | b.append("dat="); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 9242 | if (secure) { |
| 9243 | b.append(mData.toSafeString()); |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 9244 | } else { |
| 9245 | b.append(mData); |
| 9246 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9247 | } |
| 9248 | if (mType != null) { |
| 9249 | if (!first) { |
| 9250 | b.append(' '); |
| 9251 | } |
| 9252 | first = false; |
| 9253 | b.append("typ=").append(mType); |
| 9254 | } |
| 9255 | if (mFlags != 0) { |
| 9256 | if (!first) { |
| 9257 | b.append(' '); |
| 9258 | } |
| 9259 | first = false; |
| 9260 | b.append("flg=0x").append(Integer.toHexString(mFlags)); |
| 9261 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9262 | if (mPackage != null) { |
| 9263 | if (!first) { |
| 9264 | b.append(' '); |
| 9265 | } |
| 9266 | first = false; |
| 9267 | b.append("pkg=").append(mPackage); |
| 9268 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9269 | if (comp && mComponent != null) { |
| 9270 | if (!first) { |
| 9271 | b.append(' '); |
| 9272 | } |
| 9273 | first = false; |
| 9274 | b.append("cmp=").append(mComponent.flattenToShortString()); |
| 9275 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 9276 | if (mSourceBounds != null) { |
| 9277 | if (!first) { |
| 9278 | b.append(' '); |
| 9279 | } |
| 9280 | first = false; |
| 9281 | b.append("bnds=").append(mSourceBounds.toShortString()); |
| 9282 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9283 | if (mClipData != null) { |
| 9284 | if (!first) { |
| 9285 | b.append(' '); |
| 9286 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 9287 | b.append("clip={"); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9288 | if (clip) { |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9289 | mClipData.toShortString(b); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9290 | } else { |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 9291 | if (mClipData.getDescription() != null) { |
| 9292 | first = !mClipData.getDescription().toShortStringTypesOnly(b); |
| 9293 | } else { |
| 9294 | first = true; |
| 9295 | } |
| 9296 | mClipData.toShortStringShortItems(b, first); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9297 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 9298 | first = false; |
| 9299 | b.append('}'); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9300 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9301 | if (extras && mExtras != null) { |
| 9302 | if (!first) { |
| 9303 | b.append(' '); |
| 9304 | } |
| 9305 | first = false; |
| 9306 | b.append("(has extras)"); |
| 9307 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9308 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
| 9309 | if (!first) { |
| 9310 | b.append(' '); |
| 9311 | } |
| 9312 | first = false; |
| 9313 | b.append("u=").append(mContentUserHint); |
| 9314 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9315 | if (mSelector != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9316 | b.append(" sel="); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9317 | mSelector.toShortString(b, secure, comp, extras, clip); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9318 | b.append("}"); |
| 9319 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9320 | } |
| 9321 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9322 | /** |
| 9323 | * Call {@link #toUri} with 0 flags. |
| 9324 | * @deprecated Use {@link #toUri} instead. |
| 9325 | */ |
| 9326 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9327 | public String toURI() { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9328 | return toUri(0); |
| 9329 | } |
| 9330 | |
| 9331 | /** |
| 9332 | * Convert this Intent into a String holding a URI representation of it. |
| 9333 | * The returned URI string has been properly URI encoded, so it can be |
| 9334 | * used with {@link Uri#parse Uri.parse(String)}. The URI contains the |
| 9335 | * Intent's data as the base URI, with an additional fragment describing |
| 9336 | * the action, categories, type, flags, package, component, and extras. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 9337 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9338 | * <p>You can convert the returned string back to an Intent with |
| 9339 | * {@link #getIntent}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 9340 | * |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 9341 | * @param flags Additional operating flags. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 9342 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9343 | * @return Returns a URI encoding URI string describing the entire contents |
| 9344 | * of the Intent. |
| 9345 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 9346 | public String toUri(@UriFlags int flags) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 9347 | StringBuilder uri = new StringBuilder(128); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9348 | if ((flags&URI_ANDROID_APP_SCHEME) != 0) { |
| 9349 | if (mPackage == null) { |
| 9350 | throw new IllegalArgumentException( |
| 9351 | "Intent must include an explicit package name to build an android-app: " |
| 9352 | + this); |
| 9353 | } |
| 9354 | uri.append("android-app://"); |
| 9355 | uri.append(mPackage); |
| 9356 | String scheme = null; |
| 9357 | if (mData != null) { |
| 9358 | scheme = mData.getScheme(); |
| 9359 | if (scheme != null) { |
| 9360 | uri.append('/'); |
| 9361 | uri.append(scheme); |
| 9362 | String authority = mData.getEncodedAuthority(); |
| 9363 | if (authority != null) { |
| 9364 | uri.append('/'); |
| 9365 | uri.append(authority); |
| 9366 | String path = mData.getEncodedPath(); |
| 9367 | if (path != null) { |
| 9368 | uri.append(path); |
| 9369 | } |
| 9370 | String queryParams = mData.getEncodedQuery(); |
| 9371 | if (queryParams != null) { |
| 9372 | uri.append('?'); |
| 9373 | uri.append(queryParams); |
| 9374 | } |
| 9375 | String fragment = mData.getEncodedFragment(); |
| 9376 | if (fragment != null) { |
| 9377 | uri.append('#'); |
| 9378 | uri.append(fragment); |
| 9379 | } |
| 9380 | } |
| 9381 | } |
| 9382 | } |
| 9383 | toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, |
| 9384 | mPackage, flags); |
| 9385 | return uri.toString(); |
| 9386 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9387 | String scheme = null; |
| 9388 | if (mData != null) { |
| 9389 | String data = mData.toString(); |
| 9390 | if ((flags&URI_INTENT_SCHEME) != 0) { |
| 9391 | final int N = data.length(); |
| 9392 | for (int i=0; i<N; i++) { |
| 9393 | char c = data.charAt(i); |
| 9394 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') |
| 9395 | || c == '.' || c == '-') { |
| 9396 | continue; |
| 9397 | } |
| 9398 | if (c == ':' && i > 0) { |
| 9399 | // Valid scheme. |
| 9400 | scheme = data.substring(0, i); |
| 9401 | uri.append("intent:"); |
| 9402 | data = data.substring(i+1); |
| 9403 | break; |
| 9404 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 9405 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9406 | // No scheme. |
| 9407 | break; |
| 9408 | } |
| 9409 | } |
| 9410 | uri.append(data); |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 9411 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9412 | } else if ((flags&URI_INTENT_SCHEME) != 0) { |
| 9413 | uri.append("intent:"); |
| 9414 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9415 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9416 | toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9417 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9418 | return uri.toString(); |
| 9419 | } |
| 9420 | |
| 9421 | private void toUriFragment(StringBuilder uri, String scheme, String defAction, |
| 9422 | String defPackage, int flags) { |
| 9423 | StringBuilder frag = new StringBuilder(128); |
| 9424 | |
| 9425 | toUriInner(frag, scheme, defAction, defPackage, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9426 | if (mSelector != null) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 9427 | frag.append("SEL;"); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9428 | // Note that for now we are not going to try to handle the |
| 9429 | // data part; not clear how to represent this as a URI, and |
| 9430 | // not much utility in it. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9431 | mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, |
| 9432 | null, null, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9433 | } |
| 9434 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9435 | if (frag.length() > 0) { |
| 9436 | uri.append("#Intent;"); |
| 9437 | uri.append(frag); |
| 9438 | uri.append("end"); |
| 9439 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9440 | } |
| 9441 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9442 | private void toUriInner(StringBuilder uri, String scheme, String defAction, |
| 9443 | String defPackage, int flags) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9444 | if (scheme != null) { |
| 9445 | uri.append("scheme=").append(scheme).append(';'); |
| 9446 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9447 | if (mAction != null && !mAction.equals(defAction)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9448 | uri.append("action=").append(Uri.encode(mAction)).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9449 | } |
| 9450 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 9451 | for (int i=0; i<mCategories.size(); i++) { |
| 9452 | uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9453 | } |
| 9454 | } |
| 9455 | if (mType != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9456 | uri.append("type=").append(Uri.encode(mType, "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9457 | } |
| 9458 | if (mFlags != 0) { |
| 9459 | uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); |
| 9460 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 9461 | if (mPackage != null && !mPackage.equals(defPackage)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9462 | uri.append("package=").append(Uri.encode(mPackage)).append(';'); |
| 9463 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9464 | if (mComponent != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9465 | uri.append("component=").append(Uri.encode( |
| 9466 | mComponent.flattenToShortString(), "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9467 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 9468 | if (mSourceBounds != null) { |
| 9469 | uri.append("sourceBounds=") |
| 9470 | .append(Uri.encode(mSourceBounds.flattenToString())) |
| 9471 | .append(';'); |
| 9472 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9473 | if (mExtras != null) { |
| 9474 | for (String key : mExtras.keySet()) { |
| 9475 | final Object value = mExtras.get(key); |
| 9476 | char entryType = |
| 9477 | value instanceof String ? 'S' : |
| 9478 | value instanceof Boolean ? 'B' : |
| 9479 | value instanceof Byte ? 'b' : |
| 9480 | value instanceof Character ? 'c' : |
| 9481 | value instanceof Double ? 'd' : |
| 9482 | value instanceof Float ? 'f' : |
| 9483 | value instanceof Integer ? 'i' : |
| 9484 | value instanceof Long ? 'l' : |
| 9485 | value instanceof Short ? 's' : |
| 9486 | '\0'; |
| 9487 | |
| 9488 | if (entryType != '\0') { |
| 9489 | uri.append(entryType); |
| 9490 | uri.append('.'); |
| 9491 | uri.append(Uri.encode(key)); |
| 9492 | uri.append('='); |
| 9493 | uri.append(Uri.encode(value.toString())); |
| 9494 | uri.append(';'); |
| 9495 | } |
| 9496 | } |
| 9497 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9498 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 9499 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9500 | public int describeContents() { |
| 9501 | return (mExtras != null) ? mExtras.describeContents() : 0; |
| 9502 | } |
| 9503 | |
| 9504 | public void writeToParcel(Parcel out, int flags) { |
| 9505 | out.writeString(mAction); |
| 9506 | Uri.writeToParcel(out, mData); |
| 9507 | out.writeString(mType); |
| 9508 | out.writeInt(mFlags); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9509 | out.writeString(mPackage); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9510 | ComponentName.writeToParcel(mComponent, out); |
| 9511 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 9512 | if (mSourceBounds != null) { |
| 9513 | out.writeInt(1); |
| 9514 | mSourceBounds.writeToParcel(out, flags); |
| 9515 | } else { |
| 9516 | out.writeInt(0); |
| 9517 | } |
| 9518 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9519 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 9520 | final int N = mCategories.size(); |
| 9521 | out.writeInt(N); |
| 9522 | for (int i=0; i<N; i++) { |
| 9523 | out.writeString(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9524 | } |
| 9525 | } else { |
| 9526 | out.writeInt(0); |
| 9527 | } |
| 9528 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9529 | if (mSelector != null) { |
| 9530 | out.writeInt(1); |
| 9531 | mSelector.writeToParcel(out, flags); |
| 9532 | } else { |
| 9533 | out.writeInt(0); |
| 9534 | } |
| 9535 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9536 | if (mClipData != null) { |
| 9537 | out.writeInt(1); |
| 9538 | mClipData.writeToParcel(out, flags); |
| 9539 | } else { |
| 9540 | out.writeInt(0); |
| 9541 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9542 | out.writeInt(mContentUserHint); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9543 | out.writeBundle(mExtras); |
| 9544 | } |
| 9545 | |
| 9546 | public static final Parcelable.Creator<Intent> CREATOR |
| 9547 | = new Parcelable.Creator<Intent>() { |
| 9548 | public Intent createFromParcel(Parcel in) { |
| 9549 | return new Intent(in); |
| 9550 | } |
| 9551 | public Intent[] newArray(int size) { |
| 9552 | return new Intent[size]; |
| 9553 | } |
| 9554 | }; |
| 9555 | |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 9556 | /** @hide */ |
| 9557 | protected Intent(Parcel in) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9558 | readFromParcel(in); |
| 9559 | } |
| 9560 | |
| 9561 | public void readFromParcel(Parcel in) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 9562 | setAction(in.readString()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9563 | mData = Uri.CREATOR.createFromParcel(in); |
| 9564 | mType = in.readString(); |
| 9565 | mFlags = in.readInt(); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9566 | mPackage = in.readString(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9567 | mComponent = ComponentName.readFromParcel(in); |
| 9568 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 9569 | if (in.readInt() != 0) { |
| 9570 | mSourceBounds = Rect.CREATOR.createFromParcel(in); |
| 9571 | } |
| 9572 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9573 | int N = in.readInt(); |
| 9574 | if (N > 0) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 9575 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9576 | int i; |
| 9577 | for (i=0; i<N; i++) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 9578 | mCategories.add(in.readString().intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9579 | } |
| 9580 | } else { |
| 9581 | mCategories = null; |
| 9582 | } |
| 9583 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9584 | if (in.readInt() != 0) { |
| 9585 | mSelector = new Intent(in); |
| 9586 | } |
| 9587 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9588 | if (in.readInt() != 0) { |
| 9589 | mClipData = new ClipData(in); |
| 9590 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9591 | mContentUserHint = in.readInt(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9592 | mExtras = in.readBundle(); |
| 9593 | } |
| 9594 | |
| 9595 | /** |
| 9596 | * Parses the "intent" element (and its children) from XML and instantiates |
| 9597 | * an Intent object. The given XML parser should be located at the tag |
| 9598 | * where parsing should start (often named "intent"), from which the |
| 9599 | * basic action, data, type, and package and class name will be |
| 9600 | * retrieved. The function will then parse in to any child elements, |
| 9601 | * looking for <category android:name="xxx"> tags to add categories and |
| 9602 | * <extra android:name="xxx" android:value="yyy"> to attach extra data |
| 9603 | * to the intent. |
| 9604 | * |
| 9605 | * @param resources The Resources to use when inflating resources. |
| 9606 | * @param parser The XML parser pointing at an "intent" tag. |
| 9607 | * @param attrs The AttributeSet interface for retrieving extended |
| 9608 | * attribute data at the current <var>parser</var> location. |
| 9609 | * @return An Intent object matching the XML data. |
| 9610 | * @throws XmlPullParserException If there was an XML parsing error. |
| 9611 | * @throws IOException If there was an I/O error. |
| 9612 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 9613 | public static @NonNull Intent parseIntent(@NonNull Resources resources, |
| 9614 | @NonNull XmlPullParser parser, AttributeSet attrs) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9615 | throws XmlPullParserException, IOException { |
| 9616 | Intent intent = new Intent(); |
| 9617 | |
| 9618 | TypedArray sa = resources.obtainAttributes(attrs, |
| 9619 | com.android.internal.R.styleable.Intent); |
| 9620 | |
| 9621 | intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); |
| 9622 | |
| 9623 | String data = sa.getString(com.android.internal.R.styleable.Intent_data); |
| 9624 | String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); |
| 9625 | intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); |
| 9626 | |
| 9627 | String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); |
| 9628 | String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); |
| 9629 | if (packageName != null && className != null) { |
| 9630 | intent.setComponent(new ComponentName(packageName, className)); |
| 9631 | } |
| 9632 | |
| 9633 | sa.recycle(); |
| 9634 | |
| 9635 | int outerDepth = parser.getDepth(); |
| 9636 | int type; |
| 9637 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 9638 | && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { |
| 9639 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 9640 | continue; |
| 9641 | } |
| 9642 | |
| 9643 | String nodeName = parser.getName(); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9644 | if (nodeName.equals(TAG_CATEGORIES)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9645 | sa = resources.obtainAttributes(attrs, |
| 9646 | com.android.internal.R.styleable.IntentCategory); |
| 9647 | String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); |
| 9648 | sa.recycle(); |
| 9649 | |
| 9650 | if (cat != null) { |
| 9651 | intent.addCategory(cat); |
| 9652 | } |
| 9653 | XmlUtils.skipCurrentTag(parser); |
| 9654 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9655 | } else if (nodeName.equals(TAG_EXTRA)) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 9656 | if (intent.mExtras == null) { |
| 9657 | intent.mExtras = new Bundle(); |
| 9658 | } |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9659 | resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 9660 | XmlUtils.skipCurrentTag(parser); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9661 | |
| 9662 | } else { |
| 9663 | XmlUtils.skipCurrentTag(parser); |
| 9664 | } |
| 9665 | } |
| 9666 | |
| 9667 | return intent; |
| 9668 | } |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9669 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9670 | /** @hide */ |
| 9671 | public void saveToXml(XmlSerializer out) throws IOException { |
| 9672 | if (mAction != null) { |
| 9673 | out.attribute(null, ATTR_ACTION, mAction); |
| 9674 | } |
| 9675 | if (mData != null) { |
| 9676 | out.attribute(null, ATTR_DATA, mData.toString()); |
| 9677 | } |
| 9678 | if (mType != null) { |
| 9679 | out.attribute(null, ATTR_TYPE, mType); |
| 9680 | } |
| 9681 | if (mComponent != null) { |
| 9682 | out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); |
| 9683 | } |
| 9684 | out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); |
| 9685 | |
| 9686 | if (mCategories != null) { |
| 9687 | out.startTag(null, TAG_CATEGORIES); |
| 9688 | for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { |
| 9689 | out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); |
| 9690 | } |
Craig Mautner | 43e52ed | 2014-06-16 17:18:52 -0700 | [diff] [blame] | 9691 | out.endTag(null, TAG_CATEGORIES); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9692 | } |
| 9693 | } |
| 9694 | |
| 9695 | /** @hide */ |
| 9696 | public static Intent restoreFromXml(XmlPullParser in) throws IOException, |
| 9697 | XmlPullParserException { |
| 9698 | Intent intent = new Intent(); |
| 9699 | final int outerDepth = in.getDepth(); |
| 9700 | |
| 9701 | int attrCount = in.getAttributeCount(); |
| 9702 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 9703 | final String attrName = in.getAttributeName(attrNdx); |
| 9704 | final String attrValue = in.getAttributeValue(attrNdx); |
| 9705 | if (ATTR_ACTION.equals(attrName)) { |
| 9706 | intent.setAction(attrValue); |
| 9707 | } else if (ATTR_DATA.equals(attrName)) { |
| 9708 | intent.setData(Uri.parse(attrValue)); |
| 9709 | } else if (ATTR_TYPE.equals(attrName)) { |
| 9710 | intent.setType(attrValue); |
| 9711 | } else if (ATTR_COMPONENT.equals(attrName)) { |
| 9712 | intent.setComponent(ComponentName.unflattenFromString(attrValue)); |
| 9713 | } else if (ATTR_FLAGS.equals(attrName)) { |
Narayan Kamath | a09b4d2 | 2016-04-15 18:32:45 +0100 | [diff] [blame] | 9714 | intent.setFlags(Integer.parseInt(attrValue, 16)); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9715 | } else { |
| 9716 | Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName); |
| 9717 | } |
| 9718 | } |
| 9719 | |
| 9720 | int event; |
| 9721 | String name; |
| 9722 | while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && |
| 9723 | (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { |
| 9724 | if (event == XmlPullParser.START_TAG) { |
| 9725 | name = in.getName(); |
| 9726 | if (TAG_CATEGORIES.equals(name)) { |
| 9727 | attrCount = in.getAttributeCount(); |
| 9728 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 9729 | intent.addCategory(in.getAttributeValue(attrNdx)); |
| 9730 | } |
| 9731 | } else { |
| 9732 | Log.w("Intent", "restoreFromXml: unknown name=" + name); |
| 9733 | XmlUtils.skipCurrentTag(in); |
| 9734 | } |
| 9735 | } |
| 9736 | } |
| 9737 | |
| 9738 | return intent; |
| 9739 | } |
| 9740 | |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9741 | /** |
| 9742 | * Normalize a MIME data type. |
| 9743 | * |
| 9744 | * <p>A normalized MIME type has white-space trimmed, |
| 9745 | * content-type parameters removed, and is lower-case. |
| 9746 | * This aligns the type with Android best practices for |
| 9747 | * intent filtering. |
| 9748 | * |
| 9749 | * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". |
| 9750 | * "text/x-vCard" becomes "text/x-vcard". |
| 9751 | * |
| 9752 | * <p>All MIME types received from outside Android (such as user input, |
| 9753 | * or external sources like Bluetooth, NFC, or the Internet) should |
| 9754 | * be normalized before they are used to create an Intent. |
| 9755 | * |
| 9756 | * @param type MIME data type to normalize |
| 9757 | * @return normalized MIME data type, or null if the input was null |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 9758 | * @see #setType |
| 9759 | * @see #setTypeAndNormalize |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9760 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 9761 | public static @Nullable String normalizeMimeType(@Nullable String type) { |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9762 | if (type == null) { |
| 9763 | return null; |
| 9764 | } |
| 9765 | |
Elliott Hughes | cb64d43 | 2013-08-02 10:00:44 -0700 | [diff] [blame] | 9766 | type = type.trim().toLowerCase(Locale.ROOT); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9767 | |
| 9768 | final int semicolonIndex = type.indexOf(';'); |
| 9769 | if (semicolonIndex != -1) { |
| 9770 | type = type.substring(0, semicolonIndex); |
| 9771 | } |
| 9772 | return type; |
| 9773 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9774 | |
| 9775 | /** |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9776 | * Prepare this {@link Intent} to leave an app process. |
| 9777 | * |
| 9778 | * @hide |
| 9779 | */ |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9780 | public void prepareToLeaveProcess(Context context) { |
| 9781 | final boolean leavingPackage = (mComponent == null) |
| 9782 | || !Objects.equals(mComponent.getPackageName(), context.getPackageName()); |
| 9783 | prepareToLeaveProcess(leavingPackage); |
| 9784 | } |
| 9785 | |
| 9786 | /** |
| 9787 | * Prepare this {@link Intent} to leave an app process. |
| 9788 | * |
| 9789 | * @hide |
| 9790 | */ |
| 9791 | public void prepareToLeaveProcess(boolean leavingPackage) { |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9792 | setAllowFds(false); |
| 9793 | |
| 9794 | if (mSelector != null) { |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9795 | mSelector.prepareToLeaveProcess(leavingPackage); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9796 | } |
| 9797 | if (mClipData != null) { |
Jeff Sharkey | fb833f3 | 2016-12-01 14:59:59 -0700 | [diff] [blame] | 9798 | mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9799 | } |
| 9800 | |
Jeff Sharkey | c6fe23d | 2017-02-24 09:39:58 -0700 | [diff] [blame] | 9801 | if (mExtras != null && !mExtras.isParcelled()) { |
| 9802 | final Object intent = mExtras.get(Intent.EXTRA_INTENT); |
| 9803 | if (intent instanceof Intent) { |
| 9804 | ((Intent) intent).prepareToLeaveProcess(leavingPackage); |
| 9805 | } |
| 9806 | } |
| 9807 | |
Jeff Sharkey | a8b4278 | 2016-01-30 17:58:09 -0700 | [diff] [blame] | 9808 | if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() |
| 9809 | && leavingPackage) { |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9810 | switch (mAction) { |
| 9811 | case ACTION_MEDIA_REMOVED: |
| 9812 | case ACTION_MEDIA_UNMOUNTED: |
| 9813 | case ACTION_MEDIA_CHECKING: |
| 9814 | case ACTION_MEDIA_NOFS: |
| 9815 | case ACTION_MEDIA_MOUNTED: |
| 9816 | case ACTION_MEDIA_SHARED: |
| 9817 | case ACTION_MEDIA_UNSHARED: |
| 9818 | case ACTION_MEDIA_BAD_REMOVAL: |
| 9819 | case ACTION_MEDIA_UNMOUNTABLE: |
| 9820 | case ACTION_MEDIA_EJECT: |
| 9821 | case ACTION_MEDIA_SCANNER_STARTED: |
| 9822 | case ACTION_MEDIA_SCANNER_FINISHED: |
| 9823 | case ACTION_MEDIA_SCANNER_SCAN_FILE: |
Jeff Sharkey | 37355a9 | 2016-02-05 16:19:10 -0700 | [diff] [blame] | 9824 | case ACTION_PACKAGE_NEEDS_VERIFICATION: |
| 9825 | case ACTION_PACKAGE_VERIFIED: |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9826 | // Ignore legacy actions |
| 9827 | break; |
| 9828 | default: |
| 9829 | mData.checkFileUriExposed("Intent.getData()"); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9830 | } |
| 9831 | } |
Jeff Sharkey | fb833f3 | 2016-12-01 14:59:59 -0700 | [diff] [blame] | 9832 | |
| 9833 | if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() |
| 9834 | && leavingPackage) { |
| 9835 | switch (mAction) { |
| 9836 | case ACTION_PROVIDER_CHANGED: |
Makoto Onuki | 7d1911f | 2017-06-09 12:30:09 -0700 | [diff] [blame] | 9837 | case QuickContact.ACTION_QUICK_CONTACT: |
Jeff Sharkey | fb833f3 | 2016-12-01 14:59:59 -0700 | [diff] [blame] | 9838 | // Ignore actions that don't need to grant |
| 9839 | break; |
| 9840 | default: |
| 9841 | mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); |
| 9842 | } |
| 9843 | } |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9844 | } |
| 9845 | |
| 9846 | /** |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9847 | * @hide |
| 9848 | */ |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9849 | public void prepareToEnterProcess() { |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 9850 | // We just entered destination process, so we should be able to read all |
| 9851 | // parcelables inside. |
| 9852 | setDefusable(true); |
| 9853 | |
| 9854 | if (mSelector != null) { |
| 9855 | mSelector.prepareToEnterProcess(); |
| 9856 | } |
| 9857 | if (mClipData != null) { |
| 9858 | mClipData.prepareToEnterProcess(); |
| 9859 | } |
| 9860 | |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9861 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
Nicolas Prevot | c4fc00a | 2014-10-31 12:01:32 +0000 | [diff] [blame] | 9862 | if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { |
| 9863 | fixUris(mContentUserHint); |
| 9864 | mContentUserHint = UserHandle.USER_CURRENT; |
| 9865 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9866 | } |
| 9867 | } |
| 9868 | |
| 9869 | /** |
| 9870 | * @hide |
| 9871 | */ |
| 9872 | public void fixUris(int contentUserHint) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9873 | Uri data = getData(); |
| 9874 | if (data != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9875 | mData = maybeAddUserId(data, contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9876 | } |
| 9877 | if (mClipData != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9878 | mClipData.fixUris(contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9879 | } |
| 9880 | String action = getAction(); |
| 9881 | if (ACTION_SEND.equals(action)) { |
| 9882 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 9883 | if (stream != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9884 | putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9885 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9886 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9887 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 9888 | if (streams != null) { |
| 9889 | ArrayList<Uri> newStreams = new ArrayList<Uri>(); |
| 9890 | for (int i = 0; i < streams.size(); i++) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9891 | newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9892 | } |
| 9893 | putParcelableArrayListExtra(EXTRA_STREAM, newStreams); |
| 9894 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9895 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 9896 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 9897 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 9898 | final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 9899 | if (output != null) { |
| 9900 | putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); |
| 9901 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9902 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9903 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9904 | |
| 9905 | /** |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9906 | * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9907 | * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested |
| 9908 | * intents in {@link #ACTION_CHOOSER}. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9909 | * |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9910 | * @return Whether any contents were migrated. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9911 | * @hide |
| 9912 | */ |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9913 | public boolean migrateExtraStreamToClipData() { |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9914 | // Refuse to touch if extras already parcelled |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9915 | if (mExtras != null && mExtras.isParcelled()) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9916 | |
| 9917 | // Bail when someone already gave us ClipData |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9918 | if (getClipData() != null) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9919 | |
| 9920 | final String action = getAction(); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9921 | if (ACTION_CHOOSER.equals(action)) { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9922 | // Inspect contained intents to see if we need to migrate extras. We |
| 9923 | // don't promote ClipData to the parent, since ChooserActivity will |
| 9924 | // already start the picked item as the caller, and we can't combine |
| 9925 | // the flags in a safe way. |
| 9926 | |
| 9927 | boolean migrated = false; |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 9928 | try { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9929 | final Intent intent = getParcelableExtra(EXTRA_INTENT); |
| 9930 | if (intent != null) { |
| 9931 | migrated |= intent.migrateExtraStreamToClipData(); |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 9932 | } |
| 9933 | } catch (ClassCastException e) { |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9934 | } |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9935 | try { |
| 9936 | final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); |
| 9937 | if (intents != null) { |
| 9938 | for (int i = 0; i < intents.length; i++) { |
| 9939 | final Intent intent = (Intent) intents[i]; |
| 9940 | if (intent != null) { |
| 9941 | migrated |= intent.migrateExtraStreamToClipData(); |
| 9942 | } |
| 9943 | } |
| 9944 | } |
| 9945 | } catch (ClassCastException e) { |
| 9946 | } |
| 9947 | return migrated; |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9948 | |
| 9949 | } else if (ACTION_SEND.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9950 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9951 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 9952 | final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); |
| 9953 | final String htmlText = getStringExtra(EXTRA_HTML_TEXT); |
| 9954 | if (stream != null || text != null || htmlText != null) { |
| 9955 | final ClipData clipData = new ClipData( |
| 9956 | null, new String[] { getType() }, |
| 9957 | new ClipData.Item(text, htmlText, null, stream)); |
| 9958 | setClipData(clipData); |
| 9959 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9960 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9961 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9962 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9963 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9964 | |
| 9965 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9966 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9967 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 9968 | final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); |
| 9969 | final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); |
| 9970 | int num = -1; |
| 9971 | if (streams != null) { |
| 9972 | num = streams.size(); |
| 9973 | } |
| 9974 | if (texts != null) { |
| 9975 | if (num >= 0 && num != texts.size()) { |
| 9976 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9977 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9978 | } |
| 9979 | num = texts.size(); |
| 9980 | } |
| 9981 | if (htmlTexts != null) { |
| 9982 | if (num >= 0 && num != htmlTexts.size()) { |
| 9983 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9984 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9985 | } |
| 9986 | num = htmlTexts.size(); |
| 9987 | } |
| 9988 | if (num > 0) { |
| 9989 | final ClipData clipData = new ClipData( |
| 9990 | null, new String[] { getType() }, |
| 9991 | makeClipItem(streams, texts, htmlTexts, 0)); |
| 9992 | |
| 9993 | for (int i = 1; i < num; i++) { |
| 9994 | clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); |
| 9995 | } |
| 9996 | |
| 9997 | setClipData(clipData); |
| 9998 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9999 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 10000 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 10001 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 10002 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 10003 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 10004 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 10005 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 10006 | final Uri output; |
| 10007 | try { |
| 10008 | output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 10009 | } catch (ClassCastException e) { |
| 10010 | return false; |
| 10011 | } |
| 10012 | if (output != null) { |
| 10013 | setClipData(ClipData.newRawUri("", output)); |
| 10014 | addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); |
| 10015 | return true; |
| 10016 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 10017 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 10018 | |
| 10019 | return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 10020 | } |
Dianne Hackborn | ac4243f | 2012-04-13 17:32:18 -0700 | [diff] [blame] | 10021 | |
| 10022 | private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, |
| 10023 | ArrayList<String> htmlTexts, int which) { |
| 10024 | Uri uri = streams != null ? streams.get(which) : null; |
| 10025 | CharSequence text = texts != null ? texts.get(which) : null; |
| 10026 | String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; |
| 10027 | return new ClipData.Item(text, htmlText, null, uri); |
| 10028 | } |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 10029 | |
| 10030 | /** @hide */ |
| 10031 | public boolean isDocument() { |
| 10032 | return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; |
| 10033 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 10034 | } |