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 | |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 19 | import android.annotation.AnyRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 20 | import android.annotation.IntDef; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 21 | import android.annotation.SdkConstant; |
| 22 | import android.annotation.SdkConstant.SdkConstantType; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 23 | import android.annotation.SystemApi; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 24 | import android.content.pm.ActivityInfo; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 25 | import android.content.pm.ApplicationInfo; |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 26 | import android.content.pm.ComponentInfo; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 27 | import android.content.pm.PackageManager; |
| 28 | import android.content.pm.ResolveInfo; |
| 29 | import android.content.res.Resources; |
| 30 | import android.content.res.TypedArray; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 31 | import android.graphics.Rect; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 32 | import android.net.Uri; |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 33 | import android.os.Build; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 34 | import android.os.Bundle; |
| 35 | import android.os.IBinder; |
| 36 | import android.os.Parcel; |
| 37 | import android.os.Parcelable; |
Nicolas Prevot | c4fc00a | 2014-10-31 12:01:32 +0000 | [diff] [blame] | 38 | import android.os.Process; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 39 | import android.os.ResultReceiver; |
| 40 | import android.os.ShellCommand; |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 41 | import android.os.StrictMode; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 42 | import android.os.UserHandle; |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 43 | import android.provider.DocumentsContract; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 44 | import android.provider.DocumentsProvider; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 45 | import android.provider.MediaStore; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 46 | import android.provider.OpenableColumns; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 47 | import android.util.ArraySet; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 48 | import android.util.AttributeSet; |
| 49 | import android.util.Log; |
Dianne Hackborn | 2269d157 | 2010-02-24 19:54:22 -0800 | [diff] [blame] | 50 | import com.android.internal.util.XmlUtils; |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 51 | import org.xmlpull.v1.XmlPullParser; |
| 52 | import org.xmlpull.v1.XmlPullParserException; |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 53 | import org.xmlpull.v1.XmlSerializer; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 54 | |
| 55 | import java.io.IOException; |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 56 | import java.io.PrintWriter; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 57 | import java.io.Serializable; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 58 | import java.lang.annotation.Retention; |
| 59 | import java.lang.annotation.RetentionPolicy; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 60 | import java.net.URISyntaxException; |
| 61 | import java.util.ArrayList; |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 62 | import java.util.HashSet; |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 63 | import java.util.List; |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 64 | import java.util.Locale; |
Christopher Tate | 63d9ae1 | 2014-06-19 19:07:26 -0700 | [diff] [blame] | 65 | import java.util.Objects; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 66 | import java.util.Set; |
| 67 | |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 68 | import static android.content.ContentProvider.maybeAddUserId; |
| 69 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 70 | /** |
| 71 | * An intent is an abstract description of an operation to be performed. It |
| 72 | * can be used with {@link Context#startActivity(Intent) startActivity} to |
| 73 | * launch an {@link android.app.Activity}, |
| 74 | * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to |
| 75 | * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, |
| 76 | * and {@link android.content.Context#startService} or |
| 77 | * {@link android.content.Context#bindService} to communicate with a |
| 78 | * background {@link android.app.Service}. |
| 79 | * |
Joe Fernandez | b54e7a3 | 2011-10-03 15:09:50 -0700 | [diff] [blame] | 80 | * <p>An Intent provides a facility for performing late runtime binding between the code in |
| 81 | * 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] | 82 | * can be thought of as the glue between activities. It is basically a passive data structure |
| 83 | * holding an abstract description of an action to be performed.</p> |
Joe Fernandez | b54e7a3 | 2011-10-03 15:09:50 -0700 | [diff] [blame] | 84 | * |
| 85 | * <div class="special reference"> |
| 86 | * <h3>Developer Guides</h3> |
| 87 | * <p>For information about how to create and resolve intents, read the |
| 88 | * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> |
| 89 | * developer guide.</p> |
| 90 | * </div> |
| 91 | * |
| 92 | * <a name="IntentStructure"></a> |
| 93 | * <h3>Intent Structure</h3> |
| 94 | * <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] | 95 | * |
| 96 | * <ul> |
| 97 | * <li> <p><b>action</b> -- The general action to be performed, such as |
| 98 | * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, |
| 99 | * etc.</p> |
| 100 | * </li> |
| 101 | * <li> <p><b>data</b> -- The data to operate on, such as a person record |
| 102 | * in the contacts database, expressed as a {@link android.net.Uri}.</p> |
| 103 | * </li> |
| 104 | * </ul> |
| 105 | * |
| 106 | * |
| 107 | * <p>Some examples of action/data pairs are:</p> |
| 108 | * |
| 109 | * <ul> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 110 | * <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] | 111 | * information about the person whose identifier is "1".</p> |
| 112 | * </li> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 113 | * <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] | 114 | * the phone dialer with the person filled in.</p> |
| 115 | * </li> |
| 116 | * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display |
| 117 | * the phone dialer with the given number filled in. Note how the |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 118 | * 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] | 119 | * a particular URI.</p> |
| 120 | * </li> |
| 121 | * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display |
| 122 | * the phone dialer with the given number filled in.</p> |
| 123 | * </li> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 124 | * <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] | 125 | * information about the person whose identifier is "1".</p> |
| 126 | * </li> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 127 | * <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] | 128 | * a list of people, which the user can browse through. This example is a |
| 129 | * typical top-level entry into the Contacts application, showing you the |
| 130 | * 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] | 131 | * 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] | 132 | * being used to start an activity to display that person.</p> |
| 133 | * </li> |
| 134 | * </ul> |
| 135 | * |
| 136 | * <p>In addition to these primary attributes, there are a number of secondary |
| 137 | * attributes that you can also include with an intent:</p> |
| 138 | * |
| 139 | * <ul> |
| 140 | * <li> <p><b>category</b> -- Gives additional information about the action |
| 141 | * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should |
| 142 | * appear in the Launcher as a top-level application, while |
| 143 | * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list |
| 144 | * of alternative actions the user can perform on a piece of data.</p> |
| 145 | * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the |
| 146 | * intent data. Normally the type is inferred from the data itself. |
| 147 | * By setting this attribute, you disable that evaluation and force |
| 148 | * an explicit type.</p> |
| 149 | * <li> <p><b>component</b> -- Specifies an explicit name of a component |
| 150 | * class to use for the intent. Normally this is determined by looking |
| 151 | * at the other information in the intent (the action, data/type, and |
| 152 | * categories) and matching that with a component that can handle it. |
| 153 | * If this attribute is set then none of the evaluation is performed, |
| 154 | * and this component is used exactly as is. By specifying this attribute, |
| 155 | * all of the other Intent attributes become optional.</p> |
| 156 | * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. |
| 157 | * This can be used to provide extended information to the component. |
| 158 | * For example, if we have a action to send an e-mail message, we could |
| 159 | * also include extra pieces of data here to supply a subject, body, |
| 160 | * etc.</p> |
| 161 | * </ul> |
| 162 | * |
| 163 | * <p>Here are some examples of other operations you can specify as intents |
| 164 | * using these additional parameters:</p> |
| 165 | * |
| 166 | * <ul> |
| 167 | * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- |
| 168 | * Launch the home screen.</p> |
| 169 | * </li> |
| 170 | * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type |
| 171 | * <i>{@link android.provider.Contacts.Phones#CONTENT_URI |
| 172 | * vnd.android.cursor.item/phone}</i></b> |
| 173 | * -- Display the list of people's phone numbers, allowing the user to |
| 174 | * browse through them and pick one and return it to the parent activity.</p> |
| 175 | * </li> |
| 176 | * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type |
| 177 | * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> |
| 178 | * -- Display all pickers for data that can be opened with |
| 179 | * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, |
| 180 | * allowing the user to pick one of them and then some data inside of it |
| 181 | * and returning the resulting URI to the caller. This can be used, |
| 182 | * for example, in an e-mail application to allow the user to pick some |
| 183 | * data to include as an attachment.</p> |
| 184 | * </li> |
| 185 | * </ul> |
| 186 | * |
| 187 | * <p>There are a variety of standard Intent action and category constants |
| 188 | * defined in the Intent class, but applications can also define their own. |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 189 | * 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] | 190 | * example, the standard {@link #ACTION_VIEW} is called |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 191 | * "android.intent.action.VIEW".</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 192 | * |
| 193 | * <p>Put together, the set of actions, data types, categories, and extra data |
| 194 | * defines a language for the system allowing for the expression of phrases |
| 195 | * such as "call john smith's cell". As applications are added to the system, |
| 196 | * they can extend this language by adding new actions, types, and categories, or |
| 197 | * they can modify the behavior of existing phrases by supplying their own |
| 198 | * activities that handle them.</p> |
| 199 | * |
| 200 | * <a name="IntentResolution"></a> |
| 201 | * <h3>Intent Resolution</h3> |
| 202 | * |
| 203 | * <p>There are two primary forms of intents you will use. |
| 204 | * |
| 205 | * <ul> |
| 206 | * <li> <p><b>Explicit Intents</b> have specified a component (via |
| 207 | * {@link #setComponent} or {@link #setClass}), which provides the exact |
| 208 | * class to be run. Often these will not include any other information, |
| 209 | * simply being a way for an application to launch various internal |
| 210 | * activities it has as the user interacts with the application. |
| 211 | * |
| 212 | * <li> <p><b>Implicit Intents</b> have not specified a component; |
| 213 | * instead, they must include enough information for the system to |
| 214 | * determine which of the available components is best to run for that |
| 215 | * intent. |
| 216 | * </ul> |
| 217 | * |
| 218 | * <p>When using implicit intents, given such an arbitrary intent we need to |
| 219 | * know what to do with it. This is handled by the process of <em>Intent |
| 220 | * resolution</em>, which maps an Intent to an {@link android.app.Activity}, |
| 221 | * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or |
| 222 | * more activities/receivers) that can handle it.</p> |
| 223 | * |
| 224 | * <p>The intent resolution mechanism basically revolves around matching an |
| 225 | * Intent against all of the <intent-filter> descriptions in the |
| 226 | * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} |
| 227 | * objects explicitly registered with {@link Context#registerReceiver}.) More |
| 228 | * details on this can be found in the documentation on the {@link |
| 229 | * IntentFilter} class.</p> |
| 230 | * |
| 231 | * <p>There are three pieces of information in the Intent that are used for |
| 232 | * resolution: the action, type, and category. Using this information, a query |
| 233 | * is done on the {@link PackageManager} for a component that can handle the |
| 234 | * intent. The appropriate component is determined based on the intent |
| 235 | * information supplied in the <code>AndroidManifest.xml</code> file as |
| 236 | * follows:</p> |
| 237 | * |
| 238 | * <ul> |
| 239 | * <li> <p>The <b>action</b>, if given, must be listed by the component as |
| 240 | * one it handles.</p> |
| 241 | * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not |
| 242 | * already supplied in the Intent. Like the action, if a type is |
| 243 | * included in the intent (either explicitly or implicitly in its |
| 244 | * data), then this must be listed by the component as one it handles.</p> |
| 245 | * <li> For data that is not a <code>content:</code> URI and where no explicit |
| 246 | * type is included in the Intent, instead the <b>scheme</b> of the |
| 247 | * intent data (such as <code>http:</code> or <code>mailto:</code>) is |
| 248 | * considered. Again like the action, if we are matching a scheme it |
| 249 | * must be listed by the component as one it can handle. |
| 250 | * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed |
| 251 | * by the activity as categories it handles. That is, if you include |
| 252 | * the categories {@link #CATEGORY_LAUNCHER} and |
| 253 | * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components |
| 254 | * with an intent that lists <em>both</em> of those categories. |
| 255 | * Activities will very often need to support the |
| 256 | * {@link #CATEGORY_DEFAULT} so that they can be found by |
| 257 | * {@link Context#startActivity Context.startActivity()}.</p> |
| 258 | * </ul> |
| 259 | * |
| 260 | * <p>For example, consider the Note Pad sample application that |
| 261 | * allows user to browse through a list of notes data and view details about |
| 262 | * individual items. Text in italics indicate places were you would replace a |
| 263 | * name with one specific to your own package.</p> |
| 264 | * |
| 265 | * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 266 | * package="<i>com.android.notepad</i>"> |
| 267 | * <application android:icon="@drawable/app_notes" |
| 268 | * android:label="@string/app_name"> |
| 269 | * |
| 270 | * <provider class=".NotePadProvider" |
| 271 | * android:authorities="<i>com.google.provider.NotePad</i>" /> |
| 272 | * |
| 273 | * <activity class=".NotesList" android:label="@string/title_notes_list"> |
| 274 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 275 | * <action android:name="android.intent.action.MAIN" /> |
| 276 | * <category android:name="android.intent.category.LAUNCHER" /> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 277 | * </intent-filter> |
| 278 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 279 | * <action android:name="android.intent.action.VIEW" /> |
| 280 | * <action android:name="android.intent.action.EDIT" /> |
| 281 | * <action android:name="android.intent.action.PICK" /> |
| 282 | * <category android:name="android.intent.category.DEFAULT" /> |
| 283 | * <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] | 284 | * </intent-filter> |
| 285 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 286 | * <action android:name="android.intent.action.GET_CONTENT" /> |
| 287 | * <category android:name="android.intent.category.DEFAULT" /> |
| 288 | * <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] | 289 | * </intent-filter> |
| 290 | * </activity> |
| 291 | * |
| 292 | * <activity class=".NoteEditor" android:label="@string/title_note"> |
| 293 | * <intent-filter android:label="@string/resolve_edit"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 294 | * <action android:name="android.intent.action.VIEW" /> |
| 295 | * <action android:name="android.intent.action.EDIT" /> |
| 296 | * <category android:name="android.intent.category.DEFAULT" /> |
| 297 | * <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] | 298 | * </intent-filter> |
| 299 | * |
| 300 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 301 | * <action android:name="android.intent.action.INSERT" /> |
| 302 | * <category android:name="android.intent.category.DEFAULT" /> |
| 303 | * <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] | 304 | * </intent-filter> |
| 305 | * |
| 306 | * </activity> |
| 307 | * |
| 308 | * <activity class=".TitleEditor" android:label="@string/title_edit_title" |
| 309 | * android:theme="@android:style/Theme.Dialog"> |
| 310 | * <intent-filter android:label="@string/resolve_title"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 311 | * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> |
| 312 | * <category android:name="android.intent.category.DEFAULT" /> |
| 313 | * <category android:name="android.intent.category.ALTERNATIVE" /> |
| 314 | * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> |
| 315 | * <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] | 316 | * </intent-filter> |
| 317 | * </activity> |
| 318 | * |
| 319 | * </application> |
| 320 | * </manifest></pre> |
| 321 | * |
| 322 | * <p>The first activity, |
| 323 | * <code>com.android.notepad.NotesList</code>, serves as our main |
| 324 | * entry into the app. It can do three things as described by its three intent |
| 325 | * templates: |
| 326 | * <ol> |
| 327 | * <li><pre> |
| 328 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 329 | * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> |
| 330 | * <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] | 331 | * </intent-filter></pre> |
| 332 | * <p>This provides a top-level entry into the NotePad application: the standard |
| 333 | * MAIN action is a main entry point (not requiring any other information in |
| 334 | * the Intent), and the LAUNCHER category says that this entry point should be |
| 335 | * listed in the application launcher.</p> |
| 336 | * <li><pre> |
| 337 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 338 | * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> |
| 339 | * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> |
| 340 | * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> |
| 341 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 342 | * <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] | 343 | * </intent-filter></pre> |
| 344 | * <p>This declares the things that the activity can do on a directory of |
| 345 | * notes. The type being supported is given with the <type> tag, where |
| 346 | * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which |
| 347 | * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can |
| 348 | * be retrieved which holds our note pad data (<code>vnd.google.note</code>). |
| 349 | * The activity allows the user to view or edit the directory of data (via |
| 350 | * the VIEW and EDIT actions), or to pick a particular note and return it |
| 351 | * to the caller (via the PICK action). Note also the DEFAULT category |
| 352 | * supplied here: this is <em>required</em> for the |
| 353 | * {@link Context#startActivity Context.startActivity} method to resolve your |
| 354 | * activity when its component name is not explicitly specified.</p> |
| 355 | * <li><pre> |
| 356 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 357 | * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> |
| 358 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 359 | * <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] | 360 | * </intent-filter></pre> |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 361 | * <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] | 362 | * the user without needing to know where it came from. The data type |
| 363 | * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which |
| 364 | * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can |
| 365 | * be retrieved which contains our note pad data (<code>vnd.google.note</code>). |
| 366 | * The GET_CONTENT action is similar to the PICK action, where the activity |
| 367 | * will return to its caller a piece of data selected by the user. Here, |
| 368 | * however, the caller specifies the type of data they desire instead of |
| 369 | * the type of data the user will be picking from.</p> |
| 370 | * </ol> |
| 371 | * |
| 372 | * <p>Given these capabilities, the following intents will resolve to the |
| 373 | * NotesList activity:</p> |
| 374 | * |
| 375 | * <ul> |
| 376 | * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the |
| 377 | * activities that can be used as top-level entry points into an |
| 378 | * application.</p> |
| 379 | * <li> <p><b>{ action=android.app.action.MAIN, |
| 380 | * category=android.app.category.LAUNCHER }</b> is the actual intent |
| 381 | * used by the Launcher to populate its top-level list.</p> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 382 | * <li> <p><b>{ action=android.intent.action.VIEW |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 383 | * data=content://com.google.provider.NotePad/notes }</b> |
| 384 | * displays a list of all the notes under |
| 385 | * "content://com.google.provider.NotePad/notes", which |
| 386 | * the user can browse through and see the details on.</p> |
| 387 | * <li> <p><b>{ action=android.app.action.PICK |
| 388 | * data=content://com.google.provider.NotePad/notes }</b> |
| 389 | * provides a list of the notes under |
| 390 | * "content://com.google.provider.NotePad/notes", from which |
| 391 | * the user can pick a note whose data URL is returned back to the caller.</p> |
| 392 | * <li> <p><b>{ action=android.app.action.GET_CONTENT |
| 393 | * type=vnd.android.cursor.item/vnd.google.note }</b> |
| 394 | * is similar to the pick action, but allows the caller to specify the |
| 395 | * kind of data they want back so that the system can find the appropriate |
| 396 | * activity to pick something of that data type.</p> |
| 397 | * </ul> |
| 398 | * |
| 399 | * <p>The second activity, |
| 400 | * <code>com.android.notepad.NoteEditor</code>, shows the user a single |
| 401 | * note entry and allows them to edit it. It can do two things as described |
| 402 | * by its two intent templates: |
| 403 | * <ol> |
| 404 | * <li><pre> |
| 405 | * <intent-filter android:label="@string/resolve_edit"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 406 | * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> |
| 407 | * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> |
| 408 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 409 | * <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] | 410 | * </intent-filter></pre> |
| 411 | * <p>The first, primary, purpose of this activity is to let the user interact |
| 412 | * with a single note, as decribed by the MIME type |
| 413 | * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can |
| 414 | * either VIEW a note or allow the user to EDIT it. Again we support the |
| 415 | * DEFAULT category to allow the activity to be launched without explicitly |
| 416 | * specifying its component.</p> |
| 417 | * <li><pre> |
| 418 | * <intent-filter> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 419 | * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> |
| 420 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 421 | * <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] | 422 | * </intent-filter></pre> |
| 423 | * <p>The secondary use of this activity is to insert a new note entry into |
| 424 | * an existing directory of notes. This is used when the user creates a new |
| 425 | * note: the INSERT action is executed on the directory of notes, causing |
| 426 | * this activity to run and have the user create the new note data which |
| 427 | * it then adds to the content provider.</p> |
| 428 | * </ol> |
| 429 | * |
| 430 | * <p>Given these capabilities, the following intents will resolve to the |
| 431 | * NoteEditor activity:</p> |
| 432 | * |
| 433 | * <ul> |
Yusuf T. Mobile | 8ecb36e | 2009-07-10 14:13:29 -0700 | [diff] [blame] | 434 | * <li> <p><b>{ action=android.intent.action.VIEW |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 435 | * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> |
| 436 | * shows the user the content of note <var>{ID}</var>.</p> |
| 437 | * <li> <p><b>{ action=android.app.action.EDIT |
| 438 | * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> |
| 439 | * allows the user to edit the content of note <var>{ID}</var>.</p> |
| 440 | * <li> <p><b>{ action=android.app.action.INSERT |
| 441 | * data=content://com.google.provider.NotePad/notes }</b> |
| 442 | * creates a new, empty note in the notes list at |
| 443 | * "content://com.google.provider.NotePad/notes" |
| 444 | * and allows the user to edit it. If they keep their changes, the URI |
| 445 | * of the newly created note is returned to the caller.</p> |
| 446 | * </ul> |
| 447 | * |
| 448 | * <p>The last activity, |
| 449 | * <code>com.android.notepad.TitleEditor</code>, allows the user to |
| 450 | * edit the title of a note. This could be implemented as a class that the |
| 451 | * application directly invokes (by explicitly setting its component in |
| 452 | * the Intent), but here we show a way you can publish alternative |
| 453 | * operations on existing data:</p> |
| 454 | * |
| 455 | * <pre> |
| 456 | * <intent-filter android:label="@string/resolve_title"> |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 457 | * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> |
| 458 | * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> |
| 459 | * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> |
| 460 | * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> |
| 461 | * <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] | 462 | * </intent-filter></pre> |
| 463 | * |
| 464 | * <p>In the single intent template here, we |
| 465 | * have created our own private action called |
| 466 | * <code>com.android.notepad.action.EDIT_TITLE</code> which means to |
| 467 | * edit the title of a note. It must be invoked on a specific note |
| 468 | * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous |
| 469 | * view and edit actions, but here displays and edits the title contained |
| 470 | * in the note data. |
| 471 | * |
| 472 | * <p>In addition to supporting the default category as usual, our title editor |
| 473 | * also supports two other standard categories: ALTERNATIVE and |
| 474 | * SELECTED_ALTERNATIVE. Implementing |
| 475 | * these categories allows others to find the special action it provides |
| 476 | * without directly knowing about it, through the |
| 477 | * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or |
| 478 | * more often to build dynamic menu items with |
| 479 | * {@link android.view.Menu#addIntentOptions}. Note that in the intent |
| 480 | * template here was also supply an explicit name for the template |
| 481 | * (via <code>android:label="@string/resolve_title"</code>) to better control |
| 482 | * what the user sees when presented with this activity as an alternative |
| 483 | * action to the data they are viewing. |
| 484 | * |
| 485 | * <p>Given these capabilities, the following intent will resolve to the |
| 486 | * TitleEditor activity:</p> |
| 487 | * |
| 488 | * <ul> |
| 489 | * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE |
| 490 | * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> |
| 491 | * displays and allows the user to edit the title associated |
| 492 | * with note <var>{ID}</var>.</p> |
| 493 | * </ul> |
| 494 | * |
| 495 | * <h3>Standard Activity Actions</h3> |
| 496 | * |
| 497 | * <p>These are the current standard actions that Intent defines for launching |
| 498 | * activities (usually through {@link Context#startActivity}. The most |
| 499 | * important, and by far most frequently used, are {@link #ACTION_MAIN} and |
| 500 | * {@link #ACTION_EDIT}. |
| 501 | * |
| 502 | * <ul> |
| 503 | * <li> {@link #ACTION_MAIN} |
| 504 | * <li> {@link #ACTION_VIEW} |
| 505 | * <li> {@link #ACTION_ATTACH_DATA} |
| 506 | * <li> {@link #ACTION_EDIT} |
| 507 | * <li> {@link #ACTION_PICK} |
| 508 | * <li> {@link #ACTION_CHOOSER} |
| 509 | * <li> {@link #ACTION_GET_CONTENT} |
| 510 | * <li> {@link #ACTION_DIAL} |
| 511 | * <li> {@link #ACTION_CALL} |
| 512 | * <li> {@link #ACTION_SEND} |
| 513 | * <li> {@link #ACTION_SENDTO} |
| 514 | * <li> {@link #ACTION_ANSWER} |
| 515 | * <li> {@link #ACTION_INSERT} |
| 516 | * <li> {@link #ACTION_DELETE} |
| 517 | * <li> {@link #ACTION_RUN} |
| 518 | * <li> {@link #ACTION_SYNC} |
| 519 | * <li> {@link #ACTION_PICK_ACTIVITY} |
| 520 | * <li> {@link #ACTION_SEARCH} |
| 521 | * <li> {@link #ACTION_WEB_SEARCH} |
| 522 | * <li> {@link #ACTION_FACTORY_TEST} |
| 523 | * </ul> |
| 524 | * |
| 525 | * <h3>Standard Broadcast Actions</h3> |
| 526 | * |
| 527 | * <p>These are the current standard actions that Intent defines for receiving |
| 528 | * broadcasts (usually through {@link Context#registerReceiver} or a |
| 529 | * <receiver> tag in a manifest). |
| 530 | * |
| 531 | * <ul> |
| 532 | * <li> {@link #ACTION_TIME_TICK} |
| 533 | * <li> {@link #ACTION_TIME_CHANGED} |
| 534 | * <li> {@link #ACTION_TIMEZONE_CHANGED} |
| 535 | * <li> {@link #ACTION_BOOT_COMPLETED} |
| 536 | * <li> {@link #ACTION_PACKAGE_ADDED} |
| 537 | * <li> {@link #ACTION_PACKAGE_CHANGED} |
| 538 | * <li> {@link #ACTION_PACKAGE_REMOVED} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 539 | * <li> {@link #ACTION_PACKAGE_RESTARTED} |
| 540 | * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 541 | * <li> {@link #ACTION_PACKAGES_SUSPENDED} |
| 542 | * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 543 | * <li> {@link #ACTION_UID_REMOVED} |
| 544 | * <li> {@link #ACTION_BATTERY_CHANGED} |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 545 | * <li> {@link #ACTION_POWER_CONNECTED} |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 546 | * <li> {@link #ACTION_POWER_DISCONNECTED} |
| 547 | * <li> {@link #ACTION_SHUTDOWN} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 548 | * </ul> |
| 549 | * |
| 550 | * <h3>Standard Categories</h3> |
| 551 | * |
| 552 | * <p>These are the current standard categories that can be used to further |
| 553 | * clarify an Intent via {@link #addCategory}. |
| 554 | * |
| 555 | * <ul> |
| 556 | * <li> {@link #CATEGORY_DEFAULT} |
| 557 | * <li> {@link #CATEGORY_BROWSABLE} |
| 558 | * <li> {@link #CATEGORY_TAB} |
| 559 | * <li> {@link #CATEGORY_ALTERNATIVE} |
| 560 | * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} |
| 561 | * <li> {@link #CATEGORY_LAUNCHER} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 562 | * <li> {@link #CATEGORY_INFO} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 563 | * <li> {@link #CATEGORY_HOME} |
| 564 | * <li> {@link #CATEGORY_PREFERENCE} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 565 | * <li> {@link #CATEGORY_TEST} |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 566 | * <li> {@link #CATEGORY_CAR_DOCK} |
| 567 | * <li> {@link #CATEGORY_DESK_DOCK} |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 568 | * <li> {@link #CATEGORY_LE_DESK_DOCK} |
| 569 | * <li> {@link #CATEGORY_HE_DESK_DOCK} |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 570 | * <li> {@link #CATEGORY_CAR_MODE} |
Patrick Dubroy | 6dabe24 | 2010-08-30 10:43:47 -0700 | [diff] [blame] | 571 | * <li> {@link #CATEGORY_APP_MARKET} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 572 | * </ul> |
| 573 | * |
| 574 | * <h3>Standard Extra Data</h3> |
| 575 | * |
| 576 | * <p>These are the current standard fields that can be used as extra data via |
| 577 | * {@link #putExtra}. |
| 578 | * |
| 579 | * <ul> |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 580 | * <li> {@link #EXTRA_ALARM_COUNT} |
| 581 | * <li> {@link #EXTRA_BCC} |
| 582 | * <li> {@link #EXTRA_CC} |
| 583 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} |
| 584 | * <li> {@link #EXTRA_DATA_REMOVED} |
| 585 | * <li> {@link #EXTRA_DOCK_STATE} |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 586 | * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} |
| 587 | * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 588 | * <li> {@link #EXTRA_DOCK_STATE_CAR} |
| 589 | * <li> {@link #EXTRA_DOCK_STATE_DESK} |
| 590 | * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} |
| 591 | * <li> {@link #EXTRA_DONT_KILL_APP} |
| 592 | * <li> {@link #EXTRA_EMAIL} |
| 593 | * <li> {@link #EXTRA_INITIAL_INTENTS} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 594 | * <li> {@link #EXTRA_INTENT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 595 | * <li> {@link #EXTRA_KEY_EVENT} |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 596 | * <li> {@link #EXTRA_ORIGINATING_URI} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 597 | * <li> {@link #EXTRA_PHONE_NUMBER} |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 598 | * <li> {@link #EXTRA_REFERRER} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 599 | * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} |
| 600 | * <li> {@link #EXTRA_REPLACING} |
| 601 | * <li> {@link #EXTRA_SHORTCUT_ICON} |
| 602 | * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} |
| 603 | * <li> {@link #EXTRA_SHORTCUT_INTENT} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 604 | * <li> {@link #EXTRA_STREAM} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 605 | * <li> {@link #EXTRA_SHORTCUT_NAME} |
| 606 | * <li> {@link #EXTRA_SUBJECT} |
| 607 | * <li> {@link #EXTRA_TEMPLATE} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 608 | * <li> {@link #EXTRA_TEXT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 609 | * <li> {@link #EXTRA_TITLE} |
| 610 | * <li> {@link #EXTRA_UID} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 611 | * </ul> |
| 612 | * |
| 613 | * <h3>Flags</h3> |
| 614 | * |
| 615 | * <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] | 616 | * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list |
| 617 | * of all possible flags. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 618 | */ |
Dianne Hackborn | ee0511d | 2009-12-21 18:08:13 -0800 | [diff] [blame] | 619 | public class Intent implements Parcelable, Cloneable { |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 620 | private static final String ATTR_ACTION = "action"; |
| 621 | private static final String TAG_CATEGORIES = "categories"; |
| 622 | private static final String ATTR_CATEGORY = "category"; |
| 623 | private static final String TAG_EXTRA = "extra"; |
| 624 | private static final String ATTR_TYPE = "type"; |
| 625 | private static final String ATTR_COMPONENT = "component"; |
| 626 | private static final String ATTR_DATA = "data"; |
| 627 | private static final String ATTR_FLAGS = "flags"; |
| 628 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 629 | // --------------------------------------------------------------------- |
| 630 | // --------------------------------------------------------------------- |
| 631 | // Standard intent activity actions (see action variable). |
| 632 | |
| 633 | /** |
| 634 | * Activity Action: Start as a main entry point, does not expect to |
| 635 | * receive data. |
| 636 | * <p>Input: nothing |
| 637 | * <p>Output: nothing |
| 638 | */ |
| 639 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 640 | 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] | 641 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 642 | /** |
| 643 | * Activity Action: Display the data to the user. This is the most common |
| 644 | * action performed on data -- it is the generic action you can use on |
| 645 | * a piece of data to get the most reasonable thing to occur. For example, |
| 646 | * when used on a contacts entry it will view the entry; when used on a |
| 647 | * mailto: URI it will bring up a compose window filled with the information |
| 648 | * supplied by the URI; when used with a tel: URI it will invoke the |
| 649 | * dialer. |
| 650 | * <p>Input: {@link #getData} is URI from which to retrieve data. |
| 651 | * <p>Output: nothing. |
| 652 | */ |
| 653 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 654 | 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] | 655 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 656 | /** |
| 657 | * A synonym for {@link #ACTION_VIEW}, the "standard" action that is |
| 658 | * performed on a piece of data. |
| 659 | */ |
| 660 | public static final String ACTION_DEFAULT = ACTION_VIEW; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 661 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 662 | /** |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 663 | * Activity Action: Quick view the data. Launches a quick viewer for |
| 664 | * a URI or a list of URIs. |
Tomasz Mikolajewski | fe02313 | 2016-03-10 17:42:35 +0900 | [diff] [blame] | 665 | * <p>Activities handling this intent action should handle the vast majority of |
| 666 | * MIME types rather than only specific ones. |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 667 | * <p>Input: {@link #getData} is a mandatory content URI of the item to |
| 668 | * preview. {@link #getClipData} contains an optional list of content URIs |
| 669 | * if there is more than one item to preview. {@link #EXTRA_INDEX} is an |
| 670 | * optional index of the URI in the clip data to show first. |
Steve McKay | c78bcb8 | 2015-07-31 14:35:22 -0700 | [diff] [blame] | 671 | * <p>Output: nothing. |
Steve McKay | c78bcb8 | 2015-07-31 14:35:22 -0700 | [diff] [blame] | 672 | */ |
| 673 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 674 | public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; |
| 675 | |
| 676 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 677 | * Used to indicate that some piece of data should be attached to some other |
| 678 | * place. For example, image data could be attached to a contact. It is up |
| 679 | * to the recipient to decide where the data should be attached; the intent |
| 680 | * does not specify the ultimate destination. |
| 681 | * <p>Input: {@link #getData} is URI of data to be attached. |
| 682 | * <p>Output: nothing. |
| 683 | */ |
| 684 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 685 | 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] | 686 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 687 | /** |
| 688 | * Activity Action: Provide explicit editable access to the given data. |
| 689 | * <p>Input: {@link #getData} is URI of data to be edited. |
| 690 | * <p>Output: nothing. |
| 691 | */ |
| 692 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 693 | 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] | 694 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 695 | /** |
| 696 | * Activity Action: Pick an existing item, or insert a new item, and then edit it. |
| 697 | * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. |
| 698 | * The extras can contain type specific data to pass through to the editing/creating |
| 699 | * activity. |
| 700 | * <p>Output: The URI of the item that was picked. This must be a content: |
| 701 | * URI so that any receiver can access it. |
| 702 | */ |
| 703 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 704 | 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] | 705 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 706 | /** |
| 707 | * Activity Action: Pick an item from the data, returning what was selected. |
| 708 | * <p>Input: {@link #getData} is URI containing a directory of data |
| 709 | * (vnd.android.cursor.dir/*) from which to pick an item. |
| 710 | * <p>Output: The URI of the item that was picked. |
| 711 | */ |
| 712 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 713 | 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] | 714 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 715 | /** |
| 716 | * Activity Action: Creates a shortcut. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 717 | * <p>Input: Nothing.</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 718 | * <p>Output: An Intent representing the shortcut. The intent must contain three |
| 719 | * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), |
| 720 | * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 721 | * (value: ShortcutIconResource).</p> |
| 722 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 723 | * @see #EXTRA_SHORTCUT_INTENT |
| 724 | * @see #EXTRA_SHORTCUT_NAME |
| 725 | * @see #EXTRA_SHORTCUT_ICON |
| 726 | * @see #EXTRA_SHORTCUT_ICON_RESOURCE |
| 727 | * @see android.content.Intent.ShortcutIconResource |
| 728 | */ |
| 729 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 730 | public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; |
| 731 | |
| 732 | /** |
| 733 | * The name of the extra used to define the Intent of a shortcut. |
| 734 | * |
| 735 | * @see #ACTION_CREATE_SHORTCUT |
| 736 | */ |
| 737 | public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; |
| 738 | /** |
| 739 | * The name of the extra used to define the name of a shortcut. |
| 740 | * |
| 741 | * @see #ACTION_CREATE_SHORTCUT |
| 742 | */ |
| 743 | public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; |
| 744 | /** |
| 745 | * The name of the extra used to define the icon, as a Bitmap, of a shortcut. |
| 746 | * |
| 747 | * @see #ACTION_CREATE_SHORTCUT |
| 748 | */ |
| 749 | public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; |
| 750 | /** |
| 751 | * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. |
| 752 | * |
| 753 | * @see #ACTION_CREATE_SHORTCUT |
| 754 | * @see android.content.Intent.ShortcutIconResource |
| 755 | */ |
| 756 | public static final String EXTRA_SHORTCUT_ICON_RESOURCE = |
| 757 | "android.intent.extra.shortcut.ICON_RESOURCE"; |
| 758 | |
| 759 | /** |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 760 | * An activity that provides a user interface for adjusting application preferences. |
| 761 | * Optional but recommended settings for all applications which have settings. |
| 762 | */ |
| 763 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 764 | public static final String ACTION_APPLICATION_PREFERENCES |
| 765 | = "android.intent.action.APPLICATION_PREFERENCES"; |
| 766 | |
| 767 | /** |
Sudheer Shanka | 80b6641 | 2016-04-06 18:31:10 -0700 | [diff] [blame] | 768 | * Activity Action: Launch an activity showing the app information. |
| 769 | * For applications which install other applications (such as app stores), it is recommended |
| 770 | * to handle this action for providing the app information to the user. |
| 771 | * |
| 772 | * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs |
| 773 | * to be displayed. |
| 774 | * <p>Output: Nothing. |
| 775 | */ |
| 776 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 777 | public static final String ACTION_SHOW_APP_INFO |
| 778 | = "android.intent.action.SHOW_APP_INFO"; |
| 779 | |
| 780 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 781 | * Represents a shortcut/live folder icon resource. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 782 | * |
| 783 | * @see Intent#ACTION_CREATE_SHORTCUT |
| 784 | * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 785 | * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER |
| 786 | * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 787 | */ |
| 788 | public static class ShortcutIconResource implements Parcelable { |
| 789 | /** |
| 790 | * The package name of the application containing the icon. |
| 791 | */ |
| 792 | public String packageName; |
| 793 | |
| 794 | /** |
| 795 | * The resource name of the icon, including package, name and type. |
| 796 | */ |
| 797 | public String resourceName; |
| 798 | |
| 799 | /** |
| 800 | * Creates a new ShortcutIconResource for the specified context and resource |
| 801 | * identifier. |
| 802 | * |
| 803 | * @param context The context of the application. |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 804 | * @param resourceId The resource identifier for the icon. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 805 | * @return A new ShortcutIconResource with the specified's context package name |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 806 | * and icon resource identifier.`` |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 807 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 808 | public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 809 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 810 | icon.packageName = context.getPackageName(); |
| 811 | icon.resourceName = context.getResources().getResourceName(resourceId); |
| 812 | return icon; |
| 813 | } |
| 814 | |
| 815 | /** |
| 816 | * Used to read a ShortcutIconResource from a Parcel. |
| 817 | */ |
| 818 | public static final Parcelable.Creator<ShortcutIconResource> CREATOR = |
| 819 | new Parcelable.Creator<ShortcutIconResource>() { |
| 820 | |
| 821 | public ShortcutIconResource createFromParcel(Parcel source) { |
| 822 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 823 | icon.packageName = source.readString(); |
| 824 | icon.resourceName = source.readString(); |
| 825 | return icon; |
| 826 | } |
| 827 | |
| 828 | public ShortcutIconResource[] newArray(int size) { |
| 829 | return new ShortcutIconResource[size]; |
| 830 | } |
| 831 | }; |
| 832 | |
| 833 | /** |
| 834 | * No special parcel contents. |
| 835 | */ |
| 836 | public int describeContents() { |
| 837 | return 0; |
| 838 | } |
| 839 | |
| 840 | public void writeToParcel(Parcel dest, int flags) { |
| 841 | dest.writeString(packageName); |
| 842 | dest.writeString(resourceName); |
| 843 | } |
| 844 | |
| 845 | @Override |
| 846 | public String toString() { |
| 847 | return resourceName; |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * Activity Action: Display an activity chooser, allowing the user to pick |
| 853 | * what they want to before proceeding. This can be used as an alternative |
| 854 | * to the standard activity picker that is displayed by the system when |
| 855 | * you try to start an activity with multiple possible matches, with these |
| 856 | * differences in behavior: |
| 857 | * <ul> |
| 858 | * <li>You can specify the title that will appear in the activity chooser. |
| 859 | * <li>The user does not have the option to make one of the matching |
| 860 | * activities a preferred activity, and all possible activities will |
| 861 | * always be shown even if one of them is currently marked as the |
| 862 | * preferred activity. |
| 863 | * </ul> |
| 864 | * <p> |
| 865 | * This action should be used when the user will naturally expect to |
| 866 | * select an activity in order to proceed. An example if when not to use |
| 867 | * it is when the user clicks on a "mailto:" link. They would naturally |
| 868 | * expect to go directly to their mail app, so startActivity() should be |
| 869 | * called directly: it will |
| 870 | * either launch the current preferred app, or put up a dialog allowing the |
| 871 | * user to pick an app to use and optionally marking that as preferred. |
| 872 | * <p> |
| 873 | * In contrast, if the user is selecting a menu item to send a picture |
| 874 | * they are viewing to someone else, there are many different things they |
| 875 | * may want to do at this point: send it through e-mail, upload it to a |
| 876 | * web service, etc. In this case the CHOOSER action should be used, to |
| 877 | * always present to the user a list of the things they can do, with a |
| 878 | * nice title given by the caller such as "Send this photo with:". |
| 879 | * <p> |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 880 | * If you need to grant URI permissions through a chooser, you must specify |
| 881 | * the permissions to be granted on the ACTION_CHOOSER Intent |
| 882 | * <em>in addition</em> to the EXTRA_INTENT inside. This means using |
| 883 | * {@link #setClipData} to specify the URIs to be granted as well as |
| 884 | * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 885 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. |
| 886 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 887 | * As a convenience, an Intent of this form can be created with the |
| 888 | * {@link #createChooser} function. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 889 | * <p> |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 890 | * 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] | 891 | * a {@link #EXTRA_INTENT} field containing the Intent being executed, |
| 892 | * and can optionally have a {@link #EXTRA_TITLE} field containing the |
| 893 | * title text to display in the chooser. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 894 | * <p> |
| 895 | * Output: Depends on the protocol of {@link #EXTRA_INTENT}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 896 | */ |
| 897 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 898 | public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; |
| 899 | |
| 900 | /** |
| 901 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 902 | * |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 903 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 904 | * target intent, also optionally supplying a title. If the target |
| 905 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 906 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 907 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 908 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
John Spurlock | 3390018 | 2014-01-02 11:04:18 -0500 | [diff] [blame] | 909 | * or a new ClipData built from {@link #getData()}. |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 910 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 911 | * @param target The Intent that the user will be selecting an activity |
| 912 | * to perform. |
| 913 | * @param title Optional title that will be displayed in the chooser. |
| 914 | * @return Return a new Intent object that you can hand to |
| 915 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 916 | * related methods. |
| 917 | */ |
| 918 | public static Intent createChooser(Intent target, CharSequence title) { |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 919 | return createChooser(target, title, null); |
| 920 | } |
| 921 | |
| 922 | /** |
| 923 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 924 | * |
| 925 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 926 | * target intent, also optionally supplying a title. If the target |
| 927 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 928 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 929 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 930 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
| 931 | * or a new ClipData built from {@link #getData()}.</p> |
| 932 | * |
| 933 | * <p>The caller may optionally supply an {@link IntentSender} to receive a callback |
| 934 | * when the user makes a choice. This can be useful if the calling application wants |
| 935 | * to remember the last chosen target and surface it as a more prominent or one-touch |
| 936 | * affordance elsewhere in the UI for next time.</p> |
| 937 | * |
| 938 | * @param target The Intent that the user will be selecting an activity |
| 939 | * to perform. |
| 940 | * @param title Optional title that will be displayed in the chooser. |
| 941 | * @param sender Optional IntentSender to be called when a choice is made. |
| 942 | * @return Return a new Intent object that you can hand to |
| 943 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 944 | * related methods. |
| 945 | */ |
| 946 | 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] | 947 | Intent intent = new Intent(ACTION_CHOOSER); |
| 948 | intent.putExtra(EXTRA_INTENT, target); |
| 949 | if (title != null) { |
| 950 | intent.putExtra(EXTRA_TITLE, title); |
| 951 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 952 | |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 953 | if (sender != null) { |
| 954 | intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); |
| 955 | } |
| 956 | |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 957 | // Migrate any clip data and flags from target. |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 958 | int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION |
| 959 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 960 | | FLAG_GRANT_PREFIX_URI_PERMISSION); |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 961 | if (permFlags != 0) { |
| 962 | ClipData targetClipData = target.getClipData(); |
| 963 | if (targetClipData == null && target.getData() != null) { |
| 964 | ClipData.Item item = new ClipData.Item(target.getData()); |
| 965 | String[] mimeTypes; |
| 966 | if (target.getType() != null) { |
| 967 | mimeTypes = new String[] { target.getType() }; |
| 968 | } else { |
| 969 | mimeTypes = new String[] { }; |
| 970 | } |
| 971 | targetClipData = new ClipData(null, mimeTypes, item); |
| 972 | } |
| 973 | if (targetClipData != null) { |
| 974 | intent.setClipData(targetClipData); |
| 975 | intent.addFlags(permFlags); |
| 976 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 977 | } |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 978 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 979 | return intent; |
| 980 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 981 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 982 | /** |
| 983 | * Activity Action: Allow the user to select a particular kind of data and |
| 984 | * return it. This is different than {@link #ACTION_PICK} in that here we |
| 985 | * 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] | 986 | * 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] | 987 | * 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] | 988 | * 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] | 989 | * etc. |
| 990 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 991 | * 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] | 992 | * of data, such as a person contact, you set the MIME type to the kind of |
| 993 | * data you want and launch it with {@link Context#startActivity(Intent)}. |
| 994 | * The system will then launch the best application to select that kind |
| 995 | * of data for you. |
| 996 | * <p> |
| 997 | * You may also be interested in any of a set of types of content the user |
| 998 | * can pick. For example, an e-mail application that wants to allow the |
| 999 | * user to add an attachment to an e-mail message can use this action to |
| 1000 | * bring up a list of all of the types of content the user can attach. |
| 1001 | * <p> |
| 1002 | * In this case, you should wrap the GET_CONTENT intent with a chooser |
| 1003 | * (through {@link #createChooser}), which will give the proper interface |
| 1004 | * for the user to pick how to send your data and allow you to specify |
| 1005 | * a prompt indicating what they are doing. You will usually specify a |
| 1006 | * broad MIME type (such as image/* or {@literal *}/*), resulting in a |
| 1007 | * broad range of content types the user can select from. |
| 1008 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1009 | * 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] | 1010 | * only pick from data that can be represented as a stream. This is |
| 1011 | * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. |
| 1012 | * <p> |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1013 | * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1014 | * the launched content chooser only returns results representing data that |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1015 | * is locally available on the device. For example, if this extra is set |
| 1016 | * to true then an image picker should not show any pictures that are available |
| 1017 | * from a remote server but not already on the local device (thus requiring |
| 1018 | * they be downloaded when opened). |
| 1019 | * <p> |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 1020 | * If the caller can handle multiple returned items (the user performing |
| 1021 | * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 1022 | * to indicate this. |
| 1023 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1024 | * Input: {@link #getType} is the desired MIME type to retrieve. Note |
| 1025 | * that no URI is supplied in the intent, as there are no constraints on |
| 1026 | * where the returned data originally comes from. You may also include the |
| 1027 | * {@link #CATEGORY_OPENABLE} if you can only accept data that can be |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1028 | * 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] | 1029 | * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to |
| 1030 | * allow the user to select multiple items. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1031 | * <p> |
| 1032 | * Output: The URI of the item that was picked. This must be a content: |
| 1033 | * URI so that any receiver can access it. |
| 1034 | */ |
| 1035 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1036 | public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; |
| 1037 | /** |
| 1038 | * Activity Action: Dial a number as specified by the data. This shows a |
| 1039 | * UI with the number being dialed, allowing the user to explicitly |
| 1040 | * initiate the call. |
| 1041 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1042 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1043 | * number. |
| 1044 | * <p>Output: nothing. |
| 1045 | */ |
| 1046 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1047 | public static final String ACTION_DIAL = "android.intent.action.DIAL"; |
| 1048 | /** |
| 1049 | * Activity Action: Perform a call to someone specified by the data. |
| 1050 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1051 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1052 | * number. |
| 1053 | * <p>Output: nothing. |
| 1054 | * |
| 1055 | * <p>Note: there will be restrictions on which applications can initiate a |
| 1056 | * call; most applications should use the {@link #ACTION_DIAL}. |
| 1057 | * <p>Note: this Intent <strong>cannot</strong> be used to call emergency |
| 1058 | * numbers. Applications can <strong>dial</strong> emergency numbers using |
| 1059 | * {@link #ACTION_DIAL}, however. |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1060 | * |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 1061 | * <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] | 1062 | * 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] | 1063 | * permission which is not granted, then attempting to use this action will |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1064 | * result in a {@link java.lang.SecurityException}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1065 | */ |
| 1066 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1067 | public static final String ACTION_CALL = "android.intent.action.CALL"; |
| 1068 | /** |
| 1069 | * Activity Action: Perform a call to an emergency number specified by the |
| 1070 | * data. |
| 1071 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1072 | * tel: URI of an explicit phone number. |
| 1073 | * <p>Output: nothing. |
| 1074 | * @hide |
| 1075 | */ |
| 1076 | public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; |
| 1077 | /** |
| 1078 | * Activity action: Perform a call to any number (emergency or not) |
| 1079 | * specified by the data. |
| 1080 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1081 | * tel: URI of an explicit phone number. |
| 1082 | * <p>Output: nothing. |
| 1083 | * @hide |
| 1084 | */ |
| 1085 | public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; |
| 1086 | /** |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 1087 | * Activity action: Activate the current SIM card. If SIM cards do not require activation, |
| 1088 | * sending this intent is a no-op. |
| 1089 | * <p>Input: No data should be specified. get*Extra may have an optional |
| 1090 | * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to |
| 1091 | * send the activation result. |
| 1092 | * <p>Output: nothing. |
| 1093 | * @hide |
| 1094 | */ |
| 1095 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1096 | public static final String ACTION_SIM_ACTIVATION_REQUEST = |
| 1097 | "android.intent.action.SIM_ACTIVATION_REQUEST"; |
| 1098 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1099 | * Activity Action: Send a message to someone specified by the data. |
| 1100 | * <p>Input: {@link #getData} is URI describing the target. |
| 1101 | * <p>Output: nothing. |
| 1102 | */ |
| 1103 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1104 | public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; |
| 1105 | /** |
| 1106 | * Activity Action: Deliver some data to someone else. Who the data is |
| 1107 | * being delivered to is not specified; it is up to the receiver of this |
| 1108 | * action to ask the user where the data should be sent. |
| 1109 | * <p> |
| 1110 | * When launching a SEND intent, you should usually wrap it in a chooser |
| 1111 | * (through {@link #createChooser}), which will give the proper interface |
| 1112 | * for the user to pick how to send your data and allow you to specify |
| 1113 | * a prompt indicating what they are doing. |
| 1114 | * <p> |
| 1115 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1116 | * get*Extra can have either a {@link #EXTRA_TEXT} |
| 1117 | * or {@link #EXTRA_STREAM} field, containing the data to be sent. If |
| 1118 | * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it |
| 1119 | * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* |
| 1120 | * 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] | 1121 | * handle generic data streams). If using {@link #EXTRA_TEXT}, you can |
| 1122 | * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve |
| 1123 | * your text with HTML formatting. |
| 1124 | * <p> |
| 1125 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1126 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1127 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1128 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1129 | * using this approach, you still must supply the same data through the |
| 1130 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1131 | * for compatibility with old applications. If you don't set a ClipData, |
| 1132 | * 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] | 1133 | * <p> |
Tomasz Mikolajewski | d8a2e19 | 2016-12-15 16:10:46 +0900 | [diff] [blame] | 1134 | * Starting from {@link android.os.Build.VERSION_CODES#O}, if |
| 1135 | * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in |
| 1136 | * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may |
| 1137 | * be openable only as asset typed files using |
| 1138 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
| 1139 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1140 | * Optional standard extras, which may be interpreted by some recipients as |
| 1141 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1142 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1143 | * <p> |
| 1144 | * Output: nothing. |
| 1145 | */ |
| 1146 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1147 | public static final String ACTION_SEND = "android.intent.action.SEND"; |
| 1148 | /** |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1149 | * Activity Action: Deliver multiple data to someone else. |
| 1150 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1151 | * Like {@link #ACTION_SEND}, except the data is multiple. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1152 | * <p> |
| 1153 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1154 | * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1155 | * #EXTRA_STREAM} field, containing the data to be sent. If using |
| 1156 | * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} |
| 1157 | * for clients to retrieve your text with HTML formatting. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1158 | * <p> |
Chih-Chung Chang | 5962d27 | 2009-09-04 14:36:01 +0800 | [diff] [blame] | 1159 | * Multiple types are supported, and receivers should handle mixed types |
| 1160 | * whenever possible. The right way for the receiver to check them is to |
| 1161 | * use the content resolver on each URI. The intent sender should try to |
| 1162 | * put the most concrete mime type in the intent type, but it can fall |
| 1163 | * back to {@literal <type>/*} or {@literal *}/* as needed. |
| 1164 | * <p> |
| 1165 | * e.g. if you are sending image/jpg and image/jpg, the intent's type can |
| 1166 | * be image/jpg, but if you are sending image/jpg and image/png, then the |
| 1167 | * intent's type should be image/*. |
| 1168 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1169 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1170 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1171 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1172 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1173 | * using this approach, you still must supply the same data through the |
| 1174 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1175 | * for compatibility with old applications. If you don't set a ClipData, |
| 1176 | * it will be copied there for you when calling {@link Context#startActivity(Intent)}. |
| 1177 | * <p> |
Tomasz Mikolajewski | d8a2e19 | 2016-12-15 16:10:46 +0900 | [diff] [blame] | 1178 | * Starting from {@link android.os.Build.VERSION_CODES#O}, if |
| 1179 | * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in |
| 1180 | * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may |
| 1181 | * be openable only as asset typed files using |
| 1182 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
| 1183 | * <p> |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1184 | * Optional standard extras, which may be interpreted by some recipients as |
| 1185 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1186 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1187 | * <p> |
| 1188 | * Output: nothing. |
| 1189 | */ |
| 1190 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1191 | public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; |
| 1192 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1193 | * Activity Action: Handle an incoming phone call. |
| 1194 | * <p>Input: nothing. |
| 1195 | * <p>Output: nothing. |
| 1196 | */ |
| 1197 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1198 | public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; |
| 1199 | /** |
| 1200 | * Activity Action: Insert an empty item into the given container. |
| 1201 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1202 | * in which to place the data. |
| 1203 | * <p>Output: URI of the new data that was created. |
| 1204 | */ |
| 1205 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1206 | public static final String ACTION_INSERT = "android.intent.action.INSERT"; |
| 1207 | /** |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 1208 | * Activity Action: Create a new item in the given container, initializing it |
| 1209 | * from the current contents of the clipboard. |
| 1210 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1211 | * in which to place the data. |
| 1212 | * <p>Output: URI of the new data that was created. |
| 1213 | */ |
| 1214 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1215 | public static final String ACTION_PASTE = "android.intent.action.PASTE"; |
| 1216 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1217 | * Activity Action: Delete the given data from its container. |
| 1218 | * <p>Input: {@link #getData} is URI of data to be deleted. |
| 1219 | * <p>Output: nothing. |
| 1220 | */ |
| 1221 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1222 | public static final String ACTION_DELETE = "android.intent.action.DELETE"; |
| 1223 | /** |
| 1224 | * Activity Action: Run the data, whatever that means. |
| 1225 | * <p>Input: ? (Note: this is currently specific to the test harness.) |
| 1226 | * <p>Output: nothing. |
| 1227 | */ |
| 1228 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1229 | public static final String ACTION_RUN = "android.intent.action.RUN"; |
| 1230 | /** |
| 1231 | * Activity Action: Perform a data synchronization. |
| 1232 | * <p>Input: ? |
| 1233 | * <p>Output: ? |
| 1234 | */ |
| 1235 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1236 | public static final String ACTION_SYNC = "android.intent.action.SYNC"; |
| 1237 | /** |
| 1238 | * Activity Action: Pick an activity given an intent, returning the class |
| 1239 | * selected. |
| 1240 | * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent |
| 1241 | * used with {@link PackageManager#queryIntentActivities} to determine the |
| 1242 | * set of activities from which to pick. |
| 1243 | * <p>Output: Class name of the activity that was selected. |
| 1244 | */ |
| 1245 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1246 | public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; |
| 1247 | /** |
| 1248 | * Activity Action: Perform a search. |
| 1249 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1250 | * is the text to search for. If empty, simply |
| 1251 | * enter your search results Activity with the search UI activated. |
| 1252 | * <p>Output: nothing. |
| 1253 | */ |
| 1254 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1255 | public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; |
| 1256 | /** |
Jim Miller | 7e4ad35 | 2009-03-25 18:16:41 -0700 | [diff] [blame] | 1257 | * Activity Action: Start the platform-defined tutorial |
| 1258 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1259 | * is the text to search for. If empty, simply |
| 1260 | * enter your search results Activity with the search UI activated. |
| 1261 | * <p>Output: nothing. |
| 1262 | */ |
| 1263 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1264 | public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; |
| 1265 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1266 | * Activity Action: Perform a web search. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1267 | * <p> |
| 1268 | * Input: {@link android.app.SearchManager#QUERY |
| 1269 | * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is |
| 1270 | * a url starts with http or https, the site will be opened. If it is plain |
| 1271 | * text, Google search will be applied. |
| 1272 | * <p> |
| 1273 | * Output: nothing. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1274 | */ |
| 1275 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1276 | public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1277 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1278 | /** |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1279 | * Activity Action: Perform assist action. |
| 1280 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1281 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1282 | * additional optional contextual information about where the user was when they |
Dianne Hackborn | a3acdb3 | 2015-06-08 17:07:40 -0700 | [diff] [blame] | 1283 | * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer |
| 1284 | * information. |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1285 | * Output: nothing. |
| 1286 | */ |
| 1287 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1288 | public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1289 | |
| 1290 | /** |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1291 | * Activity Action: Perform voice assist action. |
| 1292 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1293 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1294 | * additional optional contextual information about where the user was when they |
Adam Skory | dfc7fd7 | 2013-08-05 19:23:41 -0700 | [diff] [blame] | 1295 | * requested the voice assist. |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1296 | * Output: nothing. |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1297 | * @hide |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1298 | */ |
| 1299 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1300 | public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; |
| 1301 | |
| 1302 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1303 | * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground |
| 1304 | * application package at the time the assist was invoked. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1305 | */ |
| 1306 | public static final String EXTRA_ASSIST_PACKAGE |
| 1307 | = "android.intent.extra.ASSIST_PACKAGE"; |
| 1308 | |
| 1309 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 1310 | * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground |
| 1311 | * application package at the time the assist was invoked. |
| 1312 | */ |
| 1313 | public static final String EXTRA_ASSIST_UID |
| 1314 | = "android.intent.extra.ASSIST_UID"; |
| 1315 | |
| 1316 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1317 | * An optional field on {@link #ACTION_ASSIST} and containing additional contextual |
| 1318 | * information supplied by the current foreground app at the time of the assist request. |
| 1319 | * This is a {@link Bundle} of additional data. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1320 | */ |
| 1321 | public static final String EXTRA_ASSIST_CONTEXT |
| 1322 | = "android.intent.extra.ASSIST_CONTEXT"; |
| 1323 | |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1324 | /** |
Michael Wright | 8ab940a | 2014-09-01 11:01:27 -0700 | [diff] [blame] | 1325 | * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a |
| 1326 | * keyboard as the primary input device for assistance. |
| 1327 | */ |
| 1328 | public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = |
| 1329 | "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; |
| 1330 | |
| 1331 | /** |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 1332 | * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id |
| 1333 | * that was used to invoke the assist. |
| 1334 | */ |
| 1335 | public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = |
| 1336 | "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; |
| 1337 | |
| 1338 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 1339 | * Activity Action: List all available applications. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1340 | * <p>Input: Nothing. |
| 1341 | * <p>Output: nothing. |
| 1342 | */ |
| 1343 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1344 | public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; |
| 1345 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 1346 | * Activity Action: Show settings for choosing wallpaper. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1347 | * <p>Input: Nothing. |
| 1348 | * <p>Output: Nothing. |
| 1349 | */ |
| 1350 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1351 | public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; |
| 1352 | |
| 1353 | /** |
| 1354 | * Activity Action: Show activity for reporting a bug. |
| 1355 | * <p>Input: Nothing. |
| 1356 | * <p>Output: Nothing. |
| 1357 | */ |
| 1358 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1359 | public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; |
| 1360 | |
| 1361 | /** |
| 1362 | * Activity Action: Main entry point for factory tests. Only used when |
| 1363 | * the device is booting in factory test node. The implementing package |
| 1364 | * must be installed in the system image. |
| 1365 | * <p>Input: nothing |
| 1366 | * <p>Output: nothing |
| 1367 | */ |
| 1368 | public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; |
| 1369 | |
| 1370 | /** |
| 1371 | * Activity Action: The user pressed the "call" button to go to the dialer |
| 1372 | * or other appropriate UI for placing a call. |
| 1373 | * <p>Input: Nothing. |
| 1374 | * <p>Output: Nothing. |
| 1375 | */ |
| 1376 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1377 | public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; |
| 1378 | |
| 1379 | /** |
| 1380 | * Activity Action: Start Voice Command. |
| 1381 | * <p>Input: Nothing. |
| 1382 | * <p>Output: Nothing. |
| 1383 | */ |
| 1384 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1385 | 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] | 1386 | |
| 1387 | /** |
| 1388 | * Activity Action: Start action associated with long pressing on the |
| 1389 | * search key. |
| 1390 | * <p>Input: Nothing. |
| 1391 | * <p>Output: Nothing. |
| 1392 | */ |
| 1393 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1394 | 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] | 1395 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1396 | /** |
| 1397 | * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. |
| 1398 | * This intent is delivered to the package which installed the application, usually |
Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 1399 | * Google Play. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1400 | * <p>Input: No data is specified. The bug report is passed in using |
| 1401 | * an {@link #EXTRA_BUG_REPORT} field. |
| 1402 | * <p>Output: Nothing. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1403 | * |
| 1404 | * @see #EXTRA_BUG_REPORT |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1405 | */ |
| 1406 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1407 | public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; |
Dianne Hackborn | 3d74bb4 | 2009-06-19 10:35:21 -0700 | [diff] [blame] | 1408 | |
| 1409 | /** |
| 1410 | * Activity Action: Show power usage information to the user. |
| 1411 | * <p>Input: Nothing. |
| 1412 | * <p>Output: Nothing. |
| 1413 | */ |
| 1414 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1415 | 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] | 1416 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1417 | /** |
| 1418 | * Activity Action: Setup wizard to launch after a platform update. This |
| 1419 | * activity should have a string meta-data field associated with it, |
| 1420 | * {@link #METADATA_SETUP_VERSION}, which defines the current version of |
| 1421 | * the platform for setup. The activity will be launched only if |
| 1422 | * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the |
| 1423 | * same value. |
| 1424 | * <p>Input: Nothing. |
| 1425 | * <p>Output: Nothing. |
| 1426 | * @hide |
| 1427 | */ |
| 1428 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1429 | public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1430 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1431 | /** |
Clara Bayarri | eb3c2d3 | 2016-04-01 14:37:32 +0100 | [diff] [blame] | 1432 | * Activity Action: Start the Keyboard Shortcuts Helper screen. |
| 1433 | * <p>Input: Nothing. |
| 1434 | * <p>Output: Nothing. |
| 1435 | * @hide |
| 1436 | */ |
| 1437 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1438 | public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = |
| 1439 | "android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; |
| 1440 | |
| 1441 | /** |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 1442 | * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. |
| 1443 | * <p>Input: Nothing. |
| 1444 | * <p>Output: Nothing. |
| 1445 | * @hide |
| 1446 | */ |
| 1447 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1448 | public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = |
| 1449 | "android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; |
| 1450 | |
| 1451 | /** |
Jeff Sharkey | 7f86827 | 2011-06-05 16:05:02 -0700 | [diff] [blame] | 1452 | * Activity Action: Show settings for managing network data usage of a |
| 1453 | * specific application. Applications should define an activity that offers |
| 1454 | * options to control data usage. |
| 1455 | */ |
| 1456 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1457 | public static final String ACTION_MANAGE_NETWORK_USAGE = |
| 1458 | "android.intent.action.MANAGE_NETWORK_USAGE"; |
| 1459 | |
| 1460 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1461 | * Activity Action: Launch application installer. |
| 1462 | * <p> |
Todd Kennedy | 9cc589a | 2016-08-18 16:23:17 -0700 | [diff] [blame] | 1463 | * Input: The data must be a content: URI at which the application |
Dianne Hackborn | eba784ff | 2012-09-19 12:42:37 -0700 | [diff] [blame] | 1464 | * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, |
| 1465 | * you can also use "package:<package-name>" to install an application for the |
| 1466 | * 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] | 1467 | * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, |
| 1468 | * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. |
| 1469 | * <p> |
| 1470 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1471 | * succeeded. |
Svet Ganov | 86877e4 | 2015-05-28 08:19:48 -0700 | [diff] [blame] | 1472 | * <p> |
| 1473 | * <strong>Note:</strong>If your app is targeting API level higher than 22 you |
| 1474 | * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} |
| 1475 | * in order to launch the application installer. |
| 1476 | * </p> |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1477 | * |
| 1478 | * @see #EXTRA_INSTALLER_PACKAGE_NAME |
| 1479 | * @see #EXTRA_NOT_UNKNOWN_SOURCE |
| 1480 | * @see #EXTRA_RETURN_RESULT |
| 1481 | */ |
| 1482 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1483 | public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; |
| 1484 | |
| 1485 | /** |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1486 | * Activity Action: Launch ephemeral installer. |
| 1487 | * <p> |
| 1488 | * Input: The data must be a http: URI that the ephemeral application is registered |
| 1489 | * to handle. |
| 1490 | * <p class="note"> |
| 1491 | * This is a protected intent that can only be sent by the system. |
| 1492 | * </p> |
| 1493 | * |
| 1494 | * @hide |
| 1495 | */ |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1496 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1497 | public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE |
| 1498 | = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE"; |
| 1499 | |
| 1500 | /** |
| 1501 | * Service Action: Resolve ephemeral application. |
| 1502 | * <p> |
| 1503 | * The system will have a persistent connection to this service. |
| 1504 | * This is a protected intent that can only be sent by the system. |
| 1505 | * </p> |
| 1506 | * |
| 1507 | * @hide |
| 1508 | */ |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1509 | @SdkConstant(SdkConstantType.SERVICE_ACTION) |
| 1510 | public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE |
| 1511 | = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE"; |
| 1512 | |
| 1513 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1514 | * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1515 | * package. Specifies the installer package name; this package will receive the |
| 1516 | * {@link #ACTION_APP_ERROR} intent. |
| 1517 | */ |
| 1518 | public static final String EXTRA_INSTALLER_PACKAGE_NAME |
| 1519 | = "android.intent.extra.INSTALLER_PACKAGE_NAME"; |
| 1520 | |
| 1521 | /** |
| 1522 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1523 | * package. Specifies that the application being installed should not be |
| 1524 | * treated as coming from an unknown source, but as coming from the app |
| 1525 | * invoking the Intent. For this to work you must start the installer with |
| 1526 | * startActivityForResult(). |
| 1527 | */ |
| 1528 | public static final String EXTRA_NOT_UNKNOWN_SOURCE |
| 1529 | = "android.intent.extra.NOT_UNKNOWN_SOURCE"; |
| 1530 | |
| 1531 | /** |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1532 | * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and |
| 1533 | * {@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] | 1534 | * data field originated from. |
| 1535 | */ |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1536 | public static final String EXTRA_ORIGINATING_URI |
| 1537 | = "android.intent.extra.ORIGINATING_URI"; |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1538 | |
| 1539 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1540 | * This extra can be used with any Intent used to launch an activity, supplying information |
| 1541 | * about who is launching that activity. This field contains a {@link android.net.Uri} |
| 1542 | * object, typically an http: or https: URI of the web site that the referral came from; |
| 1543 | * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify |
| 1544 | * a native application that it came from. |
| 1545 | * |
| 1546 | * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} |
| 1547 | * instead of directly retrieving the extra. It is also valid for applications to |
| 1548 | * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create |
| 1549 | * a string, not a Uri; the field here, if supplied, will always take precedence, |
| 1550 | * however.</p> |
| 1551 | * |
| 1552 | * @see #EXTRA_REFERRER_NAME |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1553 | */ |
| 1554 | public static final String EXTRA_REFERRER |
| 1555 | = "android.intent.extra.REFERRER"; |
| 1556 | |
| 1557 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1558 | * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather |
| 1559 | * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can |
| 1560 | * not be created, in particular when Intent extras are supplied through the |
| 1561 | * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} |
| 1562 | * schemes. |
| 1563 | * |
| 1564 | * @see #EXTRA_REFERRER |
| 1565 | */ |
| 1566 | public static final String EXTRA_REFERRER_NAME |
| 1567 | = "android.intent.extra.REFERRER_NAME"; |
| 1568 | |
| 1569 | /** |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1570 | * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and |
Gina Dimino | 98ad888 | 2016-05-31 17:25:48 -0700 | [diff] [blame] | 1571 | * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1572 | * @hide |
| 1573 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1574 | @SystemApi |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1575 | public static final String EXTRA_ORIGINATING_UID |
| 1576 | = "android.intent.extra.ORIGINATING_UID"; |
| 1577 | |
| 1578 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1579 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1580 | * package. Tells the installer UI to skip the confirmation with the user |
| 1581 | * if the .apk is replacing an existing one. |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1582 | * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android |
| 1583 | * will no longer show an interstitial message about updating existing |
| 1584 | * applications so this is no longer needed. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1585 | */ |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1586 | @Deprecated |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1587 | public static final String EXTRA_ALLOW_REPLACE |
| 1588 | = "android.intent.extra.ALLOW_REPLACE"; |
| 1589 | |
| 1590 | /** |
| 1591 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or |
| 1592 | * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should |
| 1593 | * return to the application the result code of the install/uninstall. The returned result |
| 1594 | * code will be {@link android.app.Activity#RESULT_OK} on success or |
| 1595 | * {@link android.app.Activity#RESULT_FIRST_USER} on failure. |
| 1596 | */ |
| 1597 | public static final String EXTRA_RETURN_RESULT |
| 1598 | = "android.intent.extra.RETURN_RESULT"; |
| 1599 | |
| 1600 | /** |
| 1601 | * Package manager install result code. @hide because result codes are not |
| 1602 | * yet ready to be exposed. |
| 1603 | */ |
| 1604 | public static final String EXTRA_INSTALL_RESULT |
| 1605 | = "android.intent.extra.INSTALL_RESULT"; |
| 1606 | |
| 1607 | /** |
| 1608 | * Activity Action: Launch application uninstaller. |
| 1609 | * <p> |
| 1610 | * Input: The data must be a package: URI whose scheme specific part is |
| 1611 | * the package name of the current installed package to be uninstalled. |
| 1612 | * You can optionally supply {@link #EXTRA_RETURN_RESULT}. |
| 1613 | * <p> |
| 1614 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1615 | * succeeded. |
| 1616 | */ |
| 1617 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1618 | public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; |
| 1619 | |
| 1620 | /** |
Dianne Hackborn | 6d235d8 | 2012-09-16 18:25:40 -0700 | [diff] [blame] | 1621 | * Specify whether the package should be uninstalled for all users. |
| 1622 | * @hide because these should not be part of normal application flow. |
| 1623 | */ |
| 1624 | public static final String EXTRA_UNINSTALL_ALL_USERS |
| 1625 | = "android.intent.extra.UNINSTALL_ALL_USERS"; |
| 1626 | |
| 1627 | /** |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1628 | * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity |
| 1629 | * describing the last run version of the platform that was setup. |
| 1630 | * @hide |
| 1631 | */ |
| 1632 | public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; |
| 1633 | |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1634 | /** |
| 1635 | * Activity action: Launch UI to manage the permissions of an app. |
| 1636 | * <p> |
| 1637 | * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions |
| 1638 | * will be managed by the launched UI. |
| 1639 | * </p> |
| 1640 | * <p> |
| 1641 | * Output: Nothing. |
| 1642 | * </p> |
| 1643 | * |
| 1644 | * @see #EXTRA_PACKAGE_NAME |
| 1645 | * |
| 1646 | * @hide |
| 1647 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1648 | @SystemApi |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1649 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1650 | public static final String ACTION_MANAGE_APP_PERMISSIONS = |
| 1651 | "android.intent.action.MANAGE_APP_PERMISSIONS"; |
| 1652 | |
| 1653 | /** |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1654 | * Activity action: Launch UI to manage permissions. |
| 1655 | * <p> |
| 1656 | * Input: Nothing. |
| 1657 | * </p> |
| 1658 | * <p> |
| 1659 | * Output: Nothing. |
| 1660 | * </p> |
| 1661 | * |
| 1662 | * @hide |
| 1663 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1664 | @SystemApi |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1665 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1666 | public static final String ACTION_MANAGE_PERMISSIONS = |
| 1667 | "android.intent.action.MANAGE_PERMISSIONS"; |
| 1668 | |
| 1669 | /** |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1670 | * Activity action: Launch UI to review permissions for an app. |
| 1671 | * The system uses this intent if permission review for apps not |
| 1672 | * supporting the new runtime permissions model is enabled. In |
| 1673 | * this mode a permission review is required before any of the |
| 1674 | * app components can run. |
| 1675 | * <p> |
| 1676 | * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose |
| 1677 | * permissions will be reviewed (mandatory). |
| 1678 | * </p> |
| 1679 | * <p> |
| 1680 | * Input: {@link #EXTRA_INTENT} specifies a pending intent to |
| 1681 | * be fired after the permission review (optional). |
| 1682 | * </p> |
| 1683 | * <p> |
| 1684 | * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to |
| 1685 | * be invoked after the permission review (optional). |
| 1686 | * </p> |
| 1687 | * <p> |
| 1688 | * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent |
| 1689 | * passed via {@link #EXTRA_INTENT} needs a result (optional). |
| 1690 | * </p> |
| 1691 | * <p> |
| 1692 | * Output: Nothing. |
| 1693 | * </p> |
| 1694 | * |
| 1695 | * @see #EXTRA_PACKAGE_NAME |
| 1696 | * @see #EXTRA_INTENT |
| 1697 | * @see #EXTRA_REMOTE_CALLBACK |
| 1698 | * @see #EXTRA_RESULT_NEEDED |
| 1699 | * |
| 1700 | * @hide |
| 1701 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1702 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1703 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1704 | public static final String ACTION_REVIEW_PERMISSIONS = |
| 1705 | "android.intent.action.REVIEW_PERMISSIONS"; |
| 1706 | |
| 1707 | /** |
| 1708 | * Intent extra: A callback for reporting remote result as a bundle. |
| 1709 | * <p> |
| 1710 | * Type: IRemoteCallback |
| 1711 | * </p> |
| 1712 | * |
| 1713 | * @hide |
| 1714 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1715 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1716 | public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; |
| 1717 | |
| 1718 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1719 | * Intent extra: An app package name. |
| 1720 | * <p> |
| 1721 | * Type: String |
Svet Ganov | 0b31670 | 2015-05-23 13:25:11 -0700 | [diff] [blame] | 1722 | * </p> |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1723 | * |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1724 | */ |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1725 | public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; |
| 1726 | |
| 1727 | /** |
Todd Kennedy | e5195dd | 2016-10-19 15:29:19 -0700 | [diff] [blame] | 1728 | * Intent extra: An app split name. |
| 1729 | * <p> |
| 1730 | * Type: String |
| 1731 | * </p> |
| 1732 | * @hide |
| 1733 | */ |
| 1734 | @SystemApi |
| 1735 | public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; |
| 1736 | |
| 1737 | /** |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1738 | * Intent extra: An extra for specifying whether a result is needed. |
| 1739 | * <p> |
| 1740 | * Type: boolean |
| 1741 | * </p> |
| 1742 | * |
| 1743 | * @hide |
| 1744 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1745 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1746 | public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; |
| 1747 | |
| 1748 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1749 | * Activity action: Launch UI to manage which apps have a given permission. |
| 1750 | * <p> |
| 1751 | * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access |
| 1752 | * to which will be managed by the launched UI. |
| 1753 | * </p> |
| 1754 | * <p> |
| 1755 | * Output: Nothing. |
| 1756 | * </p> |
| 1757 | * |
| 1758 | * @see #EXTRA_PERMISSION_NAME |
| 1759 | * |
| 1760 | * @hide |
| 1761 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1762 | @SystemApi |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1763 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1764 | public static final String ACTION_MANAGE_PERMISSION_APPS = |
| 1765 | "android.intent.action.MANAGE_PERMISSION_APPS"; |
| 1766 | |
| 1767 | /** |
| 1768 | * Intent extra: The name of a permission. |
| 1769 | * <p> |
| 1770 | * Type: String |
| 1771 | * </p> |
| 1772 | * |
| 1773 | * @hide |
| 1774 | */ |
| 1775 | @SystemApi |
| 1776 | public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; |
| 1777 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1778 | // --------------------------------------------------------------------- |
| 1779 | // --------------------------------------------------------------------- |
| 1780 | // Standard intent broadcast actions (see action variable). |
| 1781 | |
| 1782 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1783 | * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. |
| 1784 | * <p> |
| 1785 | * For historical reasons, the name of this broadcast action refers to the power |
| 1786 | * state of the screen but it is actually sent in response to changes in the |
| 1787 | * overall interactive state of the device. |
| 1788 | * </p><p> |
| 1789 | * This broadcast is sent when the device becomes non-interactive which may have |
| 1790 | * nothing to do with the screen turning off. To determine the |
| 1791 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1792 | * </p><p> |
| 1793 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1794 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1795 | * You <em>cannot</em> receive this through components declared in |
| 1796 | * manifests, only by explicitly registering for it with |
| 1797 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1798 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1799 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1800 | * <p class="note">This is a protected intent that can only be sent |
| 1801 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1802 | */ |
| 1803 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1804 | public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1805 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1806 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1807 | * Broadcast Action: Sent when the device wakes up and becomes interactive. |
| 1808 | * <p> |
| 1809 | * For historical reasons, the name of this broadcast action refers to the power |
| 1810 | * state of the screen but it is actually sent in response to changes in the |
| 1811 | * overall interactive state of the device. |
| 1812 | * </p><p> |
| 1813 | * This broadcast is sent when the device becomes interactive which may have |
| 1814 | * nothing to do with the screen turning on. To determine the |
| 1815 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1816 | * </p><p> |
| 1817 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1818 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1819 | * You <em>cannot</em> receive this through components declared in |
| 1820 | * manifests, only by explicitly registering for it with |
| 1821 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1822 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1823 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1824 | * <p class="note">This is a protected intent that can only be sent |
| 1825 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1826 | */ |
| 1827 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1828 | 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] | 1829 | |
| 1830 | /** |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 1831 | * Broadcast Action: Sent after the system stops dreaming. |
| 1832 | * |
| 1833 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1834 | * It is only sent to registered receivers.</p> |
| 1835 | */ |
| 1836 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1837 | public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; |
| 1838 | |
| 1839 | /** |
| 1840 | * Broadcast Action: Sent after the system starts dreaming. |
| 1841 | * |
| 1842 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1843 | * It is only sent to registered receivers.</p> |
| 1844 | */ |
| 1845 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1846 | public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; |
| 1847 | |
| 1848 | /** |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1849 | * 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] | 1850 | * keyguard is gone). |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1851 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1852 | * <p class="note">This is a protected intent that can only be sent |
| 1853 | * by the system. |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1854 | */ |
| 1855 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 1856 | 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] | 1857 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1858 | /** |
| 1859 | * Broadcast Action: The current time has changed. Sent every |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1860 | * minute. You <em>cannot</em> receive this through components declared |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1861 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1862 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1863 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1864 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1865 | * <p class="note">This is a protected intent that can only be sent |
| 1866 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1867 | */ |
| 1868 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1869 | public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; |
| 1870 | /** |
| 1871 | * Broadcast Action: The time was set. |
| 1872 | */ |
| 1873 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1874 | public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; |
| 1875 | /** |
| 1876 | * Broadcast Action: The date has changed. |
| 1877 | */ |
| 1878 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1879 | public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; |
| 1880 | /** |
| 1881 | * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> |
| 1882 | * <ul> |
| 1883 | * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li> |
| 1884 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1885 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1886 | * <p class="note">This is a protected intent that can only be sent |
| 1887 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1888 | */ |
| 1889 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1890 | public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; |
| 1891 | /** |
Robert Greenwalt | 03595d0 | 2010-11-02 14:08:23 -0700 | [diff] [blame] | 1892 | * Clear DNS Cache Action: This is broadcast when networks have changed and old |
| 1893 | * DNS entries should be tossed. |
| 1894 | * @hide |
| 1895 | */ |
| 1896 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1897 | public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE"; |
| 1898 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1899 | * Alarm Changed Action: This is broadcast when the AlarmClock |
| 1900 | * application's alarm is set or unset. It is used by the |
| 1901 | * AlarmClock application and the StatusBar service. |
| 1902 | * @hide |
| 1903 | */ |
| 1904 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1905 | public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1906 | |
| 1907 | /** |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1908 | * Broadcast Action: This is broadcast once, after the user has finished |
| 1909 | * booting, but while still in the "locked" state. It can be used to perform |
| 1910 | * application-specific initialization, such as installing alarms. You must |
| 1911 | * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} |
| 1912 | * permission in order to receive this broadcast. |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1913 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1914 | * This broadcast is sent immediately at boot by all devices (regardless of |
| 1915 | * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or |
| 1916 | * higher. Upon receipt of this broadcast, the user is still locked and only |
| 1917 | * device-protected storage can be accessed safely. If you want to access |
| 1918 | * credential-protected storage, you need to wait for the user to be |
| 1919 | * unlocked (typically by entering their lock pattern or PIN for the first |
| 1920 | * time), after which the {@link #ACTION_USER_UNLOCKED} and |
| 1921 | * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. |
| 1922 | * <p> |
| 1923 | * To receive this broadcast, your receiver component must be marked as |
| 1924 | * being {@link ComponentInfo#directBootAware}. |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1925 | * <p class="note"> |
| 1926 | * 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] | 1927 | * |
| 1928 | * @see Context#createDeviceProtectedStorageContext() |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1929 | */ |
| 1930 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1931 | public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; |
| 1932 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1933 | /** |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1934 | * Broadcast Action: This is broadcast once, after the user has finished |
| 1935 | * booting. It can be used to perform application-specific initialization, |
| 1936 | * such as installing alarms. You must hold the |
| 1937 | * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in |
| 1938 | * order to receive this broadcast. |
| 1939 | * <p> |
| 1940 | * This broadcast is sent at boot by all devices (both with and without |
| 1941 | * direct boot support). Upon receipt of this broadcast, the user is |
| 1942 | * unlocked and both device-protected and credential-protected storage can |
| 1943 | * accessed safely. |
| 1944 | * <p> |
| 1945 | * If you need to run while the user is still locked (before they've entered |
| 1946 | * their lock pattern or PIN for the first time), you can listen for the |
| 1947 | * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. |
| 1948 | * <p class="note"> |
| 1949 | * 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] | 1950 | */ |
| 1951 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1952 | public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1953 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1954 | /** |
| 1955 | * Broadcast Action: This is broadcast when a user action should request a |
| 1956 | * temporary system dialog to dismiss. Some examples of temporary system |
| 1957 | * dialogs are the notification window-shade and the recent tasks dialog. |
| 1958 | */ |
| 1959 | public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; |
| 1960 | /** |
| 1961 | * Broadcast Action: Trigger the download and eventual installation |
| 1962 | * of a package. |
| 1963 | * <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] | 1964 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1965 | * <p class="note">This is a protected intent that can only be sent |
| 1966 | * by the system. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1967 | * |
| 1968 | * @deprecated This constant has never been used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1969 | */ |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1970 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1971 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1972 | public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; |
| 1973 | /** |
| 1974 | * 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] | 1975 | * device. The data contains the name of the package. Note that the |
| 1976 | * newly installed package does <em>not</em> receive this broadcast. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 1977 | * <p>May include the following extras: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1978 | * <ul> |
| 1979 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 1980 | * <li> {@link #EXTRA_REPLACING} is set to true if this is following |
| 1981 | * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. |
| 1982 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1983 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1984 | * <p class="note">This is a protected intent that can only be sent |
| 1985 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1986 | */ |
| 1987 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1988 | public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; |
| 1989 | /** |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 1990 | * Broadcast Action: A new version of an application package has been |
| 1991 | * installed, replacing an existing version that was previously installed. |
| 1992 | * The data contains the name of the package. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 1993 | * <p>May include the following extras: |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 1994 | * <ul> |
| 1995 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 1996 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1997 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1998 | * <p class="note">This is a protected intent that can only be sent |
| 1999 | * by the system. |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2000 | */ |
| 2001 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2002 | public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; |
| 2003 | /** |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 2004 | * Broadcast Action: A new version of your application has been installed |
| 2005 | * over an existing one. This is only sent to the application that was |
| 2006 | * replaced. It does not contain any additional data; to receive it, just |
| 2007 | * use an intent filter for this action. |
| 2008 | * |
| 2009 | * <p class="note">This is a protected intent that can only be sent |
| 2010 | * by the system. |
| 2011 | */ |
| 2012 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2013 | public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; |
| 2014 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2015 | * Broadcast Action: An existing application package has been removed from |
| 2016 | * the device. The data contains the name of the package. The package |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2017 | * 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] | 2018 | * <ul> |
| 2019 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 2020 | * to the package. |
| 2021 | * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire |
| 2022 | * application -- data and code -- is being removed. |
| 2023 | * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed |
| 2024 | * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. |
| 2025 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2026 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2027 | * <p class="note">This is a protected intent that can only be sent |
| 2028 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2029 | */ |
| 2030 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2031 | public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; |
| 2032 | /** |
Dianne Hackborn | f9abb40 | 2011-08-10 15:00:59 -0700 | [diff] [blame] | 2033 | * Broadcast Action: An existing application package has been completely |
| 2034 | * removed from the device. The data contains the name of the package. |
| 2035 | * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when |
| 2036 | * {@link #EXTRA_DATA_REMOVED} is true and |
| 2037 | * {@link #EXTRA_REPLACING} is false of that broadcast. |
| 2038 | * |
| 2039 | * <ul> |
| 2040 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 2041 | * to the package. |
| 2042 | * </ul> |
| 2043 | * |
| 2044 | * <p class="note">This is a protected intent that can only be sent |
| 2045 | * by the system. |
| 2046 | */ |
| 2047 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2048 | public static final String ACTION_PACKAGE_FULLY_REMOVED |
| 2049 | = "android.intent.action.PACKAGE_FULLY_REMOVED"; |
| 2050 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2051 | * Broadcast Action: An existing application package has been changed (for |
| 2052 | * example, a component has been enabled or disabled). The data contains |
| 2053 | * the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2054 | * <ul> |
| 2055 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 2056 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 2057 | * of the changed components (or the package name itself). |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 2058 | * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the |
| 2059 | * default action of restarting the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2060 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2061 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2062 | * <p class="note">This is a protected intent that can only be sent |
| 2063 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2064 | */ |
| 2065 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2066 | public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; |
| 2067 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 2068 | * @hide |
| 2069 | * Broadcast Action: Ask system services if there is any reason to |
| 2070 | * restart the given package. The data contains the name of the |
| 2071 | * package. |
| 2072 | * <ul> |
| 2073 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2074 | * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. |
| 2075 | * </ul> |
| 2076 | * |
| 2077 | * <p class="note">This is a protected intent that can only be sent |
| 2078 | * by the system. |
| 2079 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 2080 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 2081 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2082 | public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; |
| 2083 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2084 | * Broadcast Action: The user has restarted a package, and all of its |
| 2085 | * processes have been killed. All runtime state |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2086 | * associated with it (processes, alarms, notifications, etc) should |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2087 | * be removed. Note that the restarted package does <em>not</em> |
| 2088 | * receive this broadcast. |
| 2089 | * The data contains the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2090 | * <ul> |
| 2091 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2092 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2093 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2094 | * <p class="note">This is a protected intent that can only be sent |
| 2095 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2096 | */ |
| 2097 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2098 | public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; |
| 2099 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2100 | * Broadcast Action: The user has cleared the data of a package. This should |
| 2101 | * 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] | 2102 | * its persistent data is erased and this broadcast sent. |
| 2103 | * Note that the cleared package does <em>not</em> |
| 2104 | * 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] | 2105 | * <ul> |
| 2106 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2107 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2108 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2109 | * <p class="note">This is a protected intent that can only be sent |
| 2110 | * by the system. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2111 | */ |
| 2112 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2113 | public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; |
| 2114 | /** |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 2115 | * Broadcast Action: Packages have been suspended. |
| 2116 | * <p>Includes the following extras: |
| 2117 | * <ul> |
| 2118 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended |
| 2119 | * </ul> |
| 2120 | * |
| 2121 | * <p class="note">This is a protected intent that can only be sent |
| 2122 | * by the system. It is only sent to registered receivers. |
| 2123 | */ |
| 2124 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2125 | public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; |
| 2126 | /** |
| 2127 | * Broadcast Action: Packages have been unsuspended. |
| 2128 | * <p>Includes the following extras: |
| 2129 | * <ul> |
| 2130 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended |
| 2131 | * </ul> |
| 2132 | * |
| 2133 | * <p class="note">This is a protected intent that can only be sent |
| 2134 | * by the system. It is only sent to registered receivers. |
| 2135 | */ |
| 2136 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2137 | public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; |
| 2138 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2139 | * Broadcast Action: A user ID has been removed from the system. The user |
| 2140 | * ID number is stored in the extra data under {@link #EXTRA_UID}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2141 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2142 | * <p class="note">This is a protected intent that can only be sent |
| 2143 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2144 | */ |
| 2145 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2146 | public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2147 | |
| 2148 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2149 | * Broadcast Action: Sent to the installer package of an application when |
| 2150 | * that application is first launched (that is the first time it is moved |
| 2151 | * 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] | 2152 | * |
| 2153 | * <p class="note">This is a protected intent that can only be sent |
| 2154 | * by the system. |
| 2155 | */ |
| 2156 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2157 | public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; |
| 2158 | |
| 2159 | /** |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2160 | * Broadcast Action: Sent to the system package verifier when a package |
| 2161 | * needs to be verified. The data contains the package URI. |
| 2162 | * <p class="note"> |
| 2163 | * This is a protected intent that can only be sent by the system. |
| 2164 | * </p> |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2165 | */ |
| 2166 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2167 | public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; |
| 2168 | |
| 2169 | /** |
rich cannings | d1b5cfc | 2012-08-29 14:49:51 -0700 | [diff] [blame] | 2170 | * Broadcast Action: Sent to the system package verifier when a package is |
| 2171 | * verified. The data contains the package URI. |
| 2172 | * <p class="note"> |
| 2173 | * This is a protected intent that can only be sent by the system. |
| 2174 | */ |
| 2175 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2176 | public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; |
| 2177 | |
| 2178 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2179 | * Broadcast Action: Sent to the system intent filter verifier when an |
| 2180 | * intent filter needs to be verified. The data contains the filter data |
| 2181 | * hosts to be verified against. |
Fabrice Di Meglio | 1c1b471 | 2014-11-19 17:12:32 -0800 | [diff] [blame] | 2182 | * <p class="note"> |
| 2183 | * This is a protected intent that can only be sent by the system. |
| 2184 | * </p> |
| 2185 | * |
| 2186 | * @hide |
| 2187 | */ |
| 2188 | @SystemApi |
| 2189 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2190 | public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; |
| 2191 | |
| 2192 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2193 | * Broadcast Action: Resources for a set of packages (which were |
| 2194 | * previously unavailable) are currently |
| 2195 | * available since the media on which they exist is available. |
| 2196 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2197 | * list of packages whose availability changed. |
| 2198 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2199 | * list of uids of packages whose availability changed. |
| 2200 | * Note that the |
| 2201 | * packages in this list do <em>not</em> receive this broadcast. |
| 2202 | * The specified set of packages are now available on the system. |
| 2203 | * <p>Includes the following extras: |
| 2204 | * <ul> |
| 2205 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2206 | * whose resources(were previously unavailable) are currently available. |
| 2207 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the |
| 2208 | * packages whose resources(were previously unavailable) |
| 2209 | * are currently available. |
| 2210 | * </ul> |
| 2211 | * |
| 2212 | * <p class="note">This is a protected intent that can only be sent |
| 2213 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2214 | */ |
| 2215 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2216 | public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = |
| 2217 | "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2218 | |
| 2219 | /** |
| 2220 | * Broadcast Action: Resources for a set of packages are currently |
| 2221 | * unavailable since the media on which they exist is unavailable. |
| 2222 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2223 | * list of packages whose availability changed. |
| 2224 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2225 | * list of uids of packages whose availability changed. |
| 2226 | * The specified set of packages can no longer be |
| 2227 | * launched and are practically unavailable on the system. |
| 2228 | * <p>Inclues the following extras: |
| 2229 | * <ul> |
| 2230 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2231 | * whose resources are no longer available. |
| 2232 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages |
| 2233 | * whose resources are no longer available. |
| 2234 | * </ul> |
| 2235 | * |
| 2236 | * <p class="note">This is a protected intent that can only be sent |
| 2237 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2238 | */ |
| 2239 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2240 | public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = |
Joe Onorato | 8a051a4 | 2010-03-04 15:54:50 -0500 | [diff] [blame] | 2241 | "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2242 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2243 | /** |
Makoto Onuki | 1030520 | 2016-07-14 18:14:08 -0700 | [diff] [blame] | 2244 | * Broadcast Action: preferred activities have changed *explicitly*. |
| 2245 | * |
| 2246 | * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. |
| 2247 | * when an app is installed or uninstalled, but in such cases this broadcast will *not* |
| 2248 | * be sent. |
| 2249 | * |
| 2250 | * {@link #EXTRA_USER_HANDLE} contains the user ID in question. |
| 2251 | * |
| 2252 | * @hide |
| 2253 | */ |
| 2254 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2255 | public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = |
| 2256 | "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; |
| 2257 | |
| 2258 | |
| 2259 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2260 | * Broadcast Action: The current system wallpaper has changed. See |
Scott Main | 8b2e000 | 2009-09-29 18:17:31 -0700 | [diff] [blame] | 2261 | * {@link android.app.WallpaperManager} for retrieving the new wallpaper. |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2262 | * This should <em>only</em> be used to determine when the wallpaper |
| 2263 | * has changed to show the new wallpaper to the user. You should certainly |
| 2264 | * never, in response to this, change the wallpaper or other attributes of |
| 2265 | * it such as the suggested size. That would be crazy, right? You'd cause |
| 2266 | * all kinds of loops, especially if other apps are doing similar things, |
| 2267 | * right? Of course. So please don't do this. |
| 2268 | * |
| 2269 | * @deprecated Modern applications should use |
| 2270 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER |
| 2271 | * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper |
| 2272 | * shown behind their UI, rather than watching for this broadcast and |
| 2273 | * rendering the wallpaper on their own. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2274 | */ |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2275 | @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2276 | public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; |
| 2277 | /** |
| 2278 | * Broadcast Action: The current device {@link android.content.res.Configuration} |
| 2279 | * (orientation, locale, etc) has changed. When such a change happens, the |
| 2280 | * UIs (view hierarchy) will need to be rebuilt based on this new |
| 2281 | * information; for the most part, applications don't need to worry about |
| 2282 | * this, because the system will take care of stopping and restarting the |
| 2283 | * application to make sure it sees the new changes. Some system code that |
| 2284 | * can not be restarted will need to watch for this action and handle it |
| 2285 | * appropriately. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2286 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2287 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2288 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2289 | * in manifests, only by explicitly registering for it with |
| 2290 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2291 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2292 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2293 | * <p class="note">This is a protected intent that can only be sent |
| 2294 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2295 | * |
| 2296 | * @see android.content.res.Configuration |
| 2297 | */ |
| 2298 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2299 | public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; |
| 2300 | /** |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2301 | * Broadcast Action: The current device's locale has changed. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2302 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2303 | * <p class="note">This is a protected intent that can only be sent |
| 2304 | * by the system. |
| 2305 | */ |
| 2306 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2307 | public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; |
| 2308 | /** |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2309 | * Broadcast Action: This is a <em>sticky broadcast</em> containing the |
| 2310 | * charging state, level, and other information about the battery. |
| 2311 | * See {@link android.os.BatteryManager} for documentation on the |
| 2312 | * contents of the Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2313 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2314 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2315 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2316 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2317 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2318 | * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, |
| 2319 | * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, |
| 2320 | * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related |
| 2321 | * broadcasts that are sent and can be received through manifest |
| 2322 | * receivers. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2323 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2324 | * <p class="note">This is a protected intent that can only be sent |
| 2325 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2326 | */ |
| 2327 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2328 | public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; |
| 2329 | /** |
| 2330 | * Broadcast Action: Indicates low battery condition on the device. |
| 2331 | * This broadcast corresponds to the "Low battery warning" system dialog. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2332 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2333 | * <p class="note">This is a protected intent that can only be sent |
| 2334 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2335 | */ |
| 2336 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2337 | public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; |
| 2338 | /** |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2339 | * Broadcast Action: Indicates the battery is now okay after being low. |
| 2340 | * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has |
| 2341 | * gone back up to an okay state. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2342 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2343 | * <p class="note">This is a protected intent that can only be sent |
| 2344 | * by the system. |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2345 | */ |
| 2346 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2347 | public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; |
| 2348 | /** |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2349 | * Broadcast Action: External power has been connected to the device. |
| 2350 | * This is intended for applications that wish to register specifically to this notification. |
| 2351 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2352 | * stay active to receive this notification. This action can be used to implement actions |
| 2353 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2354 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2355 | * <p class="note">This is a protected intent that can only be sent |
| 2356 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2357 | */ |
| 2358 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2359 | 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] | 2360 | /** |
| 2361 | * Broadcast Action: External power has been removed from the device. |
| 2362 | * This is intended for applications that wish to register specifically to this notification. |
| 2363 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2364 | * 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] | 2365 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2366 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2367 | * <p class="note">This is a protected intent that can only be sent |
| 2368 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2369 | */ |
| 2370 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Baptiste Queru | 1ef4564 | 2008-10-24 11:49:25 -0700 | [diff] [blame] | 2371 | public static final String ACTION_POWER_DISCONNECTED = |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2372 | "android.intent.action.ACTION_POWER_DISCONNECTED"; |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2373 | /** |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2374 | * Broadcast Action: Device is shutting down. |
| 2375 | * This is broadcast when the device is being shut down (completely turned |
| 2376 | * off, not sleeping). Once the broadcast is complete, the final shutdown |
| 2377 | * will proceed and all unsaved data lost. Apps will not normally need |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2378 | * to handle this, since the foreground activity will be paused as well. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2379 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2380 | * <p class="note">This is a protected intent that can only be sent |
| 2381 | * by the system. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 2382 | * <p>May include the following extras: |
| 2383 | * <ul> |
| 2384 | * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this |
| 2385 | * shutdown is only for userspace processes. If not set, assumed to be false. |
| 2386 | * </ul> |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2387 | */ |
| 2388 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 2389 | public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2390 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2391 | * Activity Action: Start this activity to request system shutdown. |
| 2392 | * 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] | 2393 | * to request confirmation from the user before shutting down. The optional boolean |
| 2394 | * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to |
| 2395 | * indicate that the shutdown is requested by the user. |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2396 | * |
| 2397 | * <p class="note">This is a protected intent that can only be sent |
| 2398 | * by the system. |
| 2399 | * |
| 2400 | * {@hide} |
| 2401 | */ |
| 2402 | public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN"; |
| 2403 | /** |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2404 | * Broadcast Action: A sticky broadcast that indicates low memory |
| 2405 | * condition on the device |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2406 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2407 | * <p class="note">This is a protected intent that can only be sent |
| 2408 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2409 | */ |
| 2410 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2411 | public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; |
| 2412 | /** |
| 2413 | * Broadcast Action: Indicates low memory condition on the device no longer exists |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2414 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2415 | * <p class="note">This is a protected intent that can only be sent |
| 2416 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2417 | */ |
| 2418 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2419 | public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; |
| 2420 | /** |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2421 | * Broadcast Action: A sticky broadcast that indicates a memory full |
| 2422 | * condition on the device. This is intended for activities that want |
| 2423 | * to be able to fill the data partition completely, leaving only |
| 2424 | * enough free space to prevent system-wide SQLite failures. |
| 2425 | * |
| 2426 | * <p class="note">This is a protected intent that can only be sent |
| 2427 | * by the system. |
| 2428 | * |
| 2429 | * {@hide} |
| 2430 | */ |
| 2431 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2432 | public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; |
| 2433 | /** |
| 2434 | * Broadcast Action: Indicates memory full condition on the device |
| 2435 | * no longer exists. |
| 2436 | * |
| 2437 | * <p class="note">This is a protected intent that can only be sent |
| 2438 | * by the system. |
| 2439 | * |
| 2440 | * {@hide} |
| 2441 | */ |
| 2442 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2443 | public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; |
| 2444 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2445 | * Broadcast Action: Indicates low memory condition notification acknowledged by user |
| 2446 | * and package management should be started. |
| 2447 | * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW |
| 2448 | * notification. |
| 2449 | */ |
| 2450 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2451 | public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; |
| 2452 | /** |
| 2453 | * Broadcast Action: The device has entered USB Mass Storage mode. |
| 2454 | * This is used mainly for the USB Settings panel. |
| 2455 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2456 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2457 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2458 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2459 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2460 | public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; |
| 2461 | |
| 2462 | /** |
| 2463 | * Broadcast Action: The device has exited USB Mass Storage mode. |
| 2464 | * This is used mainly for the USB Settings panel. |
| 2465 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2466 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2467 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2468 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2469 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2470 | public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; |
| 2471 | |
| 2472 | /** |
| 2473 | * Broadcast Action: External media has been removed. |
| 2474 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2475 | */ |
| 2476 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2477 | public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; |
| 2478 | |
| 2479 | /** |
| 2480 | * 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] | 2481 | * 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] | 2482 | */ |
| 2483 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2484 | public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; |
| 2485 | |
| 2486 | /** |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 2487 | * Broadcast Action: External media is present, and being disk-checked |
| 2488 | * 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] | 2489 | */ |
| 2490 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2491 | public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; |
| 2492 | |
| 2493 | /** |
| 2494 | * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) |
| 2495 | * 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] | 2496 | */ |
| 2497 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2498 | public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; |
| 2499 | |
| 2500 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2501 | * Broadcast Action: External media is present and mounted at its mount point. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2502 | * 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] | 2503 | * The Intent contains an extra with name "read-only" and Boolean value to indicate if the |
| 2504 | * media was mounted read only. |
| 2505 | */ |
| 2506 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2507 | public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; |
| 2508 | |
| 2509 | /** |
| 2510 | * 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] | 2511 | * 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] | 2512 | */ |
| 2513 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2514 | public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; |
| 2515 | |
| 2516 | /** |
Mike Lockwood | bf2dd44 | 2010-03-03 06:16:52 -0500 | [diff] [blame] | 2517 | * Broadcast Action: External media is no longer being shared via USB mass storage. |
| 2518 | * The path to the mount point for the previously shared media is contained in the Intent.mData field. |
| 2519 | * |
| 2520 | * @hide |
| 2521 | */ |
| 2522 | public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; |
| 2523 | |
| 2524 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2525 | * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. |
| 2526 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2527 | */ |
| 2528 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2529 | public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; |
| 2530 | |
| 2531 | /** |
| 2532 | * Broadcast Action: External media is present but cannot be mounted. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2533 | * 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] | 2534 | */ |
| 2535 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2536 | public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; |
| 2537 | |
| 2538 | /** |
| 2539 | * Broadcast Action: User has expressed the desire to remove the external storage media. |
| 2540 | * Applications should close all files they have open within the mount point when they receive this intent. |
| 2541 | * The path to the mount point for the media to be ejected is contained in the Intent.mData field. |
| 2542 | */ |
| 2543 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2544 | public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; |
| 2545 | |
| 2546 | /** |
| 2547 | * Broadcast Action: The media scanner has started scanning a directory. |
| 2548 | * The path to the directory being scanned is contained in the Intent.mData field. |
| 2549 | */ |
| 2550 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2551 | public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; |
| 2552 | |
| 2553 | /** |
| 2554 | * Broadcast Action: The media scanner has finished scanning a directory. |
| 2555 | * The path to the scanned directory is contained in the Intent.mData field. |
| 2556 | */ |
| 2557 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2558 | public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; |
| 2559 | |
| 2560 | /** |
| 2561 | * Broadcast Action: Request the media scanner to scan a file and add it to the media database. |
| 2562 | * The path to the file is contained in the Intent.mData field. |
| 2563 | */ |
| 2564 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2565 | public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; |
| 2566 | |
| 2567 | /** |
| 2568 | * Broadcast Action: The "Media Button" was pressed. Includes a single |
| 2569 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2570 | * caused the broadcast. |
| 2571 | */ |
| 2572 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2573 | public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; |
| 2574 | |
| 2575 | /** |
| 2576 | * Broadcast Action: The "Camera Button" was pressed. Includes a single |
| 2577 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2578 | * caused the broadcast. |
| 2579 | */ |
| 2580 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2581 | public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; |
| 2582 | |
| 2583 | // *** NOTE: @todo(*) The following really should go into a more domain-specific |
| 2584 | // location; they are not general-purpose actions. |
| 2585 | |
| 2586 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2587 | * Broadcast Action: A GTalk connection has been established. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2588 | */ |
| 2589 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2590 | public static final String ACTION_GTALK_SERVICE_CONNECTED = |
| 2591 | "android.intent.action.GTALK_CONNECTED"; |
| 2592 | |
| 2593 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2594 | * Broadcast Action: A GTalk connection has been disconnected. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2595 | */ |
| 2596 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2597 | public static final String ACTION_GTALK_SERVICE_DISCONNECTED = |
| 2598 | "android.intent.action.GTALK_DISCONNECTED"; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2599 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2600 | /** |
| 2601 | * Broadcast Action: An input method has been changed. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2602 | */ |
| 2603 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2604 | public static final String ACTION_INPUT_METHOD_CHANGED = |
| 2605 | "android.intent.action.INPUT_METHOD_CHANGED"; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2606 | |
| 2607 | /** |
| 2608 | * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or |
| 2609 | * more radios have been turned off or on. The intent will have the following extra value:</p> |
| 2610 | * <ul> |
| 2611 | * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, |
| 2612 | * then cell radio and possibly other radios such as bluetooth or WiFi may have also been |
| 2613 | * turned off</li> |
| 2614 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2615 | * |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 2616 | * <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] | 2617 | */ |
| 2618 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2619 | public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; |
| 2620 | |
| 2621 | /** |
| 2622 | * Broadcast Action: Some content providers have parts of their namespace |
| 2623 | * where they publish new events or items that the user may be especially |
| 2624 | * interested in. For these things, they may broadcast this action when the |
| 2625 | * set of interesting items change. |
| 2626 | * |
| 2627 | * For example, GmailProvider sends this notification when the set of unread |
| 2628 | * mail in the inbox changes. |
| 2629 | * |
| 2630 | * <p>The data of the intent identifies which part of which provider |
| 2631 | * changed. When queried through the content resolver, the data URI will |
| 2632 | * return the data set in question. |
| 2633 | * |
| 2634 | * <p>The intent will have the following extra values: |
| 2635 | * <ul> |
| 2636 | * <li><em>count</em> - The number of items in the data set. This is the |
| 2637 | * same as the number of items in the cursor returned by querying the |
| 2638 | * data URI. </li> |
| 2639 | * </ul> |
| 2640 | * |
| 2641 | * This intent will be sent at boot (if the count is non-zero) and when the |
| 2642 | * data set changes. It is possible for the data set to change without the |
| 2643 | * count changing (for example, if a new unread message arrives in the same |
| 2644 | * sync operation in which a message is archived). The phone should still |
| 2645 | * ring/vibrate/etc as normal in this case. |
| 2646 | */ |
| 2647 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2648 | public static final String ACTION_PROVIDER_CHANGED = |
| 2649 | "android.intent.action.PROVIDER_CHANGED"; |
| 2650 | |
| 2651 | /** |
| 2652 | * Broadcast Action: Wired Headset plugged in or unplugged. |
| 2653 | * |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2654 | * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value |
| 2655 | * and documentation. |
| 2656 | * <p>If the minimum SDK version of your application is |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 2657 | * {@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] | 2658 | * 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] | 2659 | */ |
| 2660 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2661 | 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] | 2662 | |
| 2663 | /** |
Joe Onorato | 9cdffa1 | 2011-04-06 18:27:27 -0700 | [diff] [blame] | 2664 | * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> |
| 2665 | * <ul> |
| 2666 | * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> |
| 2667 | * </ul> |
| 2668 | * |
| 2669 | * <p class="note">This is a protected intent that can only be sent |
| 2670 | * by the system. |
| 2671 | * |
| 2672 | * @hide |
| 2673 | */ |
| 2674 | //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2675 | public static final String ACTION_ADVANCED_SETTINGS_CHANGED |
| 2676 | = "android.intent.action.ADVANCED_SETTINGS"; |
| 2677 | |
| 2678 | /** |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 2679 | * Broadcast Action: Sent after application restrictions are changed. |
| 2680 | * |
| 2681 | * <p class="note">This is a protected intent that can only be sent |
| 2682 | * by the system.</p> |
| 2683 | */ |
| 2684 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2685 | public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = |
| 2686 | "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; |
| 2687 | |
| 2688 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2689 | * Broadcast Action: An outgoing call is about to be placed. |
| 2690 | * |
Dirk Dougherty | 367ce90 | 2013-05-28 17:37:12 -0700 | [diff] [blame] | 2691 | * <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] | 2692 | * <ul> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2693 | * <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] | 2694 | * the phone number originally intended to be dialed.</li> |
| 2695 | * </ul> |
| 2696 | * <p>Once the broadcast is finished, the resultData is used as the actual |
| 2697 | * 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] | 2698 | * <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] | 2699 | * outgoing call in turn: for example, a parental control application |
| 2700 | * might verify that the user is authorized to place the call at that |
| 2701 | * time, then a number-rewriting application might add an area code if |
| 2702 | * one was not specified.</p> |
| 2703 | * <p>For consistency, any receiver whose purpose is to prohibit phone |
| 2704 | * calls should have a priority of 0, to ensure it will see the final |
| 2705 | * phone number to be dialed. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2706 | * 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] | 2707 | * should have a positive priority. |
| 2708 | * Negative priorities are reserved for the system for this broadcast; |
| 2709 | * using them may cause problems.</p> |
Dirk Dougherty | 932fbcc | 2013-05-29 15:19:14 -0700 | [diff] [blame] | 2710 | * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> |
| 2711 | * abort the broadcast.</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2712 | * <p>Emergency calls cannot be intercepted using this mechanism, and |
| 2713 | * other calls cannot be modified to call emergency numbers using this |
| 2714 | * mechanism. |
Santos Cordon | ba70136 | 2013-05-17 14:48:54 -0700 | [diff] [blame] | 2715 | * <p>Some apps (such as VoIP apps) may want to redirect the outgoing |
| 2716 | * call to use their own service instead. Those apps should first prevent |
| 2717 | * the call from being placed by setting resultData to <code>null</code> |
| 2718 | * 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] | 2719 | * <p>You must hold the |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2720 | * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} |
| 2721 | * permission to receive this Intent.</p> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2722 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2723 | * <p class="note">This is a protected intent that can only be sent |
| 2724 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2725 | */ |
| 2726 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2727 | public static final String ACTION_NEW_OUTGOING_CALL = |
| 2728 | "android.intent.action.NEW_OUTGOING_CALL"; |
| 2729 | |
| 2730 | /** |
| 2731 | * Broadcast Action: Have the device reboot. This is only for use by |
| 2732 | * system code. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2733 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2734 | * <p class="note">This is a protected intent that can only be sent |
| 2735 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2736 | */ |
| 2737 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2738 | public static final String ACTION_REBOOT = |
| 2739 | "android.intent.action.REBOOT"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2740 | |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2741 | /** |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2742 | * Broadcast Action: A sticky broadcast for changes in the physical |
| 2743 | * docking state of the device. |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2744 | * |
| 2745 | * <p>The intent will have the following extra values: |
| 2746 | * <ul> |
| 2747 | * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2748 | * state, indicating which dock the device is physically in.</li> |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2749 | * </ul> |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2750 | * <p>This is intended for monitoring the current physical dock state. |
| 2751 | * See {@link android.app.UiModeManager} for the normal API dealing with |
| 2752 | * dock mode changes. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2753 | */ |
| 2754 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2755 | public static final String ACTION_DOCK_EVENT = |
| 2756 | "android.intent.action.DOCK_EVENT"; |
| 2757 | |
| 2758 | /** |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2759 | * Broadcast Action: A broadcast when idle maintenance can be started. |
| 2760 | * This means that the user is not interacting with the device and is |
| 2761 | * not expected to do so soon. Typical use of the idle maintenance is |
| 2762 | * to perform somehow expensive tasks that can be postponed at a moment |
| 2763 | * when they will not degrade user experience. |
| 2764 | * <p> |
| 2765 | * <p class="note">In order to keep the device responsive in case of an |
| 2766 | * unexpected user interaction, implementations of a maintenance task |
| 2767 | * should be interruptible. In such a scenario a broadcast with action |
| 2768 | * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you |
| 2769 | * should not do the maintenance work in |
| 2770 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a |
| 2771 | * maintenance service by {@link Context#startService(Intent)}. Also |
| 2772 | * you should hold a wake lock while your maintenance service is running |
| 2773 | * to prevent the device going to sleep. |
| 2774 | * </p> |
| 2775 | * <p> |
| 2776 | * <p class="note">This is a protected intent that can only be sent by |
| 2777 | * the system. |
| 2778 | * </p> |
| 2779 | * |
| 2780 | * @see #ACTION_IDLE_MAINTENANCE_END |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2781 | * |
| 2782 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2783 | */ |
| 2784 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2785 | public static final String ACTION_IDLE_MAINTENANCE_START = |
| 2786 | "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; |
| 2787 | |
| 2788 | /** |
| 2789 | * Broadcast Action: A broadcast when idle maintenance should be stopped. |
| 2790 | * This means that the user was not interacting with the device as a result |
| 2791 | * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} |
| 2792 | * was sent and now the user started interacting with the device. Typical |
| 2793 | * use of the idle maintenance is to perform somehow expensive tasks that |
| 2794 | * can be postponed at a moment when they will not degrade user experience. |
| 2795 | * <p> |
| 2796 | * <p class="note">In order to keep the device responsive in case of an |
| 2797 | * unexpected user interaction, implementations of a maintenance task |
| 2798 | * should be interruptible. Hence, on receiving a broadcast with this |
| 2799 | * action, the maintenance task should be interrupted as soon as possible. |
| 2800 | * In other words, you should not do the maintenance work in |
| 2801 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the |
| 2802 | * maintenance service that was started on receiving of |
| 2803 | * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake |
| 2804 | * lock you acquired when your maintenance service started. |
| 2805 | * </p> |
| 2806 | * <p class="note">This is a protected intent that can only be sent |
| 2807 | * by the system. |
| 2808 | * |
| 2809 | * @see #ACTION_IDLE_MAINTENANCE_START |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2810 | * |
| 2811 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2812 | */ |
| 2813 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2814 | public static final String ACTION_IDLE_MAINTENANCE_END = |
| 2815 | "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; |
| 2816 | |
| 2817 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2818 | * Broadcast Action: a remote intent is to be broadcasted. |
| 2819 | * |
| 2820 | * A remote intent is used for remote RPC between devices. The remote intent |
| 2821 | * is serialized and sent from one device to another device. The receiving |
| 2822 | * device parses the remote intent and broadcasts it. Note that anyone can |
| 2823 | * broadcast a remote intent. However, if the intent receiver of the remote intent |
| 2824 | * does not trust intent broadcasts from arbitrary intent senders, it should require |
| 2825 | * the sender to hold certain permissions so only trusted sender's broadcast will be |
| 2826 | * let through. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2827 | * @hide |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2828 | */ |
| 2829 | public static final String ACTION_REMOTE_INTENT = |
Costin Manolache | 8d83f9e | 2010-05-12 16:04:10 -0700 | [diff] [blame] | 2830 | "com.google.android.c2dm.intent.RECEIVE"; |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2831 | |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2832 | /** |
Jeff Sharkey | bd91e2f | 2016-03-22 15:32:31 -0600 | [diff] [blame] | 2833 | * Broadcast Action: This is broadcast once when the user is booting after a |
| 2834 | * system update. It can be used to perform cleanup or upgrades after a |
| 2835 | * system update. |
| 2836 | * <p> |
| 2837 | * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} |
| 2838 | * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's |
| 2839 | * only sent when the {@link Build#FINGERPRINT} has changed, and it's only |
| 2840 | * sent to receivers in the system image. |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2841 | * |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2842 | * @hide |
| 2843 | */ |
| 2844 | public static final String ACTION_PRE_BOOT_COMPLETED = |
| 2845 | "android.intent.action.PRE_BOOT_COMPLETED"; |
| 2846 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2847 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2848 | * Broadcast to a specific application to query any supported restrictions to impose |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 2849 | * on restricted users. The broadcast intent contains an extra |
| 2850 | * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted |
| 2851 | * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or |
| 2852 | * String[] depending on the restriction type.<p/> |
| 2853 | * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 2854 | * which is of type <code>ArrayList<RestrictionEntry></code>. It can also |
| 2855 | * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. |
| 2856 | * 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] | 2857 | * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. |
| 2858 | * The keys and values of the returned restrictions will be persisted. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2859 | * @see RestrictionEntry |
| 2860 | */ |
| 2861 | public static final String ACTION_GET_RESTRICTION_ENTRIES = |
| 2862 | "android.intent.action.GET_RESTRICTION_ENTRIES"; |
| 2863 | |
| 2864 | /** |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2865 | * Sent the first time a user is starting, to allow system apps to |
| 2866 | * perform one time initialization. (This will not be seen by third |
| 2867 | * party applications because a newly initialized user does not have any |
| 2868 | * third party applications installed for it.) This is sent early in |
| 2869 | * starting the user, around the time the home app is started, before |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2870 | * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground |
| 2871 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2872 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2873 | */ |
| 2874 | public static final String ACTION_USER_INITIALIZE = |
| 2875 | "android.intent.action.USER_INITIALIZE"; |
| 2876 | |
| 2877 | /** |
| 2878 | * Sent when a user switch is happening, causing the process's user to be |
| 2879 | * brought to the foreground. This is only sent to receivers registered |
| 2880 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2881 | * 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] | 2882 | * foreground. This is sent as a foreground |
| 2883 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2884 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2885 | */ |
| 2886 | public static final String ACTION_USER_FOREGROUND = |
| 2887 | "android.intent.action.USER_FOREGROUND"; |
| 2888 | |
| 2889 | /** |
| 2890 | * Sent when a user switch is happening, causing the process's user to be |
| 2891 | * sent to the background. This is only sent to receivers registered |
| 2892 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2893 | * 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] | 2894 | * background. This is sent as a foreground |
| 2895 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2896 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2897 | */ |
| 2898 | public static final String ACTION_USER_BACKGROUND = |
| 2899 | "android.intent.action.USER_BACKGROUND"; |
| 2900 | |
| 2901 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2902 | * Broadcast sent to the system when a user is added. Carries an extra |
| 2903 | * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to |
| 2904 | * all running users. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2905 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2906 | * @hide |
| 2907 | */ |
| 2908 | public static final String ACTION_USER_ADDED = |
| 2909 | "android.intent.action.USER_ADDED"; |
| 2910 | |
| 2911 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2912 | * Broadcast sent by the system when a user is started. Carries an extra |
| 2913 | * 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] | 2914 | * registered receivers, not manifest receivers. It is sent to the user |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2915 | * that has been started. This is sent as a foreground |
| 2916 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2917 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2918 | * @hide |
| 2919 | */ |
| 2920 | public static final String ACTION_USER_STARTED = |
| 2921 | "android.intent.action.USER_STARTED"; |
| 2922 | |
| 2923 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2924 | * Broadcast sent when a user is in the process of starting. Carries an extra |
| 2925 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 2926 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 2927 | * users (including the one that is being started). You must hold |
| 2928 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 2929 | * this broadcast. This is sent as a background broadcast, since |
| 2930 | * its result is not part of the primary UX flow; to safely keep track of |
| 2931 | * started/stopped state of a user you can use this in conjunction with |
| 2932 | * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with |
| 2933 | * other user state broadcasts since those are foreground broadcasts so can |
| 2934 | * execute in a different order. |
| 2935 | * @hide |
| 2936 | */ |
| 2937 | public static final String ACTION_USER_STARTING = |
| 2938 | "android.intent.action.USER_STARTING"; |
| 2939 | |
| 2940 | /** |
| 2941 | * Broadcast sent when a user is going to be stopped. Carries an extra |
| 2942 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 2943 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 2944 | * users (including the one that is being stopped). You must hold |
| 2945 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 2946 | * this broadcast. The user will not stop until all receivers have |
| 2947 | * handled the broadcast. This is sent as a background broadcast, since |
| 2948 | * its result is not part of the primary UX flow; to safely keep track of |
| 2949 | * started/stopped state of a user you can use this in conjunction with |
| 2950 | * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with |
| 2951 | * other user state broadcasts since those are foreground broadcasts so can |
| 2952 | * execute in a different order. |
| 2953 | * @hide |
| 2954 | */ |
| 2955 | public static final String ACTION_USER_STOPPING = |
| 2956 | "android.intent.action.USER_STOPPING"; |
| 2957 | |
| 2958 | /** |
| 2959 | * Broadcast sent to the system when a user is stopped. Carries an extra |
| 2960 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to |
| 2961 | * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a |
| 2962 | * specific package. This is only sent to registered receivers, not manifest |
| 2963 | * receivers. It is sent to all running users <em>except</em> the one that |
| 2964 | * has just been stopped (which is no longer running). |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 2965 | * @hide |
| 2966 | */ |
| 2967 | public static final String ACTION_USER_STOPPED = |
| 2968 | "android.intent.action.USER_STOPPED"; |
| 2969 | |
| 2970 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 2971 | * 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] | 2972 | * 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] | 2973 | * one that has been removed. The user will not be completely removed until all receivers have |
| 2974 | * handled the broadcast. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2975 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2976 | * @hide |
| 2977 | */ |
| 2978 | public static final String ACTION_USER_REMOVED = |
| 2979 | "android.intent.action.USER_REMOVED"; |
| 2980 | |
| 2981 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 2982 | * 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] | 2983 | * the userHandle of the user to become the current one. This is only sent to |
| 2984 | * registered receivers, not manifest receivers. It is sent to all running users. |
| 2985 | * You must hold |
| 2986 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2987 | * @hide |
| 2988 | */ |
| 2989 | public static final String ACTION_USER_SWITCHED = |
| 2990 | "android.intent.action.USER_SWITCHED"; |
| 2991 | |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 2992 | /** |
Jeff Sharkey | 8924e87 | 2015-11-30 12:52:10 -0700 | [diff] [blame] | 2993 | * Broadcast Action: Sent when the credential-encrypted private storage has |
| 2994 | * become unlocked for the target user. This is only sent to registered |
| 2995 | * receivers, not manifest receivers. |
| 2996 | */ |
| 2997 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2998 | public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; |
| 2999 | |
| 3000 | /** |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 3001 | * Broadcast sent to the system when a user's information changes. Carries an extra |
| 3002 | * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 3003 | * 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] | 3004 | * @hide |
| 3005 | */ |
| 3006 | public static final String ACTION_USER_INFO_CHANGED = |
| 3007 | "android.intent.action.USER_INFO_CHANGED"; |
| 3008 | |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 3009 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3010 | * Broadcast sent to the primary user when an associated managed profile is added (the profile |
| 3011 | * 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] | 3012 | * the UserHandle of the profile that was added. Only applications (for example Launchers) |
| 3013 | * that need to display merged content across both primary and managed profiles need to |
| 3014 | * worry about this broadcast. This is only sent to registered receivers, |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3015 | * not manifest receivers. |
| 3016 | */ |
| 3017 | public static final String ACTION_MANAGED_PROFILE_ADDED = |
| 3018 | "android.intent.action.MANAGED_PROFILE_ADDED"; |
| 3019 | |
| 3020 | /** |
| 3021 | * 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] | 3022 | * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. |
| 3023 | * Only applications (for example Launchers) that need to display merged content across both |
| 3024 | * primary and managed profiles need to worry about this broadcast. This is only sent to |
| 3025 | * registered receivers, not manifest receivers. |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3026 | */ |
| 3027 | public static final String ACTION_MANAGED_PROFILE_REMOVED = |
| 3028 | "android.intent.action.MANAGED_PROFILE_REMOVED"; |
| 3029 | |
| 3030 | /** |
Kenny Guy | b1b3026 | 2016-02-09 16:02:35 +0000 | [diff] [blame] | 3031 | * Broadcast sent to the primary user when the credential-encrypted private storage for |
| 3032 | * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that |
| 3033 | * specifies the UserHandle of the profile that was unlocked. Only applications (for example |
| 3034 | * Launchers) that need to display merged content across both primary and managed profiles |
| 3035 | * need to worry about this broadcast. This is only sent to registered receivers, |
| 3036 | * not manifest receivers. |
| 3037 | */ |
| 3038 | public static final String ACTION_MANAGED_PROFILE_UNLOCKED = |
| 3039 | "android.intent.action.MANAGED_PROFILE_UNLOCKED"; |
| 3040 | |
| 3041 | /** |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 3042 | * Broadcast sent to the primary user when an associated managed profile has become available. |
| 3043 | * 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] | 3044 | * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, |
| 3045 | * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state |
| 3046 | * 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] | 3047 | */ |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 3048 | public static final String ACTION_MANAGED_PROFILE_AVAILABLE = |
| 3049 | "android.intent.action.MANAGED_PROFILE_AVAILABLE"; |
| 3050 | |
| 3051 | /** |
| 3052 | * Broadcast sent to the primary user when an associated managed profile has become unavailable. |
| 3053 | * Currently this includes when the user enables quiet mode for the profile. Carries an extra |
| 3054 | * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, |
| 3055 | * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state |
| 3056 | * of quiet mode. This is only sent to registered receivers, not manifest receivers. |
| 3057 | */ |
| 3058 | public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = |
| 3059 | "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 3060 | |
| 3061 | /** |
Robin Lee | 92b83c6 | 2016-08-31 13:27:51 +0100 | [diff] [blame] | 3062 | * Broadcast sent to the system user when the 'device locked' state changes for any user. |
| 3063 | * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which |
| 3064 | * the device was locked or unlocked. |
| 3065 | * |
| 3066 | * This is only sent to registered receivers. |
| 3067 | * |
| 3068 | * @hide |
| 3069 | */ |
| 3070 | public static final String ACTION_DEVICE_LOCKED_CHANGED = |
| 3071 | "android.intent.action.DEVICE_LOCKED_CHANGED"; |
| 3072 | |
| 3073 | /** |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 3074 | * Sent when the user taps on the clock widget in the system's "quick settings" area. |
| 3075 | */ |
| 3076 | public static final String ACTION_QUICK_CLOCK = |
| 3077 | "android.intent.action.QUICK_CLOCK"; |
| 3078 | |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 3079 | /** |
Alan Viverette | 5a39949 | 2014-07-14 16:19:38 -0700 | [diff] [blame] | 3080 | * Activity Action: Shows the brightness setting dialog. |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 3081 | * @hide |
| 3082 | */ |
| 3083 | public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = |
| 3084 | "android.intent.action.SHOW_BRIGHTNESS_DIALOG"; |
| 3085 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3086 | /** |
| 3087 | * Broadcast Action: A global button was pressed. Includes a single |
| 3088 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 3089 | * caused the broadcast. |
| 3090 | * @hide |
| 3091 | */ |
| 3092 | public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; |
| 3093 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3094 | /** |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 3095 | * Broadcast Action: Sent when media resource is granted. |
| 3096 | * <p> |
| 3097 | * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource |
| 3098 | * granted. |
| 3099 | * </p> |
| 3100 | * <p class="note"> |
| 3101 | * This is a protected intent that can only be sent by the system. |
| 3102 | * </p> |
| 3103 | * <p class="note"> |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 3104 | * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 3105 | * </p> |
| 3106 | * |
| 3107 | * @hide |
| 3108 | */ |
| 3109 | public static final String ACTION_MEDIA_RESOURCE_GRANTED = |
| 3110 | "android.intent.action.MEDIA_RESOURCE_GRANTED"; |
| 3111 | |
| 3112 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3113 | * Activity Action: Allow the user to select and return one or more existing |
| 3114 | * documents. When invoked, the system will display the various |
| 3115 | * {@link DocumentsProvider} instances installed on the device, letting the |
| 3116 | * user interactively navigate through them. These documents include local |
| 3117 | * media, such as photos and video, and documents provided by installed |
| 3118 | * cloud storage providers. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3119 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3120 | * Each document is represented as a {@code content://} URI backed by a |
| 3121 | * {@link DocumentsProvider}, which can be opened as a stream with |
| 3122 | * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for |
| 3123 | * {@link android.provider.DocumentsContract.Document} metadata. |
| 3124 | * <p> |
| 3125 | * All selected documents are returned to the calling application with |
| 3126 | * persistable read and write permission grants. If you want to maintain |
| 3127 | * access to the documents across device reboots, you need to explicitly |
| 3128 | * take the persistable permissions using |
| 3129 | * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. |
| 3130 | * <p> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3131 | * Callers must indicate the acceptable document MIME types through |
| 3132 | * {@link #setType(String)}. For example, to select photos, use |
| 3133 | * {@code image/*}. If multiple disjoint MIME types are acceptable, define |
| 3134 | * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to |
| 3135 | * {@literal *}/*. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3136 | * <p> |
| 3137 | * If the caller can handle multiple returned items (the user performing |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3138 | * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 3139 | * to indicate this. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3140 | * <p> |
Tomasz Mikolajewski | a8057a9 | 2015-11-16 11:41:28 +0900 | [diff] [blame] | 3141 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain |
| 3142 | * URIs that can be opened with |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3143 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3144 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 3145 | * Callers can set a document URI through |
| 3146 | * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial |
| 3147 | * location of documents navigator. System will do its best to launch the |
| 3148 | * navigator in the specified document if it's a folder, or the folder that |
| 3149 | * contains the specified document if not. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3150 | * <p> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3151 | * Output: The URI of the item that was picked, returned in |
| 3152 | * {@link #getData()}. This must be a {@code content://} URI so that any |
| 3153 | * receiver can access it. If multiple documents were selected, they are |
| 3154 | * returned in {@link #getClipData()}. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3155 | * |
| 3156 | * @see DocumentsContract |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3157 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3158 | * @see #ACTION_CREATE_DOCUMENT |
| 3159 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3160 | */ |
| 3161 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3162 | public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; |
| 3163 | |
| 3164 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3165 | * Activity Action: Allow the user to create a new document. When invoked, |
| 3166 | * the system will display the various {@link DocumentsProvider} instances |
| 3167 | * installed on the device, letting the user navigate through them. The |
| 3168 | * returned document may be a newly created document with no content, or it |
| 3169 | * may be an existing document with the requested MIME type. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3170 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3171 | * Each document is represented as a {@code content://} URI backed by a |
| 3172 | * {@link DocumentsProvider}, which can be opened as a stream with |
| 3173 | * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for |
| 3174 | * {@link android.provider.DocumentsContract.Document} metadata. |
| 3175 | * <p> |
| 3176 | * Callers must indicate the concrete MIME type of the document being |
| 3177 | * created by setting {@link #setType(String)}. This MIME type cannot be |
| 3178 | * changed after the document is created. |
| 3179 | * <p> |
| 3180 | * Callers can provide an initial display name through {@link #EXTRA_TITLE}, |
| 3181 | * but the user may change this value before creating the file. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3182 | * <p> |
Tomasz Mikolajewski | a8057a9 | 2015-11-16 11:41:28 +0900 | [diff] [blame] | 3183 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain |
| 3184 | * URIs that can be opened with |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3185 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3186 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 3187 | * Callers can set a document URI through |
| 3188 | * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial |
| 3189 | * location of documents navigator. System will do its best to launch the |
| 3190 | * navigator in the specified document if it's a folder, or the folder that |
| 3191 | * contains the specified document if not. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3192 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3193 | * Output: The URI of the item that was created. This must be a |
| 3194 | * {@code content://} URI so that any receiver can access it. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3195 | * |
| 3196 | * @see DocumentsContract |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3197 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3198 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3199 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3200 | */ |
| 3201 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3202 | public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; |
| 3203 | |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3204 | /** |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3205 | * Activity Action: Allow the user to pick a directory subtree. When |
| 3206 | * invoked, the system will display the various {@link DocumentsProvider} |
| 3207 | * instances installed on the device, letting the user navigate through |
| 3208 | * them. Apps can fully manage documents within the returned directory. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3209 | * <p> |
| 3210 | * To gain access to descendant (child, grandchild, etc) documents, use |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3211 | * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and |
| 3212 | * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} |
| 3213 | * with the returned URI. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3214 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 3215 | * Callers can set a document URI through |
| 3216 | * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial |
| 3217 | * location of documents navigator. System will do its best to launch the |
| 3218 | * navigator in the specified document if it's a folder, or the folder that |
| 3219 | * contains the specified document if not. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3220 | * <p> |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3221 | * Output: The URI representing the selected directory tree. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3222 | * |
| 3223 | * @see DocumentsContract |
| 3224 | */ |
| 3225 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3226 | public static final String |
| 3227 | ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3228 | |
Felipe Leme | c7b1f89 | 2016-01-15 15:02:31 -0800 | [diff] [blame] | 3229 | /** |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 3230 | * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or |
| 3231 | * exisiting sensor being disconnected. |
| 3232 | * |
| 3233 | * <p class="note">This is a protected intent that can only be sent by the system.</p> |
| 3234 | * |
| 3235 | * {@hide} |
| 3236 | */ |
| 3237 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3238 | public static final String |
| 3239 | ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; |
| 3240 | |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3241 | /** |
| 3242 | * Deprecated - use {@link #ACTION_FACTORY_RESET} instead. |
| 3243 | * |
| 3244 | * {@hide} |
| 3245 | */ |
| 3246 | @Deprecated |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 3247 | public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; |
| 3248 | |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 3249 | /** |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3250 | * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory |
| 3251 | * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. |
| 3252 | * |
| 3253 | * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. |
| 3254 | * |
Benjamin Franz | f9d5e6a | 2016-05-26 14:24:29 +0100 | [diff] [blame] | 3255 | * @hide |
| 3256 | */ |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3257 | @Deprecated |
Benjamin Franz | f9d5e6a | 2016-05-26 14:24:29 +0100 | [diff] [blame] | 3258 | public static final String EXTRA_FORCE_MASTER_CLEAR = |
| 3259 | "android.intent.extra.FORCE_MASTER_CLEAR"; |
| 3260 | |
| 3261 | /** |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3262 | * A broadcast action to trigger a factory reset. |
| 3263 | * |
| 3264 | * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. |
| 3265 | * |
| 3266 | * <p>Not for use by third-party applications. |
| 3267 | * |
| 3268 | * @see #EXTRA_FORCE_MASTER_CLEAR |
| 3269 | * |
| 3270 | * {@hide} |
| 3271 | */ |
| 3272 | @SystemApi |
| 3273 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3274 | public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; |
| 3275 | |
| 3276 | /** |
| 3277 | * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory |
| 3278 | * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. |
| 3279 | * |
| 3280 | * <p>Not for use by third-party applications. |
| 3281 | * |
| 3282 | * @hide |
| 3283 | */ |
| 3284 | @SystemApi |
| 3285 | public static final String EXTRA_FORCE_FACTORY_RESET = |
| 3286 | "android.intent.extra.FORCE_FACTORY_RESET"; |
| 3287 | |
| 3288 | /** |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 3289 | * Broadcast action: report that a settings element is being restored from backup. The intent |
| 3290 | * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting, |
| 3291 | * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE |
| 3292 | * is the value of that settings entry prior to the restore operation. All of these values are |
| 3293 | * represented as strings. |
| 3294 | * |
| 3295 | * <p>This broadcast is sent only for settings provider entries known to require special handling |
| 3296 | * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within |
| 3297 | * the provider's backup agent implementation. |
| 3298 | * |
| 3299 | * @see #EXTRA_SETTING_NAME |
| 3300 | * @see #EXTRA_SETTING_PREVIOUS_VALUE |
| 3301 | * @see #EXTRA_SETTING_NEW_VALUE |
| 3302 | * {@hide} |
| 3303 | */ |
| 3304 | public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; |
| 3305 | |
| 3306 | /** {@hide} */ |
| 3307 | public static final String EXTRA_SETTING_NAME = "setting_name"; |
| 3308 | /** {@hide} */ |
| 3309 | public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; |
| 3310 | /** {@hide} */ |
| 3311 | public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; |
| 3312 | |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3313 | /** |
| 3314 | * Activity Action: Process a piece of text. |
| 3315 | * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. |
| 3316 | * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> |
| 3317 | * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> |
| 3318 | */ |
| 3319 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3320 | public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; |
| 3321 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3322 | * The name of the extra used to define the text to be processed, as a |
| 3323 | * CharSequence. Note that this may be a styled CharSequence, so you must use |
| 3324 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3325 | */ |
| 3326 | public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; |
| 3327 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3328 | * 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] | 3329 | */ |
| 3330 | public static final String EXTRA_PROCESS_TEXT_READONLY = |
| 3331 | "android.intent.extra.PROCESS_TEXT_READONLY"; |
| 3332 | |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3333 | /** |
| 3334 | * Broadcast action: reports when a new thermal event has been reached. When the device |
| 3335 | * is reaching its maximum temperatue, the thermal level reported |
| 3336 | * {@hide} |
| 3337 | */ |
| 3338 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3339 | public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; |
| 3340 | |
| 3341 | /** {@hide} */ |
| 3342 | public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; |
| 3343 | |
| 3344 | /** |
| 3345 | * 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] | 3346 | * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3347 | * {@hide} |
| 3348 | */ |
| 3349 | public static final int EXTRA_THERMAL_STATE_NORMAL = 0; |
| 3350 | |
| 3351 | /** |
| 3352 | * 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] | 3353 | * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3354 | * {@hide} |
| 3355 | */ |
| 3356 | public static final int EXTRA_THERMAL_STATE_WARNING = 1; |
| 3357 | |
| 3358 | /** |
| 3359 | * 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] | 3360 | * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3361 | * {@hide} |
| 3362 | */ |
| 3363 | public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; |
| 3364 | |
| 3365 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3366 | // --------------------------------------------------------------------- |
| 3367 | // --------------------------------------------------------------------- |
| 3368 | // Standard intent categories (see addCategory()). |
| 3369 | |
| 3370 | /** |
| 3371 | * Set if the activity should be an option for the default action |
| 3372 | * (center press) to perform on a piece of data. Setting this will |
| 3373 | * hide from the user any activities without it set when performing an |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3374 | * 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] | 3375 | * Intent when initiating an action -- it is for use in intent filters |
| 3376 | * specified in packages. |
| 3377 | */ |
| 3378 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3379 | public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; |
| 3380 | /** |
| 3381 | * Activities that can be safely invoked from a browser must support this |
| 3382 | * category. For example, if the user is viewing a web page or an e-mail |
| 3383 | * and clicks on a link in the text, the Intent generated execute that |
| 3384 | * link will require the BROWSABLE category, so that only activities |
| 3385 | * supporting this category will be considered as possible actions. By |
| 3386 | * supporting this category, you are promising that there is nothing |
| 3387 | * damaging (without user intervention) that can happen by invoking any |
| 3388 | * matching Intent. |
| 3389 | */ |
| 3390 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3391 | public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; |
| 3392 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3393 | * Categories for activities that can participate in voice interaction. |
| 3394 | * An activity that supports this category must be prepared to run with |
| 3395 | * no UI shown at all (though in some case it may have a UI shown), and |
| 3396 | * rely on {@link android.app.VoiceInteractor} to interact with the user. |
| 3397 | */ |
| 3398 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3399 | public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; |
| 3400 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3401 | * Set if the activity should be considered as an alternative action to |
| 3402 | * the data the user is currently viewing. See also |
| 3403 | * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that |
| 3404 | * applies to the selection in a list of items. |
| 3405 | * |
| 3406 | * <p>Supporting this category means that you would like your activity to be |
| 3407 | * displayed in the set of alternative things the user can do, usually as |
| 3408 | * part of the current activity's options menu. You will usually want to |
| 3409 | * include a specific label in the <intent-filter> of this action |
| 3410 | * describing to the user what it does. |
| 3411 | * |
| 3412 | * <p>The action of IntentFilter with this category is important in that it |
| 3413 | * describes the specific action the target will perform. This generally |
| 3414 | * should not be a generic action (such as {@link #ACTION_VIEW}, but rather |
| 3415 | * a specific name such as "com.android.camera.action.CROP. Only one |
| 3416 | * alternative of any particular action will be shown to the user, so using |
| 3417 | * a specific action like this makes sure that your alternative will be |
| 3418 | * displayed while also allowing other applications to provide their own |
| 3419 | * overrides of that particular action. |
| 3420 | */ |
| 3421 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3422 | public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; |
| 3423 | /** |
| 3424 | * Set if the activity should be considered as an alternative selection |
| 3425 | * action to the data the user has currently selected. This is like |
| 3426 | * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list |
| 3427 | * of items from which the user can select, giving them alternatives to the |
| 3428 | * default action that will be performed on it. |
| 3429 | */ |
| 3430 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3431 | public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; |
| 3432 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3433 | * 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] | 3434 | */ |
| 3435 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3436 | public static final String CATEGORY_TAB = "android.intent.category.TAB"; |
| 3437 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3438 | * Should be displayed in the top-level launcher. |
| 3439 | */ |
| 3440 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3441 | public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; |
| 3442 | /** |
Jose Lima | 38b75b6 | 2014-03-11 10:41:39 -0700 | [diff] [blame] | 3443 | * Indicates an activity optimized for Leanback mode, and that should |
| 3444 | * be displayed in the Leanback launcher. |
| 3445 | */ |
| 3446 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3447 | public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; |
| 3448 | /** |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 3449 | * Indicates a Leanback settings activity to be displayed in the Leanback launcher. |
| 3450 | * @hide |
| 3451 | */ |
| 3452 | @SystemApi |
| 3453 | public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; |
| 3454 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3455 | * Provides information about the package it is in; typically used if |
| 3456 | * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide |
| 3457 | * a front-door to the user without having to be shown in the all apps list. |
| 3458 | */ |
| 3459 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3460 | public static final String CATEGORY_INFO = "android.intent.category.INFO"; |
| 3461 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3462 | * This is the home activity, that is the first activity that is displayed |
| 3463 | * when the device boots. |
| 3464 | */ |
| 3465 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3466 | public static final String CATEGORY_HOME = "android.intent.category.HOME"; |
| 3467 | /** |
Anthony Hugh | 979b81a | 2015-09-29 16:50:35 -0700 | [diff] [blame] | 3468 | * This is the home activity that is displayed when the device is finished setting up and ready |
| 3469 | * for use. |
| 3470 | * @hide |
| 3471 | */ |
| 3472 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3473 | public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; |
| 3474 | /** |
Svet Ganov | 50a8bf4 | 2015-07-15 11:04:18 -0700 | [diff] [blame] | 3475 | * This is the setup wizard activity, that is the first activity that is displayed |
| 3476 | * when the user sets up the device for the first time. |
| 3477 | * @hide |
| 3478 | */ |
| 3479 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3480 | public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; |
| 3481 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3482 | * This activity is a preference panel. |
| 3483 | */ |
| 3484 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3485 | public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; |
| 3486 | /** |
| 3487 | * This activity is a development preference panel. |
| 3488 | */ |
| 3489 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3490 | public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; |
| 3491 | /** |
| 3492 | * Capable of running inside a parent activity container. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3493 | */ |
| 3494 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3495 | public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; |
| 3496 | /** |
Patrick Dubroy | 6dabe24 | 2010-08-30 10:43:47 -0700 | [diff] [blame] | 3497 | * This activity allows the user to browse and download new applications. |
| 3498 | */ |
| 3499 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3500 | public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; |
| 3501 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3502 | * This activity may be exercised by the monkey or other automated test tools. |
| 3503 | */ |
| 3504 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3505 | public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; |
| 3506 | /** |
| 3507 | * To be used as a test (not part of the normal user experience). |
| 3508 | */ |
| 3509 | public static final String CATEGORY_TEST = "android.intent.category.TEST"; |
| 3510 | /** |
| 3511 | * To be used as a unit test (run through the Test Harness). |
| 3512 | */ |
| 3513 | public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; |
| 3514 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3515 | * 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] | 3516 | * experience). |
| 3517 | */ |
| 3518 | public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3519 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3520 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3521 | * Used to indicate that an intent only wants URIs that can be opened with |
| 3522 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs |
| 3523 | * must support at least the columns defined in {@link OpenableColumns} when |
| 3524 | * queried. |
| 3525 | * |
| 3526 | * @see #ACTION_GET_CONTENT |
| 3527 | * @see #ACTION_OPEN_DOCUMENT |
| 3528 | * @see #ACTION_CREATE_DOCUMENT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3529 | */ |
| 3530 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3531 | public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; |
| 3532 | |
| 3533 | /** |
Tomasz Mikolajewski | 28a815c | 2016-10-28 15:54:11 +0900 | [diff] [blame] | 3534 | * Used to indicate that an intent filter can accept files which are not necessarily |
| 3535 | * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but |
| 3536 | * at least streamable via |
| 3537 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} |
| 3538 | * using one of the stream types exposed via |
| 3539 | * {@link ContentResolver#getStreamTypes(Uri, String)}. |
| 3540 | * |
| 3541 | * @see #ACTION_SEND |
| 3542 | * @see #ACTION_SEND_MULTIPLE |
| 3543 | */ |
| 3544 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3545 | public static final String CATEGORY_TYPED_OPENABLE = |
| 3546 | "android.intent.category.TYPED_OPENABLE"; |
| 3547 | |
| 3548 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3549 | * To be used as code under test for framework instrumentation tests. |
| 3550 | */ |
| 3551 | public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = |
| 3552 | "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3553 | /** |
| 3554 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3555 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3556 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3557 | */ |
| 3558 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3559 | public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; |
| 3560 | /** |
| 3561 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3562 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3563 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3564 | */ |
| 3565 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3566 | public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 3567 | /** |
| 3568 | * An activity to run when device is inserted into a analog (low end) dock. |
| 3569 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3570 | * information, see {@link android.app.UiModeManager}. |
| 3571 | */ |
| 3572 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3573 | public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; |
| 3574 | |
| 3575 | /** |
| 3576 | * An activity to run when device is inserted into a digital (high end) dock. |
| 3577 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3578 | * information, see {@link android.app.UiModeManager}. |
| 3579 | */ |
| 3580 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3581 | 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] | 3582 | |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 3583 | /** |
| 3584 | * Used to indicate that the activity can be used in a car environment. |
| 3585 | */ |
| 3586 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3587 | public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; |
| 3588 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3589 | // --------------------------------------------------------------------- |
| 3590 | // --------------------------------------------------------------------- |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3591 | // Application launch intent categories (see addCategory()). |
| 3592 | |
| 3593 | /** |
| 3594 | * Used with {@link #ACTION_MAIN} to launch the browser application. |
| 3595 | * The activity should be able to browse the Internet. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3596 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3597 | * since it will not result in the app launching with the correct |
| 3598 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3599 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3600 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3601 | */ |
| 3602 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3603 | public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; |
| 3604 | |
| 3605 | /** |
| 3606 | * Used with {@link #ACTION_MAIN} to launch the calculator application. |
| 3607 | * The activity should be able to perform standard arithmetic operations. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3608 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3609 | * since it will not result in the app launching with the correct |
| 3610 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3611 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3612 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3613 | */ |
| 3614 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3615 | public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; |
| 3616 | |
| 3617 | /** |
| 3618 | * Used with {@link #ACTION_MAIN} to launch the calendar application. |
| 3619 | * The activity should be able to view and manipulate calendar entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3620 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3621 | * since it will not result in the app launching with the correct |
| 3622 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3623 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3624 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3625 | */ |
| 3626 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3627 | public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; |
| 3628 | |
| 3629 | /** |
| 3630 | * Used with {@link #ACTION_MAIN} to launch the contacts application. |
| 3631 | * The activity should be able to view and manipulate address book entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3632 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3633 | * since it will not result in the app launching with the correct |
| 3634 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3635 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3636 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3637 | */ |
| 3638 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3639 | public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; |
| 3640 | |
| 3641 | /** |
| 3642 | * Used with {@link #ACTION_MAIN} to launch the email application. |
| 3643 | * The activity should be able to send and receive email. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3644 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3645 | * since it will not result in the app launching with the correct |
| 3646 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3647 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3648 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3649 | */ |
| 3650 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3651 | public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; |
| 3652 | |
| 3653 | /** |
| 3654 | * Used with {@link #ACTION_MAIN} to launch the gallery application. |
| 3655 | * The activity should be able to view and manipulate image and video files |
| 3656 | * stored on the device. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3657 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3658 | * since it will not result in the app launching with the correct |
| 3659 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3660 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3661 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3662 | */ |
| 3663 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3664 | public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; |
| 3665 | |
| 3666 | /** |
| 3667 | * Used with {@link #ACTION_MAIN} to launch the maps application. |
| 3668 | * 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] | 3669 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3670 | * since it will not result in the app launching with the correct |
| 3671 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3672 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3673 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3674 | */ |
| 3675 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3676 | public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; |
| 3677 | |
| 3678 | /** |
| 3679 | * Used with {@link #ACTION_MAIN} to launch the messaging application. |
| 3680 | * The activity should be able to send and receive text messages. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3681 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3682 | * since it will not result in the app launching with the correct |
| 3683 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3684 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3685 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3686 | */ |
| 3687 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3688 | public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; |
| 3689 | |
| 3690 | /** |
| 3691 | * Used with {@link #ACTION_MAIN} to launch the music application. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3692 | * The activity should be able to play, browse, or manipulate music files |
| 3693 | * stored on the device. |
| 3694 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3695 | * since it will not result in the app launching with the correct |
| 3696 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3697 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3698 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3699 | */ |
| 3700 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3701 | public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; |
| 3702 | |
| 3703 | // --------------------------------------------------------------------- |
| 3704 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3705 | // Standard extra data keys. |
| 3706 | |
| 3707 | /** |
| 3708 | * The initial data to place in a newly created record. Use with |
| 3709 | * {@link #ACTION_INSERT}. The data here is a Map containing the same |
| 3710 | * fields as would be given to the underlying ContentProvider.insert() |
| 3711 | * call. |
| 3712 | */ |
| 3713 | public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; |
| 3714 | |
| 3715 | /** |
| 3716 | * A constant CharSequence that is associated with the Intent, used with |
| 3717 | * {@link #ACTION_SEND} to supply the literal data to be sent. Note that |
| 3718 | * this may be a styled CharSequence, so you must use |
| 3719 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to |
| 3720 | * retrieve it. |
| 3721 | */ |
| 3722 | public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; |
| 3723 | |
| 3724 | /** |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 3725 | * A constant String that is associated with the Intent, used with |
| 3726 | * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} |
| 3727 | * as HTML formatted text. Note that you <em>must</em> also supply |
| 3728 | * {@link #EXTRA_TEXT}. |
| 3729 | */ |
| 3730 | public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; |
| 3731 | |
| 3732 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3733 | * A content: URI holding a stream of data associated with the Intent, |
| 3734 | * used with {@link #ACTION_SEND} to supply the data being sent. |
| 3735 | */ |
| 3736 | public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; |
| 3737 | |
| 3738 | /** |
| 3739 | * A String[] holding e-mail addresses that should be delivered to. |
| 3740 | */ |
| 3741 | public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; |
| 3742 | |
| 3743 | /** |
| 3744 | * A String[] holding e-mail addresses that should be carbon copied. |
| 3745 | */ |
| 3746 | public static final String EXTRA_CC = "android.intent.extra.CC"; |
| 3747 | |
| 3748 | /** |
| 3749 | * A String[] holding e-mail addresses that should be blind carbon copied. |
| 3750 | */ |
| 3751 | public static final String EXTRA_BCC = "android.intent.extra.BCC"; |
| 3752 | |
| 3753 | /** |
| 3754 | * A constant string holding the desired subject line of a message. |
| 3755 | */ |
| 3756 | public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; |
| 3757 | |
| 3758 | /** |
| 3759 | * An Intent describing the choices you would like shown with |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3760 | * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3761 | */ |
| 3762 | public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; |
| 3763 | |
| 3764 | /** |
Clara Bayarri | f7fea16 | 2015-10-22 16:09:52 +0100 | [diff] [blame] | 3765 | * An int representing the user id to be used. |
| 3766 | * |
| 3767 | * @hide |
| 3768 | */ |
| 3769 | public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; |
| 3770 | |
| 3771 | /** |
Clara Bayarri | ea9b10e | 2015-12-04 15:36:26 +0000 | [diff] [blame] | 3772 | * An int representing the task id to be retrieved. This is used when a launch from recents is |
| 3773 | * intercepted by another action such as credentials confirmation to remember which task should |
| 3774 | * be resumed when complete. |
| 3775 | * |
| 3776 | * @hide |
| 3777 | */ |
| 3778 | public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; |
| 3779 | |
| 3780 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3781 | * An Intent[] describing additional, alternate choices you would like shown with |
| 3782 | * {@link #ACTION_CHOOSER}. |
| 3783 | * |
| 3784 | * <p>An app may be capable of providing several different payload types to complete a |
| 3785 | * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos |
| 3786 | * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer |
| 3787 | * several different supported sending mechanisms for sharing, such as the actual "image/*" |
| 3788 | * photo data or a hosted link where the photos can be viewed.</p> |
| 3789 | * |
| 3790 | * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the |
| 3791 | * first/primary/preferred intent in the set. Additional intents specified in |
| 3792 | * this extra are ordered; by default intents that appear earlier in the array will be |
| 3793 | * preferred over intents that appear later in the array as matches for the same |
| 3794 | * target component. To alter this preference, a calling app may also supply |
| 3795 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> |
| 3796 | */ |
| 3797 | public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; |
| 3798 | |
| 3799 | /** |
Adam Powell | 52c3921 | 2016-04-07 15:14:18 -0700 | [diff] [blame] | 3800 | * A {@link ComponentName ComponentName[]} describing components that should be filtered out |
| 3801 | * and omitted from a list of components presented to the user. |
| 3802 | * |
| 3803 | * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components |
| 3804 | * in this array if it otherwise would have shown them. Useful for omitting specific targets |
| 3805 | * from your own package or other apps from your organization if the idea of sending to those |
| 3806 | * targets would be redundant with other app functionality. Filtered components will not |
| 3807 | * be able to present targets from an associated <code>ChooserTargetService</code>.</p> |
| 3808 | */ |
| 3809 | public static final String EXTRA_EXCLUDE_COMPONENTS |
| 3810 | = "android.intent.extra.EXCLUDE_COMPONENTS"; |
| 3811 | |
| 3812 | /** |
| 3813 | * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} |
| 3814 | * describing additional high-priority deep-link targets for the chooser to present to the user. |
| 3815 | * |
| 3816 | * <p>Targets provided in this way will be presented inline with all other targets provided |
| 3817 | * by services from other apps. They will be prioritized before other service targets, but |
| 3818 | * after those targets provided by sources that the user has manually pinned to the front.</p> |
| 3819 | * |
| 3820 | * @see #ACTION_CHOOSER |
| 3821 | */ |
| 3822 | public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; |
| 3823 | |
| 3824 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3825 | * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection |
| 3826 | * from the chooser activity presented by {@link #ACTION_CHOOSER}. |
| 3827 | * |
| 3828 | * <p>An app preparing an action for another app to complete may wish to allow the user to |
| 3829 | * disambiguate between several options for completing the action based on the chosen target |
| 3830 | * or otherwise refine the action before it is invoked. |
| 3831 | * </p> |
| 3832 | * |
| 3833 | * <p>When sent, this IntentSender may be filled in with the following extras:</p> |
| 3834 | * <ul> |
| 3835 | * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> |
| 3836 | * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's |
| 3837 | * chosen target beyond the first</li> |
| 3838 | * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity |
| 3839 | * should fill in and send once the disambiguation is complete</li> |
| 3840 | * </ul> |
| 3841 | */ |
| 3842 | public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER |
| 3843 | = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; |
| 3844 | |
| 3845 | /** |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame^] | 3846 | * An {@code ArrayList} of {@code String} annotations describing content for |
| 3847 | * {@link #ACTION_CHOOSER}. |
| 3848 | * |
| 3849 | * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a |
| 3850 | * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> |
| 3851 | * |
| 3852 | * <p>Annotations should describe the major components or topics of the content. It is up to |
| 3853 | * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be |
| 3854 | * learned in advance, e.g., when creating or saving content, to avoid increasing latency to |
| 3855 | * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are |
| 3856 | * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to |
| 3857 | * use the following annotations when applicable:</p> |
| 3858 | * <ul> |
| 3859 | * <li>"product": represents that the topic of the content is mainly about products, e.g., |
| 3860 | * health & beauty, and office supplies.</li> |
| 3861 | * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g., |
| 3862 | * happy, and sad.</li> |
| 3863 | * <li>"person": represents that the topic of the content is mainly about persons, e.g., |
| 3864 | * face, finger, standing, and walking.</li> |
| 3865 | * <li>"child": represents that the topic of the content is mainly about children, e.g., |
| 3866 | * child, and baby.</li> |
| 3867 | * <li>"selfie": represents that the topic of the content is mainly about selfies.</li> |
| 3868 | * <li>"crowd": represents that the topic of the content is mainly about crowds.</li> |
| 3869 | * <li>"party": represents that the topic of the content is mainly about parties.</li> |
| 3870 | * <li>"animal": represent that the topic of the content is mainly about animals.</li> |
| 3871 | * <li>"plant": represents that the topic of the content is mainly about plants, e.g., |
| 3872 | * flowers.</li> |
| 3873 | * <li>"vacation": represents that the topic of the content is mainly about vacations.</li> |
| 3874 | * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g. |
| 3875 | * sunglasses, jewelry, handbags and clothing.</li> |
| 3876 | * <li>"material": represents that the topic of the content is mainly about materials, e.g., |
| 3877 | * paper, and silk.</li> |
| 3878 | * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like |
| 3879 | * cars, and boats.</li> |
| 3880 | * <li>"document": represents that the topic of the content is mainly about documents, e.g. |
| 3881 | * posters.</li> |
| 3882 | * <li>"design": represents that the topic of the content is mainly about design, e.g. arts |
| 3883 | * and designs of houses.</li> |
| 3884 | * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g., |
| 3885 | * Christmas and Thanksgiving.</li> |
| 3886 | * </ul> |
| 3887 | */ |
| 3888 | public static final String EXTRA_CONTENT_ANNOTATIONS |
| 3889 | = "android.intent.extra.CONTENT_ANNOTATIONS"; |
| 3890 | |
| 3891 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3892 | * A {@link ResultReceiver} used to return data back to the sender. |
| 3893 | * |
| 3894 | * <p>Used to complete an app-specific |
| 3895 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> |
| 3896 | * |
| 3897 | * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent |
| 3898 | * used to start a {@link #ACTION_CHOOSER} activity this extra will be |
| 3899 | * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent |
| 3900 | * when the user selects a target component from the chooser. It is up to the recipient |
| 3901 | * to send a result to this ResultReceiver to signal that disambiguation is complete |
| 3902 | * and that the chooser should invoke the user's choice.</p> |
| 3903 | * |
| 3904 | * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent |
| 3905 | * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser |
| 3906 | * to match and fill in the final Intent or ChooserTarget before starting it. |
| 3907 | * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from |
| 3908 | * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to |
| 3909 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> |
| 3910 | * |
| 3911 | * <p>The result code passed to the ResultReceiver should be |
| 3912 | * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's |
| 3913 | * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if |
| 3914 | * the chooser should finish without starting a target.</p> |
| 3915 | */ |
| 3916 | public static final String EXTRA_RESULT_RECEIVER |
| 3917 | = "android.intent.extra.RESULT_RECEIVER"; |
| 3918 | |
| 3919 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3920 | * 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] | 3921 | * {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3922 | */ |
| 3923 | public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; |
| 3924 | |
| 3925 | /** |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 3926 | * A Parcelable[] of {@link Intent} or |
| 3927 | * {@link android.content.pm.LabeledIntent} objects as set with |
| 3928 | * {@link #putExtra(String, Parcelable[])} of additional activities to place |
| 3929 | * a the front of the list of choices, when shown to the user with a |
| 3930 | * {@link #ACTION_CHOOSER}. |
| 3931 | */ |
| 3932 | public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; |
| 3933 | |
| 3934 | /** |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 3935 | * A {@link IntentSender} to start after ephemeral installation success. |
| 3936 | * @hide |
| 3937 | */ |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 3938 | public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS"; |
| 3939 | |
| 3940 | /** |
| 3941 | * A {@link IntentSender} to start after ephemeral installation failure. |
| 3942 | * @hide |
| 3943 | */ |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 3944 | public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE"; |
| 3945 | |
| 3946 | /** |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 3947 | * The host name that triggered an ephemeral resolution. |
| 3948 | * @hide |
| 3949 | */ |
| 3950 | public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME"; |
| 3951 | |
| 3952 | /** |
| 3953 | * An opaque token to track ephemeral resolution. |
| 3954 | * @hide |
| 3955 | */ |
| 3956 | public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN"; |
| 3957 | |
| 3958 | /** |
Adam Powell | e49d939 | 2014-07-17 18:45:19 -0700 | [diff] [blame] | 3959 | * A Bundle forming a mapping of potential target package names to different extras Bundles |
| 3960 | * to add to the default intent extras in {@link #EXTRA_INTENT} when used with |
| 3961 | * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not |
| 3962 | * be currently installed on the device. |
| 3963 | * |
| 3964 | * <p>An application may choose to provide alternate extras for the case where a user |
| 3965 | * selects an activity from a predetermined set of target packages. If the activity |
| 3966 | * the user selects from the chooser belongs to a package with its package name as |
| 3967 | * a key in this bundle, the corresponding extras for that package will be merged with |
| 3968 | * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement |
| 3969 | * extra has the same key as an extra already present in the intent it will overwrite |
| 3970 | * the extra from the intent.</p> |
| 3971 | * |
| 3972 | * <p><em>Examples:</em> |
| 3973 | * <ul> |
| 3974 | * <li>An application may offer different {@link #EXTRA_TEXT} to an application |
| 3975 | * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query |
| 3976 | * parameters for that target.</li> |
| 3977 | * <li>An application may offer additional metadata for known targets of a given intent |
| 3978 | * to pass along information only relevant to that target such as account or content |
| 3979 | * identifiers already known to that application.</li> |
| 3980 | * </ul></p> |
| 3981 | */ |
| 3982 | public static final String EXTRA_REPLACEMENT_EXTRAS = |
| 3983 | "android.intent.extra.REPLACEMENT_EXTRAS"; |
| 3984 | |
| 3985 | /** |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 3986 | * An {@link IntentSender} that will be notified if a user successfully chooses a target |
| 3987 | * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender |
| 3988 | * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the |
| 3989 | * {@link ComponentName} of the chosen component. |
| 3990 | * |
| 3991 | * <p>In some situations this callback may never come, for example if the user abandons |
| 3992 | * the chooser, switches to another task or any number of other reasons. Apps should not |
| 3993 | * be written assuming that this callback will always occur.</p> |
| 3994 | */ |
| 3995 | public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = |
| 3996 | "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; |
| 3997 | |
| 3998 | /** |
| 3999 | * The {@link ComponentName} chosen by the user to complete an action. |
| 4000 | * |
| 4001 | * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER |
| 4002 | */ |
| 4003 | public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; |
| 4004 | |
| 4005 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4006 | * A {@link android.view.KeyEvent} object containing the event that |
| 4007 | * triggered the creation of the Intent it is in. |
| 4008 | */ |
| 4009 | public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; |
| 4010 | |
| 4011 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 4012 | * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user |
| 4013 | * before shutting down. |
| 4014 | * |
| 4015 | * {@hide} |
| 4016 | */ |
| 4017 | public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; |
| 4018 | |
| 4019 | /** |
Yusuke Sato | 705ffd1 | 2015-07-21 15:52:11 -0700 | [diff] [blame] | 4020 | * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is |
| 4021 | * requested by the user. |
| 4022 | * |
| 4023 | * {@hide} |
| 4024 | */ |
| 4025 | public static final String EXTRA_USER_REQUESTED_SHUTDOWN = |
| 4026 | "android.intent.extra.USER_REQUESTED_SHUTDOWN"; |
| 4027 | |
| 4028 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 4029 | * 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] | 4030 | * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action |
| 4031 | * of restarting the application. |
| 4032 | */ |
| 4033 | public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; |
| 4034 | |
| 4035 | /** |
| 4036 | * A String holding the phone number originally entered in |
| 4037 | * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual |
| 4038 | * number to call in a {@link android.content.Intent#ACTION_CALL}. |
| 4039 | */ |
| 4040 | public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 4041 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4042 | /** |
| 4043 | * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} |
| 4044 | * intents to supply the uid the package had been assigned. Also an optional |
| 4045 | * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or |
| 4046 | * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same |
| 4047 | * purpose. |
| 4048 | */ |
| 4049 | public static final String EXTRA_UID = "android.intent.extra.UID"; |
| 4050 | |
| 4051 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 4052 | * @hide String array of package names. |
| 4053 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 4054 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 4055 | public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; |
| 4056 | |
| 4057 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4058 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 4059 | * intents to indicate whether this represents a full uninstall (removing |
| 4060 | * both the code and its data) or a partial uninstall (leaving its data, |
| 4061 | * implying that this is an update). |
| 4062 | */ |
| 4063 | 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] | 4064 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4065 | /** |
Dianne Hackborn | c72fc67 | 2012-09-20 13:12:03 -0700 | [diff] [blame] | 4066 | * @hide |
| 4067 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 4068 | * intents to indicate that at this point the package has been removed for |
| 4069 | * all users on the device. |
| 4070 | */ |
| 4071 | public static final String EXTRA_REMOVED_FOR_ALL_USERS |
| 4072 | = "android.intent.extra.REMOVED_FOR_ALL_USERS"; |
| 4073 | |
| 4074 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4075 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 4076 | * intents to indicate that this is a replacement of the package, so this |
| 4077 | * broadcast will immediately be followed by an add broadcast for a |
| 4078 | * different version of the same package. |
| 4079 | */ |
| 4080 | 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] | 4081 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4082 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4083 | * Used as an int extra field in {@link android.app.AlarmManager} intents |
| 4084 | * to tell the application being invoked how many pending alarms are being |
| 4085 | * delievered with the intent. For one-shot alarms this will always be 1. |
| 4086 | * For recurring alarms, this might be greater than 1 if the device was |
| 4087 | * asleep or powered off at the time an earlier alarm would have been |
| 4088 | * delivered. |
| 4089 | */ |
| 4090 | public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 4091 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4092 | /** |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4093 | * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} |
| 4094 | * intents to request the dock state. Possible values are |
Mike Lockwood | 725fcbf | 2009-08-24 13:09:20 -0700 | [diff] [blame] | 4095 | * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, |
| 4096 | * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 4097 | * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or |
| 4098 | * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or |
| 4099 | * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4100 | */ |
| 4101 | public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; |
| 4102 | |
| 4103 | /** |
| 4104 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4105 | * to represent that the phone is not in any dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4106 | */ |
| 4107 | public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; |
| 4108 | |
| 4109 | /** |
| 4110 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4111 | * to represent that the phone is in a desk dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4112 | */ |
| 4113 | public static final int EXTRA_DOCK_STATE_DESK = 1; |
| 4114 | |
| 4115 | /** |
| 4116 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4117 | * to represent that the phone is in a car dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4118 | */ |
| 4119 | public static final int EXTRA_DOCK_STATE_CAR = 2; |
| 4120 | |
| 4121 | /** |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 4122 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4123 | * to represent that the phone is in a analog (low end) dock. |
| 4124 | */ |
| 4125 | public static final int EXTRA_DOCK_STATE_LE_DESK = 3; |
| 4126 | |
| 4127 | /** |
| 4128 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4129 | * to represent that the phone is in a digital (high end) dock. |
| 4130 | */ |
| 4131 | public static final int EXTRA_DOCK_STATE_HE_DESK = 4; |
| 4132 | |
| 4133 | /** |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 4134 | * Boolean that can be supplied as meta-data with a dock activity, to |
| 4135 | * indicate that the dock should take over the home key when it is active. |
| 4136 | */ |
| 4137 | public static final String METADATA_DOCK_HOME = "android.dock_home"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4138 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 4139 | /** |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4140 | * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing |
| 4141 | * the bug report. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4142 | */ |
| 4143 | public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; |
| 4144 | |
| 4145 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 4146 | * Used in the extra field in the remote intent. It's astring token passed with the |
| 4147 | * remote intent. |
| 4148 | */ |
| 4149 | public static final String EXTRA_REMOTE_INTENT_TOKEN = |
| 4150 | "android.intent.extra.remote_intent_token"; |
| 4151 | |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4152 | /** |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 4153 | * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 4154 | * will contain only the first name in the list. |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4155 | */ |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 4156 | @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4157 | "android.intent.extra.changed_component_name"; |
| 4158 | |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 4159 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4160 | * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 4161 | * and contains a string array of all of the components that have changed. If |
| 4162 | * the state of the overall package has changed, then it will contain an entry |
| 4163 | * with the package name itself. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 4164 | */ |
| 4165 | public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = |
| 4166 | "android.intent.extra.changed_component_name_list"; |
| 4167 | |
| 4168 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4169 | * This field is part of |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 4170 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 4171 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, |
| 4172 | * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, |
| 4173 | * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4174 | * 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] | 4175 | */ |
| 4176 | public static final String EXTRA_CHANGED_PACKAGE_LIST = |
| 4177 | "android.intent.extra.changed_package_list"; |
| 4178 | |
| 4179 | /** |
| 4180 | * This field is part of |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 4181 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
| 4182 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4183 | * and contains an integer array of uids of all of the components |
| 4184 | * that have changed. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4185 | */ |
| 4186 | public static final String EXTRA_CHANGED_UID_LIST = |
| 4187 | "android.intent.extra.changed_uid_list"; |
| 4188 | |
| 4189 | /** |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 4190 | * @hide |
| 4191 | * Magic extra system code can use when binding, to give a label for |
| 4192 | * who it is that has bound to a service. This is an integer giving |
| 4193 | * a framework string resource that can be displayed to the user. |
| 4194 | */ |
| 4195 | public static final String EXTRA_CLIENT_LABEL = |
| 4196 | "android.intent.extra.client_label"; |
| 4197 | |
| 4198 | /** |
| 4199 | * @hide |
| 4200 | * Magic extra system code can use when binding, to give a PendingIntent object |
| 4201 | * that can be launched for the user to disable the system's use of this |
| 4202 | * service. |
| 4203 | */ |
| 4204 | public static final String EXTRA_CLIENT_INTENT = |
| 4205 | "android.intent.extra.client_intent"; |
| 4206 | |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 4207 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4208 | * Extra used to indicate that an intent should only return data that is on |
| 4209 | * the local device. This is a boolean extra; the default is false. If true, |
| 4210 | * an implementation should only allow the user to select data that is |
| 4211 | * already on the device, not requiring it be downloaded from a remote |
| 4212 | * service when opened. |
| 4213 | * |
| 4214 | * @see #ACTION_GET_CONTENT |
| 4215 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 4216 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4217 | * @see #ACTION_CREATE_DOCUMENT |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 4218 | */ |
| 4219 | public static final String EXTRA_LOCAL_ONLY = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4220 | "android.intent.extra.LOCAL_ONLY"; |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 4221 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 4222 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4223 | * Extra used to indicate that an intent can allow the user to select and |
| 4224 | * return multiple items. This is a boolean extra; the default is false. If |
| 4225 | * true, an implementation is allowed to present the user with a UI where |
| 4226 | * they can pick multiple items that are all returned to the caller. When |
| 4227 | * this happens, they should be returned as the {@link #getClipData()} part |
| 4228 | * of the result Intent. |
| 4229 | * |
| 4230 | * @see #ACTION_GET_CONTENT |
| 4231 | * @see #ACTION_OPEN_DOCUMENT |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 4232 | */ |
| 4233 | public static final String EXTRA_ALLOW_MULTIPLE = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4234 | "android.intent.extra.ALLOW_MULTIPLE"; |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 4235 | |
| 4236 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 4237 | * The integer userHandle carried with broadcast intents related to addition, removal and |
| 4238 | * switching of users and managed profiles - {@link #ACTION_USER_ADDED}, |
| 4239 | * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. |
| 4240 | * |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 4241 | * @hide |
| 4242 | */ |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 4243 | public static final String EXTRA_USER_HANDLE = |
| 4244 | "android.intent.extra.user_handle"; |
Jean-Michel Trivi | 3114ce3 | 2012-06-11 15:03:52 -0700 | [diff] [blame] | 4245 | |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4246 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 4247 | * The UserHandle carried with broadcasts intents related to addition and removal of managed |
| 4248 | * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}. |
| 4249 | */ |
| 4250 | public static final String EXTRA_USER = |
Alexandra Gherghina | 3315f6b | 2014-09-05 15:48:06 +0100 | [diff] [blame] | 4251 | "android.intent.extra.USER"; |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 4252 | |
| 4253 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4254 | * Extra used in the response from a BroadcastReceiver that handles |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 4255 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is |
| 4256 | * <code>ArrayList<RestrictionEntry></code>. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4257 | */ |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 4258 | public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; |
| 4259 | |
| 4260 | /** |
| 4261 | * Extra sent in the intent to the BroadcastReceiver that handles |
| 4262 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing |
| 4263 | * the restrictions as key/value pairs. |
| 4264 | */ |
| 4265 | public static final String EXTRA_RESTRICTIONS_BUNDLE = |
| 4266 | "android.intent.extra.restrictions_bundle"; |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4267 | |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 4268 | /** |
| 4269 | * Extra used in the response from a BroadcastReceiver that handles |
| 4270 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. |
| 4271 | */ |
| 4272 | public static final String EXTRA_RESTRICTIONS_INTENT = |
| 4273 | "android.intent.extra.restrictions_intent"; |
| 4274 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 4275 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4276 | * Extra used to communicate a set of acceptable MIME types. The type of the |
| 4277 | * extra is {@code String[]}. Values may be a combination of concrete MIME |
| 4278 | * types (such as "image/png") and/or partial MIME types (such as |
| 4279 | * "audio/*"). |
| 4280 | * |
| 4281 | * @see #ACTION_GET_CONTENT |
| 4282 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 4283 | */ |
| 4284 | public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; |
| 4285 | |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 4286 | /** |
| 4287 | * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that |
| 4288 | * 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] | 4289 | * When this is true, hardware devices can use this information to determine that |
| 4290 | * they shouldn't do a complete shutdown of their device since this is not a |
| 4291 | * complete shutdown down to the kernel, but only user space restarting. |
| 4292 | * The default if not supplied is false. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 4293 | */ |
| 4294 | public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY |
| 4295 | = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; |
| 4296 | |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 4297 | /** |
Neil Fuller | b7146fe | 2016-11-15 16:52:15 +0000 | [diff] [blame] | 4298 | * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the |
| 4299 | * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, |
| 4300 | * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and |
| 4301 | * {@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] | 4302 | * |
| 4303 | * @hide for internal use only. |
| 4304 | */ |
| 4305 | public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = |
| 4306 | "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; |
Neil Fuller | b7146fe | 2016-11-15 16:52:15 +0000 | [diff] [blame] | 4307 | /** @hide */ |
| 4308 | public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; |
| 4309 | /** @hide */ |
| 4310 | public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; |
| 4311 | /** @hide */ |
| 4312 | public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 4313 | |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 4314 | /** {@hide} */ |
| 4315 | public static final String EXTRA_REASON = "android.intent.extra.REASON"; |
| 4316 | |
Rubin Xu | e8490f1 | 2015-06-25 12:17:48 +0100 | [diff] [blame] | 4317 | /** {@hide} */ |
| 4318 | public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; |
| 4319 | |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 4320 | /** |
| 4321 | * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM |
| 4322 | * activation request. |
| 4323 | * TODO: Add information about the structure and response data used with the pending intent. |
| 4324 | * @hide |
| 4325 | */ |
| 4326 | public static final String EXTRA_SIM_ACTIVATION_RESPONSE = |
| 4327 | "android.intent.extra.SIM_ACTIVATION_RESPONSE"; |
| 4328 | |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 4329 | /** |
| 4330 | * Optional index with semantics depending on the intent action. |
Tomasz Mikolajewski | fe02313 | 2016-03-10 17:42:35 +0900 | [diff] [blame] | 4331 | * |
| 4332 | * <p>The value must be an integer greater or equal to 0. |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 4333 | */ |
Steve McKay | 6eaf3863 | 2015-08-04 10:11:01 -0700 | [diff] [blame] | 4334 | public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; |
| 4335 | |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4336 | /** |
| 4337 | * 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] | 4338 | * When a profile goes into quiet mode, all apps in the profile are killed and the |
| 4339 | * profile user is stopped. Widgets originating from the profile are masked, and app |
| 4340 | * launcher icons are grayed out. |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4341 | */ |
| 4342 | public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4343 | |
| 4344 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4345 | * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4346 | * intents to specify the resource type granted. Possible values are |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4347 | * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or |
| 4348 | * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4349 | * |
| 4350 | * @hide |
| 4351 | */ |
| 4352 | public static final String EXTRA_MEDIA_RESOURCE_TYPE = |
| 4353 | "android.intent.extra.MEDIA_RESOURCE_TYPE"; |
| 4354 | |
| 4355 | /** |
Ben Lin | 145b0ca | 2016-10-14 14:23:40 -0700 | [diff] [blame] | 4356 | * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify |
| 4357 | * whether to show the chooser or not when there is only one application available |
| 4358 | * to choose from. |
| 4359 | * |
| 4360 | * @hide |
| 4361 | */ |
| 4362 | public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = |
| 4363 | "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; |
| 4364 | |
| 4365 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4366 | * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4367 | * to represent that a video codec is allowed to use. |
| 4368 | * |
| 4369 | * @hide |
| 4370 | */ |
| 4371 | public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; |
| 4372 | |
| 4373 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4374 | * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4375 | * to represent that a audio codec is allowed to use. |
| 4376 | * |
| 4377 | * @hide |
| 4378 | */ |
| 4379 | public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; |
| 4380 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4381 | // --------------------------------------------------------------------- |
| 4382 | // --------------------------------------------------------------------- |
| 4383 | // Intent flags (see mFlags variable). |
| 4384 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4385 | /** @hide */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4386 | @IntDef(flag = true, value = { |
| 4387 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, |
| 4388 | FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4389 | @Retention(RetentionPolicy.SOURCE) |
| 4390 | public @interface GrantUriMode {} |
| 4391 | |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4392 | /** @hide */ |
| 4393 | @IntDef(flag = true, value = { |
| 4394 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) |
| 4395 | @Retention(RetentionPolicy.SOURCE) |
| 4396 | public @interface AccessUriMode {} |
| 4397 | |
| 4398 | /** |
| 4399 | * Test if given mode flags specify an access mode, which must be at least |
| 4400 | * read and/or write. |
| 4401 | * |
| 4402 | * @hide |
| 4403 | */ |
| 4404 | public static boolean isAccessUriMode(int modeFlags) { |
| 4405 | return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION |
| 4406 | | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; |
| 4407 | } |
| 4408 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4409 | /** |
| 4410 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4411 | * 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] | 4412 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 4413 | * all URIs as well as recursive traversals through data or other ClipData |
| 4414 | * in Intent items will be granted; only the grant flags of the top-level |
| 4415 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4416 | */ |
| 4417 | public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; |
| 4418 | /** |
| 4419 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4420 | * 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] | 4421 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 4422 | * all URIs as well as recursive traversals through data or other ClipData |
| 4423 | * in Intent items will be granted; only the grant flags of the top-level |
| 4424 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4425 | */ |
| 4426 | public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; |
| 4427 | /** |
| 4428 | * Can be set by the caller to indicate that this Intent is coming from |
| 4429 | * a background operation, not from direct user interaction. |
| 4430 | */ |
| 4431 | public static final int FLAG_FROM_BACKGROUND = 0x00000004; |
| 4432 | /** |
| 4433 | * A flag you can enable for debugging: when set, log messages will be |
| 4434 | * printed during the resolution of this intent to show you what has |
| 4435 | * been found to create the final resolved list. |
| 4436 | */ |
| 4437 | public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 4438 | /** |
| 4439 | * If set, this intent will not match any components in packages that |
| 4440 | * are currently stopped. If this is not set, then the default behavior |
| 4441 | * is to include such applications in the result. |
| 4442 | */ |
| 4443 | public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; |
| 4444 | /** |
| 4445 | * If set, this intent will always match any components in packages that |
| 4446 | * are currently stopped. This is the default behavior when |
| 4447 | * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these |
| 4448 | * flags are set, this one wins (it allows overriding of exclude for |
| 4449 | * places where the framework may automatically set the exclude flag). |
| 4450 | */ |
| 4451 | public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4452 | |
| 4453 | /** |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 4454 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4455 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 4456 | * persisted across device reboots until explicitly revoked with |
| 4457 | * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the |
| 4458 | * grant for possible persisting; the receiving application must call |
| 4459 | * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to |
| 4460 | * actually persist. |
| 4461 | * |
| 4462 | * @see ContentResolver#takePersistableUriPermission(Uri, int) |
| 4463 | * @see ContentResolver#releasePersistableUriPermission(Uri, int) |
| 4464 | * @see ContentResolver#getPersistedUriPermissions() |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4465 | * @see ContentResolver#getOutgoingPersistedUriPermissions() |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 4466 | */ |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 4467 | public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 4468 | |
| 4469 | /** |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4470 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 4471 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant |
| 4472 | * applies to any URI that is a prefix match against the original granted |
| 4473 | * URI. (Without this flag, the URI must match exactly for access to be |
| 4474 | * granted.) Another URI is considered a prefix match only when scheme, |
| 4475 | * authority, and all path segments defined by the prefix are an exact |
| 4476 | * match. |
| 4477 | */ |
| 4478 | public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; |
| 4479 | |
| 4480 | /** |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 4481 | * Internal flag used to indicate that a system component has done their |
Jeff Sharkey | 2f3e353 | 2015-12-21 14:16:43 -0700 | [diff] [blame] | 4482 | * homework and verified that they correctly handle packages and components |
| 4483 | * that come and go over time. In particular: |
| 4484 | * <ul> |
| 4485 | * <li>Apps installed on external storage, which will appear to be |
| 4486 | * uninstalled while the the device is ejected. |
| 4487 | * <li>Apps with encryption unaware components, which will appear to not |
| 4488 | * exist while the device is locked. |
| 4489 | * </ul> |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 4490 | * |
| 4491 | * @hide |
| 4492 | */ |
Jeff Sharkey | 2f3e353 | 2015-12-21 14:16:43 -0700 | [diff] [blame] | 4493 | public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100; |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 4494 | |
| 4495 | /** |
Todd Kennedy | 8e2d9d1 | 2016-06-28 14:09:55 -0700 | [diff] [blame] | 4496 | * Internal flag used to indicate ephemeral applications should not be |
| 4497 | * considered when resolving the intent. |
| 4498 | * |
| 4499 | * @hide |
| 4500 | */ |
| 4501 | public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200; |
| 4502 | |
| 4503 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 4504 | * If set, the new activity is not kept in the history stack. As soon as |
| 4505 | * the user navigates away from it, the activity is finished. This may also |
| 4506 | * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory |
| 4507 | * noHistory} attribute. |
Ricardo Cervera | 92f6a74 | 2014-04-04 11:17:06 -0700 | [diff] [blame] | 4508 | * |
| 4509 | * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} |
| 4510 | * is never invoked when the current activity starts a new activity which |
| 4511 | * sets a result and finishes. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4512 | */ |
| 4513 | public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; |
| 4514 | /** |
| 4515 | * If set, the activity will not be launched if it is already running |
| 4516 | * at the top of the history stack. |
| 4517 | */ |
| 4518 | public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; |
| 4519 | /** |
| 4520 | * If set, this activity will become the start of a new task on this |
| 4521 | * history stack. A task (from the activity that started it to the |
| 4522 | * next task activity) defines an atomic group of activities that the |
| 4523 | * user can move to. Tasks can be moved to the foreground and background; |
| 4524 | * 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] | 4525 | * the same order. See |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4526 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4527 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4528 | * |
| 4529 | * <p>This flag is generally used by activities that want |
| 4530 | * to present a "launcher" style behavior: they give the user a list of |
| 4531 | * separate things that can be done, which otherwise run completely |
| 4532 | * independently of the activity launching them. |
| 4533 | * |
| 4534 | * <p>When using this flag, if a task is already running for the activity |
| 4535 | * you are now starting, then a new activity will not be started; instead, |
| 4536 | * the current task will simply be brought to the front of the screen with |
| 4537 | * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag |
| 4538 | * to disable this behavior. |
| 4539 | * |
| 4540 | * <p>This flag can not be used when the caller is requesting a result from |
| 4541 | * the activity being launched. |
| 4542 | */ |
| 4543 | public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; |
| 4544 | /** |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4545 | * This flag is used to create a new task and launch an activity into it. |
| 4546 | * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} |
| 4547 | * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would |
| 4548 | * search through existing tasks for ones matching this Intent. Only if no such |
| 4549 | * task is found would a new task be created. When paired with |
| 4550 | * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip |
| 4551 | * the search for a matching task and unconditionally start a new task. |
| 4552 | * |
| 4553 | * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this |
| 4554 | * flag unless you are implementing your own |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4555 | * top-level application launcher.</strong> Used in conjunction with |
| 4556 | * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the |
| 4557 | * behavior of bringing an existing task to the foreground. When set, |
| 4558 | * a new task is <em>always</em> started to host the Activity for the |
| 4559 | * Intent, regardless of whether there is already an existing task running |
| 4560 | * the same thing. |
| 4561 | * |
| 4562 | * <p><strong>Because the default system does not include graphical task management, |
| 4563 | * you should not use this flag unless you provide some way for a user to |
| 4564 | * return back to the tasks you have launched.</strong> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4565 | * |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4566 | * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for |
| 4567 | * creating new document tasks. |
| 4568 | * |
| 4569 | * <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] | 4570 | * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4571 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4572 | * <p>See |
| 4573 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4574 | * Stack</a> for more information about tasks. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4575 | * |
| 4576 | * @see #FLAG_ACTIVITY_NEW_DOCUMENT |
| 4577 | * @see #FLAG_ACTIVITY_NEW_TASK |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4578 | */ |
| 4579 | public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; |
| 4580 | /** |
| 4581 | * If set, and the activity being launched is already running in the |
| 4582 | * current task, then instead of launching a new instance of that activity, |
| 4583 | * all of the other activities on top of it will be closed and this Intent |
| 4584 | * will be delivered to the (now on top) old activity as a new Intent. |
| 4585 | * |
| 4586 | * <p>For example, consider a task consisting of the activities: A, B, C, D. |
| 4587 | * If D calls startActivity() with an Intent that resolves to the component |
| 4588 | * of activity B, then C and D will be finished and B receive the given |
| 4589 | * Intent, resulting in the stack now being: A, B. |
| 4590 | * |
Dianne Hackborn | aa52f9a | 2009-08-25 16:01:15 -0700 | [diff] [blame] | 4591 | * <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] | 4592 | * either receive the new intent you are starting here in its |
| 4593 | * 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] | 4594 | * 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] | 4595 | * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in |
| 4596 | * the same intent, then it will be finished and re-created; for all other |
| 4597 | * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this |
| 4598 | * 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] | 4599 | * |
| 4600 | * <p>This launch mode can also be used to good effect in conjunction with |
| 4601 | * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity |
| 4602 | * of a task, it will bring any currently running instance of that task |
| 4603 | * to the foreground, and then clear it to its root state. This is |
| 4604 | * especially useful, for example, when launching an activity from the |
| 4605 | * notification manager. |
| 4606 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4607 | * <p>See |
| 4608 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4609 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4610 | */ |
| 4611 | public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; |
| 4612 | /** |
| 4613 | * If set and this intent is being used to launch a new activity from an |
| 4614 | * existing one, then the reply target of the existing activity will be |
| 4615 | * transfered to the new activity. This way the new activity can call |
| 4616 | * {@link android.app.Activity#setResult} and have that result sent back to |
| 4617 | * the reply target of the original activity. |
| 4618 | */ |
| 4619 | public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; |
| 4620 | /** |
| 4621 | * If set and this intent is being used to launch a new activity from an |
| 4622 | * existing one, the current activity will not be counted as the top |
| 4623 | * activity for deciding whether the new intent should be delivered to |
| 4624 | * the top instead of starting a new one. The previous activity will |
| 4625 | * be used as the top, with the assumption being that the current activity |
| 4626 | * will finish itself immediately. |
| 4627 | */ |
| 4628 | public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; |
| 4629 | /** |
| 4630 | * If set, the new activity is not kept in the list of recently launched |
| 4631 | * activities. |
| 4632 | */ |
| 4633 | public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; |
| 4634 | /** |
| 4635 | * This flag is not normally set by application code, but set for you by |
| 4636 | * the system as described in the |
| 4637 | * {@link android.R.styleable#AndroidManifestActivity_launchMode |
| 4638 | * launchMode} documentation for the singleTask mode. |
| 4639 | */ |
| 4640 | public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; |
| 4641 | /** |
| 4642 | * If set, and this activity is either being started in a new task or |
| 4643 | * bringing to the top an existing task, then it will be launched as |
| 4644 | * the front door of the task. This will result in the application of |
| 4645 | * any affinities needed to have that task in the proper state (either |
| 4646 | * moving activities to or from it), or simply resetting that task to |
| 4647 | * its initial state if needed. |
| 4648 | */ |
| 4649 | public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; |
| 4650 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 4651 | * This flag is not normally set by application code, but set for you by |
| 4652 | * the system if this activity is being launched from history |
| 4653 | * (longpress home key). |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4654 | */ |
| 4655 | 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] | 4656 | /** |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 4657 | * @deprecated As of API 21 this performs identically to |
| 4658 | * {@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] | 4659 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 4660 | @Deprecated |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 4661 | 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] | 4662 | /** |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4663 | * This flag is used to open a document into a new task rooted at the activity launched |
| 4664 | * by this Intent. Through the use of this flag, or its equivalent attribute, |
| 4665 | * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 4666 | * containing different documents will appear in the recent tasks list. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4667 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4668 | * <p>The use of the activity attribute form of this, |
| 4669 | * {@link android.R.attr#documentLaunchMode}, is |
| 4670 | * preferred over the Intent flag described here. The attribute form allows the |
| 4671 | * Activity to specify multiple document behavior for all launchers of the Activity |
| 4672 | * 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] | 4673 | * |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4674 | * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for |
| 4675 | * it is kept after the activity is finished is different than the use of |
| 4676 | * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if |
| 4677 | * this flag is being used to create a new recents entry, then by default that entry |
| 4678 | * will be removed once the activity is finished. You can modify this behavior with |
| 4679 | * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. |
| 4680 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4681 | * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link |
| 4682 | * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the |
| 4683 | * equivalent of the Activity manifest specifying {@link |
| 4684 | * android.R.attr#documentLaunchMode}="intoExisting". When used with |
| 4685 | * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying |
| 4686 | * {@link android.R.attr#documentLaunchMode}="always". |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4687 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4688 | * Refer to {@link android.R.attr#documentLaunchMode} for more information. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4689 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4690 | * @see android.R.attr#documentLaunchMode |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4691 | * @see #FLAG_ACTIVITY_MULTIPLE_TASK |
| 4692 | */ |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 4693 | 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] | 4694 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4695 | * 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] | 4696 | * callback from occurring on the current frontmost activity before it is |
| 4697 | * 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] | 4698 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 4699 | * <p>Typically, an activity can rely on that callback to indicate that an |
| 4700 | * explicit user action has caused their activity to be moved out of the |
| 4701 | * foreground. The callback marks an appropriate point in the activity's |
| 4702 | * lifecycle for it to dismiss any notifications that it intends to display |
| 4703 | * "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] | 4704 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 4705 | * <p>If an activity is ever started via any non-user-driven events such as |
| 4706 | * phone-call receipt or an alarm handler, this flag should be passed to {@link |
| 4707 | * Context#startActivity Context.startActivity}, ensuring that the pausing |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4708 | * 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] | 4709 | */ |
| 4710 | 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] | 4711 | /** |
| 4712 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4713 | * this flag will cause the launched activity to be brought to the front of its |
| 4714 | * task's history stack if it is already running. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4715 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4716 | * <p>For example, consider a task consisting of four activities: A, B, C, D. |
| 4717 | * If D calls startActivity() with an Intent that resolves to the component |
| 4718 | * of activity B, then B will be brought to the front of the history stack, |
| 4719 | * with this resulting order: A, C, D, B. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4720 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4721 | * 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] | 4722 | * specified. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4723 | */ |
| 4724 | 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] | 4725 | /** |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 4726 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4727 | * this flag will prevent the system from applying an activity transition |
| 4728 | * animation to go to the next activity state. This doesn't mean an |
| 4729 | * animation will never run -- if another activity change happens that doesn't |
| 4730 | * specify this flag before the activity started here is displayed, then |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 4731 | * 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] | 4732 | * when you are going to do a series of activity operations but the |
| 4733 | * animation seen by the user shouldn't be driven by the first activity |
| 4734 | * change but rather a later one. |
| 4735 | */ |
| 4736 | public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; |
| 4737 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 4738 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4739 | * this flag will cause any existing task that would be associated with the |
| 4740 | * activity to be cleared before the activity is started. That is, the activity |
| 4741 | * becomes the new root of an otherwise empty task, and any old activities |
| 4742 | * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 4743 | */ |
| 4744 | public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; |
| 4745 | /** |
| 4746 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4747 | * this flag will cause a newly launching task to be placed on top of the current |
| 4748 | * home activity task (if there is one). That is, pressing back from the task |
| 4749 | * will always return the user to home even if that was not the last activity they |
| 4750 | * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 4751 | */ |
| 4752 | public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; |
| 4753 | /** |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4754 | * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will |
| 4755 | * 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] | 4756 | * 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] | 4757 | * 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] | 4758 | * this flag. When set and the task's activity is finished, the recents |
| 4759 | * entry will remain in the interface for the user to re-launch it, like a |
| 4760 | * recents entry for a top-level application. |
| 4761 | * <p> |
| 4762 | * The receiving activity can override this request with |
| 4763 | * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling |
| 4764 | * {@link android.app.Activity#finishAndRemoveTask() |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4765 | * Activity.finishAndRemoveTask()}. |
Craig Mautner | 2dac056 | 2014-05-06 09:06:44 -0700 | [diff] [blame] | 4766 | */ |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4767 | public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; |
Craig Mautner | a228ae9 | 2014-07-09 05:44:55 -0700 | [diff] [blame] | 4768 | |
| 4769 | /** |
Wale Ogunwale | 2a25a62 | 2016-01-30 11:27:21 -0800 | [diff] [blame] | 4770 | * This flag is only used in split-screen multi-window mode. The new activity will be displayed |
| 4771 | * 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] | 4772 | * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is |
| 4773 | * 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] | 4774 | */ |
Wale Ogunwale | 2a25a62 | 2016-01-30 11:27:21 -0800 | [diff] [blame] | 4775 | public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; |
Filip Gruszczynski | 80e29f1 | 2015-12-14 14:58:30 -0800 | [diff] [blame] | 4776 | |
| 4777 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4778 | * If set, when sending a broadcast only registered receivers will be |
| 4779 | * called -- no BroadcastReceiver components will be launched. |
| 4780 | */ |
| 4781 | public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4782 | /** |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 4783 | * If set, when sending a broadcast the new broadcast will replace |
| 4784 | * any existing pending broadcast that matches it. Matching is defined |
| 4785 | * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning |
| 4786 | * true for the intents of the two broadcasts. When a match is found, |
| 4787 | * the new broadcast (and receivers associated with it) will replace the |
| 4788 | * existing one in the pending broadcast list, remaining at the same |
| 4789 | * position in the list. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4790 | * |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 4791 | * <p>This flag is most typically used with sticky broadcasts, which |
| 4792 | * only care about delivering the most recent values of the broadcast |
| 4793 | * to their receivers. |
| 4794 | */ |
| 4795 | public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; |
| 4796 | /** |
Christopher Tate | f46723b | 2012-01-26 14:19:24 -0800 | [diff] [blame] | 4797 | * If set, when sending a broadcast the recipient is allowed to run at |
| 4798 | * foreground priority, with a shorter timeout interval. During normal |
| 4799 | * broadcasts the receivers are not automatically hoisted out of the |
| 4800 | * background priority class. |
| 4801 | */ |
| 4802 | public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; |
| 4803 | /** |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4804 | * If this is an ordered broadcast, don't allow receivers to abort the broadcast. |
| 4805 | * They can still propagate results through to later receivers, but they can not prevent |
| 4806 | * later receivers from seeing the broadcast. |
| 4807 | */ |
| 4808 | public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; |
| 4809 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4810 | * If set, when sending a broadcast <i>before boot has completed</i> only |
| 4811 | * registered receivers will be called -- no BroadcastReceiver components |
| 4812 | * will be launched. Sticky intent state will be recorded properly even |
| 4813 | * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} |
| 4814 | * 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] | 4815 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4816 | * <p>This flag is only for use by system sevices as a convenience to |
| 4817 | * avoid having to implement a more complex mechanism around detection |
| 4818 | * of boot completion. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4819 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4820 | * @hide |
| 4821 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4822 | public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 4823 | /** |
| 4824 | * Set when this broadcast is for a boot upgrade, a special mode that |
| 4825 | * allows the broadcast to be sent before the system is ready and launches |
| 4826 | * the app process with no providers running in it. |
| 4827 | * @hide |
| 4828 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4829 | public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; |
Dianne Hackborn | 6ac42ae | 2015-12-08 17:22:10 -0800 | [diff] [blame] | 4830 | /** |
| 4831 | * If set, the broadcast will always go to manifest receivers in background (cached |
| 4832 | * or not running) apps, regardless of whether that would be done by default. By |
| 4833 | * default they will only receive broadcasts if the broadcast has specified an |
| 4834 | * explicit component or package name. |
| 4835 | * @hide |
| 4836 | */ |
| 4837 | public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; |
| 4838 | /** |
| 4839 | * If set, the broadcast will never go to manifest receivers in background (cached |
| 4840 | * or not running) apps, regardless of whether that would be done by default. By |
| 4841 | * default they will receive broadcasts if the broadcast has specified an |
| 4842 | * explicit component or package name. |
| 4843 | * @hide |
| 4844 | */ |
| 4845 | public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 4846 | /** |
| 4847 | * If set, this broadcast is being sent from the shell. |
| 4848 | * @hide |
| 4849 | */ |
| 4850 | public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4851 | |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 4852 | /** |
| 4853 | * @hide Flags that can't be changed with PendingIntent. |
| 4854 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4855 | public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION |
| 4856 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 4857 | | FLAG_GRANT_PREFIX_URI_PERMISSION; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4858 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4859 | // --------------------------------------------------------------------- |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4860 | // --------------------------------------------------------------------- |
| 4861 | // toUri() and parseUri() options. |
| 4862 | |
| 4863 | /** |
| 4864 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 4865 | * always has the "intent:" scheme. This syntax can be used when you want |
| 4866 | * to later disambiguate between URIs that are intended to describe an |
| 4867 | * Intent vs. all others that should be treated as raw URIs. When used |
| 4868 | * with {@link #parseUri}, any other scheme will result in a generic |
| 4869 | * VIEW action for that raw URI. |
| 4870 | */ |
| 4871 | public static final int URI_INTENT_SCHEME = 1<<0; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4872 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4873 | /** |
| 4874 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 4875 | * always has the "android-app:" scheme. This is a variation of |
| 4876 | * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an |
| 4877 | * http/https URI being delivered to a specific package name. The format |
| 4878 | * is: |
| 4879 | * |
| 4880 | * <pre class="prettyprint"> |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 4881 | * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4882 | * |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 4883 | * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, |
| 4884 | * you must also include a scheme; including a path also requires both a host and a scheme. |
| 4885 | * The final #Intent; fragment can be used without a scheme, host, or path. |
| 4886 | * Note that this can not be |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4887 | * used with intents that have a {@link #setSelector}, since the base intent |
| 4888 | * will always have an explicit package name.</p> |
| 4889 | * |
| 4890 | * <p>Some examples of how this scheme maps to Intent objects:</p> |
| 4891 | * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> |
| 4892 | * <colgroup align="left" /> |
| 4893 | * <colgroup align="left" /> |
| 4894 | * <thead> |
| 4895 | * <tr><th>URI</th> <th>Intent</th></tr> |
| 4896 | * </thead> |
| 4897 | * |
| 4898 | * <tbody> |
| 4899 | * <tr><td><code>android-app://com.example.app</code></td> |
| 4900 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4901 | * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> |
| 4902 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4903 | * </table></td> |
| 4904 | * </tr> |
| 4905 | * <tr><td><code>android-app://com.example.app/http/example.com</code></td> |
| 4906 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4907 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 4908 | * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> |
| 4909 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4910 | * </table></td> |
| 4911 | * </tr> |
| 4912 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> |
| 4913 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4914 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 4915 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 4916 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4917 | * </table></td> |
| 4918 | * </tr> |
| 4919 | * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 4920 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4921 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 4922 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4923 | * </table></td> |
| 4924 | * </tr> |
| 4925 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 4926 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4927 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 4928 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 4929 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4930 | * </table></td> |
| 4931 | * </tr> |
| 4932 | * <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> |
| 4933 | * <td><table border="" style="margin:0" > |
| 4934 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 4935 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4936 | * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> |
| 4937 | * </table></td> |
| 4938 | * </tr> |
| 4939 | * </tbody> |
| 4940 | * </table> |
| 4941 | */ |
| 4942 | public static final int URI_ANDROID_APP_SCHEME = 1<<1; |
| 4943 | |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 4944 | /** |
| 4945 | * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing |
| 4946 | * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, |
| 4947 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, |
| 4948 | * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the |
| 4949 | * generated Intent can not cause unexpected data access to happen. |
| 4950 | * |
| 4951 | * <p>If you do not trust the source of the URI being parsed, you should still do further |
| 4952 | * processing to protect yourself from it. In particular, when using it to start an |
| 4953 | * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities |
| 4954 | * that can handle it.</p> |
| 4955 | */ |
| 4956 | public static final int URI_ALLOW_UNSAFE = 1<<2; |
| 4957 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4958 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4959 | |
| 4960 | private String mAction; |
| 4961 | private Uri mData; |
| 4962 | private String mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4963 | private String mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4964 | private ComponentName mComponent; |
| 4965 | private int mFlags; |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 4966 | private ArraySet<String> mCategories; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4967 | private Bundle mExtras; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 4968 | private Rect mSourceBounds; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4969 | private Intent mSelector; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 4970 | private ClipData mClipData; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 4971 | private int mContentUserHint = UserHandle.USER_CURRENT; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4972 | |
| 4973 | // --------------------------------------------------------------------- |
| 4974 | |
| 4975 | /** |
| 4976 | * Create an empty intent. |
| 4977 | */ |
| 4978 | public Intent() { |
| 4979 | } |
| 4980 | |
| 4981 | /** |
| 4982 | * Copy constructor. |
| 4983 | */ |
| 4984 | public Intent(Intent o) { |
| 4985 | this.mAction = o.mAction; |
| 4986 | this.mData = o.mData; |
| 4987 | this.mType = o.mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4988 | this.mPackage = o.mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4989 | this.mComponent = o.mComponent; |
| 4990 | this.mFlags = o.mFlags; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 4991 | this.mContentUserHint = o.mContentUserHint; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4992 | if (o.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 4993 | this.mCategories = new ArraySet<String>(o.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4994 | } |
| 4995 | if (o.mExtras != null) { |
| 4996 | this.mExtras = new Bundle(o.mExtras); |
| 4997 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 4998 | if (o.mSourceBounds != null) { |
| 4999 | this.mSourceBounds = new Rect(o.mSourceBounds); |
| 5000 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5001 | if (o.mSelector != null) { |
| 5002 | this.mSelector = new Intent(o.mSelector); |
| 5003 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5004 | if (o.mClipData != null) { |
| 5005 | this.mClipData = new ClipData(o.mClipData); |
| 5006 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5007 | } |
| 5008 | |
| 5009 | @Override |
| 5010 | public Object clone() { |
| 5011 | return new Intent(this); |
| 5012 | } |
| 5013 | |
| 5014 | private Intent(Intent o, boolean all) { |
| 5015 | this.mAction = o.mAction; |
| 5016 | this.mData = o.mData; |
| 5017 | this.mType = o.mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5018 | this.mPackage = o.mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5019 | this.mComponent = o.mComponent; |
| 5020 | if (o.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 5021 | this.mCategories = new ArraySet<String>(o.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5022 | } |
| 5023 | } |
| 5024 | |
| 5025 | /** |
| 5026 | * Make a clone of only the parts of the Intent that are relevant for |
| 5027 | * filter matching: the action, data, type, component, and categories. |
| 5028 | */ |
| 5029 | public Intent cloneFilter() { |
| 5030 | return new Intent(this, false); |
| 5031 | } |
| 5032 | |
| 5033 | /** |
| 5034 | * Create an intent with a given action. All other fields (data, type, |
| 5035 | * class) are null. Note that the action <em>must</em> be in a |
| 5036 | * namespace because Intents are used globally in the system -- for |
| 5037 | * example the system VIEW action is android.intent.action.VIEW; an |
| 5038 | * application's custom action would be something like |
| 5039 | * com.google.app.myapp.CUSTOM_ACTION. |
| 5040 | * |
| 5041 | * @param action The Intent action, such as ACTION_VIEW. |
| 5042 | */ |
| 5043 | public Intent(String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5044 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5045 | } |
| 5046 | |
| 5047 | /** |
| 5048 | * Create an intent with a given action and for a given data url. Note |
| 5049 | * that the action <em>must</em> be in a namespace because Intents are |
| 5050 | * used globally in the system -- for example the system VIEW action is |
| 5051 | * android.intent.action.VIEW; an application's custom action would be |
| 5052 | * something like com.google.app.myapp.CUSTOM_ACTION. |
| 5053 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 5054 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 5055 | * case-sensitive, unlike the formal RFC. As a result, |
| 5056 | * you should always ensure that you write your Uri with these elements |
| 5057 | * using lower case letters, and normalize any Uris you receive from |
| 5058 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 5059 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5060 | * @param action The Intent action, such as ACTION_VIEW. |
| 5061 | * @param uri The Intent data URI. |
| 5062 | */ |
| 5063 | public Intent(String action, Uri uri) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5064 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5065 | mData = uri; |
| 5066 | } |
| 5067 | |
| 5068 | /** |
| 5069 | * Create an intent for a specific component. All other fields (action, data, |
| 5070 | * type, class) are null, though they can be modified later with explicit |
| 5071 | * calls. This provides a convenient way to create an intent that is |
| 5072 | * intended to execute a hard-coded class name, rather than relying on the |
| 5073 | * system to find an appropriate class for you; see {@link #setComponent} |
| 5074 | * for more information on the repercussions of this. |
| 5075 | * |
| 5076 | * @param packageContext A Context of the application package implementing |
| 5077 | * this class. |
| 5078 | * @param cls The component class that is to be used for the intent. |
| 5079 | * |
| 5080 | * @see #setClass |
| 5081 | * @see #setComponent |
| 5082 | * @see #Intent(String, android.net.Uri , Context, Class) |
| 5083 | */ |
| 5084 | public Intent(Context packageContext, Class<?> cls) { |
| 5085 | mComponent = new ComponentName(packageContext, cls); |
| 5086 | } |
| 5087 | |
| 5088 | /** |
| 5089 | * 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] | 5090 | * 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] | 5091 | * construct the Intent and then calling {@link #setClass} to set its |
| 5092 | * class. |
| 5093 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 5094 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 5095 | * case-sensitive, unlike the formal RFC. As a result, |
| 5096 | * you should always ensure that you write your Uri with these elements |
| 5097 | * using lower case letters, and normalize any Uris you receive from |
| 5098 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 5099 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5100 | * @param action The Intent action, such as ACTION_VIEW. |
| 5101 | * @param uri The Intent data URI. |
| 5102 | * @param packageContext A Context of the application package implementing |
| 5103 | * this class. |
| 5104 | * @param cls The component class that is to be used for the intent. |
| 5105 | * |
| 5106 | * @see #Intent(String, android.net.Uri) |
| 5107 | * @see #Intent(Context, Class) |
| 5108 | * @see #setClass |
| 5109 | * @see #setComponent |
| 5110 | */ |
| 5111 | public Intent(String action, Uri uri, |
| 5112 | Context packageContext, Class<?> cls) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5113 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5114 | mData = uri; |
| 5115 | mComponent = new ComponentName(packageContext, cls); |
| 5116 | } |
| 5117 | |
| 5118 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 5119 | * Create an intent to launch the main (root) activity of a task. This |
| 5120 | * is the Intent that is started when the application's is launched from |
| 5121 | * Home. For anything else that wants to launch an application in the |
| 5122 | * same way, it is important that they use an Intent structured the same |
| 5123 | * way, and can use this function to ensure this is the case. |
| 5124 | * |
| 5125 | * <p>The returned Intent has the given Activity component as its explicit |
| 5126 | * component, {@link #ACTION_MAIN} as its action, and includes the |
| 5127 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 5128 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 5129 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 5130 | * |
| 5131 | * @param mainActivity The main activity component that this Intent will |
| 5132 | * launch. |
| 5133 | * @return Returns a newly created Intent that can be used to launch the |
| 5134 | * activity as a main application entry. |
| 5135 | * |
| 5136 | * @see #setClass |
| 5137 | * @see #setComponent |
| 5138 | */ |
| 5139 | public static Intent makeMainActivity(ComponentName mainActivity) { |
| 5140 | Intent intent = new Intent(ACTION_MAIN); |
| 5141 | intent.setComponent(mainActivity); |
| 5142 | intent.addCategory(CATEGORY_LAUNCHER); |
| 5143 | return intent; |
| 5144 | } |
| 5145 | |
| 5146 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5147 | * Make an Intent for the main activity of an application, without |
| 5148 | * specifying a specific activity to run but giving a selector to find |
| 5149 | * the activity. This results in a final Intent that is structured |
| 5150 | * the same as when the application is launched from |
| 5151 | * Home. For anything else that wants to launch an application in the |
| 5152 | * same way, it is important that they use an Intent structured the same |
| 5153 | * way, and can use this function to ensure this is the case. |
| 5154 | * |
| 5155 | * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the |
| 5156 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 5157 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 5158 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 5159 | * |
| 5160 | * @param selectorAction The action name of the Intent's selector. |
| 5161 | * @param selectorCategory The name of a category to add to the Intent's |
| 5162 | * selector. |
| 5163 | * @return Returns a newly created Intent that can be used to launch the |
| 5164 | * activity as a main application entry. |
| 5165 | * |
| 5166 | * @see #setSelector(Intent) |
| 5167 | */ |
| 5168 | public static Intent makeMainSelectorActivity(String selectorAction, |
| 5169 | String selectorCategory) { |
| 5170 | Intent intent = new Intent(ACTION_MAIN); |
| 5171 | intent.addCategory(CATEGORY_LAUNCHER); |
| 5172 | Intent selector = new Intent(); |
| 5173 | selector.setAction(selectorAction); |
| 5174 | selector.addCategory(selectorCategory); |
| 5175 | intent.setSelector(selector); |
| 5176 | return intent; |
| 5177 | } |
| 5178 | |
| 5179 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 5180 | * Make an Intent that can be used to re-launch an application's task |
| 5181 | * in its base state. This is like {@link #makeMainActivity(ComponentName)}, |
| 5182 | * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and |
| 5183 | * {@link #FLAG_ACTIVITY_CLEAR_TASK}. |
| 5184 | * |
| 5185 | * @param mainActivity The activity component that is the root of the |
| 5186 | * task; this is the activity that has been published in the application's |
| 5187 | * manifest as the main launcher icon. |
| 5188 | * |
| 5189 | * @return Returns a newly created Intent that can be used to relaunch the |
| 5190 | * activity's task in its root state. |
| 5191 | */ |
| 5192 | public static Intent makeRestartActivityTask(ComponentName mainActivity) { |
| 5193 | Intent intent = makeMainActivity(mainActivity); |
| 5194 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 5195 | | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 5196 | return intent; |
| 5197 | } |
| 5198 | |
| 5199 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5200 | * Call {@link #parseUri} with 0 flags. |
| 5201 | * @deprecated Use {@link #parseUri} instead. |
| 5202 | */ |
| 5203 | @Deprecated |
| 5204 | public static Intent getIntent(String uri) throws URISyntaxException { |
| 5205 | return parseUri(uri, 0); |
| 5206 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5207 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5208 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5209 | * Create an intent from a URI. This URI may encode the action, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5210 | * category, and other intent fields, if it was returned by |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 5211 | * {@link #toUri}. If the Intent was not generate by toUri(), its data |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5212 | * 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] | 5213 | * |
| 5214 | * <p>The URI given here must not be relative -- that is, it must include |
| 5215 | * the scheme and full path. |
| 5216 | * |
| 5217 | * @param uri The URI to turn into an Intent. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5218 | * @param flags Additional processing flags. Either 0, |
| 5219 | * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5220 | * |
| 5221 | * @return Intent The newly created Intent object. |
| 5222 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5223 | * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax |
| 5224 | * it bad (as parsed by the Uri class) or the Intent data within the |
| 5225 | * URI is invalid. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5226 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5227 | * @see #toUri |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5228 | */ |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5229 | public static Intent parseUri(String uri, int flags) throws URISyntaxException { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5230 | int i = 0; |
| 5231 | try { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5232 | final boolean androidApp = uri.startsWith("android-app:"); |
| 5233 | |
| 5234 | // Validate intent scheme if requested. |
| 5235 | if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { |
| 5236 | if (!uri.startsWith("intent:") && !androidApp) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5237 | Intent intent = new Intent(ACTION_VIEW); |
| 5238 | try { |
| 5239 | intent.setData(Uri.parse(uri)); |
| 5240 | } catch (IllegalArgumentException e) { |
| 5241 | throw new URISyntaxException(uri, e.getMessage()); |
| 5242 | } |
| 5243 | return intent; |
| 5244 | } |
| 5245 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5246 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5247 | i = uri.lastIndexOf("#"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5248 | // simple case |
| 5249 | if (i == -1) { |
| 5250 | if (!androidApp) { |
| 5251 | return new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 5252 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5253 | |
| 5254 | // old format Intent URI |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5255 | } else if (!uri.startsWith("#Intent;", i)) { |
| 5256 | if (!androidApp) { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5257 | return getIntentOld(uri, flags); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5258 | } else { |
| 5259 | i = -1; |
| 5260 | } |
| 5261 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5262 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5263 | // new format |
| 5264 | Intent intent = new Intent(ACTION_VIEW); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5265 | Intent baseIntent = intent; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5266 | boolean explicitAction = false; |
| 5267 | boolean inSelector = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5268 | |
| 5269 | // fetch data part, if present |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5270 | String scheme = null; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5271 | String data; |
| 5272 | if (i >= 0) { |
| 5273 | data = uri.substring(0, i); |
| 5274 | i += 8; // length of "#Intent;" |
| 5275 | } else { |
| 5276 | data = uri; |
| 5277 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5278 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5279 | // loop over contents of Intent, all name=value; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5280 | while (i >= 0 && !uri.startsWith("end", i)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5281 | int eq = uri.indexOf('=', i); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5282 | if (eq < 0) eq = i-1; |
| 5283 | int semi = uri.indexOf(';', i); |
| 5284 | 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] | 5285 | |
| 5286 | // action |
| 5287 | if (uri.startsWith("action=", i)) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5288 | intent.setAction(value); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5289 | if (!inSelector) { |
| 5290 | explicitAction = true; |
| 5291 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5292 | } |
| 5293 | |
| 5294 | // categories |
| 5295 | else if (uri.startsWith("category=", i)) { |
| 5296 | intent.addCategory(value); |
| 5297 | } |
| 5298 | |
| 5299 | // type |
| 5300 | else if (uri.startsWith("type=", i)) { |
| 5301 | intent.mType = value; |
| 5302 | } |
| 5303 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5304 | // launch flags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5305 | else if (uri.startsWith("launchFlags=", i)) { |
| 5306 | intent.mFlags = Integer.decode(value).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5307 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 5308 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 5309 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5310 | } |
| 5311 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5312 | // package |
| 5313 | else if (uri.startsWith("package=", i)) { |
| 5314 | intent.mPackage = value; |
| 5315 | } |
| 5316 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5317 | // component |
| 5318 | else if (uri.startsWith("component=", i)) { |
| 5319 | intent.mComponent = ComponentName.unflattenFromString(value); |
| 5320 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5321 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5322 | // scheme |
| 5323 | else if (uri.startsWith("scheme=", i)) { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5324 | if (inSelector) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 5325 | intent.mData = Uri.parse(value + ":"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5326 | } else { |
| 5327 | scheme = value; |
| 5328 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5329 | } |
| 5330 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5331 | // source bounds |
| 5332 | else if (uri.startsWith("sourceBounds=", i)) { |
| 5333 | intent.mSourceBounds = Rect.unflattenFromString(value); |
| 5334 | } |
| 5335 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5336 | // selector |
| 5337 | else if (semi == (i+3) && uri.startsWith("SEL", i)) { |
| 5338 | intent = new Intent(); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5339 | inSelector = true; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5340 | } |
| 5341 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5342 | // extra |
| 5343 | else { |
| 5344 | String key = Uri.decode(uri.substring(i + 2, eq)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5345 | // create Bundle if it doesn't already exist |
| 5346 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
| 5347 | Bundle b = intent.mExtras; |
| 5348 | // add EXTRA |
| 5349 | if (uri.startsWith("S.", i)) b.putString(key, value); |
| 5350 | else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); |
| 5351 | else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); |
| 5352 | else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); |
| 5353 | else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); |
| 5354 | else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); |
| 5355 | else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); |
| 5356 | else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); |
| 5357 | else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); |
| 5358 | else throw new URISyntaxException(uri, "unknown EXTRA type", i); |
| 5359 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5360 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5361 | // move to the next item |
| 5362 | i = semi + 1; |
| 5363 | } |
| 5364 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5365 | if (inSelector) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5366 | // The Intent had a selector; fix it up. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5367 | if (baseIntent.mPackage == null) { |
| 5368 | baseIntent.setSelector(intent); |
| 5369 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5370 | intent = baseIntent; |
| 5371 | } |
| 5372 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5373 | if (data != null) { |
| 5374 | if (data.startsWith("intent:")) { |
| 5375 | data = data.substring(7); |
| 5376 | if (scheme != null) { |
| 5377 | data = scheme + ':' + data; |
| 5378 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5379 | } else if (data.startsWith("android-app:")) { |
| 5380 | if (data.charAt(12) == '/' && data.charAt(13) == '/') { |
| 5381 | // Correctly formed android-app, first part is package name. |
| 5382 | int end = data.indexOf('/', 14); |
| 5383 | if (end < 0) { |
| 5384 | // All we have is a package name. |
| 5385 | intent.mPackage = data.substring(14); |
| 5386 | if (!explicitAction) { |
| 5387 | intent.setAction(ACTION_MAIN); |
| 5388 | } |
| 5389 | data = ""; |
| 5390 | } else { |
| 5391 | // Target the Intent at the given package name always. |
| 5392 | String authority = null; |
| 5393 | intent.mPackage = data.substring(14, end); |
| 5394 | int newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 5395 | if ((end+1) < data.length()) { |
| 5396 | if ((newEnd=data.indexOf('/', end+1)) >= 0) { |
| 5397 | // Found a scheme, remember it. |
| 5398 | scheme = data.substring(end+1, newEnd); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5399 | end = newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 5400 | if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { |
| 5401 | // Found a authority, remember it. |
| 5402 | authority = data.substring(end+1, newEnd); |
| 5403 | end = newEnd; |
| 5404 | } |
| 5405 | } else { |
| 5406 | // All we have is a scheme. |
| 5407 | scheme = data.substring(end+1); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5408 | } |
| 5409 | } |
| 5410 | if (scheme == null) { |
| 5411 | // If there was no scheme, then this just targets the package. |
| 5412 | if (!explicitAction) { |
| 5413 | intent.setAction(ACTION_MAIN); |
| 5414 | } |
| 5415 | data = ""; |
| 5416 | } else if (authority == null) { |
| 5417 | data = scheme + ":"; |
| 5418 | } else { |
| 5419 | data = scheme + "://" + authority + data.substring(end); |
| 5420 | } |
| 5421 | } |
| 5422 | } else { |
| 5423 | data = ""; |
| 5424 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5425 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5426 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5427 | if (data.length() > 0) { |
| 5428 | try { |
| 5429 | intent.mData = Uri.parse(data); |
| 5430 | } catch (IllegalArgumentException e) { |
| 5431 | throw new URISyntaxException(uri, e.getMessage()); |
| 5432 | } |
| 5433 | } |
| 5434 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5435 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5436 | return intent; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5437 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5438 | } catch (IndexOutOfBoundsException e) { |
| 5439 | throw new URISyntaxException(uri, "illegal Intent URI format", i); |
| 5440 | } |
| 5441 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5442 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5443 | public static Intent getIntentOld(String uri) throws URISyntaxException { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5444 | return getIntentOld(uri, 0); |
| 5445 | } |
| 5446 | |
| 5447 | 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] | 5448 | Intent intent; |
| 5449 | |
| 5450 | int i = uri.lastIndexOf('#'); |
| 5451 | if (i >= 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5452 | String action = null; |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5453 | final int intentFragmentStart = i; |
| 5454 | boolean isIntentFragment = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5455 | |
| 5456 | i++; |
| 5457 | |
| 5458 | if (uri.regionMatches(i, "action(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5459 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5460 | i += 7; |
| 5461 | int j = uri.indexOf(')', i); |
| 5462 | action = uri.substring(i, j); |
| 5463 | i = j + 1; |
| 5464 | } |
| 5465 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5466 | intent = new Intent(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5467 | |
| 5468 | if (uri.regionMatches(i, "categories(", 0, 11)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5469 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5470 | i += 11; |
| 5471 | int j = uri.indexOf(')', i); |
| 5472 | while (i < j) { |
| 5473 | int sep = uri.indexOf('!', i); |
Alan Viverette | 0adf32b | 2014-09-18 12:53:16 -0700 | [diff] [blame] | 5474 | if (sep < 0 || sep > j) sep = j; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5475 | if (i < sep) { |
| 5476 | intent.addCategory(uri.substring(i, sep)); |
| 5477 | } |
| 5478 | i = sep + 1; |
| 5479 | } |
| 5480 | i = j + 1; |
| 5481 | } |
| 5482 | |
| 5483 | if (uri.regionMatches(i, "type(", 0, 5)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5484 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5485 | i += 5; |
| 5486 | int j = uri.indexOf(')', i); |
| 5487 | intent.mType = uri.substring(i, j); |
| 5488 | i = j + 1; |
| 5489 | } |
| 5490 | |
| 5491 | if (uri.regionMatches(i, "launchFlags(", 0, 12)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5492 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5493 | i += 12; |
| 5494 | int j = uri.indexOf(')', i); |
| 5495 | intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5496 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 5497 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 5498 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5499 | i = j + 1; |
| 5500 | } |
| 5501 | |
| 5502 | if (uri.regionMatches(i, "component(", 0, 10)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5503 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5504 | i += 10; |
| 5505 | int j = uri.indexOf(')', i); |
| 5506 | int sep = uri.indexOf('!', i); |
| 5507 | if (sep >= 0 && sep < j) { |
| 5508 | String pkg = uri.substring(i, sep); |
| 5509 | String cls = uri.substring(sep + 1, j); |
| 5510 | intent.mComponent = new ComponentName(pkg, cls); |
| 5511 | } |
| 5512 | i = j + 1; |
| 5513 | } |
| 5514 | |
| 5515 | if (uri.regionMatches(i, "extras(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5516 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5517 | i += 7; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5518 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5519 | final int closeParen = uri.indexOf(')', i); |
| 5520 | if (closeParen == -1) throw new URISyntaxException(uri, |
| 5521 | "EXTRA missing trailing ')'", i); |
| 5522 | |
| 5523 | while (i < closeParen) { |
| 5524 | // fetch the key value |
| 5525 | int j = uri.indexOf('=', i); |
| 5526 | if (j <= i + 1 || i >= closeParen) { |
| 5527 | throw new URISyntaxException(uri, "EXTRA missing '='", i); |
| 5528 | } |
| 5529 | char type = uri.charAt(i); |
| 5530 | i++; |
| 5531 | String key = uri.substring(i, j); |
| 5532 | i = j + 1; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5533 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5534 | // get type-value |
| 5535 | j = uri.indexOf('!', i); |
| 5536 | if (j == -1 || j >= closeParen) j = closeParen; |
| 5537 | if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 5538 | String value = uri.substring(i, j); |
| 5539 | i = j; |
| 5540 | |
| 5541 | // create Bundle if it doesn't already exist |
| 5542 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5543 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5544 | // add item to bundle |
| 5545 | try { |
| 5546 | switch (type) { |
| 5547 | case 'S': |
| 5548 | intent.mExtras.putString(key, Uri.decode(value)); |
| 5549 | break; |
| 5550 | case 'B': |
| 5551 | intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); |
| 5552 | break; |
| 5553 | case 'b': |
| 5554 | intent.mExtras.putByte(key, Byte.parseByte(value)); |
| 5555 | break; |
| 5556 | case 'c': |
| 5557 | intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); |
| 5558 | break; |
| 5559 | case 'd': |
| 5560 | intent.mExtras.putDouble(key, Double.parseDouble(value)); |
| 5561 | break; |
| 5562 | case 'f': |
| 5563 | intent.mExtras.putFloat(key, Float.parseFloat(value)); |
| 5564 | break; |
| 5565 | case 'i': |
| 5566 | intent.mExtras.putInt(key, Integer.parseInt(value)); |
| 5567 | break; |
| 5568 | case 'l': |
| 5569 | intent.mExtras.putLong(key, Long.parseLong(value)); |
| 5570 | break; |
| 5571 | case 's': |
| 5572 | intent.mExtras.putShort(key, Short.parseShort(value)); |
| 5573 | break; |
| 5574 | default: |
| 5575 | throw new URISyntaxException(uri, "EXTRA has unknown type", i); |
| 5576 | } |
| 5577 | } catch (NumberFormatException e) { |
| 5578 | throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); |
| 5579 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5580 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5581 | char ch = uri.charAt(i); |
| 5582 | if (ch == ')') break; |
| 5583 | if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 5584 | i++; |
| 5585 | } |
| 5586 | } |
| 5587 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5588 | if (isIntentFragment) { |
| 5589 | intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); |
| 5590 | } else { |
| 5591 | intent.mData = Uri.parse(uri); |
| 5592 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5593 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5594 | if (intent.mAction == null) { |
| 5595 | // By default, if no action is specified, then use VIEW. |
| 5596 | intent.mAction = ACTION_VIEW; |
| 5597 | } |
| 5598 | |
| 5599 | } else { |
| 5600 | intent = new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 5601 | } |
| 5602 | |
| 5603 | return intent; |
| 5604 | } |
| 5605 | |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 5606 | /** @hide */ |
| 5607 | public interface CommandOptionHandler { |
| 5608 | boolean handleOption(String opt, ShellCommand cmd); |
| 5609 | } |
| 5610 | |
| 5611 | /** @hide */ |
| 5612 | public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) |
| 5613 | throws URISyntaxException { |
| 5614 | Intent intent = new Intent(); |
| 5615 | Intent baseIntent = intent; |
| 5616 | boolean hasIntentInfo = false; |
| 5617 | |
| 5618 | Uri data = null; |
| 5619 | String type = null; |
| 5620 | |
| 5621 | String opt; |
| 5622 | while ((opt=cmd.getNextOption()) != null) { |
| 5623 | switch (opt) { |
| 5624 | case "-a": |
| 5625 | intent.setAction(cmd.getNextArgRequired()); |
| 5626 | if (intent == baseIntent) { |
| 5627 | hasIntentInfo = true; |
| 5628 | } |
| 5629 | break; |
| 5630 | case "-d": |
| 5631 | data = Uri.parse(cmd.getNextArgRequired()); |
| 5632 | if (intent == baseIntent) { |
| 5633 | hasIntentInfo = true; |
| 5634 | } |
| 5635 | break; |
| 5636 | case "-t": |
| 5637 | type = cmd.getNextArgRequired(); |
| 5638 | if (intent == baseIntent) { |
| 5639 | hasIntentInfo = true; |
| 5640 | } |
| 5641 | break; |
| 5642 | case "-c": |
| 5643 | intent.addCategory(cmd.getNextArgRequired()); |
| 5644 | if (intent == baseIntent) { |
| 5645 | hasIntentInfo = true; |
| 5646 | } |
| 5647 | break; |
| 5648 | case "-e": |
| 5649 | case "--es": { |
| 5650 | String key = cmd.getNextArgRequired(); |
| 5651 | String value = cmd.getNextArgRequired(); |
| 5652 | intent.putExtra(key, value); |
| 5653 | } |
| 5654 | break; |
| 5655 | case "--esn": { |
| 5656 | String key = cmd.getNextArgRequired(); |
| 5657 | intent.putExtra(key, (String) null); |
| 5658 | } |
| 5659 | break; |
| 5660 | case "--ei": { |
| 5661 | String key = cmd.getNextArgRequired(); |
| 5662 | String value = cmd.getNextArgRequired(); |
| 5663 | intent.putExtra(key, Integer.decode(value)); |
| 5664 | } |
| 5665 | break; |
| 5666 | case "--eu": { |
| 5667 | String key = cmd.getNextArgRequired(); |
| 5668 | String value = cmd.getNextArgRequired(); |
| 5669 | intent.putExtra(key, Uri.parse(value)); |
| 5670 | } |
| 5671 | break; |
| 5672 | case "--ecn": { |
| 5673 | String key = cmd.getNextArgRequired(); |
| 5674 | String value = cmd.getNextArgRequired(); |
| 5675 | ComponentName cn = ComponentName.unflattenFromString(value); |
| 5676 | if (cn == null) |
| 5677 | throw new IllegalArgumentException("Bad component name: " + value); |
| 5678 | intent.putExtra(key, cn); |
| 5679 | } |
| 5680 | break; |
| 5681 | case "--eia": { |
| 5682 | String key = cmd.getNextArgRequired(); |
| 5683 | String value = cmd.getNextArgRequired(); |
| 5684 | String[] strings = value.split(","); |
| 5685 | int[] list = new int[strings.length]; |
| 5686 | for (int i = 0; i < strings.length; i++) { |
| 5687 | list[i] = Integer.decode(strings[i]); |
| 5688 | } |
| 5689 | intent.putExtra(key, list); |
| 5690 | } |
| 5691 | break; |
| 5692 | case "--eial": { |
| 5693 | String key = cmd.getNextArgRequired(); |
| 5694 | String value = cmd.getNextArgRequired(); |
| 5695 | String[] strings = value.split(","); |
| 5696 | ArrayList<Integer> list = new ArrayList<>(strings.length); |
| 5697 | for (int i = 0; i < strings.length; i++) { |
| 5698 | list.add(Integer.decode(strings[i])); |
| 5699 | } |
| 5700 | intent.putExtra(key, list); |
| 5701 | } |
| 5702 | break; |
| 5703 | case "--el": { |
| 5704 | String key = cmd.getNextArgRequired(); |
| 5705 | String value = cmd.getNextArgRequired(); |
| 5706 | intent.putExtra(key, Long.valueOf(value)); |
| 5707 | } |
| 5708 | break; |
| 5709 | case "--ela": { |
| 5710 | String key = cmd.getNextArgRequired(); |
| 5711 | String value = cmd.getNextArgRequired(); |
| 5712 | String[] strings = value.split(","); |
| 5713 | long[] list = new long[strings.length]; |
| 5714 | for (int i = 0; i < strings.length; i++) { |
| 5715 | list[i] = Long.valueOf(strings[i]); |
| 5716 | } |
| 5717 | intent.putExtra(key, list); |
| 5718 | hasIntentInfo = true; |
| 5719 | } |
| 5720 | break; |
| 5721 | case "--elal": { |
| 5722 | String key = cmd.getNextArgRequired(); |
| 5723 | String value = cmd.getNextArgRequired(); |
| 5724 | String[] strings = value.split(","); |
| 5725 | ArrayList<Long> list = new ArrayList<>(strings.length); |
| 5726 | for (int i = 0; i < strings.length; i++) { |
| 5727 | list.add(Long.valueOf(strings[i])); |
| 5728 | } |
| 5729 | intent.putExtra(key, list); |
| 5730 | hasIntentInfo = true; |
| 5731 | } |
| 5732 | break; |
| 5733 | case "--ef": { |
| 5734 | String key = cmd.getNextArgRequired(); |
| 5735 | String value = cmd.getNextArgRequired(); |
| 5736 | intent.putExtra(key, Float.valueOf(value)); |
| 5737 | hasIntentInfo = true; |
| 5738 | } |
| 5739 | break; |
| 5740 | case "--efa": { |
| 5741 | String key = cmd.getNextArgRequired(); |
| 5742 | String value = cmd.getNextArgRequired(); |
| 5743 | String[] strings = value.split(","); |
| 5744 | float[] list = new float[strings.length]; |
| 5745 | for (int i = 0; i < strings.length; i++) { |
| 5746 | list[i] = Float.valueOf(strings[i]); |
| 5747 | } |
| 5748 | intent.putExtra(key, list); |
| 5749 | hasIntentInfo = true; |
| 5750 | } |
| 5751 | break; |
| 5752 | case "--efal": { |
| 5753 | String key = cmd.getNextArgRequired(); |
| 5754 | String value = cmd.getNextArgRequired(); |
| 5755 | String[] strings = value.split(","); |
| 5756 | ArrayList<Float> list = new ArrayList<>(strings.length); |
| 5757 | for (int i = 0; i < strings.length; i++) { |
| 5758 | list.add(Float.valueOf(strings[i])); |
| 5759 | } |
| 5760 | intent.putExtra(key, list); |
| 5761 | hasIntentInfo = true; |
| 5762 | } |
| 5763 | break; |
| 5764 | case "--esa": { |
| 5765 | String key = cmd.getNextArgRequired(); |
| 5766 | String value = cmd.getNextArgRequired(); |
| 5767 | // Split on commas unless they are preceeded by an escape. |
| 5768 | // The escape character must be escaped for the string and |
| 5769 | // again for the regex, thus four escape characters become one. |
| 5770 | String[] strings = value.split("(?<!\\\\),"); |
| 5771 | intent.putExtra(key, strings); |
| 5772 | hasIntentInfo = true; |
| 5773 | } |
| 5774 | break; |
| 5775 | case "--esal": { |
| 5776 | String key = cmd.getNextArgRequired(); |
| 5777 | String value = cmd.getNextArgRequired(); |
| 5778 | // Split on commas unless they are preceeded by an escape. |
| 5779 | // The escape character must be escaped for the string and |
| 5780 | // again for the regex, thus four escape characters become one. |
| 5781 | String[] strings = value.split("(?<!\\\\),"); |
| 5782 | ArrayList<String> list = new ArrayList<>(strings.length); |
| 5783 | for (int i = 0; i < strings.length; i++) { |
| 5784 | list.add(strings[i]); |
| 5785 | } |
| 5786 | intent.putExtra(key, list); |
| 5787 | hasIntentInfo = true; |
| 5788 | } |
| 5789 | break; |
| 5790 | case "--ez": { |
| 5791 | String key = cmd.getNextArgRequired(); |
| 5792 | String value = cmd.getNextArgRequired().toLowerCase(); |
| 5793 | // Boolean.valueOf() results in false for anything that is not "true", which is |
| 5794 | // error-prone in shell commands |
| 5795 | boolean arg; |
| 5796 | if ("true".equals(value) || "t".equals(value)) { |
| 5797 | arg = true; |
| 5798 | } else if ("false".equals(value) || "f".equals(value)) { |
| 5799 | arg = false; |
| 5800 | } else { |
| 5801 | try { |
| 5802 | arg = Integer.decode(value) != 0; |
| 5803 | } catch (NumberFormatException ex) { |
| 5804 | throw new IllegalArgumentException("Invalid boolean value: " + value); |
| 5805 | } |
| 5806 | } |
| 5807 | |
| 5808 | intent.putExtra(key, arg); |
| 5809 | } |
| 5810 | break; |
| 5811 | case "-n": { |
| 5812 | String str = cmd.getNextArgRequired(); |
| 5813 | ComponentName cn = ComponentName.unflattenFromString(str); |
| 5814 | if (cn == null) |
| 5815 | throw new IllegalArgumentException("Bad component name: " + str); |
| 5816 | intent.setComponent(cn); |
| 5817 | if (intent == baseIntent) { |
| 5818 | hasIntentInfo = true; |
| 5819 | } |
| 5820 | } |
| 5821 | break; |
| 5822 | case "-p": { |
| 5823 | String str = cmd.getNextArgRequired(); |
| 5824 | intent.setPackage(str); |
| 5825 | if (intent == baseIntent) { |
| 5826 | hasIntentInfo = true; |
| 5827 | } |
| 5828 | } |
| 5829 | break; |
| 5830 | case "-f": |
| 5831 | String str = cmd.getNextArgRequired(); |
| 5832 | intent.setFlags(Integer.decode(str).intValue()); |
| 5833 | break; |
| 5834 | case "--grant-read-uri-permission": |
| 5835 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 5836 | break; |
| 5837 | case "--grant-write-uri-permission": |
| 5838 | intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
| 5839 | break; |
| 5840 | case "--grant-persistable-uri-permission": |
| 5841 | intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); |
| 5842 | break; |
| 5843 | case "--grant-prefix-uri-permission": |
| 5844 | intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); |
| 5845 | break; |
| 5846 | case "--exclude-stopped-packages": |
| 5847 | intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); |
| 5848 | break; |
| 5849 | case "--include-stopped-packages": |
| 5850 | intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| 5851 | break; |
| 5852 | case "--debug-log-resolution": |
| 5853 | intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); |
| 5854 | break; |
| 5855 | case "--activity-brought-to-front": |
| 5856 | intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); |
| 5857 | break; |
| 5858 | case "--activity-clear-top": |
| 5859 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 5860 | break; |
| 5861 | case "--activity-clear-when-task-reset": |
| 5862 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); |
| 5863 | break; |
| 5864 | case "--activity-exclude-from-recents": |
| 5865 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 5866 | break; |
| 5867 | case "--activity-launched-from-history": |
| 5868 | intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); |
| 5869 | break; |
| 5870 | case "--activity-multiple-task": |
| 5871 | intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); |
| 5872 | break; |
| 5873 | case "--activity-no-animation": |
| 5874 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); |
| 5875 | break; |
| 5876 | case "--activity-no-history": |
| 5877 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); |
| 5878 | break; |
| 5879 | case "--activity-no-user-action": |
| 5880 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); |
| 5881 | break; |
| 5882 | case "--activity-previous-is-top": |
| 5883 | intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); |
| 5884 | break; |
| 5885 | case "--activity-reorder-to-front": |
| 5886 | intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); |
| 5887 | break; |
| 5888 | case "--activity-reset-task-if-needed": |
| 5889 | intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 5890 | break; |
| 5891 | case "--activity-single-top": |
| 5892 | intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); |
| 5893 | break; |
| 5894 | case "--activity-clear-task": |
| 5895 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 5896 | break; |
| 5897 | case "--activity-task-on-home": |
| 5898 | intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); |
| 5899 | break; |
| 5900 | case "--receiver-registered-only": |
| 5901 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); |
| 5902 | break; |
| 5903 | case "--receiver-replace-pending": |
| 5904 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| 5905 | break; |
Felipe Leme | 3cb48cd | 2016-01-27 08:39:09 -0800 | [diff] [blame] | 5906 | case "--receiver-foreground": |
| 5907 | intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); |
| 5908 | break; |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 5909 | case "--selector": |
| 5910 | intent.setDataAndType(data, type); |
| 5911 | intent = new Intent(); |
| 5912 | break; |
| 5913 | default: |
| 5914 | if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { |
| 5915 | // Okay, caller handled this option. |
| 5916 | } else { |
| 5917 | throw new IllegalArgumentException("Unknown option: " + opt); |
| 5918 | } |
| 5919 | break; |
| 5920 | } |
| 5921 | } |
| 5922 | intent.setDataAndType(data, type); |
| 5923 | |
| 5924 | final boolean hasSelector = intent != baseIntent; |
| 5925 | if (hasSelector) { |
| 5926 | // A selector was specified; fix up. |
| 5927 | baseIntent.setSelector(intent); |
| 5928 | intent = baseIntent; |
| 5929 | } |
| 5930 | |
| 5931 | String arg = cmd.getNextArg(); |
| 5932 | baseIntent = null; |
| 5933 | if (arg == null) { |
| 5934 | if (hasSelector) { |
| 5935 | // If a selector has been specified, and no arguments |
| 5936 | // have been supplied for the main Intent, then we can |
| 5937 | // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't |
| 5938 | // need to have a component name specified yet, the |
| 5939 | // selector will take care of that. |
| 5940 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 5941 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 5942 | } |
| 5943 | } else if (arg.indexOf(':') >= 0) { |
| 5944 | // The argument is a URI. Fully parse it, and use that result |
| 5945 | // to fill in any data not specified so far. |
| 5946 | baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME |
| 5947 | | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); |
| 5948 | } else if (arg.indexOf('/') >= 0) { |
| 5949 | // The argument is a component name. Build an Intent to launch |
| 5950 | // it. |
| 5951 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 5952 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 5953 | baseIntent.setComponent(ComponentName.unflattenFromString(arg)); |
| 5954 | } else { |
| 5955 | // Assume the argument is a package name. |
| 5956 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 5957 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 5958 | baseIntent.setPackage(arg); |
| 5959 | } |
| 5960 | if (baseIntent != null) { |
| 5961 | Bundle extras = intent.getExtras(); |
| 5962 | intent.replaceExtras((Bundle)null); |
| 5963 | Bundle uriExtras = baseIntent.getExtras(); |
| 5964 | baseIntent.replaceExtras((Bundle)null); |
| 5965 | if (intent.getAction() != null && baseIntent.getCategories() != null) { |
| 5966 | HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); |
| 5967 | for (String c : cats) { |
| 5968 | baseIntent.removeCategory(c); |
| 5969 | } |
| 5970 | } |
| 5971 | intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); |
| 5972 | if (extras == null) { |
| 5973 | extras = uriExtras; |
| 5974 | } else if (uriExtras != null) { |
| 5975 | uriExtras.putAll(extras); |
| 5976 | extras = uriExtras; |
| 5977 | } |
| 5978 | intent.replaceExtras(extras); |
| 5979 | hasIntentInfo = true; |
| 5980 | } |
| 5981 | |
| 5982 | if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); |
| 5983 | return intent; |
| 5984 | } |
| 5985 | |
| 5986 | /** @hide */ |
| 5987 | public static void printIntentArgsHelp(PrintWriter pw, String prefix) { |
| 5988 | final String[] lines = new String[] { |
| 5989 | "<INTENT> specifications include these flags and arguments:", |
| 5990 | " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]", |
| 5991 | " [-c <CATEGORY> [-c <CATEGORY>] ...]", |
| 5992 | " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", |
| 5993 | " [--esn <EXTRA_KEY> ...]", |
| 5994 | " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", |
| 5995 | " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", |
| 5996 | " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", |
| 5997 | " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", |
| 5998 | " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", |
| 5999 | " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", |
| 6000 | " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", |
| 6001 | " (mutiple extras passed as Integer[])", |
| 6002 | " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", |
| 6003 | " (mutiple extras passed as List<Integer>)", |
| 6004 | " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", |
| 6005 | " (mutiple extras passed as Long[])", |
| 6006 | " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", |
| 6007 | " (mutiple extras passed as List<Long>)", |
| 6008 | " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", |
| 6009 | " (mutiple extras passed as Float[])", |
| 6010 | " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", |
| 6011 | " (mutiple extras passed as List<Float>)", |
| 6012 | " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", |
| 6013 | " (mutiple extras passed as String[]; to embed a comma into a string,", |
| 6014 | " escape it using \"\\,\")", |
| 6015 | " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", |
| 6016 | " (mutiple extras passed as List<String>; to embed a comma into a string,", |
| 6017 | " escape it using \"\\,\")", |
Felipe Leme | 545569d | 2016-01-11 16:27:58 -0800 | [diff] [blame] | 6018 | " [-f <FLAG>]", |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6019 | " [--grant-read-uri-permission] [--grant-write-uri-permission]", |
| 6020 | " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", |
| 6021 | " [--debug-log-resolution] [--exclude-stopped-packages]", |
| 6022 | " [--include-stopped-packages]", |
| 6023 | " [--activity-brought-to-front] [--activity-clear-top]", |
| 6024 | " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", |
| 6025 | " [--activity-launched-from-history] [--activity-multiple-task]", |
| 6026 | " [--activity-no-animation] [--activity-no-history]", |
| 6027 | " [--activity-no-user-action] [--activity-previous-is-top]", |
| 6028 | " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", |
| 6029 | " [--activity-single-top] [--activity-clear-task]", |
| 6030 | " [--activity-task-on-home]", |
| 6031 | " [--receiver-registered-only] [--receiver-replace-pending]", |
Felipe Leme | 3cb48cd | 2016-01-27 08:39:09 -0800 | [diff] [blame] | 6032 | " [--receiver-foreground]", |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6033 | " [--selector]", |
| 6034 | " [<URI> | <PACKAGE> | <COMPONENT>]" |
| 6035 | }; |
| 6036 | for (String line : lines) { |
| 6037 | pw.print(prefix); |
| 6038 | pw.println(line); |
| 6039 | } |
| 6040 | } |
| 6041 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6042 | /** |
| 6043 | * Retrieve the general action to be performed, such as |
| 6044 | * {@link #ACTION_VIEW}. The action describes the general way the rest of |
| 6045 | * the information in the intent should be interpreted -- most importantly, |
| 6046 | * what to do with the data returned by {@link #getData}. |
| 6047 | * |
| 6048 | * @return The action of this intent or null if none is specified. |
| 6049 | * |
| 6050 | * @see #setAction |
| 6051 | */ |
| 6052 | public String getAction() { |
| 6053 | return mAction; |
| 6054 | } |
| 6055 | |
| 6056 | /** |
| 6057 | * Retrieve data this intent is operating on. This URI specifies the name |
| 6058 | * of the data; often it uses the content: scheme, specifying data in a |
| 6059 | * content provider. Other schemes may be handled by specific activities, |
| 6060 | * such as http: by the web browser. |
| 6061 | * |
| 6062 | * @return The URI of the data this intent is targeting or null. |
| 6063 | * |
| 6064 | * @see #getScheme |
| 6065 | * @see #setData |
| 6066 | */ |
| 6067 | public Uri getData() { |
| 6068 | return mData; |
| 6069 | } |
| 6070 | |
| 6071 | /** |
| 6072 | * The same as {@link #getData()}, but returns the URI as an encoded |
| 6073 | * String. |
| 6074 | */ |
| 6075 | public String getDataString() { |
| 6076 | return mData != null ? mData.toString() : null; |
| 6077 | } |
| 6078 | |
| 6079 | /** |
| 6080 | * Return the scheme portion of the intent's data. If the data is null or |
| 6081 | * does not include a scheme, null is returned. Otherwise, the scheme |
| 6082 | * prefix without the final ':' is returned, i.e. "http". |
| 6083 | * |
| 6084 | * <p>This is the same as calling getData().getScheme() (and checking for |
| 6085 | * null data). |
| 6086 | * |
| 6087 | * @return The scheme of this intent. |
| 6088 | * |
| 6089 | * @see #getData |
| 6090 | */ |
| 6091 | public String getScheme() { |
| 6092 | return mData != null ? mData.getScheme() : null; |
| 6093 | } |
| 6094 | |
| 6095 | /** |
| 6096 | * Retrieve any explicit MIME type included in the intent. This is usually |
| 6097 | * null, as the type is determined by the intent data. |
| 6098 | * |
| 6099 | * @return If a type was manually set, it is returned; else null is |
| 6100 | * returned. |
| 6101 | * |
| 6102 | * @see #resolveType(ContentResolver) |
| 6103 | * @see #setType |
| 6104 | */ |
| 6105 | public String getType() { |
| 6106 | return mType; |
| 6107 | } |
| 6108 | |
| 6109 | /** |
| 6110 | * Return the MIME data type of this intent. If the type field is |
| 6111 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 6112 | * the type of that data is returned. If neither fields are set, a null is |
| 6113 | * returned. |
| 6114 | * |
| 6115 | * @return The MIME type of this intent. |
| 6116 | * |
| 6117 | * @see #getType |
| 6118 | * @see #resolveType(ContentResolver) |
| 6119 | */ |
| 6120 | public String resolveType(Context context) { |
| 6121 | return resolveType(context.getContentResolver()); |
| 6122 | } |
| 6123 | |
| 6124 | /** |
| 6125 | * Return the MIME data type of this intent. If the type field is |
| 6126 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 6127 | * the type of that data is returned. If neither fields are set, a null is |
| 6128 | * returned. |
| 6129 | * |
| 6130 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 6131 | * type of the intent's data. |
| 6132 | * |
| 6133 | * @return The MIME type of this intent. |
| 6134 | * |
| 6135 | * @see #getType |
| 6136 | * @see #resolveType(Context) |
| 6137 | */ |
| 6138 | public String resolveType(ContentResolver resolver) { |
| 6139 | if (mType != null) { |
| 6140 | return mType; |
| 6141 | } |
| 6142 | if (mData != null) { |
| 6143 | if ("content".equals(mData.getScheme())) { |
| 6144 | return resolver.getType(mData); |
| 6145 | } |
| 6146 | } |
| 6147 | return null; |
| 6148 | } |
| 6149 | |
| 6150 | /** |
| 6151 | * Return the MIME data type of this intent, only if it will be needed for |
| 6152 | * intent resolution. This is not generally useful for application code; |
| 6153 | * it is used by the frameworks for communicating with back-end system |
| 6154 | * services. |
| 6155 | * |
| 6156 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 6157 | * type of the intent's data. |
| 6158 | * |
| 6159 | * @return The MIME type of this intent, or null if it is unknown or not |
| 6160 | * needed. |
| 6161 | */ |
| 6162 | public String resolveTypeIfNeeded(ContentResolver resolver) { |
| 6163 | if (mComponent != null) { |
| 6164 | return mType; |
| 6165 | } |
| 6166 | return resolveType(resolver); |
| 6167 | } |
| 6168 | |
| 6169 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 6170 | * Check if a category exists in the intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6171 | * |
| 6172 | * @param category The category to check. |
| 6173 | * |
| 6174 | * @return boolean True if the intent contains the category, else false. |
| 6175 | * |
| 6176 | * @see #getCategories |
| 6177 | * @see #addCategory |
| 6178 | */ |
| 6179 | public boolean hasCategory(String category) { |
| 6180 | return mCategories != null && mCategories.contains(category); |
| 6181 | } |
| 6182 | |
| 6183 | /** |
| 6184 | * Return the set of all categories in the intent. If there are no categories, |
| 6185 | * returns NULL. |
| 6186 | * |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6187 | * @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] | 6188 | * |
| 6189 | * @see #hasCategory |
| 6190 | * @see #addCategory |
| 6191 | */ |
| 6192 | public Set<String> getCategories() { |
| 6193 | return mCategories; |
| 6194 | } |
| 6195 | |
| 6196 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6197 | * Return the specific selector associated with this Intent. If there is |
| 6198 | * none, returns null. See {@link #setSelector} for more information. |
| 6199 | * |
| 6200 | * @see #setSelector |
| 6201 | */ |
| 6202 | public Intent getSelector() { |
| 6203 | return mSelector; |
| 6204 | } |
| 6205 | |
| 6206 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6207 | * Return the {@link ClipData} associated with this Intent. If there is |
| 6208 | * none, returns null. See {@link #setClipData} for more information. |
| 6209 | * |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 6210 | * @see #setClipData |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6211 | */ |
| 6212 | public ClipData getClipData() { |
| 6213 | return mClipData; |
| 6214 | } |
| 6215 | |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 6216 | /** @hide */ |
| 6217 | public int getContentUserHint() { |
| 6218 | return mContentUserHint; |
| 6219 | } |
| 6220 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6221 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6222 | * Sets the ClassLoader that will be used when unmarshalling |
| 6223 | * any Parcelable values from the extras of this Intent. |
| 6224 | * |
| 6225 | * @param loader a ClassLoader, or null to use the default loader |
| 6226 | * at the time of unmarshalling. |
| 6227 | */ |
| 6228 | public void setExtrasClassLoader(ClassLoader loader) { |
| 6229 | if (mExtras != null) { |
| 6230 | mExtras.setClassLoader(loader); |
| 6231 | } |
| 6232 | } |
| 6233 | |
| 6234 | /** |
| 6235 | * Returns true if an extra value is associated with the given name. |
| 6236 | * @param name the extra's name |
| 6237 | * @return true if the given extra is present. |
| 6238 | */ |
| 6239 | public boolean hasExtra(String name) { |
| 6240 | return mExtras != null && mExtras.containsKey(name); |
| 6241 | } |
| 6242 | |
| 6243 | /** |
| 6244 | * Returns true if the Intent's extras contain a parcelled file descriptor. |
| 6245 | * @return true if the Intent contains a parcelled file descriptor. |
| 6246 | */ |
| 6247 | public boolean hasFileDescriptors() { |
| 6248 | return mExtras != null && mExtras.hasFileDescriptors(); |
| 6249 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6250 | |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 6251 | /** {@hide} */ |
Dianne Hackborn | 9ecebbf | 2011-09-28 23:19:47 -0400 | [diff] [blame] | 6252 | public void setAllowFds(boolean allowFds) { |
| 6253 | if (mExtras != null) { |
| 6254 | mExtras.setAllowFds(allowFds); |
| 6255 | } |
| 6256 | } |
| 6257 | |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 6258 | /** {@hide} */ |
| 6259 | public void setDefusable(boolean defusable) { |
| 6260 | if (mExtras != null) { |
| 6261 | mExtras.setDefusable(defusable); |
| 6262 | } |
| 6263 | } |
| 6264 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6265 | /** |
| 6266 | * Retrieve extended data from the intent. |
| 6267 | * |
| 6268 | * @param name The name of the desired item. |
| 6269 | * |
| 6270 | * @return the value of an item that previously added with putExtra() |
| 6271 | * or null if none was found. |
| 6272 | * |
| 6273 | * @deprecated |
| 6274 | * @hide |
| 6275 | */ |
| 6276 | @Deprecated |
| 6277 | public Object getExtra(String name) { |
| 6278 | return getExtra(name, null); |
| 6279 | } |
| 6280 | |
| 6281 | /** |
| 6282 | * Retrieve extended data from the intent. |
| 6283 | * |
| 6284 | * @param name The name of the desired item. |
| 6285 | * @param defaultValue the value to be returned if no value of the desired |
| 6286 | * type is stored with the given name. |
| 6287 | * |
| 6288 | * @return the value of an item that previously added with putExtra() |
| 6289 | * or the default value if none was found. |
| 6290 | * |
| 6291 | * @see #putExtra(String, boolean) |
| 6292 | */ |
| 6293 | public boolean getBooleanExtra(String name, boolean defaultValue) { |
| 6294 | return mExtras == null ? defaultValue : |
| 6295 | mExtras.getBoolean(name, defaultValue); |
| 6296 | } |
| 6297 | |
| 6298 | /** |
| 6299 | * Retrieve extended data from the intent. |
| 6300 | * |
| 6301 | * @param name The name of the desired item. |
| 6302 | * @param defaultValue the value to be returned if no value of the desired |
| 6303 | * type is stored with the given name. |
| 6304 | * |
| 6305 | * @return the value of an item that previously added with putExtra() |
| 6306 | * or the default value if none was found. |
| 6307 | * |
| 6308 | * @see #putExtra(String, byte) |
| 6309 | */ |
| 6310 | public byte getByteExtra(String name, byte defaultValue) { |
| 6311 | return mExtras == null ? defaultValue : |
| 6312 | mExtras.getByte(name, defaultValue); |
| 6313 | } |
| 6314 | |
| 6315 | /** |
| 6316 | * Retrieve extended data from the intent. |
| 6317 | * |
| 6318 | * @param name The name of the desired item. |
| 6319 | * @param defaultValue the value to be returned if no value of the desired |
| 6320 | * type is stored with the given name. |
| 6321 | * |
| 6322 | * @return the value of an item that previously added with putExtra() |
| 6323 | * or the default value if none was found. |
| 6324 | * |
| 6325 | * @see #putExtra(String, short) |
| 6326 | */ |
| 6327 | public short getShortExtra(String name, short defaultValue) { |
| 6328 | return mExtras == null ? defaultValue : |
| 6329 | mExtras.getShort(name, defaultValue); |
| 6330 | } |
| 6331 | |
| 6332 | /** |
| 6333 | * Retrieve extended data from the intent. |
| 6334 | * |
| 6335 | * @param name The name of the desired item. |
| 6336 | * @param defaultValue the value to be returned if no value of the desired |
| 6337 | * type is stored with the given name. |
| 6338 | * |
| 6339 | * @return the value of an item that previously added with putExtra() |
| 6340 | * or the default value if none was found. |
| 6341 | * |
| 6342 | * @see #putExtra(String, char) |
| 6343 | */ |
| 6344 | public char getCharExtra(String name, char defaultValue) { |
| 6345 | return mExtras == null ? defaultValue : |
| 6346 | mExtras.getChar(name, defaultValue); |
| 6347 | } |
| 6348 | |
| 6349 | /** |
| 6350 | * Retrieve extended data from the intent. |
| 6351 | * |
| 6352 | * @param name The name of the desired item. |
| 6353 | * @param defaultValue the value to be returned if no value of the desired |
| 6354 | * type is stored with the given name. |
| 6355 | * |
| 6356 | * @return the value of an item that previously added with putExtra() |
| 6357 | * or the default value if none was found. |
| 6358 | * |
| 6359 | * @see #putExtra(String, int) |
| 6360 | */ |
| 6361 | public int getIntExtra(String name, int defaultValue) { |
| 6362 | return mExtras == null ? defaultValue : |
| 6363 | mExtras.getInt(name, defaultValue); |
| 6364 | } |
| 6365 | |
| 6366 | /** |
| 6367 | * Retrieve extended data from the intent. |
| 6368 | * |
| 6369 | * @param name The name of the desired item. |
| 6370 | * @param defaultValue the value to be returned if no value of the desired |
| 6371 | * type is stored with the given name. |
| 6372 | * |
| 6373 | * @return the value of an item that previously added with putExtra() |
| 6374 | * or the default value if none was found. |
| 6375 | * |
| 6376 | * @see #putExtra(String, long) |
| 6377 | */ |
| 6378 | public long getLongExtra(String name, long defaultValue) { |
| 6379 | return mExtras == null ? defaultValue : |
| 6380 | mExtras.getLong(name, defaultValue); |
| 6381 | } |
| 6382 | |
| 6383 | /** |
| 6384 | * Retrieve extended data from the intent. |
| 6385 | * |
| 6386 | * @param name The name of the desired item. |
| 6387 | * @param defaultValue the value to be returned if no value of the desired |
| 6388 | * type is stored with the given name. |
| 6389 | * |
| 6390 | * @return the value of an item that previously added with putExtra(), |
| 6391 | * or the default value if no such item is present |
| 6392 | * |
| 6393 | * @see #putExtra(String, float) |
| 6394 | */ |
| 6395 | public float getFloatExtra(String name, float defaultValue) { |
| 6396 | return mExtras == null ? defaultValue : |
| 6397 | mExtras.getFloat(name, defaultValue); |
| 6398 | } |
| 6399 | |
| 6400 | /** |
| 6401 | * Retrieve extended data from the intent. |
| 6402 | * |
| 6403 | * @param name The name of the desired item. |
| 6404 | * @param defaultValue the value to be returned if no value of the desired |
| 6405 | * type is stored with the given name. |
| 6406 | * |
| 6407 | * @return the value of an item that previously added with putExtra() |
| 6408 | * or the default value if none was found. |
| 6409 | * |
| 6410 | * @see #putExtra(String, double) |
| 6411 | */ |
| 6412 | public double getDoubleExtra(String name, double defaultValue) { |
| 6413 | return mExtras == null ? defaultValue : |
| 6414 | mExtras.getDouble(name, defaultValue); |
| 6415 | } |
| 6416 | |
| 6417 | /** |
| 6418 | * Retrieve extended data from the intent. |
| 6419 | * |
| 6420 | * @param name The name of the desired item. |
| 6421 | * |
| 6422 | * @return the value of an item that previously added with putExtra() |
| 6423 | * or null if no String value was found. |
| 6424 | * |
| 6425 | * @see #putExtra(String, String) |
| 6426 | */ |
| 6427 | public String getStringExtra(String name) { |
| 6428 | return mExtras == null ? null : mExtras.getString(name); |
| 6429 | } |
| 6430 | |
| 6431 | /** |
| 6432 | * Retrieve extended data from the intent. |
| 6433 | * |
| 6434 | * @param name The name of the desired item. |
| 6435 | * |
| 6436 | * @return the value of an item that previously added with putExtra() |
| 6437 | * or null if no CharSequence value was found. |
| 6438 | * |
| 6439 | * @see #putExtra(String, CharSequence) |
| 6440 | */ |
| 6441 | public CharSequence getCharSequenceExtra(String name) { |
| 6442 | return mExtras == null ? null : mExtras.getCharSequence(name); |
| 6443 | } |
| 6444 | |
| 6445 | /** |
| 6446 | * Retrieve extended data from the intent. |
| 6447 | * |
| 6448 | * @param name The name of the desired item. |
| 6449 | * |
| 6450 | * @return the value of an item that previously added with putExtra() |
| 6451 | * or null if no Parcelable value was found. |
| 6452 | * |
| 6453 | * @see #putExtra(String, Parcelable) |
| 6454 | */ |
| 6455 | public <T extends Parcelable> T getParcelableExtra(String name) { |
| 6456 | return mExtras == null ? null : mExtras.<T>getParcelable(name); |
| 6457 | } |
| 6458 | |
| 6459 | /** |
| 6460 | * Retrieve extended data from the intent. |
| 6461 | * |
| 6462 | * @param name The name of the desired item. |
| 6463 | * |
| 6464 | * @return the value of an item that previously added with putExtra() |
| 6465 | * or null if no Parcelable[] value was found. |
| 6466 | * |
| 6467 | * @see #putExtra(String, Parcelable[]) |
| 6468 | */ |
| 6469 | public Parcelable[] getParcelableArrayExtra(String name) { |
| 6470 | return mExtras == null ? null : mExtras.getParcelableArray(name); |
| 6471 | } |
| 6472 | |
| 6473 | /** |
| 6474 | * Retrieve extended data from the intent. |
| 6475 | * |
| 6476 | * @param name The name of the desired item. |
| 6477 | * |
| 6478 | * @return the value of an item that previously added with putExtra() |
| 6479 | * or null if no ArrayList<Parcelable> value was found. |
| 6480 | * |
| 6481 | * @see #putParcelableArrayListExtra(String, ArrayList) |
| 6482 | */ |
| 6483 | public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { |
| 6484 | return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); |
| 6485 | } |
| 6486 | |
| 6487 | /** |
| 6488 | * Retrieve extended data from the intent. |
| 6489 | * |
| 6490 | * @param name The name of the desired item. |
| 6491 | * |
| 6492 | * @return the value of an item that previously added with putExtra() |
| 6493 | * or null if no Serializable value was found. |
| 6494 | * |
| 6495 | * @see #putExtra(String, Serializable) |
| 6496 | */ |
| 6497 | public Serializable getSerializableExtra(String name) { |
| 6498 | return mExtras == null ? null : mExtras.getSerializable(name); |
| 6499 | } |
| 6500 | |
| 6501 | /** |
| 6502 | * Retrieve extended data from the intent. |
| 6503 | * |
| 6504 | * @param name The name of the desired item. |
| 6505 | * |
| 6506 | * @return the value of an item that previously added with putExtra() |
| 6507 | * or null if no ArrayList<Integer> value was found. |
| 6508 | * |
| 6509 | * @see #putIntegerArrayListExtra(String, ArrayList) |
| 6510 | */ |
| 6511 | public ArrayList<Integer> getIntegerArrayListExtra(String name) { |
| 6512 | return mExtras == null ? null : mExtras.getIntegerArrayList(name); |
| 6513 | } |
| 6514 | |
| 6515 | /** |
| 6516 | * Retrieve extended data from the intent. |
| 6517 | * |
| 6518 | * @param name The name of the desired item. |
| 6519 | * |
| 6520 | * @return the value of an item that previously added with putExtra() |
| 6521 | * or null if no ArrayList<String> value was found. |
| 6522 | * |
| 6523 | * @see #putStringArrayListExtra(String, ArrayList) |
| 6524 | */ |
| 6525 | public ArrayList<String> getStringArrayListExtra(String name) { |
| 6526 | return mExtras == null ? null : mExtras.getStringArrayList(name); |
| 6527 | } |
| 6528 | |
| 6529 | /** |
| 6530 | * Retrieve extended data from the intent. |
| 6531 | * |
| 6532 | * @param name The name of the desired item. |
| 6533 | * |
| 6534 | * @return the value of an item that previously added with putExtra() |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 6535 | * or null if no ArrayList<CharSequence> value was found. |
| 6536 | * |
| 6537 | * @see #putCharSequenceArrayListExtra(String, ArrayList) |
| 6538 | */ |
| 6539 | public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { |
| 6540 | return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); |
| 6541 | } |
| 6542 | |
| 6543 | /** |
| 6544 | * Retrieve extended data from the intent. |
| 6545 | * |
| 6546 | * @param name The name of the desired item. |
| 6547 | * |
| 6548 | * @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] | 6549 | * or null if no boolean array value was found. |
| 6550 | * |
| 6551 | * @see #putExtra(String, boolean[]) |
| 6552 | */ |
| 6553 | public boolean[] getBooleanArrayExtra(String name) { |
| 6554 | return mExtras == null ? null : mExtras.getBooleanArray(name); |
| 6555 | } |
| 6556 | |
| 6557 | /** |
| 6558 | * Retrieve extended data from the intent. |
| 6559 | * |
| 6560 | * @param name The name of the desired item. |
| 6561 | * |
| 6562 | * @return the value of an item that previously added with putExtra() |
| 6563 | * or null if no byte array value was found. |
| 6564 | * |
| 6565 | * @see #putExtra(String, byte[]) |
| 6566 | */ |
| 6567 | public byte[] getByteArrayExtra(String name) { |
| 6568 | return mExtras == null ? null : mExtras.getByteArray(name); |
| 6569 | } |
| 6570 | |
| 6571 | /** |
| 6572 | * Retrieve extended data from the intent. |
| 6573 | * |
| 6574 | * @param name The name of the desired item. |
| 6575 | * |
| 6576 | * @return the value of an item that previously added with putExtra() |
| 6577 | * or null if no short array value was found. |
| 6578 | * |
| 6579 | * @see #putExtra(String, short[]) |
| 6580 | */ |
| 6581 | public short[] getShortArrayExtra(String name) { |
| 6582 | return mExtras == null ? null : mExtras.getShortArray(name); |
| 6583 | } |
| 6584 | |
| 6585 | /** |
| 6586 | * Retrieve extended data from the intent. |
| 6587 | * |
| 6588 | * @param name The name of the desired item. |
| 6589 | * |
| 6590 | * @return the value of an item that previously added with putExtra() |
| 6591 | * or null if no char array value was found. |
| 6592 | * |
| 6593 | * @see #putExtra(String, char[]) |
| 6594 | */ |
| 6595 | public char[] getCharArrayExtra(String name) { |
| 6596 | return mExtras == null ? null : mExtras.getCharArray(name); |
| 6597 | } |
| 6598 | |
| 6599 | /** |
| 6600 | * Retrieve extended data from the intent. |
| 6601 | * |
| 6602 | * @param name The name of the desired item. |
| 6603 | * |
| 6604 | * @return the value of an item that previously added with putExtra() |
| 6605 | * or null if no int array value was found. |
| 6606 | * |
| 6607 | * @see #putExtra(String, int[]) |
| 6608 | */ |
| 6609 | public int[] getIntArrayExtra(String name) { |
| 6610 | return mExtras == null ? null : mExtras.getIntArray(name); |
| 6611 | } |
| 6612 | |
| 6613 | /** |
| 6614 | * Retrieve extended data from the intent. |
| 6615 | * |
| 6616 | * @param name The name of the desired item. |
| 6617 | * |
| 6618 | * @return the value of an item that previously added with putExtra() |
| 6619 | * or null if no long array value was found. |
| 6620 | * |
| 6621 | * @see #putExtra(String, long[]) |
| 6622 | */ |
| 6623 | public long[] getLongArrayExtra(String name) { |
| 6624 | return mExtras == null ? null : mExtras.getLongArray(name); |
| 6625 | } |
| 6626 | |
| 6627 | /** |
| 6628 | * Retrieve extended data from the intent. |
| 6629 | * |
| 6630 | * @param name The name of the desired item. |
| 6631 | * |
| 6632 | * @return the value of an item that previously added with putExtra() |
| 6633 | * or null if no float array value was found. |
| 6634 | * |
| 6635 | * @see #putExtra(String, float[]) |
| 6636 | */ |
| 6637 | public float[] getFloatArrayExtra(String name) { |
| 6638 | return mExtras == null ? null : mExtras.getFloatArray(name); |
| 6639 | } |
| 6640 | |
| 6641 | /** |
| 6642 | * Retrieve extended data from the intent. |
| 6643 | * |
| 6644 | * @param name The name of the desired item. |
| 6645 | * |
| 6646 | * @return the value of an item that previously added with putExtra() |
| 6647 | * or null if no double array value was found. |
| 6648 | * |
| 6649 | * @see #putExtra(String, double[]) |
| 6650 | */ |
| 6651 | public double[] getDoubleArrayExtra(String name) { |
| 6652 | return mExtras == null ? null : mExtras.getDoubleArray(name); |
| 6653 | } |
| 6654 | |
| 6655 | /** |
| 6656 | * Retrieve extended data from the intent. |
| 6657 | * |
| 6658 | * @param name The name of the desired item. |
| 6659 | * |
| 6660 | * @return the value of an item that previously added with putExtra() |
| 6661 | * or null if no String array value was found. |
| 6662 | * |
| 6663 | * @see #putExtra(String, String[]) |
| 6664 | */ |
| 6665 | public String[] getStringArrayExtra(String name) { |
| 6666 | return mExtras == null ? null : mExtras.getStringArray(name); |
| 6667 | } |
| 6668 | |
| 6669 | /** |
| 6670 | * Retrieve extended data from the intent. |
| 6671 | * |
| 6672 | * @param name The name of the desired item. |
| 6673 | * |
| 6674 | * @return the value of an item that previously added with putExtra() |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 6675 | * or null if no CharSequence array value was found. |
| 6676 | * |
| 6677 | * @see #putExtra(String, CharSequence[]) |
| 6678 | */ |
| 6679 | public CharSequence[] getCharSequenceArrayExtra(String name) { |
| 6680 | return mExtras == null ? null : mExtras.getCharSequenceArray(name); |
| 6681 | } |
| 6682 | |
| 6683 | /** |
| 6684 | * Retrieve extended data from the intent. |
| 6685 | * |
| 6686 | * @param name The name of the desired item. |
| 6687 | * |
| 6688 | * @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] | 6689 | * or null if no Bundle value was found. |
| 6690 | * |
| 6691 | * @see #putExtra(String, Bundle) |
| 6692 | */ |
| 6693 | public Bundle getBundleExtra(String name) { |
| 6694 | return mExtras == null ? null : mExtras.getBundle(name); |
| 6695 | } |
| 6696 | |
| 6697 | /** |
| 6698 | * Retrieve extended data from the intent. |
| 6699 | * |
| 6700 | * @param name The name of the desired item. |
| 6701 | * |
| 6702 | * @return the value of an item that previously added with putExtra() |
| 6703 | * or null if no IBinder value was found. |
| 6704 | * |
| 6705 | * @see #putExtra(String, IBinder) |
| 6706 | * |
| 6707 | * @deprecated |
| 6708 | * @hide |
| 6709 | */ |
| 6710 | @Deprecated |
| 6711 | public IBinder getIBinderExtra(String name) { |
| 6712 | return mExtras == null ? null : mExtras.getIBinder(name); |
| 6713 | } |
| 6714 | |
| 6715 | /** |
| 6716 | * Retrieve extended data from the intent. |
| 6717 | * |
| 6718 | * @param name The name of the desired item. |
| 6719 | * @param defaultValue The default value to return in case no item is |
| 6720 | * associated with the key 'name' |
| 6721 | * |
| 6722 | * @return the value of an item that previously added with putExtra() |
| 6723 | * or defaultValue if none was found. |
| 6724 | * |
| 6725 | * @see #putExtra |
| 6726 | * |
| 6727 | * @deprecated |
| 6728 | * @hide |
| 6729 | */ |
| 6730 | @Deprecated |
| 6731 | public Object getExtra(String name, Object defaultValue) { |
| 6732 | Object result = defaultValue; |
| 6733 | if (mExtras != null) { |
| 6734 | Object result2 = mExtras.get(name); |
| 6735 | if (result2 != null) { |
| 6736 | result = result2; |
| 6737 | } |
| 6738 | } |
| 6739 | |
| 6740 | return result; |
| 6741 | } |
| 6742 | |
| 6743 | /** |
| 6744 | * Retrieves a map of extended data from the intent. |
| 6745 | * |
| 6746 | * @return the map of all extras previously added with putExtra(), |
| 6747 | * or null if none have been added. |
| 6748 | */ |
| 6749 | public Bundle getExtras() { |
| 6750 | return (mExtras != null) |
| 6751 | ? new Bundle(mExtras) |
| 6752 | : null; |
| 6753 | } |
| 6754 | |
| 6755 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 6756 | * Filter extras to only basic types. |
| 6757 | * @hide |
| 6758 | */ |
| 6759 | public void removeUnsafeExtras() { |
| 6760 | if (mExtras != null) { |
Dianne Hackborn | 851ec49 | 2016-10-12 17:20:07 -0700 | [diff] [blame] | 6761 | mExtras = mExtras.filterValues(); |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 6762 | } |
| 6763 | } |
| 6764 | |
| 6765 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6766 | * Retrieve any special flags associated with this intent. You will |
| 6767 | * normally just set them with {@link #setFlags} and let the system |
| 6768 | * take the appropriate action with them. |
| 6769 | * |
| 6770 | * @return int The currently set flags. |
| 6771 | * |
| 6772 | * @see #setFlags |
| 6773 | */ |
| 6774 | public int getFlags() { |
| 6775 | return mFlags; |
| 6776 | } |
| 6777 | |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 6778 | /** @hide */ |
| 6779 | public boolean isExcludingStopped() { |
| 6780 | return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) |
| 6781 | == FLAG_EXCLUDE_STOPPED_PACKAGES; |
| 6782 | } |
| 6783 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6784 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 6785 | * Retrieve the application package name this Intent is limited to. When |
| 6786 | * resolving an Intent, if non-null this limits the resolution to only |
| 6787 | * components in the given application package. |
| 6788 | * |
| 6789 | * @return The name of the application package for the Intent. |
| 6790 | * |
| 6791 | * @see #resolveActivity |
| 6792 | * @see #setPackage |
| 6793 | */ |
| 6794 | public String getPackage() { |
| 6795 | return mPackage; |
| 6796 | } |
| 6797 | |
| 6798 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6799 | * Retrieve the concrete component associated with the intent. When receiving |
| 6800 | * an intent, this is the component that was found to best handle it (that is, |
| 6801 | * yourself) and will always be non-null; in all other cases it will be |
| 6802 | * null unless explicitly set. |
| 6803 | * |
| 6804 | * @return The name of the application component to handle the intent. |
| 6805 | * |
| 6806 | * @see #resolveActivity |
| 6807 | * @see #setComponent |
| 6808 | */ |
| 6809 | public ComponentName getComponent() { |
| 6810 | return mComponent; |
| 6811 | } |
| 6812 | |
| 6813 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 6814 | * Get the bounds of the sender of this intent, in screen coordinates. This can be |
| 6815 | * used as a hint to the receiver for animations and the like. Null means that there |
| 6816 | * is no source bounds. |
| 6817 | */ |
| 6818 | public Rect getSourceBounds() { |
| 6819 | return mSourceBounds; |
| 6820 | } |
| 6821 | |
| 6822 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6823 | * Return the Activity component that should be used to handle this intent. |
| 6824 | * The appropriate component is determined based on the information in the |
| 6825 | * intent, evaluated as follows: |
| 6826 | * |
| 6827 | * <p>If {@link #getComponent} returns an explicit class, that is returned |
| 6828 | * without any further consideration. |
| 6829 | * |
| 6830 | * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent |
| 6831 | * category to be considered. |
| 6832 | * |
| 6833 | * <p>If {@link #getAction} is non-NULL, the activity must handle this |
| 6834 | * action. |
| 6835 | * |
| 6836 | * <p>If {@link #resolveType} returns non-NULL, the activity must handle |
| 6837 | * this type. |
| 6838 | * |
| 6839 | * <p>If {@link #addCategory} has added any categories, the activity must |
| 6840 | * handle ALL of the categories specified. |
| 6841 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 6842 | * <p>If {@link #getPackage} is non-NULL, only activity components in |
| 6843 | * that application package will be considered. |
| 6844 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6845 | * <p>If there are no activities that satisfy all of these conditions, a |
| 6846 | * null string is returned. |
| 6847 | * |
| 6848 | * <p>If multiple activities are found to satisfy the intent, the one with |
| 6849 | * the highest priority will be used. If there are multiple activities |
| 6850 | * with the same priority, the system will either pick the best activity |
| 6851 | * based on user preference, or resolve to a system class that will allow |
| 6852 | * the user to pick an activity and forward from there. |
| 6853 | * |
| 6854 | * <p>This method is implemented simply by calling |
| 6855 | * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter |
| 6856 | * true.</p> |
| 6857 | * <p> This API is called for you as part of starting an activity from an |
| 6858 | * intent. You do not normally need to call it yourself.</p> |
| 6859 | * |
| 6860 | * @param pm The package manager with which to resolve the Intent. |
| 6861 | * |
| 6862 | * @return Name of the component implementing an activity that can |
| 6863 | * display the intent. |
| 6864 | * |
| 6865 | * @see #setComponent |
| 6866 | * @see #getComponent |
| 6867 | * @see #resolveActivityInfo |
| 6868 | */ |
| 6869 | public ComponentName resolveActivity(PackageManager pm) { |
| 6870 | if (mComponent != null) { |
| 6871 | return mComponent; |
| 6872 | } |
| 6873 | |
| 6874 | ResolveInfo info = pm.resolveActivity( |
| 6875 | this, PackageManager.MATCH_DEFAULT_ONLY); |
| 6876 | if (info != null) { |
| 6877 | return new ComponentName( |
| 6878 | info.activityInfo.applicationInfo.packageName, |
| 6879 | info.activityInfo.name); |
| 6880 | } |
| 6881 | |
| 6882 | return null; |
| 6883 | } |
| 6884 | |
| 6885 | /** |
| 6886 | * Resolve the Intent into an {@link ActivityInfo} |
| 6887 | * describing the activity that should execute the intent. Resolution |
| 6888 | * follows the same rules as described for {@link #resolveActivity}, but |
| 6889 | * you get back the completely information about the resolved activity |
| 6890 | * instead of just its class name. |
| 6891 | * |
| 6892 | * @param pm The package manager with which to resolve the Intent. |
| 6893 | * @param flags Addition information to retrieve as per |
| 6894 | * {@link PackageManager#getActivityInfo(ComponentName, int) |
| 6895 | * PackageManager.getActivityInfo()}. |
| 6896 | * |
| 6897 | * @return PackageManager.ActivityInfo |
| 6898 | * |
| 6899 | * @see #resolveActivity |
| 6900 | */ |
| 6901 | public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) { |
| 6902 | ActivityInfo ai = null; |
| 6903 | if (mComponent != null) { |
| 6904 | try { |
| 6905 | ai = pm.getActivityInfo(mComponent, flags); |
| 6906 | } catch (PackageManager.NameNotFoundException e) { |
| 6907 | // ignore |
| 6908 | } |
| 6909 | } else { |
| 6910 | ResolveInfo info = pm.resolveActivity( |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 6911 | this, PackageManager.MATCH_DEFAULT_ONLY | flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6912 | if (info != null) { |
| 6913 | ai = info.activityInfo; |
| 6914 | } |
| 6915 | } |
| 6916 | |
| 6917 | return ai; |
| 6918 | } |
| 6919 | |
| 6920 | /** |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 6921 | * Special function for use by the system to resolve service |
| 6922 | * intents to system apps. Throws an exception if there are |
| 6923 | * multiple potential matches to the Intent. Returns null if |
| 6924 | * there are no matches. |
| 6925 | * @hide |
| 6926 | */ |
| 6927 | public ComponentName resolveSystemService(PackageManager pm, int flags) { |
| 6928 | if (mComponent != null) { |
| 6929 | return mComponent; |
| 6930 | } |
| 6931 | |
| 6932 | List<ResolveInfo> results = pm.queryIntentServices(this, flags); |
| 6933 | if (results == null) { |
| 6934 | return null; |
| 6935 | } |
| 6936 | ComponentName comp = null; |
| 6937 | for (int i=0; i<results.size(); i++) { |
| 6938 | ResolveInfo ri = results.get(i); |
| 6939 | if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { |
| 6940 | continue; |
| 6941 | } |
| 6942 | ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, |
| 6943 | ri.serviceInfo.name); |
| 6944 | if (comp != null) { |
| 6945 | throw new IllegalStateException("Multiple system services handle " + this |
| 6946 | + ": " + comp + ", " + foundComp); |
| 6947 | } |
| 6948 | comp = foundComp; |
| 6949 | } |
| 6950 | return comp; |
| 6951 | } |
| 6952 | |
| 6953 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6954 | * Set the general action to be performed. |
| 6955 | * |
| 6956 | * @param action An action name, such as ACTION_VIEW. Application-specific |
| 6957 | * actions should be prefixed with the vendor's package name. |
| 6958 | * |
| 6959 | * @return Returns the same Intent object, for chaining multiple calls |
| 6960 | * into a single statement. |
| 6961 | * |
| 6962 | * @see #getAction |
| 6963 | */ |
| 6964 | public Intent setAction(String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 6965 | mAction = action != null ? action.intern() : null; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6966 | return this; |
| 6967 | } |
| 6968 | |
| 6969 | /** |
| 6970 | * Set the data this intent is operating on. This method automatically |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6971 | * clears any type that was previously set by {@link #setType} or |
| 6972 | * {@link #setTypeAndNormalize}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6973 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6974 | * <p><em>Note: scheme matching in the Android framework is |
| 6975 | * case-sensitive, unlike the formal RFC. As a result, |
| 6976 | * you should always write your Uri with a lower case scheme, |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6977 | * or use {@link Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6978 | * {@link #setDataAndNormalize} |
| 6979 | * to ensure that the scheme is converted to lower case.</em> |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 6980 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6981 | * @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] | 6982 | * |
| 6983 | * @return Returns the same Intent object, for chaining multiple calls |
| 6984 | * into a single statement. |
| 6985 | * |
| 6986 | * @see #getData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6987 | * @see #setDataAndNormalize |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 6988 | * @see android.net.Uri#normalizeScheme() |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6989 | */ |
| 6990 | public Intent setData(Uri data) { |
| 6991 | mData = data; |
| 6992 | mType = null; |
| 6993 | return this; |
| 6994 | } |
| 6995 | |
| 6996 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6997 | * Normalize and set the data this intent is operating on. |
| 6998 | * |
| 6999 | * <p>This method automatically clears any type that was |
| 7000 | * previously set (for example, by {@link #setType}). |
| 7001 | * |
| 7002 | * <p>The data Uri is normalized using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7003 | * {@link android.net.Uri#normalizeScheme} before it is set, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7004 | * so really this is just a convenience method for |
| 7005 | * <pre> |
| 7006 | * setData(data.normalize()) |
| 7007 | * </pre> |
| 7008 | * |
| 7009 | * @param data The Uri of the data this intent is now targeting. |
| 7010 | * |
| 7011 | * @return Returns the same Intent object, for chaining multiple calls |
| 7012 | * into a single statement. |
| 7013 | * |
| 7014 | * @see #getData |
| 7015 | * @see #setType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7016 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7017 | */ |
| 7018 | public Intent setDataAndNormalize(Uri data) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7019 | return setData(data.normalizeScheme()); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7020 | } |
| 7021 | |
| 7022 | /** |
| 7023 | * Set an explicit MIME data type. |
| 7024 | * |
| 7025 | * <p>This is used to create intents that only specify a type and not data, |
| 7026 | * for example to indicate the type of data to return. |
| 7027 | * |
| 7028 | * <p>This method automatically clears any data that was |
| 7029 | * previously set (for example by {@link #setData}). |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 7030 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7031 | * <p><em>Note: MIME type matching in the Android framework is |
| 7032 | * case-sensitive, unlike formal RFC MIME types. As a result, |
| 7033 | * you should always write your MIME types with lower case letters, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7034 | * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} |
| 7035 | * 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] | 7036 | * |
| 7037 | * @param type The MIME type of the data being handled by this intent. |
| 7038 | * |
| 7039 | * @return Returns the same Intent object, for chaining multiple calls |
| 7040 | * into a single statement. |
| 7041 | * |
| 7042 | * @see #getType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7043 | * @see #setTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7044 | * @see #setDataAndType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7045 | * @see #normalizeMimeType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7046 | */ |
| 7047 | public Intent setType(String type) { |
| 7048 | mData = null; |
| 7049 | mType = type; |
| 7050 | return this; |
| 7051 | } |
| 7052 | |
| 7053 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7054 | * Normalize and set an explicit MIME data type. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7055 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7056 | * <p>This is used to create intents that only specify a type and not data, |
| 7057 | * for example to indicate the type of data to return. |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7058 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7059 | * <p>This method automatically clears any data that was |
| 7060 | * previously set (for example by {@link #setData}). |
| 7061 | * |
| 7062 | * <p>The MIME type is normalized using |
| 7063 | * {@link #normalizeMimeType} before it is set, |
| 7064 | * so really this is just a convenience method for |
| 7065 | * <pre> |
| 7066 | * setType(Intent.normalizeMimeType(type)) |
| 7067 | * </pre> |
| 7068 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7069 | * @param type The MIME type of the data being handled by this intent. |
| 7070 | * |
| 7071 | * @return Returns the same Intent object, for chaining multiple calls |
| 7072 | * into a single statement. |
| 7073 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7074 | * @see #getType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7075 | * @see #setData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7076 | * @see #normalizeMimeType |
| 7077 | */ |
| 7078 | public Intent setTypeAndNormalize(String type) { |
| 7079 | return setType(normalizeMimeType(type)); |
| 7080 | } |
| 7081 | |
| 7082 | /** |
| 7083 | * (Usually optional) Set the data for the intent along with an explicit |
| 7084 | * MIME data type. This method should very rarely be used -- it allows you |
| 7085 | * to override the MIME type that would ordinarily be inferred from the |
| 7086 | * data with your own type given here. |
| 7087 | * |
| 7088 | * <p><em>Note: MIME type and Uri scheme matching in the |
| 7089 | * Android framework is case-sensitive, unlike the formal RFC definitions. |
| 7090 | * 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] | 7091 | * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7092 | * {@link #setDataAndTypeAndNormalize} |
| 7093 | * to ensure that they are converted to lower case.</em> |
| 7094 | * |
| 7095 | * @param data The Uri of the data this intent is now targeting. |
| 7096 | * @param type The MIME type of the data being handled by this intent. |
| 7097 | * |
| 7098 | * @return Returns the same Intent object, for chaining multiple calls |
| 7099 | * into a single statement. |
| 7100 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7101 | * @see #setType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7102 | * @see #setData |
| 7103 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7104 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7105 | * @see #setDataAndTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7106 | */ |
| 7107 | public Intent setDataAndType(Uri data, String type) { |
| 7108 | mData = data; |
| 7109 | mType = type; |
| 7110 | return this; |
| 7111 | } |
| 7112 | |
| 7113 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7114 | * (Usually optional) Normalize and set both the data Uri and an explicit |
| 7115 | * MIME data type. This method should very rarely be used -- it allows you |
| 7116 | * to override the MIME type that would ordinarily be inferred from the |
| 7117 | * data with your own type given here. |
| 7118 | * |
| 7119 | * <p>The data Uri and the MIME type are normalize using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7120 | * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7121 | * before they are set, so really this is just a convenience method for |
| 7122 | * <pre> |
| 7123 | * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) |
| 7124 | * </pre> |
| 7125 | * |
| 7126 | * @param data The Uri of the data this intent is now targeting. |
| 7127 | * @param type The MIME type of the data being handled by this intent. |
| 7128 | * |
| 7129 | * @return Returns the same Intent object, for chaining multiple calls |
| 7130 | * into a single statement. |
| 7131 | * |
| 7132 | * @see #setType |
| 7133 | * @see #setData |
| 7134 | * @see #setDataAndType |
| 7135 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7136 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7137 | */ |
| 7138 | public Intent setDataAndTypeAndNormalize(Uri data, String type) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7139 | return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7140 | } |
| 7141 | |
| 7142 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7143 | * Add a new category to the intent. Categories provide additional detail |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 7144 | * 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] | 7145 | * activities that provide <em>all</em> of the requested categories will be |
| 7146 | * used. |
| 7147 | * |
| 7148 | * @param category The desired category. This can be either one of the |
| 7149 | * predefined Intent categories, or a custom category in your own |
| 7150 | * namespace. |
| 7151 | * |
| 7152 | * @return Returns the same Intent object, for chaining multiple calls |
| 7153 | * into a single statement. |
| 7154 | * |
| 7155 | * @see #hasCategory |
| 7156 | * @see #removeCategory |
| 7157 | */ |
| 7158 | public Intent addCategory(String category) { |
| 7159 | if (mCategories == null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7160 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7161 | } |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 7162 | mCategories.add(category.intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7163 | return this; |
| 7164 | } |
| 7165 | |
| 7166 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 7167 | * Remove a category from an intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7168 | * |
| 7169 | * @param category The category to remove. |
| 7170 | * |
| 7171 | * @see #addCategory |
| 7172 | */ |
| 7173 | public void removeCategory(String category) { |
| 7174 | if (mCategories != null) { |
| 7175 | mCategories.remove(category); |
| 7176 | if (mCategories.size() == 0) { |
| 7177 | mCategories = null; |
| 7178 | } |
| 7179 | } |
| 7180 | } |
| 7181 | |
| 7182 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7183 | * Set a selector for this Intent. This is a modification to the kinds of |
| 7184 | * things the Intent will match. If the selector is set, it will be used |
| 7185 | * when trying to find entities that can handle the Intent, instead of the |
| 7186 | * main contents of the Intent. This allows you build an Intent containing |
| 7187 | * a generic protocol while targeting it more specifically. |
| 7188 | * |
| 7189 | * <p>An example of where this may be used is with things like |
| 7190 | * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an |
| 7191 | * Intent that will launch the Browser application. However, the correct |
| 7192 | * main entry point of an application is actually {@link #ACTION_MAIN} |
| 7193 | * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} |
| 7194 | * used to specify the actual Activity to launch. If you launch the browser |
| 7195 | * with something different, undesired behavior may happen if the user has |
| 7196 | * previously or later launches it the normal way, since they do not match. |
| 7197 | * Instead, you can build an Intent with the MAIN action (but no ComponentName |
| 7198 | * yet specified) and set a selector with {@link #ACTION_MAIN} and |
| 7199 | * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. |
| 7200 | * |
| 7201 | * <p>Setting a selector does not impact the behavior of |
| 7202 | * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the |
| 7203 | * desired behavior of a selector -- it does not impact the base meaning |
| 7204 | * of the Intent, just what kinds of things will be matched against it |
| 7205 | * when determining who can handle it.</p> |
| 7206 | * |
| 7207 | * <p>You can not use both a selector and {@link #setPackage(String)} on |
| 7208 | * the same base Intent.</p> |
| 7209 | * |
| 7210 | * @param selector The desired selector Intent; set to null to not use |
| 7211 | * a special selector. |
| 7212 | */ |
| 7213 | public void setSelector(Intent selector) { |
| 7214 | if (selector == this) { |
| 7215 | throw new IllegalArgumentException( |
| 7216 | "Intent being set as a selector of itself"); |
| 7217 | } |
| 7218 | if (selector != null && mPackage != null) { |
| 7219 | throw new IllegalArgumentException( |
| 7220 | "Can't set selector when package name is already set"); |
| 7221 | } |
| 7222 | mSelector = selector; |
| 7223 | } |
| 7224 | |
| 7225 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7226 | * Set a {@link ClipData} associated with this Intent. This replaces any |
| 7227 | * previously set ClipData. |
| 7228 | * |
| 7229 | * <p>The ClipData in an intent is not used for Intent matching or other |
| 7230 | * such operations. Semantically it is like extras, used to transmit |
| 7231 | * additional data with the Intent. The main feature of using this over |
| 7232 | * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} |
| 7233 | * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI |
| 7234 | * items included in the clip data. This is useful, in particular, if |
| 7235 | * you want to transmit an Intent containing multiple <code>content:</code> |
| 7236 | * URIs for which the recipient may not have global permission to access the |
| 7237 | * content provider. |
| 7238 | * |
| 7239 | * <p>If the ClipData contains items that are themselves Intents, any |
| 7240 | * grant flags in those Intents will be ignored. Only the top-level flags |
| 7241 | * of the main Intent are respected, and will be applied to all Uri or |
| 7242 | * Intent items in the clip (or sub-items of the clip). |
| 7243 | * |
| 7244 | * <p>The MIME type, label, and icon in the ClipData object are not |
| 7245 | * directly used by Intent. Applications should generally rely on the |
| 7246 | * MIME type of the Intent itself, not what it may find in the ClipData. |
| 7247 | * 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] | 7248 | * with a MIME type of "*/*". |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7249 | * |
| 7250 | * @param clip The new clip to set. May be null to clear the current clip. |
| 7251 | */ |
| 7252 | public void setClipData(ClipData clip) { |
| 7253 | mClipData = clip; |
| 7254 | } |
| 7255 | |
| 7256 | /** |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7257 | * This is NOT a secure mechanism to identify the user who sent the intent. |
| 7258 | * When the intent is sent to a different user, it is used to fix uris by adding the userId |
| 7259 | * who sent the intent. |
| 7260 | * @hide |
| 7261 | */ |
Nicolas Prevot | 107f7b7 | 2015-07-01 16:31:48 +0100 | [diff] [blame] | 7262 | public void prepareToLeaveUser(int userId) { |
| 7263 | // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. |
| 7264 | // We want mContentUserHint to refer to the original user, so don't do anything. |
| 7265 | if (mContentUserHint == UserHandle.USER_CURRENT) { |
| 7266 | mContentUserHint = userId; |
| 7267 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7268 | } |
| 7269 | |
| 7270 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7271 | * Add extended data to the intent. The name must include a package |
| 7272 | * prefix, for example the app com.android.contacts would use names |
| 7273 | * like "com.android.contacts.ShowAll". |
| 7274 | * |
| 7275 | * @param name The name of the extra data, with package prefix. |
| 7276 | * @param value The boolean data value. |
| 7277 | * |
| 7278 | * @return Returns the same Intent object, for chaining multiple calls |
| 7279 | * into a single statement. |
| 7280 | * |
| 7281 | * @see #putExtras |
| 7282 | * @see #removeExtra |
| 7283 | * @see #getBooleanExtra(String, boolean) |
| 7284 | */ |
| 7285 | public Intent putExtra(String name, boolean value) { |
| 7286 | if (mExtras == null) { |
| 7287 | mExtras = new Bundle(); |
| 7288 | } |
| 7289 | mExtras.putBoolean(name, value); |
| 7290 | return this; |
| 7291 | } |
| 7292 | |
| 7293 | /** |
| 7294 | * Add extended data to the intent. The name must include a package |
| 7295 | * prefix, for example the app com.android.contacts would use names |
| 7296 | * like "com.android.contacts.ShowAll". |
| 7297 | * |
| 7298 | * @param name The name of the extra data, with package prefix. |
| 7299 | * @param value The byte data value. |
| 7300 | * |
| 7301 | * @return Returns the same Intent object, for chaining multiple calls |
| 7302 | * into a single statement. |
| 7303 | * |
| 7304 | * @see #putExtras |
| 7305 | * @see #removeExtra |
| 7306 | * @see #getByteExtra(String, byte) |
| 7307 | */ |
| 7308 | public Intent putExtra(String name, byte value) { |
| 7309 | if (mExtras == null) { |
| 7310 | mExtras = new Bundle(); |
| 7311 | } |
| 7312 | mExtras.putByte(name, value); |
| 7313 | return this; |
| 7314 | } |
| 7315 | |
| 7316 | /** |
| 7317 | * Add extended data to the intent. The name must include a package |
| 7318 | * prefix, for example the app com.android.contacts would use names |
| 7319 | * like "com.android.contacts.ShowAll". |
| 7320 | * |
| 7321 | * @param name The name of the extra data, with package prefix. |
| 7322 | * @param value The char data value. |
| 7323 | * |
| 7324 | * @return Returns the same Intent object, for chaining multiple calls |
| 7325 | * into a single statement. |
| 7326 | * |
| 7327 | * @see #putExtras |
| 7328 | * @see #removeExtra |
| 7329 | * @see #getCharExtra(String, char) |
| 7330 | */ |
| 7331 | public Intent putExtra(String name, char value) { |
| 7332 | if (mExtras == null) { |
| 7333 | mExtras = new Bundle(); |
| 7334 | } |
| 7335 | mExtras.putChar(name, value); |
| 7336 | return this; |
| 7337 | } |
| 7338 | |
| 7339 | /** |
| 7340 | * Add extended data to the intent. The name must include a package |
| 7341 | * prefix, for example the app com.android.contacts would use names |
| 7342 | * like "com.android.contacts.ShowAll". |
| 7343 | * |
| 7344 | * @param name The name of the extra data, with package prefix. |
| 7345 | * @param value The short data value. |
| 7346 | * |
| 7347 | * @return Returns the same Intent object, for chaining multiple calls |
| 7348 | * into a single statement. |
| 7349 | * |
| 7350 | * @see #putExtras |
| 7351 | * @see #removeExtra |
| 7352 | * @see #getShortExtra(String, short) |
| 7353 | */ |
| 7354 | public Intent putExtra(String name, short value) { |
| 7355 | if (mExtras == null) { |
| 7356 | mExtras = new Bundle(); |
| 7357 | } |
| 7358 | mExtras.putShort(name, value); |
| 7359 | return this; |
| 7360 | } |
| 7361 | |
| 7362 | /** |
| 7363 | * Add extended data to the intent. The name must include a package |
| 7364 | * prefix, for example the app com.android.contacts would use names |
| 7365 | * like "com.android.contacts.ShowAll". |
| 7366 | * |
| 7367 | * @param name The name of the extra data, with package prefix. |
| 7368 | * @param value The integer data value. |
| 7369 | * |
| 7370 | * @return Returns the same Intent object, for chaining multiple calls |
| 7371 | * into a single statement. |
| 7372 | * |
| 7373 | * @see #putExtras |
| 7374 | * @see #removeExtra |
| 7375 | * @see #getIntExtra(String, int) |
| 7376 | */ |
| 7377 | public Intent putExtra(String name, int value) { |
| 7378 | if (mExtras == null) { |
| 7379 | mExtras = new Bundle(); |
| 7380 | } |
| 7381 | mExtras.putInt(name, value); |
| 7382 | return this; |
| 7383 | } |
| 7384 | |
| 7385 | /** |
| 7386 | * Add extended data to the intent. The name must include a package |
| 7387 | * prefix, for example the app com.android.contacts would use names |
| 7388 | * like "com.android.contacts.ShowAll". |
| 7389 | * |
| 7390 | * @param name The name of the extra data, with package prefix. |
| 7391 | * @param value The long data value. |
| 7392 | * |
| 7393 | * @return Returns the same Intent object, for chaining multiple calls |
| 7394 | * into a single statement. |
| 7395 | * |
| 7396 | * @see #putExtras |
| 7397 | * @see #removeExtra |
| 7398 | * @see #getLongExtra(String, long) |
| 7399 | */ |
| 7400 | public Intent putExtra(String name, long value) { |
| 7401 | if (mExtras == null) { |
| 7402 | mExtras = new Bundle(); |
| 7403 | } |
| 7404 | mExtras.putLong(name, value); |
| 7405 | return this; |
| 7406 | } |
| 7407 | |
| 7408 | /** |
| 7409 | * Add extended data to the intent. The name must include a package |
| 7410 | * prefix, for example the app com.android.contacts would use names |
| 7411 | * like "com.android.contacts.ShowAll". |
| 7412 | * |
| 7413 | * @param name The name of the extra data, with package prefix. |
| 7414 | * @param value The float data value. |
| 7415 | * |
| 7416 | * @return Returns the same Intent object, for chaining multiple calls |
| 7417 | * into a single statement. |
| 7418 | * |
| 7419 | * @see #putExtras |
| 7420 | * @see #removeExtra |
| 7421 | * @see #getFloatExtra(String, float) |
| 7422 | */ |
| 7423 | public Intent putExtra(String name, float value) { |
| 7424 | if (mExtras == null) { |
| 7425 | mExtras = new Bundle(); |
| 7426 | } |
| 7427 | mExtras.putFloat(name, value); |
| 7428 | return this; |
| 7429 | } |
| 7430 | |
| 7431 | /** |
| 7432 | * Add extended data to the intent. The name must include a package |
| 7433 | * prefix, for example the app com.android.contacts would use names |
| 7434 | * like "com.android.contacts.ShowAll". |
| 7435 | * |
| 7436 | * @param name The name of the extra data, with package prefix. |
| 7437 | * @param value The double data value. |
| 7438 | * |
| 7439 | * @return Returns the same Intent object, for chaining multiple calls |
| 7440 | * into a single statement. |
| 7441 | * |
| 7442 | * @see #putExtras |
| 7443 | * @see #removeExtra |
| 7444 | * @see #getDoubleExtra(String, double) |
| 7445 | */ |
| 7446 | public Intent putExtra(String name, double value) { |
| 7447 | if (mExtras == null) { |
| 7448 | mExtras = new Bundle(); |
| 7449 | } |
| 7450 | mExtras.putDouble(name, value); |
| 7451 | return this; |
| 7452 | } |
| 7453 | |
| 7454 | /** |
| 7455 | * Add extended data to the intent. The name must include a package |
| 7456 | * prefix, for example the app com.android.contacts would use names |
| 7457 | * like "com.android.contacts.ShowAll". |
| 7458 | * |
| 7459 | * @param name The name of the extra data, with package prefix. |
| 7460 | * @param value The String data value. |
| 7461 | * |
| 7462 | * @return Returns the same Intent object, for chaining multiple calls |
| 7463 | * into a single statement. |
| 7464 | * |
| 7465 | * @see #putExtras |
| 7466 | * @see #removeExtra |
| 7467 | * @see #getStringExtra(String) |
| 7468 | */ |
| 7469 | public Intent putExtra(String name, String value) { |
| 7470 | if (mExtras == null) { |
| 7471 | mExtras = new Bundle(); |
| 7472 | } |
| 7473 | mExtras.putString(name, value); |
| 7474 | return this; |
| 7475 | } |
| 7476 | |
| 7477 | /** |
| 7478 | * Add extended data to the intent. The name must include a package |
| 7479 | * prefix, for example the app com.android.contacts would use names |
| 7480 | * like "com.android.contacts.ShowAll". |
| 7481 | * |
| 7482 | * @param name The name of the extra data, with package prefix. |
| 7483 | * @param value The CharSequence data value. |
| 7484 | * |
| 7485 | * @return Returns the same Intent object, for chaining multiple calls |
| 7486 | * into a single statement. |
| 7487 | * |
| 7488 | * @see #putExtras |
| 7489 | * @see #removeExtra |
| 7490 | * @see #getCharSequenceExtra(String) |
| 7491 | */ |
| 7492 | public Intent putExtra(String name, CharSequence value) { |
| 7493 | if (mExtras == null) { |
| 7494 | mExtras = new Bundle(); |
| 7495 | } |
| 7496 | mExtras.putCharSequence(name, value); |
| 7497 | return this; |
| 7498 | } |
| 7499 | |
| 7500 | /** |
| 7501 | * Add extended data to the intent. The name must include a package |
| 7502 | * prefix, for example the app com.android.contacts would use names |
| 7503 | * like "com.android.contacts.ShowAll". |
| 7504 | * |
| 7505 | * @param name The name of the extra data, with package prefix. |
| 7506 | * @param value The Parcelable data value. |
| 7507 | * |
| 7508 | * @return Returns the same Intent object, for chaining multiple calls |
| 7509 | * into a single statement. |
| 7510 | * |
| 7511 | * @see #putExtras |
| 7512 | * @see #removeExtra |
| 7513 | * @see #getParcelableExtra(String) |
| 7514 | */ |
| 7515 | public Intent putExtra(String name, Parcelable value) { |
| 7516 | if (mExtras == null) { |
| 7517 | mExtras = new Bundle(); |
| 7518 | } |
| 7519 | mExtras.putParcelable(name, value); |
| 7520 | return this; |
| 7521 | } |
| 7522 | |
| 7523 | /** |
| 7524 | * Add extended data to the intent. The name must include a package |
| 7525 | * prefix, for example the app com.android.contacts would use names |
| 7526 | * like "com.android.contacts.ShowAll". |
| 7527 | * |
| 7528 | * @param name The name of the extra data, with package prefix. |
| 7529 | * @param value The Parcelable[] data value. |
| 7530 | * |
| 7531 | * @return Returns the same Intent object, for chaining multiple calls |
| 7532 | * into a single statement. |
| 7533 | * |
| 7534 | * @see #putExtras |
| 7535 | * @see #removeExtra |
| 7536 | * @see #getParcelableArrayExtra(String) |
| 7537 | */ |
| 7538 | public Intent putExtra(String name, Parcelable[] value) { |
| 7539 | if (mExtras == null) { |
| 7540 | mExtras = new Bundle(); |
| 7541 | } |
| 7542 | mExtras.putParcelableArray(name, value); |
| 7543 | return this; |
| 7544 | } |
| 7545 | |
| 7546 | /** |
| 7547 | * Add extended data to the intent. The name must include a package |
| 7548 | * prefix, for example the app com.android.contacts would use names |
| 7549 | * like "com.android.contacts.ShowAll". |
| 7550 | * |
| 7551 | * @param name The name of the extra data, with package prefix. |
| 7552 | * @param value The ArrayList<Parcelable> data value. |
| 7553 | * |
| 7554 | * @return Returns the same Intent object, for chaining multiple calls |
| 7555 | * into a single statement. |
| 7556 | * |
| 7557 | * @see #putExtras |
| 7558 | * @see #removeExtra |
| 7559 | * @see #getParcelableArrayListExtra(String) |
| 7560 | */ |
| 7561 | public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) { |
| 7562 | if (mExtras == null) { |
| 7563 | mExtras = new Bundle(); |
| 7564 | } |
| 7565 | mExtras.putParcelableArrayList(name, value); |
| 7566 | return this; |
| 7567 | } |
| 7568 | |
| 7569 | /** |
| 7570 | * Add extended data to the intent. The name must include a package |
| 7571 | * prefix, for example the app com.android.contacts would use names |
| 7572 | * like "com.android.contacts.ShowAll". |
| 7573 | * |
| 7574 | * @param name The name of the extra data, with package prefix. |
| 7575 | * @param value The ArrayList<Integer> data value. |
| 7576 | * |
| 7577 | * @return Returns the same Intent object, for chaining multiple calls |
| 7578 | * into a single statement. |
| 7579 | * |
| 7580 | * @see #putExtras |
| 7581 | * @see #removeExtra |
| 7582 | * @see #getIntegerArrayListExtra(String) |
| 7583 | */ |
| 7584 | public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) { |
| 7585 | if (mExtras == null) { |
| 7586 | mExtras = new Bundle(); |
| 7587 | } |
| 7588 | mExtras.putIntegerArrayList(name, value); |
| 7589 | return this; |
| 7590 | } |
| 7591 | |
| 7592 | /** |
| 7593 | * Add extended data to the intent. The name must include a package |
| 7594 | * prefix, for example the app com.android.contacts would use names |
| 7595 | * like "com.android.contacts.ShowAll". |
| 7596 | * |
| 7597 | * @param name The name of the extra data, with package prefix. |
| 7598 | * @param value The ArrayList<String> data value. |
| 7599 | * |
| 7600 | * @return Returns the same Intent object, for chaining multiple calls |
| 7601 | * into a single statement. |
| 7602 | * |
| 7603 | * @see #putExtras |
| 7604 | * @see #removeExtra |
| 7605 | * @see #getStringArrayListExtra(String) |
| 7606 | */ |
| 7607 | public Intent putStringArrayListExtra(String name, ArrayList<String> value) { |
| 7608 | if (mExtras == null) { |
| 7609 | mExtras = new Bundle(); |
| 7610 | } |
| 7611 | mExtras.putStringArrayList(name, value); |
| 7612 | return this; |
| 7613 | } |
| 7614 | |
| 7615 | /** |
| 7616 | * Add extended data to the intent. The name must include a package |
| 7617 | * prefix, for example the app com.android.contacts would use names |
| 7618 | * like "com.android.contacts.ShowAll". |
| 7619 | * |
| 7620 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 7621 | * @param value The ArrayList<CharSequence> data value. |
| 7622 | * |
| 7623 | * @return Returns the same Intent object, for chaining multiple calls |
| 7624 | * into a single statement. |
| 7625 | * |
| 7626 | * @see #putExtras |
| 7627 | * @see #removeExtra |
| 7628 | * @see #getCharSequenceArrayListExtra(String) |
| 7629 | */ |
| 7630 | public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) { |
| 7631 | if (mExtras == null) { |
| 7632 | mExtras = new Bundle(); |
| 7633 | } |
| 7634 | mExtras.putCharSequenceArrayList(name, value); |
| 7635 | return this; |
| 7636 | } |
| 7637 | |
| 7638 | /** |
| 7639 | * Add extended data to the intent. The name must include a package |
| 7640 | * prefix, for example the app com.android.contacts would use names |
| 7641 | * like "com.android.contacts.ShowAll". |
| 7642 | * |
| 7643 | * @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] | 7644 | * @param value The Serializable data value. |
| 7645 | * |
| 7646 | * @return Returns the same Intent object, for chaining multiple calls |
| 7647 | * into a single statement. |
| 7648 | * |
| 7649 | * @see #putExtras |
| 7650 | * @see #removeExtra |
| 7651 | * @see #getSerializableExtra(String) |
| 7652 | */ |
| 7653 | public Intent putExtra(String name, Serializable value) { |
| 7654 | if (mExtras == null) { |
| 7655 | mExtras = new Bundle(); |
| 7656 | } |
| 7657 | mExtras.putSerializable(name, value); |
| 7658 | return this; |
| 7659 | } |
| 7660 | |
| 7661 | /** |
| 7662 | * Add extended data to the intent. The name must include a package |
| 7663 | * prefix, for example the app com.android.contacts would use names |
| 7664 | * like "com.android.contacts.ShowAll". |
| 7665 | * |
| 7666 | * @param name The name of the extra data, with package prefix. |
| 7667 | * @param value The boolean array data value. |
| 7668 | * |
| 7669 | * @return Returns the same Intent object, for chaining multiple calls |
| 7670 | * into a single statement. |
| 7671 | * |
| 7672 | * @see #putExtras |
| 7673 | * @see #removeExtra |
| 7674 | * @see #getBooleanArrayExtra(String) |
| 7675 | */ |
| 7676 | public Intent putExtra(String name, boolean[] value) { |
| 7677 | if (mExtras == null) { |
| 7678 | mExtras = new Bundle(); |
| 7679 | } |
| 7680 | mExtras.putBooleanArray(name, value); |
| 7681 | return this; |
| 7682 | } |
| 7683 | |
| 7684 | /** |
| 7685 | * Add extended data to the intent. The name must include a package |
| 7686 | * prefix, for example the app com.android.contacts would use names |
| 7687 | * like "com.android.contacts.ShowAll". |
| 7688 | * |
| 7689 | * @param name The name of the extra data, with package prefix. |
| 7690 | * @param value The byte array data value. |
| 7691 | * |
| 7692 | * @return Returns the same Intent object, for chaining multiple calls |
| 7693 | * into a single statement. |
| 7694 | * |
| 7695 | * @see #putExtras |
| 7696 | * @see #removeExtra |
| 7697 | * @see #getByteArrayExtra(String) |
| 7698 | */ |
| 7699 | public Intent putExtra(String name, byte[] value) { |
| 7700 | if (mExtras == null) { |
| 7701 | mExtras = new Bundle(); |
| 7702 | } |
| 7703 | mExtras.putByteArray(name, value); |
| 7704 | return this; |
| 7705 | } |
| 7706 | |
| 7707 | /** |
| 7708 | * Add extended data to the intent. The name must include a package |
| 7709 | * prefix, for example the app com.android.contacts would use names |
| 7710 | * like "com.android.contacts.ShowAll". |
| 7711 | * |
| 7712 | * @param name The name of the extra data, with package prefix. |
| 7713 | * @param value The short array data value. |
| 7714 | * |
| 7715 | * @return Returns the same Intent object, for chaining multiple calls |
| 7716 | * into a single statement. |
| 7717 | * |
| 7718 | * @see #putExtras |
| 7719 | * @see #removeExtra |
| 7720 | * @see #getShortArrayExtra(String) |
| 7721 | */ |
| 7722 | public Intent putExtra(String name, short[] value) { |
| 7723 | if (mExtras == null) { |
| 7724 | mExtras = new Bundle(); |
| 7725 | } |
| 7726 | mExtras.putShortArray(name, value); |
| 7727 | return this; |
| 7728 | } |
| 7729 | |
| 7730 | /** |
| 7731 | * Add extended data to the intent. The name must include a package |
| 7732 | * prefix, for example the app com.android.contacts would use names |
| 7733 | * like "com.android.contacts.ShowAll". |
| 7734 | * |
| 7735 | * @param name The name of the extra data, with package prefix. |
| 7736 | * @param value The char array data value. |
| 7737 | * |
| 7738 | * @return Returns the same Intent object, for chaining multiple calls |
| 7739 | * into a single statement. |
| 7740 | * |
| 7741 | * @see #putExtras |
| 7742 | * @see #removeExtra |
| 7743 | * @see #getCharArrayExtra(String) |
| 7744 | */ |
| 7745 | public Intent putExtra(String name, char[] value) { |
| 7746 | if (mExtras == null) { |
| 7747 | mExtras = new Bundle(); |
| 7748 | } |
| 7749 | mExtras.putCharArray(name, value); |
| 7750 | return this; |
| 7751 | } |
| 7752 | |
| 7753 | /** |
| 7754 | * Add extended data to the intent. The name must include a package |
| 7755 | * prefix, for example the app com.android.contacts would use names |
| 7756 | * like "com.android.contacts.ShowAll". |
| 7757 | * |
| 7758 | * @param name The name of the extra data, with package prefix. |
| 7759 | * @param value The int array data value. |
| 7760 | * |
| 7761 | * @return Returns the same Intent object, for chaining multiple calls |
| 7762 | * into a single statement. |
| 7763 | * |
| 7764 | * @see #putExtras |
| 7765 | * @see #removeExtra |
| 7766 | * @see #getIntArrayExtra(String) |
| 7767 | */ |
| 7768 | public Intent putExtra(String name, int[] value) { |
| 7769 | if (mExtras == null) { |
| 7770 | mExtras = new Bundle(); |
| 7771 | } |
| 7772 | mExtras.putIntArray(name, value); |
| 7773 | return this; |
| 7774 | } |
| 7775 | |
| 7776 | /** |
| 7777 | * Add extended data to the intent. The name must include a package |
| 7778 | * prefix, for example the app com.android.contacts would use names |
| 7779 | * like "com.android.contacts.ShowAll". |
| 7780 | * |
| 7781 | * @param name The name of the extra data, with package prefix. |
| 7782 | * @param value The byte array data value. |
| 7783 | * |
| 7784 | * @return Returns the same Intent object, for chaining multiple calls |
| 7785 | * into a single statement. |
| 7786 | * |
| 7787 | * @see #putExtras |
| 7788 | * @see #removeExtra |
| 7789 | * @see #getLongArrayExtra(String) |
| 7790 | */ |
| 7791 | public Intent putExtra(String name, long[] value) { |
| 7792 | if (mExtras == null) { |
| 7793 | mExtras = new Bundle(); |
| 7794 | } |
| 7795 | mExtras.putLongArray(name, value); |
| 7796 | return this; |
| 7797 | } |
| 7798 | |
| 7799 | /** |
| 7800 | * Add extended data to the intent. The name must include a package |
| 7801 | * prefix, for example the app com.android.contacts would use names |
| 7802 | * like "com.android.contacts.ShowAll". |
| 7803 | * |
| 7804 | * @param name The name of the extra data, with package prefix. |
| 7805 | * @param value The float array data value. |
| 7806 | * |
| 7807 | * @return Returns the same Intent object, for chaining multiple calls |
| 7808 | * into a single statement. |
| 7809 | * |
| 7810 | * @see #putExtras |
| 7811 | * @see #removeExtra |
| 7812 | * @see #getFloatArrayExtra(String) |
| 7813 | */ |
| 7814 | public Intent putExtra(String name, float[] value) { |
| 7815 | if (mExtras == null) { |
| 7816 | mExtras = new Bundle(); |
| 7817 | } |
| 7818 | mExtras.putFloatArray(name, value); |
| 7819 | return this; |
| 7820 | } |
| 7821 | |
| 7822 | /** |
| 7823 | * Add extended data to the intent. The name must include a package |
| 7824 | * prefix, for example the app com.android.contacts would use names |
| 7825 | * like "com.android.contacts.ShowAll". |
| 7826 | * |
| 7827 | * @param name The name of the extra data, with package prefix. |
| 7828 | * @param value The double array data value. |
| 7829 | * |
| 7830 | * @return Returns the same Intent object, for chaining multiple calls |
| 7831 | * into a single statement. |
| 7832 | * |
| 7833 | * @see #putExtras |
| 7834 | * @see #removeExtra |
| 7835 | * @see #getDoubleArrayExtra(String) |
| 7836 | */ |
| 7837 | public Intent putExtra(String name, double[] value) { |
| 7838 | if (mExtras == null) { |
| 7839 | mExtras = new Bundle(); |
| 7840 | } |
| 7841 | mExtras.putDoubleArray(name, value); |
| 7842 | return this; |
| 7843 | } |
| 7844 | |
| 7845 | /** |
| 7846 | * Add extended data to the intent. The name must include a package |
| 7847 | * prefix, for example the app com.android.contacts would use names |
| 7848 | * like "com.android.contacts.ShowAll". |
| 7849 | * |
| 7850 | * @param name The name of the extra data, with package prefix. |
| 7851 | * @param value The String array data value. |
| 7852 | * |
| 7853 | * @return Returns the same Intent object, for chaining multiple calls |
| 7854 | * into a single statement. |
| 7855 | * |
| 7856 | * @see #putExtras |
| 7857 | * @see #removeExtra |
| 7858 | * @see #getStringArrayExtra(String) |
| 7859 | */ |
| 7860 | public Intent putExtra(String name, String[] value) { |
| 7861 | if (mExtras == null) { |
| 7862 | mExtras = new Bundle(); |
| 7863 | } |
| 7864 | mExtras.putStringArray(name, value); |
| 7865 | return this; |
| 7866 | } |
| 7867 | |
| 7868 | /** |
| 7869 | * Add extended data to the intent. The name must include a package |
| 7870 | * prefix, for example the app com.android.contacts would use names |
| 7871 | * like "com.android.contacts.ShowAll". |
| 7872 | * |
| 7873 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 7874 | * @param value The CharSequence array data value. |
| 7875 | * |
| 7876 | * @return Returns the same Intent object, for chaining multiple calls |
| 7877 | * into a single statement. |
| 7878 | * |
| 7879 | * @see #putExtras |
| 7880 | * @see #removeExtra |
| 7881 | * @see #getCharSequenceArrayExtra(String) |
| 7882 | */ |
| 7883 | public Intent putExtra(String name, CharSequence[] value) { |
| 7884 | if (mExtras == null) { |
| 7885 | mExtras = new Bundle(); |
| 7886 | } |
| 7887 | mExtras.putCharSequenceArray(name, value); |
| 7888 | return this; |
| 7889 | } |
| 7890 | |
| 7891 | /** |
| 7892 | * Add extended data to the intent. The name must include a package |
| 7893 | * prefix, for example the app com.android.contacts would use names |
| 7894 | * like "com.android.contacts.ShowAll". |
| 7895 | * |
| 7896 | * @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] | 7897 | * @param value The Bundle data value. |
| 7898 | * |
| 7899 | * @return Returns the same Intent object, for chaining multiple calls |
| 7900 | * into a single statement. |
| 7901 | * |
| 7902 | * @see #putExtras |
| 7903 | * @see #removeExtra |
| 7904 | * @see #getBundleExtra(String) |
| 7905 | */ |
| 7906 | public Intent putExtra(String name, Bundle value) { |
| 7907 | if (mExtras == null) { |
| 7908 | mExtras = new Bundle(); |
| 7909 | } |
| 7910 | mExtras.putBundle(name, value); |
| 7911 | return this; |
| 7912 | } |
| 7913 | |
| 7914 | /** |
| 7915 | * Add extended data to the intent. The name must include a package |
| 7916 | * prefix, for example the app com.android.contacts would use names |
| 7917 | * like "com.android.contacts.ShowAll". |
| 7918 | * |
| 7919 | * @param name The name of the extra data, with package prefix. |
| 7920 | * @param value The IBinder data value. |
| 7921 | * |
| 7922 | * @return Returns the same Intent object, for chaining multiple calls |
| 7923 | * into a single statement. |
| 7924 | * |
| 7925 | * @see #putExtras |
| 7926 | * @see #removeExtra |
| 7927 | * @see #getIBinderExtra(String) |
| 7928 | * |
| 7929 | * @deprecated |
| 7930 | * @hide |
| 7931 | */ |
| 7932 | @Deprecated |
| 7933 | public Intent putExtra(String name, IBinder value) { |
| 7934 | if (mExtras == null) { |
| 7935 | mExtras = new Bundle(); |
| 7936 | } |
| 7937 | mExtras.putIBinder(name, value); |
| 7938 | return this; |
| 7939 | } |
| 7940 | |
| 7941 | /** |
| 7942 | * Copy all extras in 'src' in to this intent. |
| 7943 | * |
| 7944 | * @param src Contains the extras to copy. |
| 7945 | * |
| 7946 | * @see #putExtra |
| 7947 | */ |
| 7948 | public Intent putExtras(Intent src) { |
| 7949 | if (src.mExtras != null) { |
| 7950 | if (mExtras == null) { |
| 7951 | mExtras = new Bundle(src.mExtras); |
| 7952 | } else { |
| 7953 | mExtras.putAll(src.mExtras); |
| 7954 | } |
| 7955 | } |
| 7956 | return this; |
| 7957 | } |
| 7958 | |
| 7959 | /** |
| 7960 | * Add a set of extended data to the intent. The keys must include a package |
| 7961 | * prefix, for example the app com.android.contacts would use names |
| 7962 | * like "com.android.contacts.ShowAll". |
| 7963 | * |
| 7964 | * @param extras The Bundle of extras to add to this intent. |
| 7965 | * |
| 7966 | * @see #putExtra |
| 7967 | * @see #removeExtra |
| 7968 | */ |
| 7969 | public Intent putExtras(Bundle extras) { |
| 7970 | if (mExtras == null) { |
| 7971 | mExtras = new Bundle(); |
| 7972 | } |
| 7973 | mExtras.putAll(extras); |
| 7974 | return this; |
| 7975 | } |
| 7976 | |
| 7977 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7978 | * Completely replace the extras in the Intent with the extras in the |
| 7979 | * given Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 7980 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7981 | * @param src The exact extras contained in this Intent are copied |
| 7982 | * into the target intent, replacing any that were previously there. |
| 7983 | */ |
| 7984 | public Intent replaceExtras(Intent src) { |
| 7985 | mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; |
| 7986 | return this; |
| 7987 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 7988 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7989 | /** |
| 7990 | * Completely replace the extras in the Intent with the given Bundle of |
| 7991 | * extras. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 7992 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7993 | * @param extras The new set of extras in the Intent, or null to erase |
| 7994 | * all extras. |
| 7995 | */ |
| 7996 | public Intent replaceExtras(Bundle extras) { |
| 7997 | mExtras = extras != null ? new Bundle(extras) : null; |
| 7998 | return this; |
| 7999 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8000 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8001 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8002 | * Remove extended data from the intent. |
| 8003 | * |
| 8004 | * @see #putExtra |
| 8005 | */ |
| 8006 | public void removeExtra(String name) { |
| 8007 | if (mExtras != null) { |
| 8008 | mExtras.remove(name); |
| 8009 | if (mExtras.size() == 0) { |
| 8010 | mExtras = null; |
| 8011 | } |
| 8012 | } |
| 8013 | } |
| 8014 | |
| 8015 | /** |
| 8016 | * Set special flags controlling how this intent is handled. Most values |
| 8017 | * here depend on the type of component being executed by the Intent, |
| 8018 | * specifically the FLAG_ACTIVITY_* flags are all for use with |
| 8019 | * {@link Context#startActivity Context.startActivity()} and the |
| 8020 | * FLAG_RECEIVER_* flags are all for use with |
| 8021 | * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. |
| 8022 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 8023 | * <p>See the |
| 8024 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 8025 | * 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] | 8026 | * the behavior of your application. |
| 8027 | * |
| 8028 | * @param flags The desired flags. |
| 8029 | * |
| 8030 | * @return Returns the same Intent object, for chaining multiple calls |
| 8031 | * into a single statement. |
| 8032 | * |
| 8033 | * @see #getFlags |
| 8034 | * @see #addFlags |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8035 | * @see #removeFlags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8036 | * |
| 8037 | * @see #FLAG_GRANT_READ_URI_PERMISSION |
| 8038 | * @see #FLAG_GRANT_WRITE_URI_PERMISSION |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 8039 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 8040 | * @see #FLAG_GRANT_PREFIX_URI_PERMISSION |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8041 | * @see #FLAG_DEBUG_LOG_RESOLUTION |
| 8042 | * @see #FLAG_FROM_BACKGROUND |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8043 | * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8044 | * @see #FLAG_ACTIVITY_CLEAR_TASK |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8045 | * @see #FLAG_ACTIVITY_CLEAR_TOP |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8046 | * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8047 | * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS |
| 8048 | * @see #FLAG_ACTIVITY_FORWARD_RESULT |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8049 | * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8050 | * @see #FLAG_ACTIVITY_MULTIPLE_TASK |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 8051 | * @see #FLAG_ACTIVITY_NEW_DOCUMENT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8052 | * @see #FLAG_ACTIVITY_NEW_TASK |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8053 | * @see #FLAG_ACTIVITY_NO_ANIMATION |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8054 | * @see #FLAG_ACTIVITY_NO_HISTORY |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 8055 | * @see #FLAG_ACTIVITY_NO_USER_ACTION |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8056 | * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP |
| 8057 | * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8058 | * @see #FLAG_ACTIVITY_REORDER_TO_FRONT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8059 | * @see #FLAG_ACTIVITY_SINGLE_TOP |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8060 | * @see #FLAG_ACTIVITY_TASK_ON_HOME |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8061 | * @see #FLAG_RECEIVER_REGISTERED_ONLY |
| 8062 | */ |
| 8063 | public Intent setFlags(int flags) { |
| 8064 | mFlags = flags; |
| 8065 | return this; |
| 8066 | } |
| 8067 | |
| 8068 | /** |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8069 | * 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] | 8070 | * |
| 8071 | * @param flags The new flags to set. |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8072 | * @return Returns the same Intent object, for chaining multiple calls into |
| 8073 | * a single statement. |
| 8074 | * @see #setFlags(int) |
| 8075 | * @see #removeFlags(int) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8076 | */ |
| 8077 | public Intent addFlags(int flags) { |
| 8078 | mFlags |= flags; |
| 8079 | return this; |
| 8080 | } |
| 8081 | |
| 8082 | /** |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8083 | * Remove these flags from the intent. |
| 8084 | * |
| 8085 | * @param flags The flags to remove. |
| 8086 | * @see #setFlags(int) |
| 8087 | * @see #addFlags(int) |
| 8088 | */ |
| 8089 | public void removeFlags(int flags) { |
| 8090 | mFlags &= ~flags; |
| 8091 | } |
| 8092 | |
| 8093 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8094 | * (Usually optional) Set an explicit application package name that limits |
| 8095 | * the components this Intent will resolve to. If left to the default |
| 8096 | * value of null, all components in all applications will considered. |
| 8097 | * If non-null, the Intent can only match the components in the given |
| 8098 | * application package. |
| 8099 | * |
| 8100 | * @param packageName The name of the application package to handle the |
| 8101 | * intent, or null to allow any application package. |
| 8102 | * |
| 8103 | * @return Returns the same Intent object, for chaining multiple calls |
| 8104 | * into a single statement. |
| 8105 | * |
| 8106 | * @see #getPackage |
| 8107 | * @see #resolveActivity |
| 8108 | */ |
| 8109 | public Intent setPackage(String packageName) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8110 | if (packageName != null && mSelector != null) { |
| 8111 | throw new IllegalArgumentException( |
| 8112 | "Can't set package name when selector is already set"); |
| 8113 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8114 | mPackage = packageName; |
| 8115 | return this; |
| 8116 | } |
| 8117 | |
| 8118 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8119 | * (Usually optional) Explicitly set the component to handle the intent. |
| 8120 | * If left with the default value of null, the system will determine the |
| 8121 | * appropriate class to use based on the other fields (action, data, |
| 8122 | * type, categories) in the Intent. If this class is defined, the |
| 8123 | * specified class will always be used regardless of the other fields. You |
| 8124 | * should only set this value when you know you absolutely want a specific |
| 8125 | * class to be used; otherwise it is better to let the system find the |
| 8126 | * appropriate class so that you will respect the installed applications |
| 8127 | * and user preferences. |
| 8128 | * |
| 8129 | * @param component The name of the application component to handle the |
| 8130 | * intent, or null to let the system find one for you. |
| 8131 | * |
| 8132 | * @return Returns the same Intent object, for chaining multiple calls |
| 8133 | * into a single statement. |
| 8134 | * |
| 8135 | * @see #setClass |
| 8136 | * @see #setClassName(Context, String) |
| 8137 | * @see #setClassName(String, String) |
| 8138 | * @see #getComponent |
| 8139 | * @see #resolveActivity |
| 8140 | */ |
| 8141 | public Intent setComponent(ComponentName component) { |
| 8142 | mComponent = component; |
| 8143 | return this; |
| 8144 | } |
| 8145 | |
| 8146 | /** |
| 8147 | * Convenience for calling {@link #setComponent} with an |
| 8148 | * explicit class name. |
| 8149 | * |
| 8150 | * @param packageContext A Context of the application package implementing |
| 8151 | * this class. |
| 8152 | * @param className The name of a class inside of the application package |
| 8153 | * that will be used as the component for this Intent. |
| 8154 | * |
| 8155 | * @return Returns the same Intent object, for chaining multiple calls |
| 8156 | * into a single statement. |
| 8157 | * |
| 8158 | * @see #setComponent |
| 8159 | * @see #setClass |
| 8160 | */ |
| 8161 | public Intent setClassName(Context packageContext, String className) { |
| 8162 | mComponent = new ComponentName(packageContext, className); |
| 8163 | return this; |
| 8164 | } |
| 8165 | |
| 8166 | /** |
| 8167 | * Convenience for calling {@link #setComponent} with an |
| 8168 | * explicit application package name and class name. |
| 8169 | * |
| 8170 | * @param packageName The name of the package implementing the desired |
| 8171 | * component. |
| 8172 | * @param className The name of a class inside of the application package |
| 8173 | * that will be used as the component for this Intent. |
| 8174 | * |
| 8175 | * @return Returns the same Intent object, for chaining multiple calls |
| 8176 | * into a single statement. |
| 8177 | * |
| 8178 | * @see #setComponent |
| 8179 | * @see #setClass |
| 8180 | */ |
| 8181 | public Intent setClassName(String packageName, String className) { |
| 8182 | mComponent = new ComponentName(packageName, className); |
| 8183 | return this; |
| 8184 | } |
| 8185 | |
| 8186 | /** |
| 8187 | * Convenience for calling {@link #setComponent(ComponentName)} with the |
| 8188 | * name returned by a {@link Class} object. |
| 8189 | * |
| 8190 | * @param packageContext A Context of the application package implementing |
| 8191 | * this class. |
| 8192 | * @param cls The class name to set, equivalent to |
| 8193 | * <code>setClassName(context, cls.getName())</code>. |
| 8194 | * |
| 8195 | * @return Returns the same Intent object, for chaining multiple calls |
| 8196 | * into a single statement. |
| 8197 | * |
| 8198 | * @see #setComponent |
| 8199 | */ |
| 8200 | public Intent setClass(Context packageContext, Class<?> cls) { |
| 8201 | mComponent = new ComponentName(packageContext, cls); |
| 8202 | return this; |
| 8203 | } |
| 8204 | |
| 8205 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8206 | * Set the bounds of the sender of this intent, in screen coordinates. This can be |
| 8207 | * used as a hint to the receiver for animations and the like. Null means that there |
| 8208 | * is no source bounds. |
| 8209 | */ |
| 8210 | public void setSourceBounds(Rect r) { |
| 8211 | if (r != null) { |
| 8212 | mSourceBounds = new Rect(r); |
| 8213 | } else { |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 8214 | mSourceBounds = null; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8215 | } |
| 8216 | } |
| 8217 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8218 | /** @hide */ |
| 8219 | @IntDef(flag = true, |
| 8220 | value = { |
| 8221 | FILL_IN_ACTION, |
| 8222 | FILL_IN_DATA, |
| 8223 | FILL_IN_CATEGORIES, |
| 8224 | FILL_IN_COMPONENT, |
| 8225 | FILL_IN_PACKAGE, |
| 8226 | FILL_IN_SOURCE_BOUNDS, |
| 8227 | FILL_IN_SELECTOR, |
| 8228 | FILL_IN_CLIP_DATA |
| 8229 | }) |
| 8230 | @Retention(RetentionPolicy.SOURCE) |
| 8231 | public @interface FillInFlags {} |
| 8232 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8233 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8234 | * Use with {@link #fillIn} to allow the current action value to be |
| 8235 | * overwritten, even if it is already set. |
| 8236 | */ |
| 8237 | public static final int FILL_IN_ACTION = 1<<0; |
| 8238 | |
| 8239 | /** |
| 8240 | * Use with {@link #fillIn} to allow the current data or type value |
| 8241 | * overwritten, even if it is already set. |
| 8242 | */ |
| 8243 | public static final int FILL_IN_DATA = 1<<1; |
| 8244 | |
| 8245 | /** |
| 8246 | * Use with {@link #fillIn} to allow the current categories to be |
| 8247 | * overwritten, even if they are already set. |
| 8248 | */ |
| 8249 | public static final int FILL_IN_CATEGORIES = 1<<2; |
| 8250 | |
| 8251 | /** |
| 8252 | * Use with {@link #fillIn} to allow the current component value to be |
| 8253 | * overwritten, even if it is already set. |
| 8254 | */ |
| 8255 | public static final int FILL_IN_COMPONENT = 1<<3; |
| 8256 | |
| 8257 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8258 | * Use with {@link #fillIn} to allow the current package value to be |
| 8259 | * overwritten, even if it is already set. |
| 8260 | */ |
| 8261 | public static final int FILL_IN_PACKAGE = 1<<4; |
| 8262 | |
| 8263 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8264 | * Use with {@link #fillIn} to allow the current bounds rectangle to be |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8265 | * overwritten, even if it is already set. |
| 8266 | */ |
| 8267 | public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; |
| 8268 | |
| 8269 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8270 | * Use with {@link #fillIn} to allow the current selector to be |
| 8271 | * overwritten, even if it is already set. |
| 8272 | */ |
| 8273 | public static final int FILL_IN_SELECTOR = 1<<6; |
| 8274 | |
| 8275 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8276 | * Use with {@link #fillIn} to allow the current ClipData to be |
| 8277 | * overwritten, even if it is already set. |
| 8278 | */ |
| 8279 | public static final int FILL_IN_CLIP_DATA = 1<<7; |
| 8280 | |
| 8281 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8282 | * Copy the contents of <var>other</var> in to this object, but only |
| 8283 | * where fields are not defined by this object. For purposes of a field |
| 8284 | * being defined, the following pieces of data in the Intent are |
| 8285 | * considered to be separate fields: |
| 8286 | * |
| 8287 | * <ul> |
| 8288 | * <li> action, as set by {@link #setAction}. |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 8289 | * <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] | 8290 | * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. |
| 8291 | * <li> categories, as set by {@link #addCategory}. |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8292 | * <li> package, as set by {@link #setPackage}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8293 | * <li> component, as set by {@link #setComponent(ComponentName)} or |
| 8294 | * related methods. |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8295 | * <li> source bounds, as set by {@link #setSourceBounds}. |
| 8296 | * <li> selector, as set by {@link #setSelector(Intent)}. |
| 8297 | * <li> clip data, as set by {@link #setClipData(ClipData)}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8298 | * <li> each top-level name in the associated extras. |
| 8299 | * </ul> |
| 8300 | * |
| 8301 | * <p>In addition, you can use the {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8302 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8303 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
| 8304 | * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override |
| 8305 | * the restriction where the corresponding field will not be replaced if |
| 8306 | * it is already set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8307 | * |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8308 | * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} |
| 8309 | * is explicitly specified. The selector will only be copied if |
| 8310 | * {@link #FILL_IN_SELECTOR} is explicitly specified. |
Brett Chabot | 3e39175 | 2009-07-21 16:07:23 -0700 | [diff] [blame] | 8311 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8312 | * <p>For example, consider Intent A with {data="foo", categories="bar"} |
| 8313 | * and Intent B with {action="gotit", data-type="some/thing", |
| 8314 | * categories="one","two"}. |
| 8315 | * |
| 8316 | * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now |
| 8317 | * containing: {action="gotit", data-type="some/thing", |
| 8318 | * categories="bar"}. |
| 8319 | * |
| 8320 | * @param other Another Intent whose values are to be used to fill in |
| 8321 | * the current one. |
| 8322 | * @param flags Options to control which fields can be filled in. |
| 8323 | * |
| 8324 | * @return Returns a bit mask of {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8325 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8326 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
| 8327 | * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were |
| 8328 | * changed. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8329 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8330 | @FillInFlags |
| 8331 | public int fillIn(Intent other, @FillInFlags int flags) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8332 | int changes = 0; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8333 | boolean mayHaveCopiedUris = false; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8334 | if (other.mAction != null |
| 8335 | && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8336 | mAction = other.mAction; |
| 8337 | changes |= FILL_IN_ACTION; |
| 8338 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8339 | if ((other.mData != null || other.mType != null) |
| 8340 | && ((mData == null && mType == null) |
| 8341 | || (flags&FILL_IN_DATA) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8342 | mData = other.mData; |
| 8343 | mType = other.mType; |
| 8344 | changes |= FILL_IN_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8345 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8346 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8347 | if (other.mCategories != null |
| 8348 | && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8349 | if (other.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8350 | mCategories = new ArraySet<String>(other.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8351 | } |
| 8352 | changes |= FILL_IN_CATEGORIES; |
| 8353 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8354 | if (other.mPackage != null |
| 8355 | && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8356 | // Only do this if mSelector is not set. |
| 8357 | if (mSelector == null) { |
| 8358 | mPackage = other.mPackage; |
| 8359 | changes |= FILL_IN_PACKAGE; |
| 8360 | } |
| 8361 | } |
| 8362 | // Selector is special: it can only be set if explicitly allowed, |
| 8363 | // for the same reason as the component name. |
| 8364 | if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { |
| 8365 | if (mPackage == null) { |
| 8366 | mSelector = new Intent(other.mSelector); |
| 8367 | mPackage = null; |
| 8368 | changes |= FILL_IN_SELECTOR; |
| 8369 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8370 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8371 | if (other.mClipData != null |
| 8372 | && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { |
| 8373 | mClipData = other.mClipData; |
| 8374 | changes |= FILL_IN_CLIP_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8375 | mayHaveCopiedUris = true; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8376 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8377 | // Component is special: it can -only- be set if explicitly allowed, |
| 8378 | // since otherwise the sender could force the intent somewhere the |
| 8379 | // originator didn't intend. |
| 8380 | if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8381 | mComponent = other.mComponent; |
| 8382 | changes |= FILL_IN_COMPONENT; |
| 8383 | } |
| 8384 | mFlags |= other.mFlags; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8385 | if (other.mSourceBounds != null |
| 8386 | && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { |
| 8387 | mSourceBounds = new Rect(other.mSourceBounds); |
| 8388 | changes |= FILL_IN_SOURCE_BOUNDS; |
| 8389 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8390 | if (mExtras == null) { |
| 8391 | if (other.mExtras != null) { |
| 8392 | mExtras = new Bundle(other.mExtras); |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8393 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8394 | } |
| 8395 | } else if (other.mExtras != null) { |
| 8396 | try { |
| 8397 | Bundle newb = new Bundle(other.mExtras); |
| 8398 | newb.putAll(mExtras); |
| 8399 | mExtras = newb; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8400 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8401 | } catch (RuntimeException e) { |
| 8402 | // Modifying the extras can cause us to unparcel the contents |
| 8403 | // of the bundle, and if we do this in the system process that |
| 8404 | // may fail. We really should handle this (i.e., the Bundle |
| 8405 | // impl shouldn't be on top of a plain map), but for now just |
| 8406 | // ignore it and keep the original contents. :( |
| 8407 | Log.w("Intent", "Failure filling in extras", e); |
| 8408 | } |
| 8409 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8410 | if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT |
| 8411 | && other.mContentUserHint != UserHandle.USER_CURRENT) { |
| 8412 | mContentUserHint = other.mContentUserHint; |
| 8413 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8414 | return changes; |
| 8415 | } |
| 8416 | |
| 8417 | /** |
| 8418 | * Wrapper class holding an Intent and implementing comparisons on it for |
| 8419 | * the purpose of filtering. The class implements its |
| 8420 | * {@link #equals equals()} and {@link #hashCode hashCode()} methods as |
| 8421 | * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and |
| 8422 | * {@link android.content.Intent#filterHashCode()} filterHashCode()} |
| 8423 | * on the wrapped Intent. |
| 8424 | */ |
| 8425 | public static final class FilterComparison { |
| 8426 | private final Intent mIntent; |
| 8427 | private final int mHashCode; |
| 8428 | |
| 8429 | public FilterComparison(Intent intent) { |
| 8430 | mIntent = intent; |
| 8431 | mHashCode = intent.filterHashCode(); |
| 8432 | } |
| 8433 | |
| 8434 | /** |
| 8435 | * Return the Intent that this FilterComparison represents. |
| 8436 | * @return Returns the Intent held by the FilterComparison. Do |
| 8437 | * not modify! |
| 8438 | */ |
| 8439 | public Intent getIntent() { |
| 8440 | return mIntent; |
| 8441 | } |
| 8442 | |
| 8443 | @Override |
| 8444 | public boolean equals(Object obj) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 8445 | if (obj instanceof FilterComparison) { |
| 8446 | Intent other = ((FilterComparison)obj).mIntent; |
| 8447 | return mIntent.filterEquals(other); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8448 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 8449 | return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8450 | } |
| 8451 | |
| 8452 | @Override |
| 8453 | public int hashCode() { |
| 8454 | return mHashCode; |
| 8455 | } |
| 8456 | } |
| 8457 | |
| 8458 | /** |
| 8459 | * Determine if two intents are the same for the purposes of intent |
| 8460 | * resolution (filtering). That is, if their action, data, type, |
| 8461 | * class, and categories are the same. This does <em>not</em> compare |
| 8462 | * any extra data included in the intents. |
| 8463 | * |
| 8464 | * @param other The other Intent to compare against. |
| 8465 | * |
| 8466 | * @return Returns true if action, data, type, class, and categories |
| 8467 | * are the same. |
| 8468 | */ |
| 8469 | public boolean filterEquals(Intent other) { |
| 8470 | if (other == null) { |
| 8471 | return false; |
| 8472 | } |
Christopher Tate | 63d9ae1 | 2014-06-19 19:07:26 -0700 | [diff] [blame] | 8473 | if (!Objects.equals(this.mAction, other.mAction)) return false; |
| 8474 | if (!Objects.equals(this.mData, other.mData)) return false; |
| 8475 | if (!Objects.equals(this.mType, other.mType)) return false; |
| 8476 | if (!Objects.equals(this.mPackage, other.mPackage)) return false; |
| 8477 | if (!Objects.equals(this.mComponent, other.mComponent)) return false; |
| 8478 | if (!Objects.equals(this.mCategories, other.mCategories)) return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8479 | |
| 8480 | return true; |
| 8481 | } |
| 8482 | |
| 8483 | /** |
| 8484 | * Generate hash code that matches semantics of filterEquals(). |
| 8485 | * |
| 8486 | * @return Returns the hash value of the action, data, type, class, and |
| 8487 | * categories. |
| 8488 | * |
| 8489 | * @see #filterEquals |
| 8490 | */ |
| 8491 | public int filterHashCode() { |
| 8492 | int code = 0; |
| 8493 | if (mAction != null) { |
| 8494 | code += mAction.hashCode(); |
| 8495 | } |
| 8496 | if (mData != null) { |
| 8497 | code += mData.hashCode(); |
| 8498 | } |
| 8499 | if (mType != null) { |
| 8500 | code += mType.hashCode(); |
| 8501 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8502 | if (mPackage != null) { |
| 8503 | code += mPackage.hashCode(); |
| 8504 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8505 | if (mComponent != null) { |
| 8506 | code += mComponent.hashCode(); |
| 8507 | } |
| 8508 | if (mCategories != null) { |
| 8509 | code += mCategories.hashCode(); |
| 8510 | } |
| 8511 | return code; |
| 8512 | } |
| 8513 | |
| 8514 | @Override |
| 8515 | public String toString() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8516 | StringBuilder b = new StringBuilder(128); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8517 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8518 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8519 | toShortString(b, true, true, true, false); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8520 | b.append(" }"); |
| 8521 | |
| 8522 | return b.toString(); |
| 8523 | } |
| 8524 | |
| 8525 | /** @hide */ |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8526 | public String toInsecureString() { |
| 8527 | StringBuilder b = new StringBuilder(128); |
| 8528 | |
| 8529 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8530 | toShortString(b, false, true, true, false); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8531 | b.append(" }"); |
| 8532 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8533 | return b.toString(); |
| 8534 | } |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 8535 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8536 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8537 | public String toInsecureStringWithClip() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8538 | StringBuilder b = new StringBuilder(128); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8539 | |
| 8540 | b.append("Intent { "); |
| 8541 | toShortString(b, false, true, true, true); |
| 8542 | b.append(" }"); |
| 8543 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8544 | return b.toString(); |
| 8545 | } |
| 8546 | |
| 8547 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8548 | public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { |
| 8549 | StringBuilder b = new StringBuilder(128); |
| 8550 | toShortString(b, secure, comp, extras, clip); |
| 8551 | return b.toString(); |
| 8552 | } |
| 8553 | |
| 8554 | /** @hide */ |
| 8555 | public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, |
| 8556 | boolean clip) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8557 | boolean first = true; |
| 8558 | if (mAction != null) { |
| 8559 | b.append("act=").append(mAction); |
| 8560 | first = false; |
| 8561 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8562 | if (mCategories != null) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8563 | if (!first) { |
| 8564 | b.append(' '); |
| 8565 | } |
| 8566 | first = false; |
| 8567 | b.append("cat=["); |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8568 | for (int i=0; i<mCategories.size(); i++) { |
| 8569 | if (i > 0) b.append(','); |
| 8570 | b.append(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8571 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8572 | b.append("]"); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8573 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8574 | if (mData != null) { |
| 8575 | if (!first) { |
| 8576 | b.append(' '); |
| 8577 | } |
| 8578 | first = false; |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 8579 | b.append("dat="); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8580 | if (secure) { |
| 8581 | b.append(mData.toSafeString()); |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 8582 | } else { |
| 8583 | b.append(mData); |
| 8584 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8585 | } |
| 8586 | if (mType != null) { |
| 8587 | if (!first) { |
| 8588 | b.append(' '); |
| 8589 | } |
| 8590 | first = false; |
| 8591 | b.append("typ=").append(mType); |
| 8592 | } |
| 8593 | if (mFlags != 0) { |
| 8594 | if (!first) { |
| 8595 | b.append(' '); |
| 8596 | } |
| 8597 | first = false; |
| 8598 | b.append("flg=0x").append(Integer.toHexString(mFlags)); |
| 8599 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8600 | if (mPackage != null) { |
| 8601 | if (!first) { |
| 8602 | b.append(' '); |
| 8603 | } |
| 8604 | first = false; |
| 8605 | b.append("pkg=").append(mPackage); |
| 8606 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8607 | if (comp && mComponent != null) { |
| 8608 | if (!first) { |
| 8609 | b.append(' '); |
| 8610 | } |
| 8611 | first = false; |
| 8612 | b.append("cmp=").append(mComponent.flattenToShortString()); |
| 8613 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8614 | if (mSourceBounds != null) { |
| 8615 | if (!first) { |
| 8616 | b.append(' '); |
| 8617 | } |
| 8618 | first = false; |
| 8619 | b.append("bnds=").append(mSourceBounds.toShortString()); |
| 8620 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8621 | if (mClipData != null) { |
| 8622 | if (!first) { |
| 8623 | b.append(' '); |
| 8624 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 8625 | b.append("clip={"); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8626 | if (clip) { |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8627 | mClipData.toShortString(b); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8628 | } else { |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 8629 | if (mClipData.getDescription() != null) { |
| 8630 | first = !mClipData.getDescription().toShortStringTypesOnly(b); |
| 8631 | } else { |
| 8632 | first = true; |
| 8633 | } |
| 8634 | mClipData.toShortStringShortItems(b, first); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8635 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 8636 | first = false; |
| 8637 | b.append('}'); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8638 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8639 | if (extras && mExtras != null) { |
| 8640 | if (!first) { |
| 8641 | b.append(' '); |
| 8642 | } |
| 8643 | first = false; |
| 8644 | b.append("(has extras)"); |
| 8645 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8646 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
| 8647 | if (!first) { |
| 8648 | b.append(' '); |
| 8649 | } |
| 8650 | first = false; |
| 8651 | b.append("u=").append(mContentUserHint); |
| 8652 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8653 | if (mSelector != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8654 | b.append(" sel="); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8655 | mSelector.toShortString(b, secure, comp, extras, clip); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8656 | b.append("}"); |
| 8657 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8658 | } |
| 8659 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8660 | /** |
| 8661 | * Call {@link #toUri} with 0 flags. |
| 8662 | * @deprecated Use {@link #toUri} instead. |
| 8663 | */ |
| 8664 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8665 | public String toURI() { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8666 | return toUri(0); |
| 8667 | } |
| 8668 | |
| 8669 | /** |
| 8670 | * Convert this Intent into a String holding a URI representation of it. |
| 8671 | * The returned URI string has been properly URI encoded, so it can be |
| 8672 | * used with {@link Uri#parse Uri.parse(String)}. The URI contains the |
| 8673 | * Intent's data as the base URI, with an additional fragment describing |
| 8674 | * the action, categories, type, flags, package, component, and extras. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8675 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8676 | * <p>You can convert the returned string back to an Intent with |
| 8677 | * {@link #getIntent}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8678 | * |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8679 | * @param flags Additional operating flags. Either 0, |
| 8680 | * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8681 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8682 | * @return Returns a URI encoding URI string describing the entire contents |
| 8683 | * of the Intent. |
| 8684 | */ |
| 8685 | public String toUri(int flags) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8686 | StringBuilder uri = new StringBuilder(128); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8687 | if ((flags&URI_ANDROID_APP_SCHEME) != 0) { |
| 8688 | if (mPackage == null) { |
| 8689 | throw new IllegalArgumentException( |
| 8690 | "Intent must include an explicit package name to build an android-app: " |
| 8691 | + this); |
| 8692 | } |
| 8693 | uri.append("android-app://"); |
| 8694 | uri.append(mPackage); |
| 8695 | String scheme = null; |
| 8696 | if (mData != null) { |
| 8697 | scheme = mData.getScheme(); |
| 8698 | if (scheme != null) { |
| 8699 | uri.append('/'); |
| 8700 | uri.append(scheme); |
| 8701 | String authority = mData.getEncodedAuthority(); |
| 8702 | if (authority != null) { |
| 8703 | uri.append('/'); |
| 8704 | uri.append(authority); |
| 8705 | String path = mData.getEncodedPath(); |
| 8706 | if (path != null) { |
| 8707 | uri.append(path); |
| 8708 | } |
| 8709 | String queryParams = mData.getEncodedQuery(); |
| 8710 | if (queryParams != null) { |
| 8711 | uri.append('?'); |
| 8712 | uri.append(queryParams); |
| 8713 | } |
| 8714 | String fragment = mData.getEncodedFragment(); |
| 8715 | if (fragment != null) { |
| 8716 | uri.append('#'); |
| 8717 | uri.append(fragment); |
| 8718 | } |
| 8719 | } |
| 8720 | } |
| 8721 | } |
| 8722 | toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, |
| 8723 | mPackage, flags); |
| 8724 | return uri.toString(); |
| 8725 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8726 | String scheme = null; |
| 8727 | if (mData != null) { |
| 8728 | String data = mData.toString(); |
| 8729 | if ((flags&URI_INTENT_SCHEME) != 0) { |
| 8730 | final int N = data.length(); |
| 8731 | for (int i=0; i<N; i++) { |
| 8732 | char c = data.charAt(i); |
| 8733 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') |
| 8734 | || c == '.' || c == '-') { |
| 8735 | continue; |
| 8736 | } |
| 8737 | if (c == ':' && i > 0) { |
| 8738 | // Valid scheme. |
| 8739 | scheme = data.substring(0, i); |
| 8740 | uri.append("intent:"); |
| 8741 | data = data.substring(i+1); |
| 8742 | break; |
| 8743 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8744 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8745 | // No scheme. |
| 8746 | break; |
| 8747 | } |
| 8748 | } |
| 8749 | uri.append(data); |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8750 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8751 | } else if ((flags&URI_INTENT_SCHEME) != 0) { |
| 8752 | uri.append("intent:"); |
| 8753 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8754 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8755 | toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8756 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8757 | return uri.toString(); |
| 8758 | } |
| 8759 | |
| 8760 | private void toUriFragment(StringBuilder uri, String scheme, String defAction, |
| 8761 | String defPackage, int flags) { |
| 8762 | StringBuilder frag = new StringBuilder(128); |
| 8763 | |
| 8764 | toUriInner(frag, scheme, defAction, defPackage, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8765 | if (mSelector != null) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 8766 | frag.append("SEL;"); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8767 | // Note that for now we are not going to try to handle the |
| 8768 | // data part; not clear how to represent this as a URI, and |
| 8769 | // not much utility in it. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8770 | mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, |
| 8771 | null, null, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8772 | } |
| 8773 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8774 | if (frag.length() > 0) { |
| 8775 | uri.append("#Intent;"); |
| 8776 | uri.append(frag); |
| 8777 | uri.append("end"); |
| 8778 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8779 | } |
| 8780 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8781 | private void toUriInner(StringBuilder uri, String scheme, String defAction, |
| 8782 | String defPackage, int flags) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8783 | if (scheme != null) { |
| 8784 | uri.append("scheme=").append(scheme).append(';'); |
| 8785 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8786 | if (mAction != null && !mAction.equals(defAction)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8787 | uri.append("action=").append(Uri.encode(mAction)).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8788 | } |
| 8789 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8790 | for (int i=0; i<mCategories.size(); i++) { |
| 8791 | 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] | 8792 | } |
| 8793 | } |
| 8794 | if (mType != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8795 | uri.append("type=").append(Uri.encode(mType, "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8796 | } |
| 8797 | if (mFlags != 0) { |
| 8798 | uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); |
| 8799 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8800 | if (mPackage != null && !mPackage.equals(defPackage)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8801 | uri.append("package=").append(Uri.encode(mPackage)).append(';'); |
| 8802 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8803 | if (mComponent != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8804 | uri.append("component=").append(Uri.encode( |
| 8805 | mComponent.flattenToShortString(), "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8806 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8807 | if (mSourceBounds != null) { |
| 8808 | uri.append("sourceBounds=") |
| 8809 | .append(Uri.encode(mSourceBounds.flattenToString())) |
| 8810 | .append(';'); |
| 8811 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8812 | if (mExtras != null) { |
| 8813 | for (String key : mExtras.keySet()) { |
| 8814 | final Object value = mExtras.get(key); |
| 8815 | char entryType = |
| 8816 | value instanceof String ? 'S' : |
| 8817 | value instanceof Boolean ? 'B' : |
| 8818 | value instanceof Byte ? 'b' : |
| 8819 | value instanceof Character ? 'c' : |
| 8820 | value instanceof Double ? 'd' : |
| 8821 | value instanceof Float ? 'f' : |
| 8822 | value instanceof Integer ? 'i' : |
| 8823 | value instanceof Long ? 'l' : |
| 8824 | value instanceof Short ? 's' : |
| 8825 | '\0'; |
| 8826 | |
| 8827 | if (entryType != '\0') { |
| 8828 | uri.append(entryType); |
| 8829 | uri.append('.'); |
| 8830 | uri.append(Uri.encode(key)); |
| 8831 | uri.append('='); |
| 8832 | uri.append(Uri.encode(value.toString())); |
| 8833 | uri.append(';'); |
| 8834 | } |
| 8835 | } |
| 8836 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8837 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8838 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8839 | public int describeContents() { |
| 8840 | return (mExtras != null) ? mExtras.describeContents() : 0; |
| 8841 | } |
| 8842 | |
| 8843 | public void writeToParcel(Parcel out, int flags) { |
| 8844 | out.writeString(mAction); |
| 8845 | Uri.writeToParcel(out, mData); |
| 8846 | out.writeString(mType); |
| 8847 | out.writeInt(mFlags); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8848 | out.writeString(mPackage); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8849 | ComponentName.writeToParcel(mComponent, out); |
| 8850 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8851 | if (mSourceBounds != null) { |
| 8852 | out.writeInt(1); |
| 8853 | mSourceBounds.writeToParcel(out, flags); |
| 8854 | } else { |
| 8855 | out.writeInt(0); |
| 8856 | } |
| 8857 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8858 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8859 | final int N = mCategories.size(); |
| 8860 | out.writeInt(N); |
| 8861 | for (int i=0; i<N; i++) { |
| 8862 | out.writeString(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8863 | } |
| 8864 | } else { |
| 8865 | out.writeInt(0); |
| 8866 | } |
| 8867 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8868 | if (mSelector != null) { |
| 8869 | out.writeInt(1); |
| 8870 | mSelector.writeToParcel(out, flags); |
| 8871 | } else { |
| 8872 | out.writeInt(0); |
| 8873 | } |
| 8874 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8875 | if (mClipData != null) { |
| 8876 | out.writeInt(1); |
| 8877 | mClipData.writeToParcel(out, flags); |
| 8878 | } else { |
| 8879 | out.writeInt(0); |
| 8880 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8881 | out.writeInt(mContentUserHint); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8882 | out.writeBundle(mExtras); |
| 8883 | } |
| 8884 | |
| 8885 | public static final Parcelable.Creator<Intent> CREATOR |
| 8886 | = new Parcelable.Creator<Intent>() { |
| 8887 | public Intent createFromParcel(Parcel in) { |
| 8888 | return new Intent(in); |
| 8889 | } |
| 8890 | public Intent[] newArray(int size) { |
| 8891 | return new Intent[size]; |
| 8892 | } |
| 8893 | }; |
| 8894 | |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 8895 | /** @hide */ |
| 8896 | protected Intent(Parcel in) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8897 | readFromParcel(in); |
| 8898 | } |
| 8899 | |
| 8900 | public void readFromParcel(Parcel in) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 8901 | setAction(in.readString()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8902 | mData = Uri.CREATOR.createFromParcel(in); |
| 8903 | mType = in.readString(); |
| 8904 | mFlags = in.readInt(); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8905 | mPackage = in.readString(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8906 | mComponent = ComponentName.readFromParcel(in); |
| 8907 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8908 | if (in.readInt() != 0) { |
| 8909 | mSourceBounds = Rect.CREATOR.createFromParcel(in); |
| 8910 | } |
| 8911 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8912 | int N = in.readInt(); |
| 8913 | if (N > 0) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8914 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8915 | int i; |
| 8916 | for (i=0; i<N; i++) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 8917 | mCategories.add(in.readString().intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8918 | } |
| 8919 | } else { |
| 8920 | mCategories = null; |
| 8921 | } |
| 8922 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8923 | if (in.readInt() != 0) { |
| 8924 | mSelector = new Intent(in); |
| 8925 | } |
| 8926 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8927 | if (in.readInt() != 0) { |
| 8928 | mClipData = new ClipData(in); |
| 8929 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8930 | mContentUserHint = in.readInt(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8931 | mExtras = in.readBundle(); |
| 8932 | } |
| 8933 | |
| 8934 | /** |
| 8935 | * Parses the "intent" element (and its children) from XML and instantiates |
| 8936 | * an Intent object. The given XML parser should be located at the tag |
| 8937 | * where parsing should start (often named "intent"), from which the |
| 8938 | * basic action, data, type, and package and class name will be |
| 8939 | * retrieved. The function will then parse in to any child elements, |
| 8940 | * looking for <category android:name="xxx"> tags to add categories and |
| 8941 | * <extra android:name="xxx" android:value="yyy"> to attach extra data |
| 8942 | * to the intent. |
| 8943 | * |
| 8944 | * @param resources The Resources to use when inflating resources. |
| 8945 | * @param parser The XML parser pointing at an "intent" tag. |
| 8946 | * @param attrs The AttributeSet interface for retrieving extended |
| 8947 | * attribute data at the current <var>parser</var> location. |
| 8948 | * @return An Intent object matching the XML data. |
| 8949 | * @throws XmlPullParserException If there was an XML parsing error. |
| 8950 | * @throws IOException If there was an I/O error. |
| 8951 | */ |
| 8952 | public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs) |
| 8953 | throws XmlPullParserException, IOException { |
| 8954 | Intent intent = new Intent(); |
| 8955 | |
| 8956 | TypedArray sa = resources.obtainAttributes(attrs, |
| 8957 | com.android.internal.R.styleable.Intent); |
| 8958 | |
| 8959 | intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); |
| 8960 | |
| 8961 | String data = sa.getString(com.android.internal.R.styleable.Intent_data); |
| 8962 | String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); |
| 8963 | intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); |
| 8964 | |
| 8965 | String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); |
| 8966 | String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); |
| 8967 | if (packageName != null && className != null) { |
| 8968 | intent.setComponent(new ComponentName(packageName, className)); |
| 8969 | } |
| 8970 | |
| 8971 | sa.recycle(); |
| 8972 | |
| 8973 | int outerDepth = parser.getDepth(); |
| 8974 | int type; |
| 8975 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 8976 | && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { |
| 8977 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 8978 | continue; |
| 8979 | } |
| 8980 | |
| 8981 | String nodeName = parser.getName(); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 8982 | if (nodeName.equals(TAG_CATEGORIES)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8983 | sa = resources.obtainAttributes(attrs, |
| 8984 | com.android.internal.R.styleable.IntentCategory); |
| 8985 | String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); |
| 8986 | sa.recycle(); |
| 8987 | |
| 8988 | if (cat != null) { |
| 8989 | intent.addCategory(cat); |
| 8990 | } |
| 8991 | XmlUtils.skipCurrentTag(parser); |
| 8992 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 8993 | } else if (nodeName.equals(TAG_EXTRA)) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8994 | if (intent.mExtras == null) { |
| 8995 | intent.mExtras = new Bundle(); |
| 8996 | } |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 8997 | resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8998 | XmlUtils.skipCurrentTag(parser); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8999 | |
| 9000 | } else { |
| 9001 | XmlUtils.skipCurrentTag(parser); |
| 9002 | } |
| 9003 | } |
| 9004 | |
| 9005 | return intent; |
| 9006 | } |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9007 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9008 | /** @hide */ |
| 9009 | public void saveToXml(XmlSerializer out) throws IOException { |
| 9010 | if (mAction != null) { |
| 9011 | out.attribute(null, ATTR_ACTION, mAction); |
| 9012 | } |
| 9013 | if (mData != null) { |
| 9014 | out.attribute(null, ATTR_DATA, mData.toString()); |
| 9015 | } |
| 9016 | if (mType != null) { |
| 9017 | out.attribute(null, ATTR_TYPE, mType); |
| 9018 | } |
| 9019 | if (mComponent != null) { |
| 9020 | out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); |
| 9021 | } |
| 9022 | out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); |
| 9023 | |
| 9024 | if (mCategories != null) { |
| 9025 | out.startTag(null, TAG_CATEGORIES); |
| 9026 | for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { |
| 9027 | out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); |
| 9028 | } |
Craig Mautner | 43e52ed | 2014-06-16 17:18:52 -0700 | [diff] [blame] | 9029 | out.endTag(null, TAG_CATEGORIES); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9030 | } |
| 9031 | } |
| 9032 | |
| 9033 | /** @hide */ |
| 9034 | public static Intent restoreFromXml(XmlPullParser in) throws IOException, |
| 9035 | XmlPullParserException { |
| 9036 | Intent intent = new Intent(); |
| 9037 | final int outerDepth = in.getDepth(); |
| 9038 | |
| 9039 | int attrCount = in.getAttributeCount(); |
| 9040 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 9041 | final String attrName = in.getAttributeName(attrNdx); |
| 9042 | final String attrValue = in.getAttributeValue(attrNdx); |
| 9043 | if (ATTR_ACTION.equals(attrName)) { |
| 9044 | intent.setAction(attrValue); |
| 9045 | } else if (ATTR_DATA.equals(attrName)) { |
| 9046 | intent.setData(Uri.parse(attrValue)); |
| 9047 | } else if (ATTR_TYPE.equals(attrName)) { |
| 9048 | intent.setType(attrValue); |
| 9049 | } else if (ATTR_COMPONENT.equals(attrName)) { |
| 9050 | intent.setComponent(ComponentName.unflattenFromString(attrValue)); |
| 9051 | } else if (ATTR_FLAGS.equals(attrName)) { |
Narayan Kamath | a09b4d2 | 2016-04-15 18:32:45 +0100 | [diff] [blame] | 9052 | intent.setFlags(Integer.parseInt(attrValue, 16)); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9053 | } else { |
| 9054 | Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName); |
| 9055 | } |
| 9056 | } |
| 9057 | |
| 9058 | int event; |
| 9059 | String name; |
| 9060 | while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && |
| 9061 | (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { |
| 9062 | if (event == XmlPullParser.START_TAG) { |
| 9063 | name = in.getName(); |
| 9064 | if (TAG_CATEGORIES.equals(name)) { |
| 9065 | attrCount = in.getAttributeCount(); |
| 9066 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 9067 | intent.addCategory(in.getAttributeValue(attrNdx)); |
| 9068 | } |
| 9069 | } else { |
| 9070 | Log.w("Intent", "restoreFromXml: unknown name=" + name); |
| 9071 | XmlUtils.skipCurrentTag(in); |
| 9072 | } |
| 9073 | } |
| 9074 | } |
| 9075 | |
| 9076 | return intent; |
| 9077 | } |
| 9078 | |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9079 | /** |
| 9080 | * Normalize a MIME data type. |
| 9081 | * |
| 9082 | * <p>A normalized MIME type has white-space trimmed, |
| 9083 | * content-type parameters removed, and is lower-case. |
| 9084 | * This aligns the type with Android best practices for |
| 9085 | * intent filtering. |
| 9086 | * |
| 9087 | * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". |
| 9088 | * "text/x-vCard" becomes "text/x-vcard". |
| 9089 | * |
| 9090 | * <p>All MIME types received from outside Android (such as user input, |
| 9091 | * or external sources like Bluetooth, NFC, or the Internet) should |
| 9092 | * be normalized before they are used to create an Intent. |
| 9093 | * |
| 9094 | * @param type MIME data type to normalize |
| 9095 | * @return normalized MIME data type, or null if the input was null |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 9096 | * @see #setType |
| 9097 | * @see #setTypeAndNormalize |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9098 | */ |
| 9099 | public static String normalizeMimeType(String type) { |
| 9100 | if (type == null) { |
| 9101 | return null; |
| 9102 | } |
| 9103 | |
Elliott Hughes | cb64d43 | 2013-08-02 10:00:44 -0700 | [diff] [blame] | 9104 | type = type.trim().toLowerCase(Locale.ROOT); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9105 | |
| 9106 | final int semicolonIndex = type.indexOf(';'); |
| 9107 | if (semicolonIndex != -1) { |
| 9108 | type = type.substring(0, semicolonIndex); |
| 9109 | } |
| 9110 | return type; |
| 9111 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9112 | |
| 9113 | /** |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9114 | * Prepare this {@link Intent} to leave an app process. |
| 9115 | * |
| 9116 | * @hide |
| 9117 | */ |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9118 | public void prepareToLeaveProcess(Context context) { |
| 9119 | final boolean leavingPackage = (mComponent == null) |
| 9120 | || !Objects.equals(mComponent.getPackageName(), context.getPackageName()); |
| 9121 | prepareToLeaveProcess(leavingPackage); |
| 9122 | } |
| 9123 | |
| 9124 | /** |
| 9125 | * Prepare this {@link Intent} to leave an app process. |
| 9126 | * |
| 9127 | * @hide |
| 9128 | */ |
| 9129 | public void prepareToLeaveProcess(boolean leavingPackage) { |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9130 | setAllowFds(false); |
| 9131 | |
| 9132 | if (mSelector != null) { |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9133 | mSelector.prepareToLeaveProcess(leavingPackage); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9134 | } |
| 9135 | if (mClipData != null) { |
Jeff Sharkey | fb833f3 | 2016-12-01 14:59:59 -0700 | [diff] [blame] | 9136 | mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9137 | } |
| 9138 | |
Jeff Sharkey | a8b4278 | 2016-01-30 17:58:09 -0700 | [diff] [blame] | 9139 | if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() |
| 9140 | && leavingPackage) { |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9141 | switch (mAction) { |
| 9142 | case ACTION_MEDIA_REMOVED: |
| 9143 | case ACTION_MEDIA_UNMOUNTED: |
| 9144 | case ACTION_MEDIA_CHECKING: |
| 9145 | case ACTION_MEDIA_NOFS: |
| 9146 | case ACTION_MEDIA_MOUNTED: |
| 9147 | case ACTION_MEDIA_SHARED: |
| 9148 | case ACTION_MEDIA_UNSHARED: |
| 9149 | case ACTION_MEDIA_BAD_REMOVAL: |
| 9150 | case ACTION_MEDIA_UNMOUNTABLE: |
| 9151 | case ACTION_MEDIA_EJECT: |
| 9152 | case ACTION_MEDIA_SCANNER_STARTED: |
| 9153 | case ACTION_MEDIA_SCANNER_FINISHED: |
| 9154 | case ACTION_MEDIA_SCANNER_SCAN_FILE: |
Jeff Sharkey | 37355a9 | 2016-02-05 16:19:10 -0700 | [diff] [blame] | 9155 | case ACTION_PACKAGE_NEEDS_VERIFICATION: |
| 9156 | case ACTION_PACKAGE_VERIFIED: |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9157 | // Ignore legacy actions |
| 9158 | break; |
| 9159 | default: |
| 9160 | mData.checkFileUriExposed("Intent.getData()"); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9161 | } |
| 9162 | } |
Jeff Sharkey | fb833f3 | 2016-12-01 14:59:59 -0700 | [diff] [blame] | 9163 | |
| 9164 | if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() |
| 9165 | && leavingPackage) { |
| 9166 | switch (mAction) { |
| 9167 | case ACTION_PROVIDER_CHANGED: |
| 9168 | // Ignore actions that don't need to grant |
| 9169 | break; |
| 9170 | default: |
| 9171 | mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); |
| 9172 | } |
| 9173 | } |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9174 | } |
| 9175 | |
| 9176 | /** |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9177 | * @hide |
| 9178 | */ |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9179 | public void prepareToEnterProcess() { |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 9180 | // We just entered destination process, so we should be able to read all |
| 9181 | // parcelables inside. |
| 9182 | setDefusable(true); |
| 9183 | |
| 9184 | if (mSelector != null) { |
| 9185 | mSelector.prepareToEnterProcess(); |
| 9186 | } |
| 9187 | if (mClipData != null) { |
| 9188 | mClipData.prepareToEnterProcess(); |
| 9189 | } |
| 9190 | |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9191 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
Nicolas Prevot | c4fc00a | 2014-10-31 12:01:32 +0000 | [diff] [blame] | 9192 | if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { |
| 9193 | fixUris(mContentUserHint); |
| 9194 | mContentUserHint = UserHandle.USER_CURRENT; |
| 9195 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9196 | } |
| 9197 | } |
| 9198 | |
| 9199 | /** |
| 9200 | * @hide |
| 9201 | */ |
| 9202 | public void fixUris(int contentUserHint) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9203 | Uri data = getData(); |
| 9204 | if (data != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9205 | mData = maybeAddUserId(data, contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9206 | } |
| 9207 | if (mClipData != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9208 | mClipData.fixUris(contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9209 | } |
| 9210 | String action = getAction(); |
| 9211 | if (ACTION_SEND.equals(action)) { |
| 9212 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 9213 | if (stream != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9214 | putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9215 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9216 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9217 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 9218 | if (streams != null) { |
| 9219 | ArrayList<Uri> newStreams = new ArrayList<Uri>(); |
| 9220 | for (int i = 0; i < streams.size(); i++) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9221 | newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9222 | } |
| 9223 | putParcelableArrayListExtra(EXTRA_STREAM, newStreams); |
| 9224 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9225 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 9226 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 9227 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 9228 | final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 9229 | if (output != null) { |
| 9230 | putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); |
| 9231 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9232 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9233 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9234 | |
| 9235 | /** |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9236 | * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9237 | * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested |
| 9238 | * intents in {@link #ACTION_CHOOSER}. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9239 | * |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9240 | * @return Whether any contents were migrated. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9241 | * @hide |
| 9242 | */ |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9243 | public boolean migrateExtraStreamToClipData() { |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9244 | // Refuse to touch if extras already parcelled |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9245 | if (mExtras != null && mExtras.isParcelled()) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9246 | |
| 9247 | // Bail when someone already gave us ClipData |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9248 | if (getClipData() != null) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9249 | |
| 9250 | final String action = getAction(); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9251 | if (ACTION_CHOOSER.equals(action)) { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9252 | // Inspect contained intents to see if we need to migrate extras. We |
| 9253 | // don't promote ClipData to the parent, since ChooserActivity will |
| 9254 | // already start the picked item as the caller, and we can't combine |
| 9255 | // the flags in a safe way. |
| 9256 | |
| 9257 | boolean migrated = false; |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 9258 | try { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9259 | final Intent intent = getParcelableExtra(EXTRA_INTENT); |
| 9260 | if (intent != null) { |
| 9261 | migrated |= intent.migrateExtraStreamToClipData(); |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 9262 | } |
| 9263 | } catch (ClassCastException e) { |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9264 | } |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9265 | try { |
| 9266 | final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); |
| 9267 | if (intents != null) { |
| 9268 | for (int i = 0; i < intents.length; i++) { |
| 9269 | final Intent intent = (Intent) intents[i]; |
| 9270 | if (intent != null) { |
| 9271 | migrated |= intent.migrateExtraStreamToClipData(); |
| 9272 | } |
| 9273 | } |
| 9274 | } |
| 9275 | } catch (ClassCastException e) { |
| 9276 | } |
| 9277 | return migrated; |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9278 | |
| 9279 | } else if (ACTION_SEND.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9280 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9281 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 9282 | final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); |
| 9283 | final String htmlText = getStringExtra(EXTRA_HTML_TEXT); |
| 9284 | if (stream != null || text != null || htmlText != null) { |
| 9285 | final ClipData clipData = new ClipData( |
| 9286 | null, new String[] { getType() }, |
| 9287 | new ClipData.Item(text, htmlText, null, stream)); |
| 9288 | setClipData(clipData); |
| 9289 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9290 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9291 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9292 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9293 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9294 | |
| 9295 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9296 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9297 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 9298 | final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); |
| 9299 | final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); |
| 9300 | int num = -1; |
| 9301 | if (streams != null) { |
| 9302 | num = streams.size(); |
| 9303 | } |
| 9304 | if (texts != null) { |
| 9305 | if (num >= 0 && num != texts.size()) { |
| 9306 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9307 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9308 | } |
| 9309 | num = texts.size(); |
| 9310 | } |
| 9311 | if (htmlTexts != null) { |
| 9312 | if (num >= 0 && num != htmlTexts.size()) { |
| 9313 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9314 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9315 | } |
| 9316 | num = htmlTexts.size(); |
| 9317 | } |
| 9318 | if (num > 0) { |
| 9319 | final ClipData clipData = new ClipData( |
| 9320 | null, new String[] { getType() }, |
| 9321 | makeClipItem(streams, texts, htmlTexts, 0)); |
| 9322 | |
| 9323 | for (int i = 1; i < num; i++) { |
| 9324 | clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); |
| 9325 | } |
| 9326 | |
| 9327 | setClipData(clipData); |
| 9328 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9329 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9330 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9331 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9332 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9333 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 9334 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 9335 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 9336 | final Uri output; |
| 9337 | try { |
| 9338 | output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 9339 | } catch (ClassCastException e) { |
| 9340 | return false; |
| 9341 | } |
| 9342 | if (output != null) { |
| 9343 | setClipData(ClipData.newRawUri("", output)); |
| 9344 | addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); |
| 9345 | return true; |
| 9346 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9347 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9348 | |
| 9349 | return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9350 | } |
Dianne Hackborn | ac4243f | 2012-04-13 17:32:18 -0700 | [diff] [blame] | 9351 | |
| 9352 | private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, |
| 9353 | ArrayList<String> htmlTexts, int which) { |
| 9354 | Uri uri = streams != null ? streams.get(which) : null; |
| 9355 | CharSequence text = texts != null ? texts.get(which) : null; |
| 9356 | String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; |
| 9357 | return new ClipData.Item(text, htmlText, null, uri); |
| 9358 | } |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 9359 | |
| 9360 | /** @hide */ |
| 9361 | public boolean isDocument() { |
| 9362 | return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; |
| 9363 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9364 | } |