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} |
Zak Cohen | db6ca49 | 2017-01-26 14:09:00 -0800 | [diff] [blame] | 572 | * <li> {@link #CATEGORY_VR_HOME} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 573 | * </ul> |
| 574 | * |
| 575 | * <h3>Standard Extra Data</h3> |
| 576 | * |
| 577 | * <p>These are the current standard fields that can be used as extra data via |
| 578 | * {@link #putExtra}. |
| 579 | * |
| 580 | * <ul> |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 581 | * <li> {@link #EXTRA_ALARM_COUNT} |
| 582 | * <li> {@link #EXTRA_BCC} |
| 583 | * <li> {@link #EXTRA_CC} |
| 584 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} |
| 585 | * <li> {@link #EXTRA_DATA_REMOVED} |
| 586 | * <li> {@link #EXTRA_DOCK_STATE} |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 587 | * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} |
| 588 | * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 589 | * <li> {@link #EXTRA_DOCK_STATE_CAR} |
| 590 | * <li> {@link #EXTRA_DOCK_STATE_DESK} |
| 591 | * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} |
| 592 | * <li> {@link #EXTRA_DONT_KILL_APP} |
| 593 | * <li> {@link #EXTRA_EMAIL} |
| 594 | * <li> {@link #EXTRA_INITIAL_INTENTS} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 595 | * <li> {@link #EXTRA_INTENT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 596 | * <li> {@link #EXTRA_KEY_EVENT} |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 597 | * <li> {@link #EXTRA_ORIGINATING_URI} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 598 | * <li> {@link #EXTRA_PHONE_NUMBER} |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 599 | * <li> {@link #EXTRA_REFERRER} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 600 | * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} |
| 601 | * <li> {@link #EXTRA_REPLACING} |
| 602 | * <li> {@link #EXTRA_SHORTCUT_ICON} |
| 603 | * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} |
| 604 | * <li> {@link #EXTRA_SHORTCUT_INTENT} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 605 | * <li> {@link #EXTRA_STREAM} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 606 | * <li> {@link #EXTRA_SHORTCUT_NAME} |
| 607 | * <li> {@link #EXTRA_SUBJECT} |
| 608 | * <li> {@link #EXTRA_TEMPLATE} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 609 | * <li> {@link #EXTRA_TEXT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 610 | * <li> {@link #EXTRA_TITLE} |
| 611 | * <li> {@link #EXTRA_UID} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 612 | * </ul> |
| 613 | * |
| 614 | * <h3>Flags</h3> |
| 615 | * |
| 616 | * <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] | 617 | * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list |
| 618 | * of all possible flags. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 619 | */ |
Dianne Hackborn | ee0511d | 2009-12-21 18:08:13 -0800 | [diff] [blame] | 620 | public class Intent implements Parcelable, Cloneable { |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 621 | private static final String ATTR_ACTION = "action"; |
| 622 | private static final String TAG_CATEGORIES = "categories"; |
| 623 | private static final String ATTR_CATEGORY = "category"; |
| 624 | private static final String TAG_EXTRA = "extra"; |
| 625 | private static final String ATTR_TYPE = "type"; |
| 626 | private static final String ATTR_COMPONENT = "component"; |
| 627 | private static final String ATTR_DATA = "data"; |
| 628 | private static final String ATTR_FLAGS = "flags"; |
| 629 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 630 | // --------------------------------------------------------------------- |
| 631 | // --------------------------------------------------------------------- |
| 632 | // Standard intent activity actions (see action variable). |
| 633 | |
| 634 | /** |
| 635 | * Activity Action: Start as a main entry point, does not expect to |
| 636 | * receive data. |
| 637 | * <p>Input: nothing |
| 638 | * <p>Output: nothing |
| 639 | */ |
| 640 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 641 | 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] | 642 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 643 | /** |
| 644 | * Activity Action: Display the data to the user. This is the most common |
| 645 | * action performed on data -- it is the generic action you can use on |
| 646 | * a piece of data to get the most reasonable thing to occur. For example, |
| 647 | * when used on a contacts entry it will view the entry; when used on a |
| 648 | * mailto: URI it will bring up a compose window filled with the information |
| 649 | * supplied by the URI; when used with a tel: URI it will invoke the |
| 650 | * dialer. |
| 651 | * <p>Input: {@link #getData} is URI from which to retrieve data. |
| 652 | * <p>Output: nothing. |
| 653 | */ |
| 654 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 655 | 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] | 656 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 657 | /** |
| 658 | * A synonym for {@link #ACTION_VIEW}, the "standard" action that is |
| 659 | * performed on a piece of data. |
| 660 | */ |
| 661 | public static final String ACTION_DEFAULT = ACTION_VIEW; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 662 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 663 | /** |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 664 | * Activity Action: Quick view the data. Launches a quick viewer for |
| 665 | * a URI or a list of URIs. |
Tomasz Mikolajewski | fe02313 | 2016-03-10 17:42:35 +0900 | [diff] [blame] | 666 | * <p>Activities handling this intent action should handle the vast majority of |
| 667 | * MIME types rather than only specific ones. |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 668 | * <p>Input: {@link #getData} is a mandatory content URI of the item to |
| 669 | * preview. {@link #getClipData} contains an optional list of content URIs |
| 670 | * if there is more than one item to preview. {@link #EXTRA_INDEX} is an |
| 671 | * optional index of the URI in the clip data to show first. |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 672 | * If {@link #EXTRA_QUICK_VIEW_PLAIN} is true, then the quick viewer should show |
| 673 | * basic UI without any extra features other than quick viewing the passed items. |
| 674 | * Especially, the quick viewer should not let users open the passed files |
| 675 | * in other apps, which includes sharing, opening, editing, printing, etc in the |
| 676 | * plain mode. |
Steve McKay | c78bcb8 | 2015-07-31 14:35:22 -0700 | [diff] [blame] | 677 | * <p>Output: nothing. |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 678 | * @see #EXTRA_QUICK_VIEW_HIDE_DEFAULT_ACTIONS |
| 679 | * @see #EXTRA_INDEX |
Steve McKay | c78bcb8 | 2015-07-31 14:35:22 -0700 | [diff] [blame] | 680 | */ |
| 681 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 682 | public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; |
| 683 | |
| 684 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 685 | * Used to indicate that some piece of data should be attached to some other |
| 686 | * place. For example, image data could be attached to a contact. It is up |
| 687 | * to the recipient to decide where the data should be attached; the intent |
| 688 | * does not specify the ultimate destination. |
| 689 | * <p>Input: {@link #getData} is URI of data to be attached. |
| 690 | * <p>Output: nothing. |
| 691 | */ |
| 692 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 693 | 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] | 694 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 695 | /** |
| 696 | * Activity Action: Provide explicit editable access to the given data. |
| 697 | * <p>Input: {@link #getData} is URI of data to be edited. |
| 698 | * <p>Output: nothing. |
| 699 | */ |
| 700 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 701 | 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] | 702 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 703 | /** |
| 704 | * Activity Action: Pick an existing item, or insert a new item, and then edit it. |
| 705 | * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. |
| 706 | * The extras can contain type specific data to pass through to the editing/creating |
| 707 | * activity. |
| 708 | * <p>Output: The URI of the item that was picked. This must be a content: |
| 709 | * URI so that any receiver can access it. |
| 710 | */ |
| 711 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 712 | 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] | 713 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 714 | /** |
| 715 | * Activity Action: Pick an item from the data, returning what was selected. |
| 716 | * <p>Input: {@link #getData} is URI containing a directory of data |
| 717 | * (vnd.android.cursor.dir/*) from which to pick an item. |
| 718 | * <p>Output: The URI of the item that was picked. |
| 719 | */ |
| 720 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 721 | 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] | 722 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 723 | /** |
| 724 | * Activity Action: Creates a shortcut. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 725 | * <p>Input: Nothing.</p> |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 726 | * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> |
| 727 | * <p>For compatibility with older versions of android the intent may also contain three |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 728 | * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), |
| 729 | * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 730 | * (value: ShortcutIconResource).</p> |
| 731 | * |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 732 | * @see android.content.pm.ShortcutManager#createShortcutResultIntent |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 733 | * @see #EXTRA_SHORTCUT_INTENT |
| 734 | * @see #EXTRA_SHORTCUT_NAME |
| 735 | * @see #EXTRA_SHORTCUT_ICON |
| 736 | * @see #EXTRA_SHORTCUT_ICON_RESOURCE |
| 737 | * @see android.content.Intent.ShortcutIconResource |
| 738 | */ |
| 739 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 740 | public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; |
| 741 | |
| 742 | /** |
| 743 | * The name of the extra used to define the Intent of a shortcut. |
| 744 | * |
| 745 | * @see #ACTION_CREATE_SHORTCUT |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 746 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 747 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 748 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 749 | public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; |
| 750 | /** |
| 751 | * The name of the extra used to define the name of a shortcut. |
| 752 | * |
| 753 | * @see #ACTION_CREATE_SHORTCUT |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 754 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 755 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 756 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 757 | public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; |
| 758 | /** |
| 759 | * The name of the extra used to define the icon, as a Bitmap, of a shortcut. |
| 760 | * |
| 761 | * @see #ACTION_CREATE_SHORTCUT |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 762 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 763 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 764 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 765 | public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; |
| 766 | /** |
| 767 | * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. |
| 768 | * |
| 769 | * @see #ACTION_CREATE_SHORTCUT |
| 770 | * @see android.content.Intent.ShortcutIconResource |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 771 | * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 772 | */ |
Sunny Goyal | a6be88a | 2017-01-12 16:27:58 -0800 | [diff] [blame] | 773 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 774 | public static final String EXTRA_SHORTCUT_ICON_RESOURCE = |
| 775 | "android.intent.extra.shortcut.ICON_RESOURCE"; |
| 776 | |
| 777 | /** |
Jason Monk | 2f68e8a | 2016-02-23 17:57:28 -0500 | [diff] [blame] | 778 | * An activity that provides a user interface for adjusting application preferences. |
| 779 | * Optional but recommended settings for all applications which have settings. |
| 780 | */ |
| 781 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 782 | public static final String ACTION_APPLICATION_PREFERENCES |
| 783 | = "android.intent.action.APPLICATION_PREFERENCES"; |
| 784 | |
| 785 | /** |
Sudheer Shanka | 80b6641 | 2016-04-06 18:31:10 -0700 | [diff] [blame] | 786 | * Activity Action: Launch an activity showing the app information. |
| 787 | * For applications which install other applications (such as app stores), it is recommended |
| 788 | * to handle this action for providing the app information to the user. |
| 789 | * |
| 790 | * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs |
| 791 | * to be displayed. |
| 792 | * <p>Output: Nothing. |
| 793 | */ |
| 794 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 795 | public static final String ACTION_SHOW_APP_INFO |
| 796 | = "android.intent.action.SHOW_APP_INFO"; |
| 797 | |
| 798 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 799 | * Represents a shortcut/live folder icon resource. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 800 | * |
| 801 | * @see Intent#ACTION_CREATE_SHORTCUT |
| 802 | * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 803 | * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER |
| 804 | * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 805 | */ |
| 806 | public static class ShortcutIconResource implements Parcelable { |
| 807 | /** |
| 808 | * The package name of the application containing the icon. |
| 809 | */ |
| 810 | public String packageName; |
| 811 | |
| 812 | /** |
| 813 | * The resource name of the icon, including package, name and type. |
| 814 | */ |
| 815 | public String resourceName; |
| 816 | |
| 817 | /** |
| 818 | * Creates a new ShortcutIconResource for the specified context and resource |
| 819 | * identifier. |
| 820 | * |
| 821 | * @param context The context of the application. |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 822 | * @param resourceId The resource identifier for the icon. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 823 | * @return A new ShortcutIconResource with the specified's context package name |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 824 | * and icon resource identifier.`` |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 825 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 826 | public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 827 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 828 | icon.packageName = context.getPackageName(); |
| 829 | icon.resourceName = context.getResources().getResourceName(resourceId); |
| 830 | return icon; |
| 831 | } |
| 832 | |
| 833 | /** |
| 834 | * Used to read a ShortcutIconResource from a Parcel. |
| 835 | */ |
| 836 | public static final Parcelable.Creator<ShortcutIconResource> CREATOR = |
| 837 | new Parcelable.Creator<ShortcutIconResource>() { |
| 838 | |
| 839 | public ShortcutIconResource createFromParcel(Parcel source) { |
| 840 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 841 | icon.packageName = source.readString(); |
| 842 | icon.resourceName = source.readString(); |
| 843 | return icon; |
| 844 | } |
| 845 | |
| 846 | public ShortcutIconResource[] newArray(int size) { |
| 847 | return new ShortcutIconResource[size]; |
| 848 | } |
| 849 | }; |
| 850 | |
| 851 | /** |
| 852 | * No special parcel contents. |
| 853 | */ |
| 854 | public int describeContents() { |
| 855 | return 0; |
| 856 | } |
| 857 | |
| 858 | public void writeToParcel(Parcel dest, int flags) { |
| 859 | dest.writeString(packageName); |
| 860 | dest.writeString(resourceName); |
| 861 | } |
| 862 | |
| 863 | @Override |
| 864 | public String toString() { |
| 865 | return resourceName; |
| 866 | } |
| 867 | } |
| 868 | |
| 869 | /** |
| 870 | * Activity Action: Display an activity chooser, allowing the user to pick |
| 871 | * what they want to before proceeding. This can be used as an alternative |
| 872 | * to the standard activity picker that is displayed by the system when |
| 873 | * you try to start an activity with multiple possible matches, with these |
| 874 | * differences in behavior: |
| 875 | * <ul> |
| 876 | * <li>You can specify the title that will appear in the activity chooser. |
| 877 | * <li>The user does not have the option to make one of the matching |
| 878 | * activities a preferred activity, and all possible activities will |
| 879 | * always be shown even if one of them is currently marked as the |
| 880 | * preferred activity. |
| 881 | * </ul> |
| 882 | * <p> |
| 883 | * This action should be used when the user will naturally expect to |
| 884 | * select an activity in order to proceed. An example if when not to use |
| 885 | * it is when the user clicks on a "mailto:" link. They would naturally |
| 886 | * expect to go directly to their mail app, so startActivity() should be |
| 887 | * called directly: it will |
| 888 | * either launch the current preferred app, or put up a dialog allowing the |
| 889 | * user to pick an app to use and optionally marking that as preferred. |
| 890 | * <p> |
| 891 | * In contrast, if the user is selecting a menu item to send a picture |
| 892 | * they are viewing to someone else, there are many different things they |
| 893 | * may want to do at this point: send it through e-mail, upload it to a |
| 894 | * web service, etc. In this case the CHOOSER action should be used, to |
| 895 | * always present to the user a list of the things they can do, with a |
| 896 | * nice title given by the caller such as "Send this photo with:". |
| 897 | * <p> |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 898 | * If you need to grant URI permissions through a chooser, you must specify |
| 899 | * the permissions to be granted on the ACTION_CHOOSER Intent |
| 900 | * <em>in addition</em> to the EXTRA_INTENT inside. This means using |
| 901 | * {@link #setClipData} to specify the URIs to be granted as well as |
| 902 | * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 903 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. |
| 904 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 905 | * As a convenience, an Intent of this form can be created with the |
| 906 | * {@link #createChooser} function. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 907 | * <p> |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 908 | * 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] | 909 | * a {@link #EXTRA_INTENT} field containing the Intent being executed, |
| 910 | * and can optionally have a {@link #EXTRA_TITLE} field containing the |
| 911 | * title text to display in the chooser. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 912 | * <p> |
| 913 | * Output: Depends on the protocol of {@link #EXTRA_INTENT}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 914 | */ |
| 915 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 916 | public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; |
| 917 | |
| 918 | /** |
| 919 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 920 | * |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 921 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 922 | * target intent, also optionally supplying a title. If the target |
| 923 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 924 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 925 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 926 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
John Spurlock | 3390018 | 2014-01-02 11:04:18 -0500 | [diff] [blame] | 927 | * or a new ClipData built from {@link #getData()}. |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 928 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 929 | * @param target The Intent that the user will be selecting an activity |
| 930 | * to perform. |
| 931 | * @param title Optional title that will be displayed in the chooser. |
| 932 | * @return Return a new Intent object that you can hand to |
| 933 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 934 | * related methods. |
| 935 | */ |
| 936 | public static Intent createChooser(Intent target, CharSequence title) { |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 937 | return createChooser(target, title, null); |
| 938 | } |
| 939 | |
| 940 | /** |
| 941 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 942 | * |
| 943 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 944 | * target intent, also optionally supplying a title. If the target |
| 945 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 946 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 947 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 948 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
| 949 | * or a new ClipData built from {@link #getData()}.</p> |
| 950 | * |
| 951 | * <p>The caller may optionally supply an {@link IntentSender} to receive a callback |
| 952 | * when the user makes a choice. This can be useful if the calling application wants |
| 953 | * to remember the last chosen target and surface it as a more prominent or one-touch |
| 954 | * affordance elsewhere in the UI for next time.</p> |
| 955 | * |
| 956 | * @param target The Intent that the user will be selecting an activity |
| 957 | * to perform. |
| 958 | * @param title Optional title that will be displayed in the chooser. |
| 959 | * @param sender Optional IntentSender to be called when a choice is made. |
| 960 | * @return Return a new Intent object that you can hand to |
| 961 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 962 | * related methods. |
| 963 | */ |
| 964 | 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] | 965 | Intent intent = new Intent(ACTION_CHOOSER); |
| 966 | intent.putExtra(EXTRA_INTENT, target); |
| 967 | if (title != null) { |
| 968 | intent.putExtra(EXTRA_TITLE, title); |
| 969 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 970 | |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 971 | if (sender != null) { |
| 972 | intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); |
| 973 | } |
| 974 | |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 975 | // Migrate any clip data and flags from target. |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 976 | int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION |
| 977 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 978 | | FLAG_GRANT_PREFIX_URI_PERMISSION); |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 979 | if (permFlags != 0) { |
| 980 | ClipData targetClipData = target.getClipData(); |
| 981 | if (targetClipData == null && target.getData() != null) { |
| 982 | ClipData.Item item = new ClipData.Item(target.getData()); |
| 983 | String[] mimeTypes; |
| 984 | if (target.getType() != null) { |
| 985 | mimeTypes = new String[] { target.getType() }; |
| 986 | } else { |
| 987 | mimeTypes = new String[] { }; |
| 988 | } |
| 989 | targetClipData = new ClipData(null, mimeTypes, item); |
| 990 | } |
| 991 | if (targetClipData != null) { |
| 992 | intent.setClipData(targetClipData); |
| 993 | intent.addFlags(permFlags); |
| 994 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 995 | } |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 996 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 997 | return intent; |
| 998 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 999 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1000 | /** |
| 1001 | * Activity Action: Allow the user to select a particular kind of data and |
| 1002 | * return it. This is different than {@link #ACTION_PICK} in that here we |
| 1003 | * 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] | 1004 | * 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] | 1005 | * 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] | 1006 | * 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] | 1007 | * etc. |
| 1008 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1009 | * 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] | 1010 | * of data, such as a person contact, you set the MIME type to the kind of |
| 1011 | * data you want and launch it with {@link Context#startActivity(Intent)}. |
| 1012 | * The system will then launch the best application to select that kind |
| 1013 | * of data for you. |
| 1014 | * <p> |
| 1015 | * You may also be interested in any of a set of types of content the user |
| 1016 | * can pick. For example, an e-mail application that wants to allow the |
| 1017 | * user to add an attachment to an e-mail message can use this action to |
| 1018 | * bring up a list of all of the types of content the user can attach. |
| 1019 | * <p> |
| 1020 | * In this case, you should wrap the GET_CONTENT intent with a chooser |
| 1021 | * (through {@link #createChooser}), which will give the proper interface |
| 1022 | * for the user to pick how to send your data and allow you to specify |
| 1023 | * a prompt indicating what they are doing. You will usually specify a |
| 1024 | * broad MIME type (such as image/* or {@literal *}/*), resulting in a |
| 1025 | * broad range of content types the user can select from. |
| 1026 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1027 | * 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] | 1028 | * only pick from data that can be represented as a stream. This is |
| 1029 | * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. |
| 1030 | * <p> |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1031 | * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1032 | * the launched content chooser only returns results representing data that |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1033 | * is locally available on the device. For example, if this extra is set |
| 1034 | * to true then an image picker should not show any pictures that are available |
| 1035 | * from a remote server but not already on the local device (thus requiring |
| 1036 | * they be downloaded when opened). |
| 1037 | * <p> |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 1038 | * If the caller can handle multiple returned items (the user performing |
| 1039 | * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 1040 | * to indicate this. |
| 1041 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1042 | * Input: {@link #getType} is the desired MIME type to retrieve. Note |
| 1043 | * that no URI is supplied in the intent, as there are no constraints on |
| 1044 | * where the returned data originally comes from. You may also include the |
| 1045 | * {@link #CATEGORY_OPENABLE} if you can only accept data that can be |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 1046 | * 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] | 1047 | * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to |
| 1048 | * allow the user to select multiple items. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1049 | * <p> |
| 1050 | * Output: The URI of the item that was picked. This must be a content: |
| 1051 | * URI so that any receiver can access it. |
| 1052 | */ |
| 1053 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1054 | public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; |
| 1055 | /** |
| 1056 | * Activity Action: Dial a number as specified by the data. This shows a |
| 1057 | * UI with the number being dialed, allowing the user to explicitly |
| 1058 | * initiate the call. |
| 1059 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1060 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1061 | * number. |
| 1062 | * <p>Output: nothing. |
| 1063 | */ |
| 1064 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1065 | public static final String ACTION_DIAL = "android.intent.action.DIAL"; |
| 1066 | /** |
| 1067 | * Activity Action: Perform a call to someone specified by the data. |
| 1068 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1069 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1070 | * number. |
| 1071 | * <p>Output: nothing. |
| 1072 | * |
| 1073 | * <p>Note: there will be restrictions on which applications can initiate a |
| 1074 | * call; most applications should use the {@link #ACTION_DIAL}. |
| 1075 | * <p>Note: this Intent <strong>cannot</strong> be used to call emergency |
| 1076 | * numbers. Applications can <strong>dial</strong> emergency numbers using |
| 1077 | * {@link #ACTION_DIAL}, however. |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1078 | * |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 1079 | * <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] | 1080 | * 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] | 1081 | * permission which is not granted, then attempting to use this action will |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1082 | * result in a {@link java.lang.SecurityException}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1083 | */ |
| 1084 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1085 | public static final String ACTION_CALL = "android.intent.action.CALL"; |
| 1086 | /** |
| 1087 | * Activity Action: Perform a call to an emergency number specified by the |
| 1088 | * data. |
| 1089 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1090 | * tel: URI of an explicit phone number. |
| 1091 | * <p>Output: nothing. |
| 1092 | * @hide |
| 1093 | */ |
| 1094 | public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; |
| 1095 | /** |
| 1096 | * Activity action: Perform a call to any number (emergency or not) |
| 1097 | * specified by the data. |
| 1098 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1099 | * tel: URI of an explicit phone number. |
| 1100 | * <p>Output: nothing. |
| 1101 | * @hide |
| 1102 | */ |
| 1103 | public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; |
| 1104 | /** |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 1105 | * Activity action: Activate the current SIM card. If SIM cards do not require activation, |
| 1106 | * sending this intent is a no-op. |
| 1107 | * <p>Input: No data should be specified. get*Extra may have an optional |
| 1108 | * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to |
| 1109 | * send the activation result. |
| 1110 | * <p>Output: nothing. |
| 1111 | * @hide |
| 1112 | */ |
| 1113 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1114 | public static final String ACTION_SIM_ACTIVATION_REQUEST = |
| 1115 | "android.intent.action.SIM_ACTIVATION_REQUEST"; |
| 1116 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1117 | * Activity Action: Send a message to someone specified by the data. |
| 1118 | * <p>Input: {@link #getData} is URI describing the target. |
| 1119 | * <p>Output: nothing. |
| 1120 | */ |
| 1121 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1122 | public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; |
| 1123 | /** |
| 1124 | * Activity Action: Deliver some data to someone else. Who the data is |
| 1125 | * being delivered to is not specified; it is up to the receiver of this |
| 1126 | * action to ask the user where the data should be sent. |
| 1127 | * <p> |
| 1128 | * When launching a SEND intent, you should usually wrap it in a chooser |
| 1129 | * (through {@link #createChooser}), which will give the proper interface |
| 1130 | * for the user to pick how to send your data and allow you to specify |
| 1131 | * a prompt indicating what they are doing. |
| 1132 | * <p> |
| 1133 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1134 | * get*Extra can have either a {@link #EXTRA_TEXT} |
| 1135 | * or {@link #EXTRA_STREAM} field, containing the data to be sent. If |
| 1136 | * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it |
| 1137 | * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* |
| 1138 | * 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] | 1139 | * handle generic data streams). If using {@link #EXTRA_TEXT}, you can |
| 1140 | * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve |
| 1141 | * your text with HTML formatting. |
| 1142 | * <p> |
| 1143 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1144 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1145 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1146 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1147 | * using this approach, you still must supply the same data through the |
| 1148 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1149 | * for compatibility with old applications. If you don't set a ClipData, |
| 1150 | * 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] | 1151 | * <p> |
Tomasz Mikolajewski | d8a2e19 | 2016-12-15 16:10:46 +0900 | [diff] [blame] | 1152 | * Starting from {@link android.os.Build.VERSION_CODES#O}, if |
| 1153 | * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in |
| 1154 | * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may |
| 1155 | * be openable only as asset typed files using |
| 1156 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
| 1157 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1158 | * Optional standard extras, which may be interpreted by some recipients as |
| 1159 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1160 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1161 | * <p> |
| 1162 | * Output: nothing. |
| 1163 | */ |
| 1164 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1165 | public static final String ACTION_SEND = "android.intent.action.SEND"; |
| 1166 | /** |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1167 | * Activity Action: Deliver multiple data to someone else. |
| 1168 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1169 | * Like {@link #ACTION_SEND}, except the data is multiple. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1170 | * <p> |
| 1171 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1172 | * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1173 | * #EXTRA_STREAM} field, containing the data to be sent. If using |
| 1174 | * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} |
| 1175 | * for clients to retrieve your text with HTML formatting. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1176 | * <p> |
Chih-Chung Chang | 5962d27 | 2009-09-04 14:36:01 +0800 | [diff] [blame] | 1177 | * Multiple types are supported, and receivers should handle mixed types |
| 1178 | * whenever possible. The right way for the receiver to check them is to |
| 1179 | * use the content resolver on each URI. The intent sender should try to |
| 1180 | * put the most concrete mime type in the intent type, but it can fall |
| 1181 | * back to {@literal <type>/*} or {@literal *}/* as needed. |
| 1182 | * <p> |
| 1183 | * e.g. if you are sending image/jpg and image/jpg, the intent's type can |
| 1184 | * be image/jpg, but if you are sending image/jpg and image/png, then the |
| 1185 | * intent's type should be image/*. |
| 1186 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1187 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1188 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1189 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1190 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1191 | * using this approach, you still must supply the same data through the |
| 1192 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1193 | * for compatibility with old applications. If you don't set a ClipData, |
| 1194 | * it will be copied there for you when calling {@link Context#startActivity(Intent)}. |
| 1195 | * <p> |
Tomasz Mikolajewski | d8a2e19 | 2016-12-15 16:10:46 +0900 | [diff] [blame] | 1196 | * Starting from {@link android.os.Build.VERSION_CODES#O}, if |
| 1197 | * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in |
| 1198 | * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may |
| 1199 | * be openable only as asset typed files using |
| 1200 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
| 1201 | * <p> |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1202 | * Optional standard extras, which may be interpreted by some recipients as |
| 1203 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1204 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1205 | * <p> |
| 1206 | * Output: nothing. |
| 1207 | */ |
| 1208 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1209 | public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; |
| 1210 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1211 | * Activity Action: Handle an incoming phone call. |
| 1212 | * <p>Input: nothing. |
| 1213 | * <p>Output: nothing. |
| 1214 | */ |
| 1215 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1216 | public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; |
| 1217 | /** |
| 1218 | * Activity Action: Insert an empty item into the given container. |
| 1219 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1220 | * in which to place the data. |
| 1221 | * <p>Output: URI of the new data that was created. |
| 1222 | */ |
| 1223 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1224 | public static final String ACTION_INSERT = "android.intent.action.INSERT"; |
| 1225 | /** |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 1226 | * Activity Action: Create a new item in the given container, initializing it |
| 1227 | * from the current contents of the clipboard. |
| 1228 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1229 | * in which to place the data. |
| 1230 | * <p>Output: URI of the new data that was created. |
| 1231 | */ |
| 1232 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1233 | public static final String ACTION_PASTE = "android.intent.action.PASTE"; |
| 1234 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1235 | * Activity Action: Delete the given data from its container. |
| 1236 | * <p>Input: {@link #getData} is URI of data to be deleted. |
| 1237 | * <p>Output: nothing. |
| 1238 | */ |
| 1239 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1240 | public static final String ACTION_DELETE = "android.intent.action.DELETE"; |
| 1241 | /** |
| 1242 | * Activity Action: Run the data, whatever that means. |
| 1243 | * <p>Input: ? (Note: this is currently specific to the test harness.) |
| 1244 | * <p>Output: nothing. |
| 1245 | */ |
| 1246 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1247 | public static final String ACTION_RUN = "android.intent.action.RUN"; |
| 1248 | /** |
| 1249 | * Activity Action: Perform a data synchronization. |
| 1250 | * <p>Input: ? |
| 1251 | * <p>Output: ? |
| 1252 | */ |
| 1253 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1254 | public static final String ACTION_SYNC = "android.intent.action.SYNC"; |
| 1255 | /** |
| 1256 | * Activity Action: Pick an activity given an intent, returning the class |
| 1257 | * selected. |
| 1258 | * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent |
| 1259 | * used with {@link PackageManager#queryIntentActivities} to determine the |
| 1260 | * set of activities from which to pick. |
| 1261 | * <p>Output: Class name of the activity that was selected. |
| 1262 | */ |
| 1263 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1264 | public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; |
| 1265 | /** |
| 1266 | * Activity Action: Perform a search. |
| 1267 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1268 | * is the text to search for. If empty, simply |
| 1269 | * enter your search results Activity with the search UI activated. |
| 1270 | * <p>Output: nothing. |
| 1271 | */ |
| 1272 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1273 | public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; |
| 1274 | /** |
Jim Miller | 7e4ad35 | 2009-03-25 18:16:41 -0700 | [diff] [blame] | 1275 | * Activity Action: Start the platform-defined tutorial |
| 1276 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1277 | * is the text to search for. If empty, simply |
| 1278 | * enter your search results Activity with the search UI activated. |
| 1279 | * <p>Output: nothing. |
| 1280 | */ |
| 1281 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1282 | public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; |
| 1283 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1284 | * Activity Action: Perform a web search. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1285 | * <p> |
| 1286 | * Input: {@link android.app.SearchManager#QUERY |
| 1287 | * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is |
| 1288 | * a url starts with http or https, the site will be opened. If it is plain |
| 1289 | * text, Google search will be applied. |
| 1290 | * <p> |
| 1291 | * Output: nothing. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1292 | */ |
| 1293 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1294 | public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1295 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1296 | /** |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1297 | * Activity Action: Perform assist action. |
| 1298 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1299 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1300 | * additional optional contextual information about where the user was when they |
Dianne Hackborn | a3acdb3 | 2015-06-08 17:07:40 -0700 | [diff] [blame] | 1301 | * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer |
| 1302 | * information. |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1303 | * Output: nothing. |
| 1304 | */ |
| 1305 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1306 | public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1307 | |
| 1308 | /** |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1309 | * Activity Action: Perform voice assist action. |
| 1310 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1311 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1312 | * additional optional contextual information about where the user was when they |
Adam Skory | dfc7fd7 | 2013-08-05 19:23:41 -0700 | [diff] [blame] | 1313 | * requested the voice assist. |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1314 | * Output: nothing. |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1315 | * @hide |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1316 | */ |
| 1317 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1318 | public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; |
| 1319 | |
| 1320 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1321 | * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground |
| 1322 | * application package at the time the assist was invoked. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1323 | */ |
| 1324 | public static final String EXTRA_ASSIST_PACKAGE |
| 1325 | = "android.intent.extra.ASSIST_PACKAGE"; |
| 1326 | |
| 1327 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 1328 | * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground |
| 1329 | * application package at the time the assist was invoked. |
| 1330 | */ |
| 1331 | public static final String EXTRA_ASSIST_UID |
| 1332 | = "android.intent.extra.ASSIST_UID"; |
| 1333 | |
| 1334 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1335 | * An optional field on {@link #ACTION_ASSIST} and containing additional contextual |
| 1336 | * information supplied by the current foreground app at the time of the assist request. |
| 1337 | * This is a {@link Bundle} of additional data. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1338 | */ |
| 1339 | public static final String EXTRA_ASSIST_CONTEXT |
| 1340 | = "android.intent.extra.ASSIST_CONTEXT"; |
| 1341 | |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1342 | /** |
Michael Wright | 8ab940a | 2014-09-01 11:01:27 -0700 | [diff] [blame] | 1343 | * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a |
| 1344 | * keyboard as the primary input device for assistance. |
| 1345 | */ |
| 1346 | public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = |
| 1347 | "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; |
| 1348 | |
| 1349 | /** |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 1350 | * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id |
| 1351 | * that was used to invoke the assist. |
| 1352 | */ |
| 1353 | public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = |
| 1354 | "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; |
| 1355 | |
| 1356 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 1357 | * Activity Action: List all available applications. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1358 | * <p>Input: Nothing. |
| 1359 | * <p>Output: nothing. |
| 1360 | */ |
| 1361 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1362 | public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; |
| 1363 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 1364 | * Activity Action: Show settings for choosing wallpaper. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1365 | * <p>Input: Nothing. |
| 1366 | * <p>Output: Nothing. |
| 1367 | */ |
| 1368 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1369 | public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; |
| 1370 | |
| 1371 | /** |
| 1372 | * Activity Action: Show activity for reporting a bug. |
| 1373 | * <p>Input: Nothing. |
| 1374 | * <p>Output: Nothing. |
| 1375 | */ |
| 1376 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1377 | public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; |
| 1378 | |
| 1379 | /** |
| 1380 | * Activity Action: Main entry point for factory tests. Only used when |
| 1381 | * the device is booting in factory test node. The implementing package |
| 1382 | * must be installed in the system image. |
| 1383 | * <p>Input: nothing |
| 1384 | * <p>Output: nothing |
| 1385 | */ |
| 1386 | public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; |
| 1387 | |
| 1388 | /** |
| 1389 | * Activity Action: The user pressed the "call" button to go to the dialer |
| 1390 | * or other appropriate UI for placing a call. |
| 1391 | * <p>Input: Nothing. |
| 1392 | * <p>Output: Nothing. |
| 1393 | */ |
| 1394 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1395 | public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; |
| 1396 | |
| 1397 | /** |
| 1398 | * Activity Action: Start Voice Command. |
| 1399 | * <p>Input: Nothing. |
| 1400 | * <p>Output: Nothing. |
| 1401 | */ |
| 1402 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1403 | 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] | 1404 | |
| 1405 | /** |
| 1406 | * Activity Action: Start action associated with long pressing on the |
| 1407 | * search key. |
| 1408 | * <p>Input: Nothing. |
| 1409 | * <p>Output: Nothing. |
| 1410 | */ |
| 1411 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1412 | 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] | 1413 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1414 | /** |
| 1415 | * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. |
| 1416 | * This intent is delivered to the package which installed the application, usually |
Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 1417 | * Google Play. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1418 | * <p>Input: No data is specified. The bug report is passed in using |
| 1419 | * an {@link #EXTRA_BUG_REPORT} field. |
| 1420 | * <p>Output: Nothing. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1421 | * |
| 1422 | * @see #EXTRA_BUG_REPORT |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1423 | */ |
| 1424 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1425 | public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; |
Dianne Hackborn | 3d74bb4 | 2009-06-19 10:35:21 -0700 | [diff] [blame] | 1426 | |
| 1427 | /** |
| 1428 | * Activity Action: Show power usage information to the user. |
| 1429 | * <p>Input: Nothing. |
| 1430 | * <p>Output: Nothing. |
| 1431 | */ |
| 1432 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1433 | 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] | 1434 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1435 | /** |
| 1436 | * Activity Action: Setup wizard to launch after a platform update. This |
| 1437 | * activity should have a string meta-data field associated with it, |
| 1438 | * {@link #METADATA_SETUP_VERSION}, which defines the current version of |
| 1439 | * the platform for setup. The activity will be launched only if |
| 1440 | * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the |
| 1441 | * same value. |
| 1442 | * <p>Input: Nothing. |
| 1443 | * <p>Output: Nothing. |
| 1444 | * @hide |
| 1445 | */ |
| 1446 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1447 | public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1448 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1449 | /** |
Clara Bayarri | eb3c2d3 | 2016-04-01 14:37:32 +0100 | [diff] [blame] | 1450 | * Activity Action: Start the Keyboard Shortcuts Helper screen. |
| 1451 | * <p>Input: Nothing. |
| 1452 | * <p>Output: Nothing. |
| 1453 | * @hide |
| 1454 | */ |
| 1455 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1456 | public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = |
| 1457 | "android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; |
| 1458 | |
| 1459 | /** |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 1460 | * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. |
| 1461 | * <p>Input: Nothing. |
| 1462 | * <p>Output: Nothing. |
| 1463 | * @hide |
| 1464 | */ |
| 1465 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1466 | public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = |
| 1467 | "android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; |
| 1468 | |
| 1469 | /** |
Jeff Sharkey | 7f86827 | 2011-06-05 16:05:02 -0700 | [diff] [blame] | 1470 | * Activity Action: Show settings for managing network data usage of a |
| 1471 | * specific application. Applications should define an activity that offers |
| 1472 | * options to control data usage. |
| 1473 | */ |
| 1474 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1475 | public static final String ACTION_MANAGE_NETWORK_USAGE = |
| 1476 | "android.intent.action.MANAGE_NETWORK_USAGE"; |
| 1477 | |
| 1478 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1479 | * Activity Action: Launch application installer. |
| 1480 | * <p> |
Todd Kennedy | 9cc589a | 2016-08-18 16:23:17 -0700 | [diff] [blame] | 1481 | * Input: The data must be a content: URI at which the application |
Dianne Hackborn | eba784ff | 2012-09-19 12:42:37 -0700 | [diff] [blame] | 1482 | * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, |
| 1483 | * you can also use "package:<package-name>" to install an application for the |
| 1484 | * 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] | 1485 | * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, |
| 1486 | * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. |
| 1487 | * <p> |
| 1488 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1489 | * succeeded. |
Svet Ganov | 86877e4 | 2015-05-28 08:19:48 -0700 | [diff] [blame] | 1490 | * <p> |
| 1491 | * <strong>Note:</strong>If your app is targeting API level higher than 22 you |
| 1492 | * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} |
| 1493 | * in order to launch the application installer. |
| 1494 | * </p> |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1495 | * |
| 1496 | * @see #EXTRA_INSTALLER_PACKAGE_NAME |
| 1497 | * @see #EXTRA_NOT_UNKNOWN_SOURCE |
| 1498 | * @see #EXTRA_RETURN_RESULT |
| 1499 | */ |
| 1500 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1501 | public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; |
| 1502 | |
| 1503 | /** |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1504 | * Activity Action: Launch ephemeral installer. |
| 1505 | * <p> |
| 1506 | * Input: The data must be a http: URI that the ephemeral application is registered |
| 1507 | * to handle. |
| 1508 | * <p class="note"> |
| 1509 | * This is a protected intent that can only be sent by the system. |
| 1510 | * </p> |
| 1511 | * |
| 1512 | * @hide |
| 1513 | */ |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1514 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1515 | public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE |
| 1516 | = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE"; |
| 1517 | |
| 1518 | /** |
| 1519 | * Service Action: Resolve ephemeral application. |
| 1520 | * <p> |
| 1521 | * The system will have a persistent connection to this service. |
| 1522 | * This is a protected intent that can only be sent by the system. |
| 1523 | * </p> |
| 1524 | * |
| 1525 | * @hide |
| 1526 | */ |
Todd Kennedy | b8a279e | 2015-11-18 09:59:47 -0800 | [diff] [blame] | 1527 | @SdkConstant(SdkConstantType.SERVICE_ACTION) |
| 1528 | public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE |
| 1529 | = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE"; |
| 1530 | |
| 1531 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1532 | * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1533 | * package. Specifies the installer package name; this package will receive the |
| 1534 | * {@link #ACTION_APP_ERROR} intent. |
| 1535 | */ |
| 1536 | public static final String EXTRA_INSTALLER_PACKAGE_NAME |
| 1537 | = "android.intent.extra.INSTALLER_PACKAGE_NAME"; |
| 1538 | |
| 1539 | /** |
| 1540 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1541 | * package. Specifies that the application being installed should not be |
| 1542 | * treated as coming from an unknown source, but as coming from the app |
| 1543 | * invoking the Intent. For this to work you must start the installer with |
| 1544 | * startActivityForResult(). |
| 1545 | */ |
| 1546 | public static final String EXTRA_NOT_UNKNOWN_SOURCE |
| 1547 | = "android.intent.extra.NOT_UNKNOWN_SOURCE"; |
| 1548 | |
| 1549 | /** |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1550 | * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and |
| 1551 | * {@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] | 1552 | * data field originated from. |
| 1553 | */ |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1554 | public static final String EXTRA_ORIGINATING_URI |
| 1555 | = "android.intent.extra.ORIGINATING_URI"; |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1556 | |
| 1557 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1558 | * This extra can be used with any Intent used to launch an activity, supplying information |
| 1559 | * about who is launching that activity. This field contains a {@link android.net.Uri} |
| 1560 | * object, typically an http: or https: URI of the web site that the referral came from; |
| 1561 | * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify |
| 1562 | * a native application that it came from. |
| 1563 | * |
| 1564 | * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} |
| 1565 | * instead of directly retrieving the extra. It is also valid for applications to |
| 1566 | * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create |
| 1567 | * a string, not a Uri; the field here, if supplied, will always take precedence, |
| 1568 | * however.</p> |
| 1569 | * |
| 1570 | * @see #EXTRA_REFERRER_NAME |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1571 | */ |
| 1572 | public static final String EXTRA_REFERRER |
| 1573 | = "android.intent.extra.REFERRER"; |
| 1574 | |
| 1575 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1576 | * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather |
| 1577 | * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can |
| 1578 | * not be created, in particular when Intent extras are supplied through the |
| 1579 | * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} |
| 1580 | * schemes. |
| 1581 | * |
| 1582 | * @see #EXTRA_REFERRER |
| 1583 | */ |
| 1584 | public static final String EXTRA_REFERRER_NAME |
| 1585 | = "android.intent.extra.REFERRER_NAME"; |
| 1586 | |
| 1587 | /** |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1588 | * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and |
Gina Dimino | 98ad888 | 2016-05-31 17:25:48 -0700 | [diff] [blame] | 1589 | * {@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] | 1590 | * @hide |
| 1591 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1592 | @SystemApi |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1593 | public static final String EXTRA_ORIGINATING_UID |
| 1594 | = "android.intent.extra.ORIGINATING_UID"; |
| 1595 | |
| 1596 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1597 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1598 | * package. Tells the installer UI to skip the confirmation with the user |
| 1599 | * if the .apk is replacing an existing one. |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1600 | * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android |
| 1601 | * will no longer show an interstitial message about updating existing |
| 1602 | * applications so this is no longer needed. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1603 | */ |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1604 | @Deprecated |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1605 | public static final String EXTRA_ALLOW_REPLACE |
| 1606 | = "android.intent.extra.ALLOW_REPLACE"; |
| 1607 | |
| 1608 | /** |
| 1609 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or |
| 1610 | * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should |
| 1611 | * return to the application the result code of the install/uninstall. The returned result |
| 1612 | * code will be {@link android.app.Activity#RESULT_OK} on success or |
| 1613 | * {@link android.app.Activity#RESULT_FIRST_USER} on failure. |
| 1614 | */ |
| 1615 | public static final String EXTRA_RETURN_RESULT |
| 1616 | = "android.intent.extra.RETURN_RESULT"; |
| 1617 | |
| 1618 | /** |
| 1619 | * Package manager install result code. @hide because result codes are not |
| 1620 | * yet ready to be exposed. |
| 1621 | */ |
| 1622 | public static final String EXTRA_INSTALL_RESULT |
| 1623 | = "android.intent.extra.INSTALL_RESULT"; |
| 1624 | |
| 1625 | /** |
| 1626 | * Activity Action: Launch application uninstaller. |
| 1627 | * <p> |
| 1628 | * Input: The data must be a package: URI whose scheme specific part is |
| 1629 | * the package name of the current installed package to be uninstalled. |
| 1630 | * You can optionally supply {@link #EXTRA_RETURN_RESULT}. |
| 1631 | * <p> |
| 1632 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1633 | * succeeded. |
| 1634 | */ |
| 1635 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1636 | public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; |
| 1637 | |
| 1638 | /** |
msnider | 3c191b8 | 2017-01-23 14:23:16 -0800 | [diff] [blame] | 1639 | * Activity Action: Launch application uninstaller. |
| 1640 | * <p> |
| 1641 | * Input: The data must be a package: URI whose scheme specific part is |
| 1642 | * the package name of the current installed package to be uninstalled. |
| 1643 | * You can optionally supply {@link #EXTRA_RETURN_RESULT}. |
| 1644 | * <p> |
| 1645 | * Output: Nothing. |
| 1646 | * </p> |
| 1647 | */ |
| 1648 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1649 | public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE"; |
| 1650 | |
| 1651 | /** |
Dianne Hackborn | 6d235d8 | 2012-09-16 18:25:40 -0700 | [diff] [blame] | 1652 | * Specify whether the package should be uninstalled for all users. |
| 1653 | * @hide because these should not be part of normal application flow. |
| 1654 | */ |
| 1655 | public static final String EXTRA_UNINSTALL_ALL_USERS |
| 1656 | = "android.intent.extra.UNINSTALL_ALL_USERS"; |
| 1657 | |
| 1658 | /** |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1659 | * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity |
| 1660 | * describing the last run version of the platform that was setup. |
| 1661 | * @hide |
| 1662 | */ |
| 1663 | public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; |
| 1664 | |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1665 | /** |
| 1666 | * Activity action: Launch UI to manage the permissions of an app. |
| 1667 | * <p> |
| 1668 | * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions |
| 1669 | * will be managed by the launched UI. |
| 1670 | * </p> |
| 1671 | * <p> |
| 1672 | * Output: Nothing. |
| 1673 | * </p> |
| 1674 | * |
| 1675 | * @see #EXTRA_PACKAGE_NAME |
| 1676 | * |
| 1677 | * @hide |
| 1678 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1679 | @SystemApi |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1680 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1681 | public static final String ACTION_MANAGE_APP_PERMISSIONS = |
| 1682 | "android.intent.action.MANAGE_APP_PERMISSIONS"; |
| 1683 | |
| 1684 | /** |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1685 | * Activity action: Launch UI to manage permissions. |
| 1686 | * <p> |
| 1687 | * Input: Nothing. |
| 1688 | * </p> |
| 1689 | * <p> |
| 1690 | * Output: Nothing. |
| 1691 | * </p> |
| 1692 | * |
| 1693 | * @hide |
| 1694 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1695 | @SystemApi |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1696 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1697 | public static final String ACTION_MANAGE_PERMISSIONS = |
| 1698 | "android.intent.action.MANAGE_PERMISSIONS"; |
| 1699 | |
| 1700 | /** |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1701 | * Activity action: Launch UI to review permissions for an app. |
| 1702 | * The system uses this intent if permission review for apps not |
| 1703 | * supporting the new runtime permissions model is enabled. In |
| 1704 | * this mode a permission review is required before any of the |
| 1705 | * app components can run. |
| 1706 | * <p> |
| 1707 | * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose |
| 1708 | * permissions will be reviewed (mandatory). |
| 1709 | * </p> |
| 1710 | * <p> |
| 1711 | * Input: {@link #EXTRA_INTENT} specifies a pending intent to |
| 1712 | * be fired after the permission review (optional). |
| 1713 | * </p> |
| 1714 | * <p> |
| 1715 | * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to |
| 1716 | * be invoked after the permission review (optional). |
| 1717 | * </p> |
| 1718 | * <p> |
| 1719 | * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent |
| 1720 | * passed via {@link #EXTRA_INTENT} needs a result (optional). |
| 1721 | * </p> |
| 1722 | * <p> |
| 1723 | * Output: Nothing. |
| 1724 | * </p> |
| 1725 | * |
| 1726 | * @see #EXTRA_PACKAGE_NAME |
| 1727 | * @see #EXTRA_INTENT |
| 1728 | * @see #EXTRA_REMOTE_CALLBACK |
| 1729 | * @see #EXTRA_RESULT_NEEDED |
| 1730 | * |
| 1731 | * @hide |
| 1732 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1733 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1734 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1735 | public static final String ACTION_REVIEW_PERMISSIONS = |
| 1736 | "android.intent.action.REVIEW_PERMISSIONS"; |
| 1737 | |
| 1738 | /** |
| 1739 | * Intent extra: A callback for reporting remote result as a bundle. |
| 1740 | * <p> |
| 1741 | * Type: IRemoteCallback |
| 1742 | * </p> |
| 1743 | * |
| 1744 | * @hide |
| 1745 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1746 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1747 | public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; |
| 1748 | |
| 1749 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1750 | * Intent extra: An app package name. |
| 1751 | * <p> |
| 1752 | * Type: String |
Svet Ganov | 0b31670 | 2015-05-23 13:25:11 -0700 | [diff] [blame] | 1753 | * </p> |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1754 | * |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1755 | */ |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1756 | public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; |
| 1757 | |
| 1758 | /** |
Todd Kennedy | e5195dd | 2016-10-19 15:29:19 -0700 | [diff] [blame] | 1759 | * Intent extra: An app split name. |
| 1760 | * <p> |
| 1761 | * Type: String |
| 1762 | * </p> |
| 1763 | * @hide |
| 1764 | */ |
| 1765 | @SystemApi |
| 1766 | public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; |
| 1767 | |
| 1768 | /** |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1769 | * Intent extra: An extra for specifying whether a result is needed. |
| 1770 | * <p> |
| 1771 | * Type: boolean |
| 1772 | * </p> |
| 1773 | * |
| 1774 | * @hide |
| 1775 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1776 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1777 | public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; |
| 1778 | |
| 1779 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1780 | * Activity action: Launch UI to manage which apps have a given permission. |
| 1781 | * <p> |
| 1782 | * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access |
| 1783 | * to which will be managed by the launched UI. |
| 1784 | * </p> |
| 1785 | * <p> |
| 1786 | * Output: Nothing. |
| 1787 | * </p> |
| 1788 | * |
| 1789 | * @see #EXTRA_PERMISSION_NAME |
| 1790 | * |
| 1791 | * @hide |
| 1792 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1793 | @SystemApi |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1794 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1795 | public static final String ACTION_MANAGE_PERMISSION_APPS = |
| 1796 | "android.intent.action.MANAGE_PERMISSION_APPS"; |
| 1797 | |
| 1798 | /** |
| 1799 | * Intent extra: The name of a permission. |
| 1800 | * <p> |
| 1801 | * Type: String |
| 1802 | * </p> |
| 1803 | * |
| 1804 | * @hide |
| 1805 | */ |
| 1806 | @SystemApi |
| 1807 | public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; |
| 1808 | |
Svet Ganov | 0f4928f | 2017-02-02 20:02:51 -0800 | [diff] [blame] | 1809 | /** |
| 1810 | * Intent extra: An id if an autofill item ({@link |
| 1811 | * android.view.autofill.Dataset} or {@link android.view.autofill.FillResponse}). |
| 1812 | * <p> |
| 1813 | * Type: String |
| 1814 | * </p> |
| 1815 | */ |
| 1816 | public static final String EXTRA_AUTO_FILL_ITEM_ID = "android.intent.extra.AUTO_FILL_ITEM_ID"; |
| 1817 | |
| 1818 | /** |
| 1819 | * Intent extra: The assist structure which captures the filled screen. |
| 1820 | * <p> |
| 1821 | * Type: {@link android.app.assist.AssistStructure} |
| 1822 | * </p> |
| 1823 | */ |
| 1824 | public static final String EXTRA_AUTO_FILL_ASSIST_STRUCTURE = |
| 1825 | "android.intent.extra.AUTO_FILL_ASSIST_STRUCTURE"; |
| 1826 | |
| 1827 | /** |
| 1828 | * Intent extra: The metadata associated with the authenticated entity ({@link |
| 1829 | * android.view.autofill.Dataset} or {@link android.view.autofill.FillResponse}). |
| 1830 | * <p> |
| 1831 | * Type: {@link android.os.Bundle} |
| 1832 | * </p> |
| 1833 | */ |
| 1834 | public static final String EXTRA_AUTO_FILL_EXTRAS = "android.intent.extra.AUTO_FILL_EXTRAS"; |
| 1835 | |
| 1836 | /** |
| 1837 | * Intent extra: A callback to report an authentication result. |
| 1838 | * <p> |
| 1839 | * Type: {@link android.view.autofill.FillResponse} |
| 1840 | * </p> |
| 1841 | */ |
| 1842 | public static final String EXTRA_AUTO_FILL_CALLBACK = "android.intent.extra.AUTO_FILL_CALLBACK"; |
| 1843 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1844 | // --------------------------------------------------------------------- |
| 1845 | // --------------------------------------------------------------------- |
| 1846 | // Standard intent broadcast actions (see action variable). |
| 1847 | |
| 1848 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1849 | * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. |
| 1850 | * <p> |
| 1851 | * For historical reasons, the name of this broadcast action refers to the power |
| 1852 | * state of the screen but it is actually sent in response to changes in the |
| 1853 | * overall interactive state of the device. |
| 1854 | * </p><p> |
| 1855 | * This broadcast is sent when the device becomes non-interactive which may have |
| 1856 | * nothing to do with the screen turning off. To determine the |
| 1857 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1858 | * </p><p> |
| 1859 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1860 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1861 | * You <em>cannot</em> receive this through components declared in |
| 1862 | * manifests, only by explicitly registering for it with |
| 1863 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1864 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1865 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1866 | * <p class="note">This is a protected intent that can only be sent |
| 1867 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1868 | */ |
| 1869 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1870 | public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1871 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1872 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1873 | * Broadcast Action: Sent when the device wakes up and becomes interactive. |
| 1874 | * <p> |
| 1875 | * For historical reasons, the name of this broadcast action refers to the power |
| 1876 | * state of the screen but it is actually sent in response to changes in the |
| 1877 | * overall interactive state of the device. |
| 1878 | * </p><p> |
| 1879 | * This broadcast is sent when the device becomes interactive which may have |
| 1880 | * nothing to do with the screen turning on. To determine the |
| 1881 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1882 | * </p><p> |
| 1883 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1884 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1885 | * You <em>cannot</em> receive this through components declared in |
| 1886 | * manifests, only by explicitly registering for it with |
| 1887 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1888 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1889 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1890 | * <p class="note">This is a protected intent that can only be sent |
| 1891 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1892 | */ |
| 1893 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1894 | 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] | 1895 | |
| 1896 | /** |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 1897 | * Broadcast Action: Sent after the system stops dreaming. |
| 1898 | * |
| 1899 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1900 | * It is only sent to registered receivers.</p> |
| 1901 | */ |
| 1902 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1903 | public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; |
| 1904 | |
| 1905 | /** |
| 1906 | * Broadcast Action: Sent after the system starts dreaming. |
| 1907 | * |
| 1908 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1909 | * It is only sent to registered receivers.</p> |
| 1910 | */ |
| 1911 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1912 | public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; |
| 1913 | |
| 1914 | /** |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1915 | * 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] | 1916 | * keyguard is gone). |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1917 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1918 | * <p class="note">This is a protected intent that can only be sent |
| 1919 | * by the system. |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1920 | */ |
| 1921 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 1922 | 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] | 1923 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1924 | /** |
| 1925 | * Broadcast Action: The current time has changed. Sent every |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1926 | * minute. You <em>cannot</em> receive this through components declared |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1927 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1928 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1929 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1930 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1931 | * <p class="note">This is a protected intent that can only be sent |
| 1932 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1933 | */ |
| 1934 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1935 | public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; |
| 1936 | /** |
| 1937 | * Broadcast Action: The time was set. |
| 1938 | */ |
| 1939 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1940 | public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; |
| 1941 | /** |
| 1942 | * Broadcast Action: The date has changed. |
| 1943 | */ |
| 1944 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1945 | public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; |
| 1946 | /** |
| 1947 | * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> |
| 1948 | * <ul> |
| 1949 | * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li> |
| 1950 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1951 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1952 | * <p class="note">This is a protected intent that can only be sent |
| 1953 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1954 | */ |
| 1955 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1956 | public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; |
| 1957 | /** |
Robert Greenwalt | 03595d0 | 2010-11-02 14:08:23 -0700 | [diff] [blame] | 1958 | * Clear DNS Cache Action: This is broadcast when networks have changed and old |
| 1959 | * DNS entries should be tossed. |
| 1960 | * @hide |
| 1961 | */ |
| 1962 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1963 | public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE"; |
| 1964 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1965 | * Alarm Changed Action: This is broadcast when the AlarmClock |
| 1966 | * application's alarm is set or unset. It is used by the |
| 1967 | * AlarmClock application and the StatusBar service. |
| 1968 | * @hide |
| 1969 | */ |
| 1970 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1971 | public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1972 | |
| 1973 | /** |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1974 | * Broadcast Action: This is broadcast once, after the user has finished |
| 1975 | * booting, but while still in the "locked" state. It can be used to perform |
| 1976 | * application-specific initialization, such as installing alarms. You must |
| 1977 | * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} |
| 1978 | * permission in order to receive this broadcast. |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1979 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1980 | * This broadcast is sent immediately at boot by all devices (regardless of |
| 1981 | * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or |
| 1982 | * higher. Upon receipt of this broadcast, the user is still locked and only |
| 1983 | * device-protected storage can be accessed safely. If you want to access |
| 1984 | * credential-protected storage, you need to wait for the user to be |
| 1985 | * unlocked (typically by entering their lock pattern or PIN for the first |
| 1986 | * time), after which the {@link #ACTION_USER_UNLOCKED} and |
| 1987 | * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. |
| 1988 | * <p> |
| 1989 | * To receive this broadcast, your receiver component must be marked as |
| 1990 | * being {@link ComponentInfo#directBootAware}. |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1991 | * <p class="note"> |
| 1992 | * 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] | 1993 | * |
| 1994 | * @see Context#createDeviceProtectedStorageContext() |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 1995 | */ |
| 1996 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1997 | public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; |
| 1998 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1999 | /** |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 2000 | * Broadcast Action: This is broadcast once, after the user has finished |
| 2001 | * booting. It can be used to perform application-specific initialization, |
| 2002 | * such as installing alarms. You must hold the |
| 2003 | * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in |
| 2004 | * order to receive this broadcast. |
| 2005 | * <p> |
| 2006 | * This broadcast is sent at boot by all devices (both with and without |
| 2007 | * direct boot support). Upon receipt of this broadcast, the user is |
| 2008 | * unlocked and both device-protected and credential-protected storage can |
| 2009 | * accessed safely. |
| 2010 | * <p> |
| 2011 | * If you need to run while the user is still locked (before they've entered |
| 2012 | * their lock pattern or PIN for the first time), you can listen for the |
| 2013 | * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. |
| 2014 | * <p class="note"> |
| 2015 | * 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] | 2016 | */ |
| 2017 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2018 | public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; |
Jeff Sharkey | bedbaa9 | 2015-12-02 16:42:25 -0700 | [diff] [blame] | 2019 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2020 | /** |
| 2021 | * Broadcast Action: This is broadcast when a user action should request a |
| 2022 | * temporary system dialog to dismiss. Some examples of temporary system |
| 2023 | * dialogs are the notification window-shade and the recent tasks dialog. |
| 2024 | */ |
| 2025 | public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; |
| 2026 | /** |
| 2027 | * Broadcast Action: Trigger the download and eventual installation |
| 2028 | * of a package. |
| 2029 | * <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] | 2030 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2031 | * <p class="note">This is a protected intent that can only be sent |
| 2032 | * by the system. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 2033 | * |
| 2034 | * @deprecated This constant has never been used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2035 | */ |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 2036 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2037 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2038 | public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; |
| 2039 | /** |
| 2040 | * 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] | 2041 | * device. The data contains the name of the package. Note that the |
| 2042 | * newly installed package does <em>not</em> receive this broadcast. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 2043 | * <p>May include the following extras: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2044 | * <ul> |
| 2045 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 2046 | * <li> {@link #EXTRA_REPLACING} is set to true if this is following |
| 2047 | * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. |
| 2048 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2049 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2050 | * <p class="note">This is a protected intent that can only be sent |
| 2051 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2052 | */ |
| 2053 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2054 | public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; |
| 2055 | /** |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2056 | * Broadcast Action: A new version of an application package has been |
| 2057 | * installed, replacing an existing version that was previously installed. |
| 2058 | * The data contains the name of the package. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 2059 | * <p>May include the following extras: |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2060 | * <ul> |
| 2061 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 2062 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2063 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2064 | * <p class="note">This is a protected intent that can only be sent |
| 2065 | * by the system. |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2066 | */ |
| 2067 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2068 | public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; |
| 2069 | /** |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 2070 | * Broadcast Action: A new version of your application has been installed |
| 2071 | * over an existing one. This is only sent to the application that was |
| 2072 | * replaced. It does not contain any additional data; to receive it, just |
| 2073 | * use an intent filter for this action. |
| 2074 | * |
| 2075 | * <p class="note">This is a protected intent that can only be sent |
| 2076 | * by the system. |
| 2077 | */ |
| 2078 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2079 | public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; |
| 2080 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2081 | * Broadcast Action: An existing application package has been removed from |
| 2082 | * the device. The data contains the name of the package. The package |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2083 | * 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] | 2084 | * <ul> |
| 2085 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 2086 | * to the package. |
| 2087 | * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire |
| 2088 | * application -- data and code -- is being removed. |
| 2089 | * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed |
| 2090 | * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. |
| 2091 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2092 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2093 | * <p class="note">This is a protected intent that can only be sent |
| 2094 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2095 | */ |
| 2096 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2097 | public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; |
| 2098 | /** |
Dianne Hackborn | f9abb40 | 2011-08-10 15:00:59 -0700 | [diff] [blame] | 2099 | * Broadcast Action: An existing application package has been completely |
| 2100 | * removed from the device. The data contains the name of the package. |
| 2101 | * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when |
| 2102 | * {@link #EXTRA_DATA_REMOVED} is true and |
| 2103 | * {@link #EXTRA_REPLACING} is false of that broadcast. |
| 2104 | * |
| 2105 | * <ul> |
| 2106 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 2107 | * to the package. |
| 2108 | * </ul> |
| 2109 | * |
| 2110 | * <p class="note">This is a protected intent that can only be sent |
| 2111 | * by the system. |
| 2112 | */ |
| 2113 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2114 | public static final String ACTION_PACKAGE_FULLY_REMOVED |
| 2115 | = "android.intent.action.PACKAGE_FULLY_REMOVED"; |
| 2116 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2117 | * Broadcast Action: An existing application package has been changed (for |
| 2118 | * example, a component has been enabled or disabled). The data contains |
| 2119 | * the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2120 | * <ul> |
| 2121 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 2122 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 2123 | * of the changed components (or the package name itself). |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 2124 | * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the |
| 2125 | * default action of restarting the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2126 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2127 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2128 | * <p class="note">This is a protected intent that can only be sent |
| 2129 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2130 | */ |
| 2131 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2132 | public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; |
| 2133 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 2134 | * @hide |
| 2135 | * Broadcast Action: Ask system services if there is any reason to |
| 2136 | * restart the given package. The data contains the name of the |
| 2137 | * package. |
| 2138 | * <ul> |
| 2139 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2140 | * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. |
| 2141 | * </ul> |
| 2142 | * |
| 2143 | * <p class="note">This is a protected intent that can only be sent |
| 2144 | * by the system. |
| 2145 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 2146 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 2147 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2148 | public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; |
| 2149 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2150 | * Broadcast Action: The user has restarted a package, and all of its |
| 2151 | * processes have been killed. All runtime state |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2152 | * associated with it (processes, alarms, notifications, etc) should |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 2153 | * be removed. Note that the restarted package does <em>not</em> |
| 2154 | * receive this broadcast. |
| 2155 | * The data contains the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2156 | * <ul> |
| 2157 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2158 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2159 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2160 | * <p class="note">This is a protected intent that can only be sent |
| 2161 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2162 | */ |
| 2163 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2164 | public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; |
| 2165 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2166 | * Broadcast Action: The user has cleared the data of a package. This should |
| 2167 | * 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] | 2168 | * its persistent data is erased and this broadcast sent. |
| 2169 | * Note that the cleared package does <em>not</em> |
| 2170 | * 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] | 2171 | * <ul> |
| 2172 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 2173 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2174 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2175 | * <p class="note">This is a protected intent that can only be sent |
| 2176 | * by the system. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2177 | */ |
| 2178 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2179 | public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; |
| 2180 | /** |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 2181 | * Broadcast Action: Packages have been suspended. |
| 2182 | * <p>Includes the following extras: |
| 2183 | * <ul> |
| 2184 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended |
| 2185 | * </ul> |
| 2186 | * |
| 2187 | * <p class="note">This is a protected intent that can only be sent |
| 2188 | * by the system. It is only sent to registered receivers. |
| 2189 | */ |
| 2190 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2191 | public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; |
| 2192 | /** |
| 2193 | * Broadcast Action: Packages have been unsuspended. |
| 2194 | * <p>Includes the following extras: |
| 2195 | * <ul> |
| 2196 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended |
| 2197 | * </ul> |
| 2198 | * |
| 2199 | * <p class="note">This is a protected intent that can only be sent |
| 2200 | * by the system. It is only sent to registered receivers. |
| 2201 | */ |
| 2202 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2203 | public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; |
| 2204 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2205 | * Broadcast Action: A user ID has been removed from the system. The user |
| 2206 | * ID number is stored in the extra data under {@link #EXTRA_UID}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2207 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2208 | * <p class="note">This is a protected intent that can only be sent |
| 2209 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2210 | */ |
| 2211 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2212 | public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2213 | |
| 2214 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2215 | * Broadcast Action: Sent to the installer package of an application when |
| 2216 | * that application is first launched (that is the first time it is moved |
| 2217 | * 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] | 2218 | * |
| 2219 | * <p class="note">This is a protected intent that can only be sent |
| 2220 | * by the system. |
| 2221 | */ |
| 2222 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2223 | public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; |
| 2224 | |
| 2225 | /** |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2226 | * Broadcast Action: Sent to the system package verifier when a package |
| 2227 | * needs to be verified. The data contains the package URI. |
| 2228 | * <p class="note"> |
| 2229 | * This is a protected intent that can only be sent by the system. |
| 2230 | * </p> |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2231 | */ |
| 2232 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2233 | public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; |
| 2234 | |
| 2235 | /** |
rich cannings | d1b5cfc | 2012-08-29 14:49:51 -0700 | [diff] [blame] | 2236 | * Broadcast Action: Sent to the system package verifier when a package is |
| 2237 | * verified. The data contains the package URI. |
| 2238 | * <p class="note"> |
| 2239 | * This is a protected intent that can only be sent by the system. |
| 2240 | */ |
| 2241 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2242 | public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; |
| 2243 | |
| 2244 | /** |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2245 | * Broadcast Action: Sent to the system intent filter verifier when an |
| 2246 | * intent filter needs to be verified. The data contains the filter data |
| 2247 | * hosts to be verified against. |
Fabrice Di Meglio | 1c1b471 | 2014-11-19 17:12:32 -0800 | [diff] [blame] | 2248 | * <p class="note"> |
| 2249 | * This is a protected intent that can only be sent by the system. |
| 2250 | * </p> |
| 2251 | * |
| 2252 | * @hide |
| 2253 | */ |
| 2254 | @SystemApi |
| 2255 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2256 | public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; |
| 2257 | |
| 2258 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2259 | * Broadcast Action: Resources for a set of packages (which were |
| 2260 | * previously unavailable) are currently |
| 2261 | * available since the media on which they exist is available. |
| 2262 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2263 | * list of packages whose availability changed. |
| 2264 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2265 | * list of uids of packages whose availability changed. |
| 2266 | * Note that the |
| 2267 | * packages in this list do <em>not</em> receive this broadcast. |
| 2268 | * The specified set of packages are now available on the system. |
| 2269 | * <p>Includes the following extras: |
| 2270 | * <ul> |
| 2271 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2272 | * whose resources(were previously unavailable) are currently available. |
| 2273 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the |
| 2274 | * packages whose resources(were previously unavailable) |
| 2275 | * are currently available. |
| 2276 | * </ul> |
| 2277 | * |
| 2278 | * <p class="note">This is a protected intent that can only be sent |
| 2279 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2280 | */ |
| 2281 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2282 | public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = |
| 2283 | "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2284 | |
| 2285 | /** |
| 2286 | * Broadcast Action: Resources for a set of packages are currently |
| 2287 | * unavailable since the media on which they exist is unavailable. |
| 2288 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2289 | * list of packages whose availability changed. |
| 2290 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2291 | * list of uids of packages whose availability changed. |
| 2292 | * The specified set of packages can no longer be |
| 2293 | * launched and are practically unavailable on the system. |
| 2294 | * <p>Inclues the following extras: |
| 2295 | * <ul> |
| 2296 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2297 | * whose resources are no longer available. |
| 2298 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages |
| 2299 | * whose resources are no longer available. |
| 2300 | * </ul> |
| 2301 | * |
| 2302 | * <p class="note">This is a protected intent that can only be sent |
| 2303 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2304 | */ |
| 2305 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2306 | public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = |
Joe Onorato | 8a051a4 | 2010-03-04 15:54:50 -0500 | [diff] [blame] | 2307 | "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2308 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2309 | /** |
Makoto Onuki | 1030520 | 2016-07-14 18:14:08 -0700 | [diff] [blame] | 2310 | * Broadcast Action: preferred activities have changed *explicitly*. |
| 2311 | * |
| 2312 | * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. |
| 2313 | * when an app is installed or uninstalled, but in such cases this broadcast will *not* |
| 2314 | * be sent. |
| 2315 | * |
| 2316 | * {@link #EXTRA_USER_HANDLE} contains the user ID in question. |
| 2317 | * |
| 2318 | * @hide |
| 2319 | */ |
| 2320 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2321 | public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = |
| 2322 | "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; |
| 2323 | |
| 2324 | |
| 2325 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2326 | * Broadcast Action: The current system wallpaper has changed. See |
Scott Main | 8b2e000 | 2009-09-29 18:17:31 -0700 | [diff] [blame] | 2327 | * {@link android.app.WallpaperManager} for retrieving the new wallpaper. |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2328 | * This should <em>only</em> be used to determine when the wallpaper |
| 2329 | * has changed to show the new wallpaper to the user. You should certainly |
| 2330 | * never, in response to this, change the wallpaper or other attributes of |
| 2331 | * it such as the suggested size. That would be crazy, right? You'd cause |
| 2332 | * all kinds of loops, especially if other apps are doing similar things, |
| 2333 | * right? Of course. So please don't do this. |
| 2334 | * |
| 2335 | * @deprecated Modern applications should use |
| 2336 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER |
| 2337 | * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper |
| 2338 | * shown behind their UI, rather than watching for this broadcast and |
| 2339 | * rendering the wallpaper on their own. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2340 | */ |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2341 | @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2342 | public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; |
| 2343 | /** |
| 2344 | * Broadcast Action: The current device {@link android.content.res.Configuration} |
| 2345 | * (orientation, locale, etc) has changed. When such a change happens, the |
| 2346 | * UIs (view hierarchy) will need to be rebuilt based on this new |
| 2347 | * information; for the most part, applications don't need to worry about |
| 2348 | * this, because the system will take care of stopping and restarting the |
| 2349 | * application to make sure it sees the new changes. Some system code that |
| 2350 | * can not be restarted will need to watch for this action and handle it |
| 2351 | * appropriately. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2352 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2353 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2354 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2355 | * in manifests, only by explicitly registering for it with |
| 2356 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2357 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2358 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2359 | * <p class="note">This is a protected intent that can only be sent |
| 2360 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2361 | * |
| 2362 | * @see android.content.res.Configuration |
| 2363 | */ |
| 2364 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2365 | public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; |
| 2366 | /** |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2367 | * Broadcast Action: The current device's locale has changed. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2368 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2369 | * <p class="note">This is a protected intent that can only be sent |
| 2370 | * by the system. |
| 2371 | */ |
| 2372 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2373 | public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; |
| 2374 | /** |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2375 | * Broadcast Action: This is a <em>sticky broadcast</em> containing the |
| 2376 | * charging state, level, and other information about the battery. |
| 2377 | * See {@link android.os.BatteryManager} for documentation on the |
| 2378 | * contents of the Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2379 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2380 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2381 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2382 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2383 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2384 | * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, |
| 2385 | * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, |
| 2386 | * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related |
| 2387 | * broadcasts that are sent and can be received through manifest |
| 2388 | * receivers. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2389 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2390 | * <p class="note">This is a protected intent that can only be sent |
| 2391 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2392 | */ |
| 2393 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2394 | public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; |
| 2395 | /** |
| 2396 | * Broadcast Action: Indicates low battery condition on the device. |
| 2397 | * This broadcast corresponds to the "Low battery warning" system dialog. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2398 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2399 | * <p class="note">This is a protected intent that can only be sent |
| 2400 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2401 | */ |
| 2402 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2403 | public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; |
| 2404 | /** |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2405 | * Broadcast Action: Indicates the battery is now okay after being low. |
| 2406 | * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has |
| 2407 | * gone back up to an okay state. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2408 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2409 | * <p class="note">This is a protected intent that can only be sent |
| 2410 | * by the system. |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2411 | */ |
| 2412 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2413 | public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; |
| 2414 | /** |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2415 | * Broadcast Action: External power has been connected to the device. |
| 2416 | * This is intended for applications that wish to register specifically to this notification. |
| 2417 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2418 | * stay active to receive this notification. This action can be used to implement actions |
| 2419 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2420 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2421 | * <p class="note">This is a protected intent that can only be sent |
| 2422 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2423 | */ |
| 2424 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2425 | 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] | 2426 | /** |
| 2427 | * Broadcast Action: External power has been removed from the device. |
| 2428 | * This is intended for applications that wish to register specifically to this notification. |
| 2429 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2430 | * 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] | 2431 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2432 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2433 | * <p class="note">This is a protected intent that can only be sent |
| 2434 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2435 | */ |
| 2436 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Baptiste Queru | 1ef4564 | 2008-10-24 11:49:25 -0700 | [diff] [blame] | 2437 | public static final String ACTION_POWER_DISCONNECTED = |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2438 | "android.intent.action.ACTION_POWER_DISCONNECTED"; |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2439 | /** |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2440 | * Broadcast Action: Device is shutting down. |
| 2441 | * This is broadcast when the device is being shut down (completely turned |
| 2442 | * off, not sleeping). Once the broadcast is complete, the final shutdown |
| 2443 | * will proceed and all unsaved data lost. Apps will not normally need |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2444 | * to handle this, since the foreground activity will be paused as well. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2445 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2446 | * <p class="note">This is a protected intent that can only be sent |
| 2447 | * by the system. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 2448 | * <p>May include the following extras: |
| 2449 | * <ul> |
| 2450 | * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this |
| 2451 | * shutdown is only for userspace processes. If not set, assumed to be false. |
| 2452 | * </ul> |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2453 | */ |
| 2454 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 2455 | public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2456 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2457 | * Activity Action: Start this activity to request system shutdown. |
| 2458 | * 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] | 2459 | * to request confirmation from the user before shutting down. The optional boolean |
| 2460 | * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to |
| 2461 | * indicate that the shutdown is requested by the user. |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2462 | * |
| 2463 | * <p class="note">This is a protected intent that can only be sent |
| 2464 | * by the system. |
| 2465 | * |
| 2466 | * {@hide} |
| 2467 | */ |
| 2468 | public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN"; |
| 2469 | /** |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2470 | * Broadcast Action: A sticky broadcast that indicates low memory |
| 2471 | * condition on the device |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2472 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2473 | * <p class="note">This is a protected intent that can only be sent |
| 2474 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2475 | */ |
| 2476 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2477 | public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; |
| 2478 | /** |
| 2479 | * Broadcast Action: Indicates low memory condition on the device no longer exists |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2480 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2481 | * <p class="note">This is a protected intent that can only be sent |
| 2482 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2483 | */ |
| 2484 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2485 | public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; |
| 2486 | /** |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2487 | * Broadcast Action: A sticky broadcast that indicates a memory full |
| 2488 | * condition on the device. This is intended for activities that want |
| 2489 | * to be able to fill the data partition completely, leaving only |
| 2490 | * enough free space to prevent system-wide SQLite failures. |
| 2491 | * |
| 2492 | * <p class="note">This is a protected intent that can only be sent |
| 2493 | * by the system. |
| 2494 | * |
| 2495 | * {@hide} |
| 2496 | */ |
| 2497 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2498 | public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; |
| 2499 | /** |
| 2500 | * Broadcast Action: Indicates memory full condition on the device |
| 2501 | * no longer exists. |
| 2502 | * |
| 2503 | * <p class="note">This is a protected intent that can only be sent |
| 2504 | * by the system. |
| 2505 | * |
| 2506 | * {@hide} |
| 2507 | */ |
| 2508 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2509 | public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; |
| 2510 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2511 | * Broadcast Action: Indicates low memory condition notification acknowledged by user |
| 2512 | * and package management should be started. |
| 2513 | * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW |
| 2514 | * notification. |
| 2515 | */ |
| 2516 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2517 | public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; |
| 2518 | /** |
| 2519 | * Broadcast Action: The device has entered USB Mass Storage mode. |
| 2520 | * This is used mainly for the USB Settings panel. |
| 2521 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2522 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2523 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2524 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2525 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2526 | public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; |
| 2527 | |
| 2528 | /** |
| 2529 | * Broadcast Action: The device has exited USB Mass Storage mode. |
| 2530 | * This is used mainly for the USB Settings panel. |
| 2531 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2532 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2533 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2534 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2535 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2536 | public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; |
| 2537 | |
| 2538 | /** |
| 2539 | * Broadcast Action: External media has been removed. |
| 2540 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2541 | */ |
| 2542 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2543 | public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; |
| 2544 | |
| 2545 | /** |
| 2546 | * 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] | 2547 | * 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] | 2548 | */ |
| 2549 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2550 | public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; |
| 2551 | |
| 2552 | /** |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 2553 | * Broadcast Action: External media is present, and being disk-checked |
| 2554 | * 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] | 2555 | */ |
| 2556 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2557 | public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; |
| 2558 | |
| 2559 | /** |
| 2560 | * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) |
| 2561 | * 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] | 2562 | */ |
| 2563 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2564 | public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; |
| 2565 | |
| 2566 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2567 | * Broadcast Action: External media is present and mounted at its mount point. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2568 | * 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] | 2569 | * The Intent contains an extra with name "read-only" and Boolean value to indicate if the |
| 2570 | * media was mounted read only. |
| 2571 | */ |
| 2572 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2573 | public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; |
| 2574 | |
| 2575 | /** |
| 2576 | * 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] | 2577 | * 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] | 2578 | */ |
| 2579 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2580 | public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; |
| 2581 | |
| 2582 | /** |
Mike Lockwood | bf2dd44 | 2010-03-03 06:16:52 -0500 | [diff] [blame] | 2583 | * Broadcast Action: External media is no longer being shared via USB mass storage. |
| 2584 | * The path to the mount point for the previously shared media is contained in the Intent.mData field. |
| 2585 | * |
| 2586 | * @hide |
| 2587 | */ |
| 2588 | public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; |
| 2589 | |
| 2590 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2591 | * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. |
| 2592 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2593 | */ |
| 2594 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2595 | public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; |
| 2596 | |
| 2597 | /** |
| 2598 | * Broadcast Action: External media is present but cannot be mounted. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2599 | * 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] | 2600 | */ |
| 2601 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2602 | public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; |
| 2603 | |
| 2604 | /** |
| 2605 | * Broadcast Action: User has expressed the desire to remove the external storage media. |
| 2606 | * Applications should close all files they have open within the mount point when they receive this intent. |
| 2607 | * The path to the mount point for the media to be ejected is contained in the Intent.mData field. |
| 2608 | */ |
| 2609 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2610 | public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; |
| 2611 | |
| 2612 | /** |
| 2613 | * Broadcast Action: The media scanner has started scanning a directory. |
| 2614 | * The path to the directory being scanned is contained in the Intent.mData field. |
| 2615 | */ |
| 2616 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2617 | public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; |
| 2618 | |
| 2619 | /** |
| 2620 | * Broadcast Action: The media scanner has finished scanning a directory. |
| 2621 | * The path to the scanned directory is contained in the Intent.mData field. |
| 2622 | */ |
| 2623 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2624 | public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; |
| 2625 | |
| 2626 | /** |
| 2627 | * Broadcast Action: Request the media scanner to scan a file and add it to the media database. |
| 2628 | * The path to the file is contained in the Intent.mData field. |
| 2629 | */ |
| 2630 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2631 | public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; |
| 2632 | |
| 2633 | /** |
| 2634 | * Broadcast Action: The "Media Button" was pressed. Includes a single |
| 2635 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2636 | * caused the broadcast. |
| 2637 | */ |
| 2638 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2639 | public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; |
| 2640 | |
| 2641 | /** |
| 2642 | * Broadcast Action: The "Camera Button" was pressed. Includes a single |
| 2643 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2644 | * caused the broadcast. |
| 2645 | */ |
| 2646 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2647 | public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; |
| 2648 | |
| 2649 | // *** NOTE: @todo(*) The following really should go into a more domain-specific |
| 2650 | // location; they are not general-purpose actions. |
| 2651 | |
| 2652 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2653 | * Broadcast Action: A GTalk connection has been established. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2654 | */ |
| 2655 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2656 | public static final String ACTION_GTALK_SERVICE_CONNECTED = |
| 2657 | "android.intent.action.GTALK_CONNECTED"; |
| 2658 | |
| 2659 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2660 | * Broadcast Action: A GTalk connection has been disconnected. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2661 | */ |
| 2662 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2663 | public static final String ACTION_GTALK_SERVICE_DISCONNECTED = |
| 2664 | "android.intent.action.GTALK_DISCONNECTED"; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2665 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2666 | /** |
| 2667 | * Broadcast Action: An input method has been changed. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2668 | */ |
| 2669 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2670 | public static final String ACTION_INPUT_METHOD_CHANGED = |
| 2671 | "android.intent.action.INPUT_METHOD_CHANGED"; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2672 | |
| 2673 | /** |
| 2674 | * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or |
| 2675 | * more radios have been turned off or on. The intent will have the following extra value:</p> |
| 2676 | * <ul> |
| 2677 | * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, |
| 2678 | * then cell radio and possibly other radios such as bluetooth or WiFi may have also been |
| 2679 | * turned off</li> |
| 2680 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2681 | * |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 2682 | * <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] | 2683 | */ |
| 2684 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2685 | public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; |
| 2686 | |
| 2687 | /** |
| 2688 | * Broadcast Action: Some content providers have parts of their namespace |
| 2689 | * where they publish new events or items that the user may be especially |
| 2690 | * interested in. For these things, they may broadcast this action when the |
| 2691 | * set of interesting items change. |
| 2692 | * |
| 2693 | * For example, GmailProvider sends this notification when the set of unread |
| 2694 | * mail in the inbox changes. |
| 2695 | * |
| 2696 | * <p>The data of the intent identifies which part of which provider |
| 2697 | * changed. When queried through the content resolver, the data URI will |
| 2698 | * return the data set in question. |
| 2699 | * |
| 2700 | * <p>The intent will have the following extra values: |
| 2701 | * <ul> |
| 2702 | * <li><em>count</em> - The number of items in the data set. This is the |
| 2703 | * same as the number of items in the cursor returned by querying the |
| 2704 | * data URI. </li> |
| 2705 | * </ul> |
| 2706 | * |
| 2707 | * This intent will be sent at boot (if the count is non-zero) and when the |
| 2708 | * data set changes. It is possible for the data set to change without the |
| 2709 | * count changing (for example, if a new unread message arrives in the same |
| 2710 | * sync operation in which a message is archived). The phone should still |
| 2711 | * ring/vibrate/etc as normal in this case. |
| 2712 | */ |
| 2713 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2714 | public static final String ACTION_PROVIDER_CHANGED = |
| 2715 | "android.intent.action.PROVIDER_CHANGED"; |
| 2716 | |
| 2717 | /** |
| 2718 | * Broadcast Action: Wired Headset plugged in or unplugged. |
| 2719 | * |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2720 | * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value |
| 2721 | * and documentation. |
| 2722 | * <p>If the minimum SDK version of your application is |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 2723 | * {@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] | 2724 | * 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] | 2725 | */ |
| 2726 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2727 | 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] | 2728 | |
| 2729 | /** |
Joe Onorato | 9cdffa1 | 2011-04-06 18:27:27 -0700 | [diff] [blame] | 2730 | * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> |
| 2731 | * <ul> |
| 2732 | * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> |
| 2733 | * </ul> |
| 2734 | * |
| 2735 | * <p class="note">This is a protected intent that can only be sent |
| 2736 | * by the system. |
| 2737 | * |
| 2738 | * @hide |
| 2739 | */ |
| 2740 | //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2741 | public static final String ACTION_ADVANCED_SETTINGS_CHANGED |
| 2742 | = "android.intent.action.ADVANCED_SETTINGS"; |
| 2743 | |
| 2744 | /** |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 2745 | * Broadcast Action: Sent after application restrictions are changed. |
| 2746 | * |
| 2747 | * <p class="note">This is a protected intent that can only be sent |
| 2748 | * by the system.</p> |
| 2749 | */ |
| 2750 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2751 | public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = |
| 2752 | "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; |
| 2753 | |
| 2754 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2755 | * Broadcast Action: An outgoing call is about to be placed. |
| 2756 | * |
Dirk Dougherty | 367ce90 | 2013-05-28 17:37:12 -0700 | [diff] [blame] | 2757 | * <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] | 2758 | * <ul> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2759 | * <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] | 2760 | * the phone number originally intended to be dialed.</li> |
| 2761 | * </ul> |
| 2762 | * <p>Once the broadcast is finished, the resultData is used as the actual |
| 2763 | * 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] | 2764 | * <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] | 2765 | * outgoing call in turn: for example, a parental control application |
| 2766 | * might verify that the user is authorized to place the call at that |
| 2767 | * time, then a number-rewriting application might add an area code if |
| 2768 | * one was not specified.</p> |
| 2769 | * <p>For consistency, any receiver whose purpose is to prohibit phone |
| 2770 | * calls should have a priority of 0, to ensure it will see the final |
| 2771 | * phone number to be dialed. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2772 | * 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] | 2773 | * should have a positive priority. |
| 2774 | * Negative priorities are reserved for the system for this broadcast; |
| 2775 | * using them may cause problems.</p> |
Dirk Dougherty | 932fbcc | 2013-05-29 15:19:14 -0700 | [diff] [blame] | 2776 | * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> |
| 2777 | * abort the broadcast.</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2778 | * <p>Emergency calls cannot be intercepted using this mechanism, and |
| 2779 | * other calls cannot be modified to call emergency numbers using this |
| 2780 | * mechanism. |
Santos Cordon | ba70136 | 2013-05-17 14:48:54 -0700 | [diff] [blame] | 2781 | * <p>Some apps (such as VoIP apps) may want to redirect the outgoing |
| 2782 | * call to use their own service instead. Those apps should first prevent |
| 2783 | * the call from being placed by setting resultData to <code>null</code> |
| 2784 | * 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] | 2785 | * <p>You must hold the |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2786 | * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} |
| 2787 | * permission to receive this Intent.</p> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2788 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2789 | * <p class="note">This is a protected intent that can only be sent |
| 2790 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2791 | */ |
| 2792 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2793 | public static final String ACTION_NEW_OUTGOING_CALL = |
| 2794 | "android.intent.action.NEW_OUTGOING_CALL"; |
| 2795 | |
| 2796 | /** |
| 2797 | * Broadcast Action: Have the device reboot. This is only for use by |
| 2798 | * system code. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2799 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2800 | * <p class="note">This is a protected intent that can only be sent |
| 2801 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2802 | */ |
| 2803 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2804 | public static final String ACTION_REBOOT = |
| 2805 | "android.intent.action.REBOOT"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2806 | |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2807 | /** |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2808 | * Broadcast Action: A sticky broadcast for changes in the physical |
| 2809 | * docking state of the device. |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2810 | * |
| 2811 | * <p>The intent will have the following extra values: |
| 2812 | * <ul> |
| 2813 | * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2814 | * state, indicating which dock the device is physically in.</li> |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2815 | * </ul> |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2816 | * <p>This is intended for monitoring the current physical dock state. |
| 2817 | * See {@link android.app.UiModeManager} for the normal API dealing with |
| 2818 | * dock mode changes. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2819 | */ |
| 2820 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2821 | public static final String ACTION_DOCK_EVENT = |
| 2822 | "android.intent.action.DOCK_EVENT"; |
| 2823 | |
| 2824 | /** |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2825 | * Broadcast Action: A broadcast when idle maintenance can be started. |
| 2826 | * This means that the user is not interacting with the device and is |
| 2827 | * not expected to do so soon. Typical use of the idle maintenance is |
| 2828 | * to perform somehow expensive tasks that can be postponed at a moment |
| 2829 | * when they will not degrade user experience. |
| 2830 | * <p> |
| 2831 | * <p class="note">In order to keep the device responsive in case of an |
| 2832 | * unexpected user interaction, implementations of a maintenance task |
| 2833 | * should be interruptible. In such a scenario a broadcast with action |
| 2834 | * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you |
| 2835 | * should not do the maintenance work in |
| 2836 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a |
| 2837 | * maintenance service by {@link Context#startService(Intent)}. Also |
| 2838 | * you should hold a wake lock while your maintenance service is running |
| 2839 | * to prevent the device going to sleep. |
| 2840 | * </p> |
| 2841 | * <p> |
| 2842 | * <p class="note">This is a protected intent that can only be sent by |
| 2843 | * the system. |
| 2844 | * </p> |
| 2845 | * |
| 2846 | * @see #ACTION_IDLE_MAINTENANCE_END |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2847 | * |
| 2848 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2849 | */ |
| 2850 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2851 | public static final String ACTION_IDLE_MAINTENANCE_START = |
| 2852 | "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; |
| 2853 | |
| 2854 | /** |
| 2855 | * Broadcast Action: A broadcast when idle maintenance should be stopped. |
| 2856 | * This means that the user was not interacting with the device as a result |
| 2857 | * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} |
| 2858 | * was sent and now the user started interacting with the device. Typical |
| 2859 | * use of the idle maintenance is to perform somehow expensive tasks that |
| 2860 | * can be postponed at a moment when they will not degrade user experience. |
| 2861 | * <p> |
| 2862 | * <p class="note">In order to keep the device responsive in case of an |
| 2863 | * unexpected user interaction, implementations of a maintenance task |
| 2864 | * should be interruptible. Hence, on receiving a broadcast with this |
| 2865 | * action, the maintenance task should be interrupted as soon as possible. |
| 2866 | * In other words, you should not do the maintenance work in |
| 2867 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the |
| 2868 | * maintenance service that was started on receiving of |
| 2869 | * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake |
| 2870 | * lock you acquired when your maintenance service started. |
| 2871 | * </p> |
| 2872 | * <p class="note">This is a protected intent that can only be sent |
| 2873 | * by the system. |
| 2874 | * |
| 2875 | * @see #ACTION_IDLE_MAINTENANCE_START |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2876 | * |
| 2877 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2878 | */ |
| 2879 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2880 | public static final String ACTION_IDLE_MAINTENANCE_END = |
| 2881 | "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; |
| 2882 | |
| 2883 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2884 | * Broadcast Action: a remote intent is to be broadcasted. |
| 2885 | * |
| 2886 | * A remote intent is used for remote RPC between devices. The remote intent |
| 2887 | * is serialized and sent from one device to another device. The receiving |
| 2888 | * device parses the remote intent and broadcasts it. Note that anyone can |
| 2889 | * broadcast a remote intent. However, if the intent receiver of the remote intent |
| 2890 | * does not trust intent broadcasts from arbitrary intent senders, it should require |
| 2891 | * the sender to hold certain permissions so only trusted sender's broadcast will be |
| 2892 | * let through. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2893 | * @hide |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2894 | */ |
| 2895 | public static final String ACTION_REMOTE_INTENT = |
Costin Manolache | 8d83f9e | 2010-05-12 16:04:10 -0700 | [diff] [blame] | 2896 | "com.google.android.c2dm.intent.RECEIVE"; |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2897 | |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2898 | /** |
Jeff Sharkey | bd91e2f | 2016-03-22 15:32:31 -0600 | [diff] [blame] | 2899 | * Broadcast Action: This is broadcast once when the user is booting after a |
| 2900 | * system update. It can be used to perform cleanup or upgrades after a |
| 2901 | * system update. |
| 2902 | * <p> |
| 2903 | * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} |
| 2904 | * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's |
| 2905 | * only sent when the {@link Build#FINGERPRINT} has changed, and it's only |
| 2906 | * sent to receivers in the system image. |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2907 | * |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2908 | * @hide |
| 2909 | */ |
| 2910 | public static final String ACTION_PRE_BOOT_COMPLETED = |
| 2911 | "android.intent.action.PRE_BOOT_COMPLETED"; |
| 2912 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2913 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2914 | * Broadcast to a specific application to query any supported restrictions to impose |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 2915 | * on restricted users. The broadcast intent contains an extra |
| 2916 | * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted |
| 2917 | * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or |
| 2918 | * String[] depending on the restriction type.<p/> |
| 2919 | * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 2920 | * which is of type <code>ArrayList<RestrictionEntry></code>. It can also |
| 2921 | * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. |
| 2922 | * 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] | 2923 | * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. |
| 2924 | * The keys and values of the returned restrictions will be persisted. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2925 | * @see RestrictionEntry |
| 2926 | */ |
| 2927 | public static final String ACTION_GET_RESTRICTION_ENTRIES = |
| 2928 | "android.intent.action.GET_RESTRICTION_ENTRIES"; |
| 2929 | |
| 2930 | /** |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2931 | * Sent the first time a user is starting, to allow system apps to |
| 2932 | * perform one time initialization. (This will not be seen by third |
| 2933 | * party applications because a newly initialized user does not have any |
| 2934 | * third party applications installed for it.) This is sent early in |
| 2935 | * starting the user, around the time the home app is started, before |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2936 | * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground |
| 2937 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2938 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2939 | */ |
| 2940 | public static final String ACTION_USER_INITIALIZE = |
| 2941 | "android.intent.action.USER_INITIALIZE"; |
| 2942 | |
| 2943 | /** |
| 2944 | * Sent when a user switch is happening, causing the process's user to be |
| 2945 | * brought to the foreground. This is only sent to receivers registered |
| 2946 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2947 | * 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] | 2948 | * foreground. This is sent as a foreground |
| 2949 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2950 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2951 | */ |
| 2952 | public static final String ACTION_USER_FOREGROUND = |
| 2953 | "android.intent.action.USER_FOREGROUND"; |
| 2954 | |
| 2955 | /** |
| 2956 | * Sent when a user switch is happening, causing the process's user to be |
| 2957 | * sent to the background. This is only sent to receivers registered |
| 2958 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2959 | * 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] | 2960 | * background. This is sent as a foreground |
| 2961 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2962 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2963 | */ |
| 2964 | public static final String ACTION_USER_BACKGROUND = |
| 2965 | "android.intent.action.USER_BACKGROUND"; |
| 2966 | |
| 2967 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2968 | * Broadcast sent to the system when a user is added. Carries an extra |
| 2969 | * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to |
| 2970 | * all running users. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2971 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2972 | * @hide |
| 2973 | */ |
| 2974 | public static final String ACTION_USER_ADDED = |
| 2975 | "android.intent.action.USER_ADDED"; |
| 2976 | |
| 2977 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2978 | * Broadcast sent by the system when a user is started. Carries an extra |
| 2979 | * 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] | 2980 | * registered receivers, not manifest receivers. It is sent to the user |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2981 | * that has been started. This is sent as a foreground |
| 2982 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2983 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2984 | * @hide |
| 2985 | */ |
| 2986 | public static final String ACTION_USER_STARTED = |
| 2987 | "android.intent.action.USER_STARTED"; |
| 2988 | |
| 2989 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2990 | * Broadcast sent when a user is in the process of starting. Carries an extra |
| 2991 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 2992 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 2993 | * users (including the one that is being started). You must hold |
| 2994 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 2995 | * this broadcast. This is sent as a background broadcast, since |
| 2996 | * its result is not part of the primary UX flow; to safely keep track of |
| 2997 | * started/stopped state of a user you can use this in conjunction with |
| 2998 | * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with |
| 2999 | * other user state broadcasts since those are foreground broadcasts so can |
| 3000 | * execute in a different order. |
| 3001 | * @hide |
| 3002 | */ |
| 3003 | public static final String ACTION_USER_STARTING = |
| 3004 | "android.intent.action.USER_STARTING"; |
| 3005 | |
| 3006 | /** |
| 3007 | * Broadcast sent when a user is going to be stopped. Carries an extra |
| 3008 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 3009 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 3010 | * users (including the one that is being stopped). You must hold |
| 3011 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 3012 | * this broadcast. The user will not stop until all receivers have |
| 3013 | * handled the broadcast. This is sent as a background broadcast, since |
| 3014 | * its result is not part of the primary UX flow; to safely keep track of |
| 3015 | * started/stopped state of a user you can use this in conjunction with |
| 3016 | * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with |
| 3017 | * other user state broadcasts since those are foreground broadcasts so can |
| 3018 | * execute in a different order. |
| 3019 | * @hide |
| 3020 | */ |
| 3021 | public static final String ACTION_USER_STOPPING = |
| 3022 | "android.intent.action.USER_STOPPING"; |
| 3023 | |
| 3024 | /** |
| 3025 | * Broadcast sent to the system when a user is stopped. Carries an extra |
| 3026 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to |
| 3027 | * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a |
| 3028 | * specific package. This is only sent to registered receivers, not manifest |
| 3029 | * receivers. It is sent to all running users <em>except</em> the one that |
| 3030 | * has just been stopped (which is no longer running). |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 3031 | * @hide |
| 3032 | */ |
| 3033 | public static final String ACTION_USER_STOPPED = |
| 3034 | "android.intent.action.USER_STOPPED"; |
| 3035 | |
| 3036 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 3037 | * 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] | 3038 | * 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] | 3039 | * one that has been removed. The user will not be completely removed until all receivers have |
| 3040 | * handled the broadcast. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 3041 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3042 | * @hide |
| 3043 | */ |
| 3044 | public static final String ACTION_USER_REMOVED = |
| 3045 | "android.intent.action.USER_REMOVED"; |
| 3046 | |
| 3047 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 3048 | * 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] | 3049 | * the userHandle of the user to become the current one. This is only sent to |
| 3050 | * registered receivers, not manifest receivers. It is sent to all running users. |
| 3051 | * You must hold |
| 3052 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3053 | * @hide |
| 3054 | */ |
| 3055 | public static final String ACTION_USER_SWITCHED = |
| 3056 | "android.intent.action.USER_SWITCHED"; |
| 3057 | |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 3058 | /** |
Jeff Sharkey | 8924e87 | 2015-11-30 12:52:10 -0700 | [diff] [blame] | 3059 | * Broadcast Action: Sent when the credential-encrypted private storage has |
| 3060 | * become unlocked for the target user. This is only sent to registered |
| 3061 | * receivers, not manifest receivers. |
| 3062 | */ |
| 3063 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3064 | public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; |
| 3065 | |
| 3066 | /** |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 3067 | * Broadcast sent to the system when a user's information changes. Carries an extra |
| 3068 | * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 3069 | * 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] | 3070 | * @hide |
| 3071 | */ |
| 3072 | public static final String ACTION_USER_INFO_CHANGED = |
| 3073 | "android.intent.action.USER_INFO_CHANGED"; |
| 3074 | |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 3075 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3076 | * Broadcast sent to the primary user when an associated managed profile is added (the profile |
| 3077 | * 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] | 3078 | * the UserHandle of the profile that was added. Only applications (for example Launchers) |
| 3079 | * that need to display merged content across both primary and managed profiles need to |
| 3080 | * worry about this broadcast. This is only sent to registered receivers, |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3081 | * not manifest receivers. |
| 3082 | */ |
| 3083 | public static final String ACTION_MANAGED_PROFILE_ADDED = |
| 3084 | "android.intent.action.MANAGED_PROFILE_ADDED"; |
| 3085 | |
| 3086 | /** |
| 3087 | * 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] | 3088 | * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. |
| 3089 | * Only applications (for example Launchers) that need to display merged content across both |
| 3090 | * primary and managed profiles need to worry about this broadcast. This is only sent to |
| 3091 | * registered receivers, not manifest receivers. |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3092 | */ |
| 3093 | public static final String ACTION_MANAGED_PROFILE_REMOVED = |
| 3094 | "android.intent.action.MANAGED_PROFILE_REMOVED"; |
| 3095 | |
| 3096 | /** |
Kenny Guy | b1b3026 | 2016-02-09 16:02:35 +0000 | [diff] [blame] | 3097 | * Broadcast sent to the primary user when the credential-encrypted private storage for |
| 3098 | * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that |
| 3099 | * specifies the UserHandle of the profile that was unlocked. Only applications (for example |
| 3100 | * Launchers) that need to display merged content across both primary and managed profiles |
| 3101 | * need to worry about this broadcast. This is only sent to registered receivers, |
| 3102 | * not manifest receivers. |
| 3103 | */ |
| 3104 | public static final String ACTION_MANAGED_PROFILE_UNLOCKED = |
| 3105 | "android.intent.action.MANAGED_PROFILE_UNLOCKED"; |
| 3106 | |
| 3107 | /** |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 3108 | * Broadcast sent to the primary user when an associated managed profile has become available. |
| 3109 | * 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] | 3110 | * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, |
| 3111 | * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state |
| 3112 | * 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] | 3113 | */ |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 3114 | public static final String ACTION_MANAGED_PROFILE_AVAILABLE = |
| 3115 | "android.intent.action.MANAGED_PROFILE_AVAILABLE"; |
| 3116 | |
| 3117 | /** |
| 3118 | * Broadcast sent to the primary user when an associated managed profile has become unavailable. |
| 3119 | * Currently this includes when the user enables quiet mode for the profile. Carries an extra |
| 3120 | * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed, |
| 3121 | * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state |
| 3122 | * of quiet mode. This is only sent to registered receivers, not manifest receivers. |
| 3123 | */ |
| 3124 | public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = |
| 3125 | "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 3126 | |
| 3127 | /** |
Robin Lee | 92b83c6 | 2016-08-31 13:27:51 +0100 | [diff] [blame] | 3128 | * Broadcast sent to the system user when the 'device locked' state changes for any user. |
| 3129 | * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which |
| 3130 | * the device was locked or unlocked. |
| 3131 | * |
| 3132 | * This is only sent to registered receivers. |
| 3133 | * |
| 3134 | * @hide |
| 3135 | */ |
| 3136 | public static final String ACTION_DEVICE_LOCKED_CHANGED = |
| 3137 | "android.intent.action.DEVICE_LOCKED_CHANGED"; |
| 3138 | |
| 3139 | /** |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 3140 | * Sent when the user taps on the clock widget in the system's "quick settings" area. |
| 3141 | */ |
| 3142 | public static final String ACTION_QUICK_CLOCK = |
| 3143 | "android.intent.action.QUICK_CLOCK"; |
| 3144 | |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 3145 | /** |
Alan Viverette | 5a39949 | 2014-07-14 16:19:38 -0700 | [diff] [blame] | 3146 | * Activity Action: Shows the brightness setting dialog. |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 3147 | * @hide |
| 3148 | */ |
| 3149 | public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = |
| 3150 | "android.intent.action.SHOW_BRIGHTNESS_DIALOG"; |
| 3151 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3152 | /** |
| 3153 | * Broadcast Action: A global button was pressed. Includes a single |
| 3154 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 3155 | * caused the broadcast. |
| 3156 | * @hide |
| 3157 | */ |
| 3158 | public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; |
| 3159 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3160 | /** |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 3161 | * Broadcast Action: Sent when media resource is granted. |
| 3162 | * <p> |
| 3163 | * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource |
| 3164 | * granted. |
| 3165 | * </p> |
| 3166 | * <p class="note"> |
| 3167 | * This is a protected intent that can only be sent by the system. |
| 3168 | * </p> |
| 3169 | * <p class="note"> |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 3170 | * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 3171 | * </p> |
| 3172 | * |
| 3173 | * @hide |
| 3174 | */ |
| 3175 | public static final String ACTION_MEDIA_RESOURCE_GRANTED = |
| 3176 | "android.intent.action.MEDIA_RESOURCE_GRANTED"; |
| 3177 | |
| 3178 | /** |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 3179 | * Broadcast Action: An overlay package has been installed. The data |
| 3180 | * contains the name of the added overlay package. |
| 3181 | * @hide |
| 3182 | */ |
| 3183 | public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED"; |
| 3184 | |
| 3185 | /** |
| 3186 | * Broadcast Action: An overlay package has changed. The data contains the |
| 3187 | * name of the overlay package which has changed. This is broadcast on all |
| 3188 | * changes to the OverlayInfo returned by {@link |
| 3189 | * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The |
| 3190 | * most common change is a state change that will change whether the |
| 3191 | * overlay is enabled or not. |
| 3192 | * @hide |
| 3193 | */ |
| 3194 | public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; |
| 3195 | |
| 3196 | /** |
| 3197 | * Broadcast Action: An overlay package has been removed. The data contains |
| 3198 | * the name of the overlay package which has been removed. |
| 3199 | * @hide |
| 3200 | */ |
| 3201 | public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED"; |
| 3202 | |
| 3203 | /** |
| 3204 | * Broadcast Action: The order of a package's list of overlay packages has |
| 3205 | * changed. The data contains the package name of the overlay package that |
| 3206 | * had its position in the list adjusted. |
| 3207 | * @hide |
| 3208 | */ |
| 3209 | public static final String |
| 3210 | ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED"; |
| 3211 | |
| 3212 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3213 | * Activity Action: Allow the user to select and return one or more existing |
| 3214 | * documents. When invoked, the system will display the various |
| 3215 | * {@link DocumentsProvider} instances installed on the device, letting the |
| 3216 | * user interactively navigate through them. These documents include local |
| 3217 | * media, such as photos and video, and documents provided by installed |
| 3218 | * cloud storage providers. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3219 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3220 | * Each document is represented as a {@code content://} URI backed by a |
| 3221 | * {@link DocumentsProvider}, which can be opened as a stream with |
| 3222 | * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for |
| 3223 | * {@link android.provider.DocumentsContract.Document} metadata. |
| 3224 | * <p> |
| 3225 | * All selected documents are returned to the calling application with |
| 3226 | * persistable read and write permission grants. If you want to maintain |
| 3227 | * access to the documents across device reboots, you need to explicitly |
| 3228 | * take the persistable permissions using |
| 3229 | * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. |
| 3230 | * <p> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3231 | * Callers must indicate the acceptable document MIME types through |
| 3232 | * {@link #setType(String)}. For example, to select photos, use |
| 3233 | * {@code image/*}. If multiple disjoint MIME types are acceptable, define |
| 3234 | * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to |
| 3235 | * {@literal *}/*. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3236 | * <p> |
| 3237 | * If the caller can handle multiple returned items (the user performing |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3238 | * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 3239 | * to indicate this. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3240 | * <p> |
Tomasz Mikolajewski | a8057a9 | 2015-11-16 11:41:28 +0900 | [diff] [blame] | 3241 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain |
| 3242 | * URIs that can be opened with |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3243 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3244 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 3245 | * Callers can set a document URI through |
| 3246 | * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial |
| 3247 | * location of documents navigator. System will do its best to launch the |
| 3248 | * navigator in the specified document if it's a folder, or the folder that |
| 3249 | * contains the specified document if not. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3250 | * <p> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3251 | * Output: The URI of the item that was picked, returned in |
| 3252 | * {@link #getData()}. This must be a {@code content://} URI so that any |
| 3253 | * receiver can access it. If multiple documents were selected, they are |
| 3254 | * returned in {@link #getClipData()}. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3255 | * |
| 3256 | * @see DocumentsContract |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3257 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3258 | * @see #ACTION_CREATE_DOCUMENT |
| 3259 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3260 | */ |
| 3261 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3262 | public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; |
| 3263 | |
| 3264 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3265 | * Activity Action: Allow the user to create a new document. When invoked, |
| 3266 | * the system will display the various {@link DocumentsProvider} instances |
| 3267 | * installed on the device, letting the user navigate through them. The |
| 3268 | * returned document may be a newly created document with no content, or it |
| 3269 | * may be an existing document with the requested MIME type. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3270 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3271 | * Each document is represented as a {@code content://} URI backed by a |
| 3272 | * {@link DocumentsProvider}, which can be opened as a stream with |
| 3273 | * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for |
| 3274 | * {@link android.provider.DocumentsContract.Document} metadata. |
| 3275 | * <p> |
| 3276 | * Callers must indicate the concrete MIME type of the document being |
| 3277 | * created by setting {@link #setType(String)}. This MIME type cannot be |
| 3278 | * changed after the document is created. |
| 3279 | * <p> |
| 3280 | * Callers can provide an initial display name through {@link #EXTRA_TITLE}, |
| 3281 | * but the user may change this value before creating the file. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3282 | * <p> |
Tomasz Mikolajewski | a8057a9 | 2015-11-16 11:41:28 +0900 | [diff] [blame] | 3283 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain |
| 3284 | * URIs that can be opened with |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3285 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3286 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 3287 | * Callers can set a document URI through |
| 3288 | * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial |
| 3289 | * location of documents navigator. System will do its best to launch the |
| 3290 | * navigator in the specified document if it's a folder, or the folder that |
| 3291 | * contains the specified document if not. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3292 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3293 | * Output: The URI of the item that was created. This must be a |
| 3294 | * {@code content://} URI so that any receiver can access it. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 3295 | * |
| 3296 | * @see DocumentsContract |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3297 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3298 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3299 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3300 | */ |
| 3301 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3302 | public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; |
| 3303 | |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3304 | /** |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3305 | * Activity Action: Allow the user to pick a directory subtree. When |
| 3306 | * invoked, the system will display the various {@link DocumentsProvider} |
| 3307 | * instances installed on the device, letting the user navigate through |
| 3308 | * them. Apps can fully manage documents within the returned directory. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3309 | * <p> |
| 3310 | * To gain access to descendant (child, grandchild, etc) documents, use |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3311 | * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and |
| 3312 | * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} |
| 3313 | * with the returned URI. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3314 | * <p> |
Garfield Tan | b44ae61 | 2016-11-07 16:46:37 -0800 | [diff] [blame] | 3315 | * Callers can set a document URI through |
| 3316 | * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial |
| 3317 | * location of documents navigator. System will do its best to launch the |
| 3318 | * navigator in the specified document if it's a folder, or the folder that |
| 3319 | * contains the specified document if not. |
Garfield Tan | 0b3cf66 | 2016-10-31 12:59:45 -0700 | [diff] [blame] | 3320 | * <p> |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3321 | * Output: The URI representing the selected directory tree. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3322 | * |
| 3323 | * @see DocumentsContract |
| 3324 | */ |
| 3325 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3326 | public static final String |
| 3327 | ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 3328 | |
Felipe Leme | c7b1f89 | 2016-01-15 15:02:31 -0800 | [diff] [blame] | 3329 | /** |
Peng Xu | a35b553 | 2016-01-20 00:05:45 -0800 | [diff] [blame] | 3330 | * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or |
| 3331 | * exisiting sensor being disconnected. |
| 3332 | * |
| 3333 | * <p class="note">This is a protected intent that can only be sent by the system.</p> |
| 3334 | * |
| 3335 | * {@hide} |
| 3336 | */ |
| 3337 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3338 | public static final String |
| 3339 | ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; |
| 3340 | |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3341 | /** |
| 3342 | * Deprecated - use {@link #ACTION_FACTORY_RESET} instead. |
| 3343 | * |
| 3344 | * {@hide} |
| 3345 | */ |
| 3346 | @Deprecated |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 3347 | public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; |
| 3348 | |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 3349 | /** |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3350 | * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory |
| 3351 | * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. |
| 3352 | * |
| 3353 | * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. |
| 3354 | * |
Benjamin Franz | f9d5e6a | 2016-05-26 14:24:29 +0100 | [diff] [blame] | 3355 | * @hide |
| 3356 | */ |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3357 | @Deprecated |
Benjamin Franz | f9d5e6a | 2016-05-26 14:24:29 +0100 | [diff] [blame] | 3358 | public static final String EXTRA_FORCE_MASTER_CLEAR = |
| 3359 | "android.intent.extra.FORCE_MASTER_CLEAR"; |
| 3360 | |
| 3361 | /** |
Lenka Trochtova | 73aeea2 | 2016-11-18 17:34:34 +0100 | [diff] [blame] | 3362 | * A broadcast action to trigger a factory reset. |
| 3363 | * |
| 3364 | * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. |
| 3365 | * |
| 3366 | * <p>Not for use by third-party applications. |
| 3367 | * |
| 3368 | * @see #EXTRA_FORCE_MASTER_CLEAR |
| 3369 | * |
| 3370 | * {@hide} |
| 3371 | */ |
| 3372 | @SystemApi |
| 3373 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 3374 | public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; |
| 3375 | |
| 3376 | /** |
| 3377 | * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory |
| 3378 | * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. |
| 3379 | * |
| 3380 | * <p>Not for use by third-party applications. |
| 3381 | * |
| 3382 | * @hide |
| 3383 | */ |
| 3384 | @SystemApi |
| 3385 | public static final String EXTRA_FORCE_FACTORY_RESET = |
| 3386 | "android.intent.extra.FORCE_FACTORY_RESET"; |
| 3387 | |
| 3388 | /** |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 3389 | * Broadcast action: report that a settings element is being restored from backup. The intent |
| 3390 | * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting, |
| 3391 | * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE |
| 3392 | * is the value of that settings entry prior to the restore operation. All of these values are |
| 3393 | * represented as strings. |
| 3394 | * |
| 3395 | * <p>This broadcast is sent only for settings provider entries known to require special handling |
| 3396 | * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within |
| 3397 | * the provider's backup agent implementation. |
| 3398 | * |
| 3399 | * @see #EXTRA_SETTING_NAME |
| 3400 | * @see #EXTRA_SETTING_PREVIOUS_VALUE |
| 3401 | * @see #EXTRA_SETTING_NEW_VALUE |
| 3402 | * {@hide} |
| 3403 | */ |
| 3404 | public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; |
| 3405 | |
| 3406 | /** {@hide} */ |
| 3407 | public static final String EXTRA_SETTING_NAME = "setting_name"; |
| 3408 | /** {@hide} */ |
| 3409 | public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; |
| 3410 | /** {@hide} */ |
| 3411 | public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; |
| 3412 | |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3413 | /** |
| 3414 | * Activity Action: Process a piece of text. |
| 3415 | * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. |
| 3416 | * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> |
| 3417 | * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> |
| 3418 | */ |
| 3419 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3420 | public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; |
| 3421 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3422 | * The name of the extra used to define the text to be processed, as a |
| 3423 | * CharSequence. Note that this may be a styled CharSequence, so you must use |
| 3424 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3425 | */ |
| 3426 | public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; |
| 3427 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3428 | * 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] | 3429 | */ |
| 3430 | public static final String EXTRA_PROCESS_TEXT_READONLY = |
| 3431 | "android.intent.extra.PROCESS_TEXT_READONLY"; |
| 3432 | |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3433 | /** |
| 3434 | * Broadcast action: reports when a new thermal event has been reached. When the device |
| 3435 | * is reaching its maximum temperatue, the thermal level reported |
| 3436 | * {@hide} |
| 3437 | */ |
| 3438 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3439 | public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; |
| 3440 | |
| 3441 | /** {@hide} */ |
| 3442 | public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; |
| 3443 | |
| 3444 | /** |
| 3445 | * 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] | 3446 | * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3447 | * {@hide} |
| 3448 | */ |
| 3449 | public static final int EXTRA_THERMAL_STATE_NORMAL = 0; |
| 3450 | |
| 3451 | /** |
| 3452 | * 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] | 3453 | * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3454 | * {@hide} |
| 3455 | */ |
| 3456 | public static final int EXTRA_THERMAL_STATE_WARNING = 1; |
| 3457 | |
| 3458 | /** |
| 3459 | * 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] | 3460 | * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3461 | * {@hide} |
| 3462 | */ |
| 3463 | public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; |
| 3464 | |
| 3465 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3466 | // --------------------------------------------------------------------- |
| 3467 | // --------------------------------------------------------------------- |
| 3468 | // Standard intent categories (see addCategory()). |
| 3469 | |
| 3470 | /** |
| 3471 | * Set if the activity should be an option for the default action |
| 3472 | * (center press) to perform on a piece of data. Setting this will |
| 3473 | * hide from the user any activities without it set when performing an |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3474 | * 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] | 3475 | * Intent when initiating an action -- it is for use in intent filters |
| 3476 | * specified in packages. |
| 3477 | */ |
| 3478 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3479 | public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; |
| 3480 | /** |
| 3481 | * Activities that can be safely invoked from a browser must support this |
| 3482 | * category. For example, if the user is viewing a web page or an e-mail |
| 3483 | * and clicks on a link in the text, the Intent generated execute that |
| 3484 | * link will require the BROWSABLE category, so that only activities |
| 3485 | * supporting this category will be considered as possible actions. By |
| 3486 | * supporting this category, you are promising that there is nothing |
| 3487 | * damaging (without user intervention) that can happen by invoking any |
| 3488 | * matching Intent. |
| 3489 | */ |
| 3490 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3491 | public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; |
| 3492 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3493 | * Categories for activities that can participate in voice interaction. |
| 3494 | * An activity that supports this category must be prepared to run with |
| 3495 | * no UI shown at all (though in some case it may have a UI shown), and |
| 3496 | * rely on {@link android.app.VoiceInteractor} to interact with the user. |
| 3497 | */ |
| 3498 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3499 | public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; |
| 3500 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3501 | * Set if the activity should be considered as an alternative action to |
| 3502 | * the data the user is currently viewing. See also |
| 3503 | * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that |
| 3504 | * applies to the selection in a list of items. |
| 3505 | * |
| 3506 | * <p>Supporting this category means that you would like your activity to be |
| 3507 | * displayed in the set of alternative things the user can do, usually as |
| 3508 | * part of the current activity's options menu. You will usually want to |
| 3509 | * include a specific label in the <intent-filter> of this action |
| 3510 | * describing to the user what it does. |
| 3511 | * |
| 3512 | * <p>The action of IntentFilter with this category is important in that it |
| 3513 | * describes the specific action the target will perform. This generally |
| 3514 | * should not be a generic action (such as {@link #ACTION_VIEW}, but rather |
| 3515 | * a specific name such as "com.android.camera.action.CROP. Only one |
| 3516 | * alternative of any particular action will be shown to the user, so using |
| 3517 | * a specific action like this makes sure that your alternative will be |
| 3518 | * displayed while also allowing other applications to provide their own |
| 3519 | * overrides of that particular action. |
| 3520 | */ |
| 3521 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3522 | public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; |
| 3523 | /** |
| 3524 | * Set if the activity should be considered as an alternative selection |
| 3525 | * action to the data the user has currently selected. This is like |
| 3526 | * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list |
| 3527 | * of items from which the user can select, giving them alternatives to the |
| 3528 | * default action that will be performed on it. |
| 3529 | */ |
| 3530 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3531 | public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; |
| 3532 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3533 | * 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] | 3534 | */ |
| 3535 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3536 | public static final String CATEGORY_TAB = "android.intent.category.TAB"; |
| 3537 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3538 | * Should be displayed in the top-level launcher. |
| 3539 | */ |
| 3540 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3541 | public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; |
| 3542 | /** |
Jose Lima | 38b75b6 | 2014-03-11 10:41:39 -0700 | [diff] [blame] | 3543 | * Indicates an activity optimized for Leanback mode, and that should |
| 3544 | * be displayed in the Leanback launcher. |
| 3545 | */ |
| 3546 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3547 | public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; |
| 3548 | /** |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 3549 | * Indicates a Leanback settings activity to be displayed in the Leanback launcher. |
| 3550 | * @hide |
| 3551 | */ |
| 3552 | @SystemApi |
| 3553 | public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; |
| 3554 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3555 | * Provides information about the package it is in; typically used if |
| 3556 | * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide |
| 3557 | * a front-door to the user without having to be shown in the all apps list. |
| 3558 | */ |
| 3559 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3560 | public static final String CATEGORY_INFO = "android.intent.category.INFO"; |
| 3561 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3562 | * This is the home activity, that is the first activity that is displayed |
| 3563 | * when the device boots. |
| 3564 | */ |
| 3565 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3566 | public static final String CATEGORY_HOME = "android.intent.category.HOME"; |
| 3567 | /** |
Anthony Hugh | 979b81a | 2015-09-29 16:50:35 -0700 | [diff] [blame] | 3568 | * This is the home activity that is displayed when the device is finished setting up and ready |
| 3569 | * for use. |
| 3570 | * @hide |
| 3571 | */ |
| 3572 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3573 | public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; |
| 3574 | /** |
Svet Ganov | 50a8bf4 | 2015-07-15 11:04:18 -0700 | [diff] [blame] | 3575 | * This is the setup wizard activity, that is the first activity that is displayed |
| 3576 | * when the user sets up the device for the first time. |
| 3577 | * @hide |
| 3578 | */ |
| 3579 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3580 | public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; |
| 3581 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3582 | * This activity is a preference panel. |
| 3583 | */ |
| 3584 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3585 | public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; |
| 3586 | /** |
| 3587 | * This activity is a development preference panel. |
| 3588 | */ |
| 3589 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3590 | public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; |
| 3591 | /** |
| 3592 | * Capable of running inside a parent activity container. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3593 | */ |
| 3594 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3595 | public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; |
| 3596 | /** |
Patrick Dubroy | 6dabe24 | 2010-08-30 10:43:47 -0700 | [diff] [blame] | 3597 | * This activity allows the user to browse and download new applications. |
| 3598 | */ |
| 3599 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3600 | public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; |
| 3601 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3602 | * This activity may be exercised by the monkey or other automated test tools. |
| 3603 | */ |
| 3604 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3605 | public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; |
| 3606 | /** |
| 3607 | * To be used as a test (not part of the normal user experience). |
| 3608 | */ |
| 3609 | public static final String CATEGORY_TEST = "android.intent.category.TEST"; |
| 3610 | /** |
| 3611 | * To be used as a unit test (run through the Test Harness). |
| 3612 | */ |
| 3613 | public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; |
| 3614 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3615 | * 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] | 3616 | * experience). |
| 3617 | */ |
| 3618 | public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3619 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3620 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3621 | * Used to indicate that an intent only wants URIs that can be opened with |
| 3622 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs |
| 3623 | * must support at least the columns defined in {@link OpenableColumns} when |
| 3624 | * queried. |
| 3625 | * |
| 3626 | * @see #ACTION_GET_CONTENT |
| 3627 | * @see #ACTION_OPEN_DOCUMENT |
| 3628 | * @see #ACTION_CREATE_DOCUMENT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3629 | */ |
| 3630 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3631 | public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; |
| 3632 | |
| 3633 | /** |
Tomasz Mikolajewski | 28a815c | 2016-10-28 15:54:11 +0900 | [diff] [blame] | 3634 | * Used to indicate that an intent filter can accept files which are not necessarily |
| 3635 | * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but |
| 3636 | * at least streamable via |
| 3637 | * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} |
| 3638 | * using one of the stream types exposed via |
| 3639 | * {@link ContentResolver#getStreamTypes(Uri, String)}. |
| 3640 | * |
| 3641 | * @see #ACTION_SEND |
| 3642 | * @see #ACTION_SEND_MULTIPLE |
| 3643 | */ |
| 3644 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3645 | public static final String CATEGORY_TYPED_OPENABLE = |
| 3646 | "android.intent.category.TYPED_OPENABLE"; |
| 3647 | |
| 3648 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3649 | * To be used as code under test for framework instrumentation tests. |
| 3650 | */ |
| 3651 | public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = |
| 3652 | "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3653 | /** |
| 3654 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3655 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3656 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3657 | */ |
| 3658 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3659 | public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; |
| 3660 | /** |
| 3661 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3662 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3663 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3664 | */ |
| 3665 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3666 | public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 3667 | /** |
| 3668 | * An activity to run when device is inserted into a analog (low end) dock. |
| 3669 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3670 | * information, see {@link android.app.UiModeManager}. |
| 3671 | */ |
| 3672 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3673 | public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; |
| 3674 | |
| 3675 | /** |
| 3676 | * An activity to run when device is inserted into a digital (high end) dock. |
| 3677 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3678 | * information, see {@link android.app.UiModeManager}. |
| 3679 | */ |
| 3680 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3681 | 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] | 3682 | |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 3683 | /** |
| 3684 | * Used to indicate that the activity can be used in a car environment. |
| 3685 | */ |
| 3686 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3687 | public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; |
| 3688 | |
Zak Cohen | db6ca49 | 2017-01-26 14:09:00 -0800 | [diff] [blame] | 3689 | /** |
| 3690 | * An activity to use for the launcher when the device is placed in a VR Headset viewer. |
| 3691 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3692 | * information, see {@link android.app.UiModeManager}. |
| 3693 | */ |
| 3694 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3695 | public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3696 | // --------------------------------------------------------------------- |
| 3697 | // --------------------------------------------------------------------- |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3698 | // Application launch intent categories (see addCategory()). |
| 3699 | |
| 3700 | /** |
| 3701 | * Used with {@link #ACTION_MAIN} to launch the browser application. |
| 3702 | * The activity should be able to browse the Internet. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3703 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3704 | * since it will not result in the app launching with the correct |
| 3705 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3706 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3707 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3708 | */ |
| 3709 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3710 | public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; |
| 3711 | |
| 3712 | /** |
| 3713 | * Used with {@link #ACTION_MAIN} to launch the calculator application. |
| 3714 | * The activity should be able to perform standard arithmetic operations. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3715 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3716 | * since it will not result in the app launching with the correct |
| 3717 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3718 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3719 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3720 | */ |
| 3721 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3722 | public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; |
| 3723 | |
| 3724 | /** |
| 3725 | * Used with {@link #ACTION_MAIN} to launch the calendar application. |
| 3726 | * The activity should be able to view and manipulate calendar entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3727 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3728 | * since it will not result in the app launching with the correct |
| 3729 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3730 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3731 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3732 | */ |
| 3733 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3734 | public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; |
| 3735 | |
| 3736 | /** |
| 3737 | * Used with {@link #ACTION_MAIN} to launch the contacts application. |
| 3738 | * The activity should be able to view and manipulate address book entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3739 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3740 | * since it will not result in the app launching with the correct |
| 3741 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3742 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3743 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3744 | */ |
| 3745 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3746 | public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; |
| 3747 | |
| 3748 | /** |
| 3749 | * Used with {@link #ACTION_MAIN} to launch the email application. |
| 3750 | * The activity should be able to send and receive email. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3751 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3752 | * since it will not result in the app launching with the correct |
| 3753 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3754 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3755 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3756 | */ |
| 3757 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3758 | public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; |
| 3759 | |
| 3760 | /** |
| 3761 | * Used with {@link #ACTION_MAIN} to launch the gallery application. |
| 3762 | * The activity should be able to view and manipulate image and video files |
| 3763 | * stored on the device. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3764 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3765 | * since it will not result in the app launching with the correct |
| 3766 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3767 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3768 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3769 | */ |
| 3770 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3771 | public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; |
| 3772 | |
| 3773 | /** |
| 3774 | * Used with {@link #ACTION_MAIN} to launch the maps application. |
| 3775 | * 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] | 3776 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3777 | * since it will not result in the app launching with the correct |
| 3778 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3779 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3780 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3781 | */ |
| 3782 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3783 | public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; |
| 3784 | |
| 3785 | /** |
| 3786 | * Used with {@link #ACTION_MAIN} to launch the messaging application. |
| 3787 | * The activity should be able to send and receive text messages. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3788 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3789 | * since it will not result in the app launching with the correct |
| 3790 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3791 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3792 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3793 | */ |
| 3794 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3795 | public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; |
| 3796 | |
| 3797 | /** |
| 3798 | * Used with {@link #ACTION_MAIN} to launch the music application. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3799 | * The activity should be able to play, browse, or manipulate music files |
| 3800 | * stored on the device. |
| 3801 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3802 | * since it will not result in the app launching with the correct |
| 3803 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3804 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3805 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3806 | */ |
| 3807 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3808 | public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; |
| 3809 | |
| 3810 | // --------------------------------------------------------------------- |
| 3811 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3812 | // Standard extra data keys. |
| 3813 | |
| 3814 | /** |
| 3815 | * The initial data to place in a newly created record. Use with |
| 3816 | * {@link #ACTION_INSERT}. The data here is a Map containing the same |
| 3817 | * fields as would be given to the underlying ContentProvider.insert() |
| 3818 | * call. |
| 3819 | */ |
| 3820 | public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; |
| 3821 | |
| 3822 | /** |
| 3823 | * A constant CharSequence that is associated with the Intent, used with |
| 3824 | * {@link #ACTION_SEND} to supply the literal data to be sent. Note that |
| 3825 | * this may be a styled CharSequence, so you must use |
| 3826 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to |
| 3827 | * retrieve it. |
| 3828 | */ |
| 3829 | public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; |
| 3830 | |
| 3831 | /** |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 3832 | * A constant String that is associated with the Intent, used with |
| 3833 | * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} |
| 3834 | * as HTML formatted text. Note that you <em>must</em> also supply |
| 3835 | * {@link #EXTRA_TEXT}. |
| 3836 | */ |
| 3837 | public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; |
| 3838 | |
| 3839 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3840 | * A content: URI holding a stream of data associated with the Intent, |
| 3841 | * used with {@link #ACTION_SEND} to supply the data being sent. |
| 3842 | */ |
| 3843 | public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; |
| 3844 | |
| 3845 | /** |
| 3846 | * A String[] holding e-mail addresses that should be delivered to. |
| 3847 | */ |
| 3848 | public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; |
| 3849 | |
| 3850 | /** |
| 3851 | * A String[] holding e-mail addresses that should be carbon copied. |
| 3852 | */ |
| 3853 | public static final String EXTRA_CC = "android.intent.extra.CC"; |
| 3854 | |
| 3855 | /** |
| 3856 | * A String[] holding e-mail addresses that should be blind carbon copied. |
| 3857 | */ |
| 3858 | public static final String EXTRA_BCC = "android.intent.extra.BCC"; |
| 3859 | |
| 3860 | /** |
| 3861 | * A constant string holding the desired subject line of a message. |
| 3862 | */ |
| 3863 | public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; |
| 3864 | |
| 3865 | /** |
| 3866 | * An Intent describing the choices you would like shown with |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3867 | * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3868 | */ |
| 3869 | public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; |
| 3870 | |
| 3871 | /** |
Clara Bayarri | f7fea16 | 2015-10-22 16:09:52 +0100 | [diff] [blame] | 3872 | * An int representing the user id to be used. |
| 3873 | * |
| 3874 | * @hide |
| 3875 | */ |
| 3876 | public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; |
| 3877 | |
| 3878 | /** |
Clara Bayarri | ea9b10e | 2015-12-04 15:36:26 +0000 | [diff] [blame] | 3879 | * An int representing the task id to be retrieved. This is used when a launch from recents is |
| 3880 | * intercepted by another action such as credentials confirmation to remember which task should |
| 3881 | * be resumed when complete. |
| 3882 | * |
| 3883 | * @hide |
| 3884 | */ |
| 3885 | public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; |
| 3886 | |
| 3887 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3888 | * An Intent[] describing additional, alternate choices you would like shown with |
| 3889 | * {@link #ACTION_CHOOSER}. |
| 3890 | * |
| 3891 | * <p>An app may be capable of providing several different payload types to complete a |
| 3892 | * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos |
| 3893 | * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer |
| 3894 | * several different supported sending mechanisms for sharing, such as the actual "image/*" |
| 3895 | * photo data or a hosted link where the photos can be viewed.</p> |
| 3896 | * |
| 3897 | * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the |
| 3898 | * first/primary/preferred intent in the set. Additional intents specified in |
| 3899 | * this extra are ordered; by default intents that appear earlier in the array will be |
| 3900 | * preferred over intents that appear later in the array as matches for the same |
| 3901 | * target component. To alter this preference, a calling app may also supply |
| 3902 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> |
| 3903 | */ |
| 3904 | public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; |
| 3905 | |
| 3906 | /** |
Adam Powell | 52c3921 | 2016-04-07 15:14:18 -0700 | [diff] [blame] | 3907 | * A {@link ComponentName ComponentName[]} describing components that should be filtered out |
| 3908 | * and omitted from a list of components presented to the user. |
| 3909 | * |
| 3910 | * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components |
| 3911 | * in this array if it otherwise would have shown them. Useful for omitting specific targets |
| 3912 | * from your own package or other apps from your organization if the idea of sending to those |
| 3913 | * targets would be redundant with other app functionality. Filtered components will not |
| 3914 | * be able to present targets from an associated <code>ChooserTargetService</code>.</p> |
| 3915 | */ |
| 3916 | public static final String EXTRA_EXCLUDE_COMPONENTS |
| 3917 | = "android.intent.extra.EXCLUDE_COMPONENTS"; |
| 3918 | |
| 3919 | /** |
| 3920 | * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} |
| 3921 | * describing additional high-priority deep-link targets for the chooser to present to the user. |
| 3922 | * |
| 3923 | * <p>Targets provided in this way will be presented inline with all other targets provided |
| 3924 | * by services from other apps. They will be prioritized before other service targets, but |
| 3925 | * after those targets provided by sources that the user has manually pinned to the front.</p> |
| 3926 | * |
| 3927 | * @see #ACTION_CHOOSER |
| 3928 | */ |
| 3929 | public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; |
| 3930 | |
| 3931 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3932 | * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection |
| 3933 | * from the chooser activity presented by {@link #ACTION_CHOOSER}. |
| 3934 | * |
| 3935 | * <p>An app preparing an action for another app to complete may wish to allow the user to |
| 3936 | * disambiguate between several options for completing the action based on the chosen target |
| 3937 | * or otherwise refine the action before it is invoked. |
| 3938 | * </p> |
| 3939 | * |
| 3940 | * <p>When sent, this IntentSender may be filled in with the following extras:</p> |
| 3941 | * <ul> |
| 3942 | * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> |
| 3943 | * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's |
| 3944 | * chosen target beyond the first</li> |
| 3945 | * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity |
| 3946 | * should fill in and send once the disambiguation is complete</li> |
| 3947 | * </ul> |
| 3948 | */ |
| 3949 | public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER |
| 3950 | = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; |
| 3951 | |
| 3952 | /** |
Kang Li | 9fa2a2c | 2017-01-06 13:33:24 -0800 | [diff] [blame] | 3953 | * An {@code ArrayList} of {@code String} annotations describing content for |
| 3954 | * {@link #ACTION_CHOOSER}. |
| 3955 | * |
| 3956 | * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a |
| 3957 | * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> |
| 3958 | * |
| 3959 | * <p>Annotations should describe the major components or topics of the content. It is up to |
| 3960 | * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be |
| 3961 | * learned in advance, e.g., when creating or saving content, to avoid increasing latency to |
| 3962 | * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are |
| 3963 | * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to |
| 3964 | * use the following annotations when applicable:</p> |
| 3965 | * <ul> |
| 3966 | * <li>"product": represents that the topic of the content is mainly about products, e.g., |
| 3967 | * health & beauty, and office supplies.</li> |
| 3968 | * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g., |
| 3969 | * happy, and sad.</li> |
| 3970 | * <li>"person": represents that the topic of the content is mainly about persons, e.g., |
| 3971 | * face, finger, standing, and walking.</li> |
| 3972 | * <li>"child": represents that the topic of the content is mainly about children, e.g., |
| 3973 | * child, and baby.</li> |
| 3974 | * <li>"selfie": represents that the topic of the content is mainly about selfies.</li> |
| 3975 | * <li>"crowd": represents that the topic of the content is mainly about crowds.</li> |
| 3976 | * <li>"party": represents that the topic of the content is mainly about parties.</li> |
| 3977 | * <li>"animal": represent that the topic of the content is mainly about animals.</li> |
| 3978 | * <li>"plant": represents that the topic of the content is mainly about plants, e.g., |
| 3979 | * flowers.</li> |
| 3980 | * <li>"vacation": represents that the topic of the content is mainly about vacations.</li> |
| 3981 | * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g. |
| 3982 | * sunglasses, jewelry, handbags and clothing.</li> |
| 3983 | * <li>"material": represents that the topic of the content is mainly about materials, e.g., |
| 3984 | * paper, and silk.</li> |
| 3985 | * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like |
| 3986 | * cars, and boats.</li> |
| 3987 | * <li>"document": represents that the topic of the content is mainly about documents, e.g. |
| 3988 | * posters.</li> |
| 3989 | * <li>"design": represents that the topic of the content is mainly about design, e.g. arts |
| 3990 | * and designs of houses.</li> |
| 3991 | * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g., |
| 3992 | * Christmas and Thanksgiving.</li> |
| 3993 | * </ul> |
| 3994 | */ |
| 3995 | public static final String EXTRA_CONTENT_ANNOTATIONS |
| 3996 | = "android.intent.extra.CONTENT_ANNOTATIONS"; |
| 3997 | |
| 3998 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3999 | * A {@link ResultReceiver} used to return data back to the sender. |
| 4000 | * |
| 4001 | * <p>Used to complete an app-specific |
| 4002 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> |
| 4003 | * |
| 4004 | * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent |
| 4005 | * used to start a {@link #ACTION_CHOOSER} activity this extra will be |
| 4006 | * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent |
| 4007 | * when the user selects a target component from the chooser. It is up to the recipient |
| 4008 | * to send a result to this ResultReceiver to signal that disambiguation is complete |
| 4009 | * and that the chooser should invoke the user's choice.</p> |
| 4010 | * |
| 4011 | * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent |
| 4012 | * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser |
| 4013 | * to match and fill in the final Intent or ChooserTarget before starting it. |
| 4014 | * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from |
| 4015 | * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to |
| 4016 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> |
| 4017 | * |
| 4018 | * <p>The result code passed to the ResultReceiver should be |
| 4019 | * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's |
| 4020 | * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if |
| 4021 | * the chooser should finish without starting a target.</p> |
| 4022 | */ |
| 4023 | public static final String EXTRA_RESULT_RECEIVER |
| 4024 | = "android.intent.extra.RESULT_RECEIVER"; |
| 4025 | |
| 4026 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4027 | * 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] | 4028 | * {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4029 | */ |
| 4030 | public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; |
| 4031 | |
| 4032 | /** |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 4033 | * A Parcelable[] of {@link Intent} or |
| 4034 | * {@link android.content.pm.LabeledIntent} objects as set with |
| 4035 | * {@link #putExtra(String, Parcelable[])} of additional activities to place |
| 4036 | * a the front of the list of choices, when shown to the user with a |
| 4037 | * {@link #ACTION_CHOOSER}. |
| 4038 | */ |
| 4039 | public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; |
| 4040 | |
| 4041 | /** |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 4042 | * A {@link IntentSender} to start after ephemeral installation success. |
| 4043 | * @hide |
| 4044 | */ |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 4045 | public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS"; |
| 4046 | |
| 4047 | /** |
| 4048 | * A {@link IntentSender} to start after ephemeral installation failure. |
| 4049 | * @hide |
| 4050 | */ |
Todd Kennedy | 7440f17 | 2015-12-09 14:31:22 -0800 | [diff] [blame] | 4051 | public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE"; |
| 4052 | |
| 4053 | /** |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 4054 | * The host name that triggered an ephemeral resolution. |
| 4055 | * @hide |
| 4056 | */ |
| 4057 | public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME"; |
| 4058 | |
| 4059 | /** |
| 4060 | * An opaque token to track ephemeral resolution. |
| 4061 | * @hide |
| 4062 | */ |
| 4063 | public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN"; |
| 4064 | |
| 4065 | /** |
Todd Kennedy | 316c2f2 | 2017-01-23 15:40:07 -0800 | [diff] [blame] | 4066 | * The version code of the app to install components from. |
| 4067 | * @hide |
| 4068 | */ |
| 4069 | public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; |
| 4070 | |
| 4071 | /** |
Adam Powell | e49d939 | 2014-07-17 18:45:19 -0700 | [diff] [blame] | 4072 | * A Bundle forming a mapping of potential target package names to different extras Bundles |
| 4073 | * to add to the default intent extras in {@link #EXTRA_INTENT} when used with |
| 4074 | * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not |
| 4075 | * be currently installed on the device. |
| 4076 | * |
| 4077 | * <p>An application may choose to provide alternate extras for the case where a user |
| 4078 | * selects an activity from a predetermined set of target packages. If the activity |
| 4079 | * the user selects from the chooser belongs to a package with its package name as |
| 4080 | * a key in this bundle, the corresponding extras for that package will be merged with |
| 4081 | * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement |
| 4082 | * extra has the same key as an extra already present in the intent it will overwrite |
| 4083 | * the extra from the intent.</p> |
| 4084 | * |
| 4085 | * <p><em>Examples:</em> |
| 4086 | * <ul> |
| 4087 | * <li>An application may offer different {@link #EXTRA_TEXT} to an application |
| 4088 | * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query |
| 4089 | * parameters for that target.</li> |
| 4090 | * <li>An application may offer additional metadata for known targets of a given intent |
| 4091 | * to pass along information only relevant to that target such as account or content |
| 4092 | * identifiers already known to that application.</li> |
| 4093 | * </ul></p> |
| 4094 | */ |
| 4095 | public static final String EXTRA_REPLACEMENT_EXTRAS = |
| 4096 | "android.intent.extra.REPLACEMENT_EXTRAS"; |
| 4097 | |
| 4098 | /** |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 4099 | * An {@link IntentSender} that will be notified if a user successfully chooses a target |
| 4100 | * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender |
| 4101 | * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the |
| 4102 | * {@link ComponentName} of the chosen component. |
| 4103 | * |
| 4104 | * <p>In some situations this callback may never come, for example if the user abandons |
| 4105 | * the chooser, switches to another task or any number of other reasons. Apps should not |
| 4106 | * be written assuming that this callback will always occur.</p> |
| 4107 | */ |
| 4108 | public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = |
| 4109 | "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; |
| 4110 | |
| 4111 | /** |
| 4112 | * The {@link ComponentName} chosen by the user to complete an action. |
| 4113 | * |
| 4114 | * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER |
| 4115 | */ |
| 4116 | public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; |
| 4117 | |
| 4118 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4119 | * A {@link android.view.KeyEvent} object containing the event that |
| 4120 | * triggered the creation of the Intent it is in. |
| 4121 | */ |
| 4122 | public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; |
| 4123 | |
| 4124 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 4125 | * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user |
| 4126 | * before shutting down. |
| 4127 | * |
| 4128 | * {@hide} |
| 4129 | */ |
| 4130 | public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; |
| 4131 | |
| 4132 | /** |
Yusuke Sato | 705ffd1 | 2015-07-21 15:52:11 -0700 | [diff] [blame] | 4133 | * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is |
| 4134 | * requested by the user. |
| 4135 | * |
| 4136 | * {@hide} |
| 4137 | */ |
| 4138 | public static final String EXTRA_USER_REQUESTED_SHUTDOWN = |
| 4139 | "android.intent.extra.USER_REQUESTED_SHUTDOWN"; |
| 4140 | |
| 4141 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 4142 | * 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] | 4143 | * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action |
| 4144 | * of restarting the application. |
| 4145 | */ |
| 4146 | public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; |
| 4147 | |
| 4148 | /** |
| 4149 | * A String holding the phone number originally entered in |
| 4150 | * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual |
| 4151 | * number to call in a {@link android.content.Intent#ACTION_CALL}. |
| 4152 | */ |
| 4153 | public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 4154 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4155 | /** |
| 4156 | * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} |
| 4157 | * intents to supply the uid the package had been assigned. Also an optional |
| 4158 | * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or |
| 4159 | * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same |
| 4160 | * purpose. |
| 4161 | */ |
| 4162 | public static final String EXTRA_UID = "android.intent.extra.UID"; |
| 4163 | |
| 4164 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 4165 | * @hide String array of package names. |
| 4166 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 4167 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 4168 | public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; |
| 4169 | |
| 4170 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4171 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 4172 | * intents to indicate whether this represents a full uninstall (removing |
| 4173 | * both the code and its data) or a partial uninstall (leaving its data, |
| 4174 | * implying that this is an update). |
| 4175 | */ |
| 4176 | 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] | 4177 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4178 | /** |
Dianne Hackborn | c72fc67 | 2012-09-20 13:12:03 -0700 | [diff] [blame] | 4179 | * @hide |
| 4180 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 4181 | * intents to indicate that at this point the package has been removed for |
| 4182 | * all users on the device. |
| 4183 | */ |
| 4184 | public static final String EXTRA_REMOVED_FOR_ALL_USERS |
| 4185 | = "android.intent.extra.REMOVED_FOR_ALL_USERS"; |
| 4186 | |
| 4187 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4188 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 4189 | * intents to indicate that this is a replacement of the package, so this |
| 4190 | * broadcast will immediately be followed by an add broadcast for a |
| 4191 | * different version of the same package. |
| 4192 | */ |
| 4193 | 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] | 4194 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4195 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4196 | * Used as an int extra field in {@link android.app.AlarmManager} intents |
| 4197 | * to tell the application being invoked how many pending alarms are being |
| 4198 | * delievered with the intent. For one-shot alarms this will always be 1. |
| 4199 | * For recurring alarms, this might be greater than 1 if the device was |
| 4200 | * asleep or powered off at the time an earlier alarm would have been |
| 4201 | * delivered. |
| 4202 | */ |
| 4203 | public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 4204 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4205 | /** |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4206 | * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} |
| 4207 | * intents to request the dock state. Possible values are |
Mike Lockwood | 725fcbf | 2009-08-24 13:09:20 -0700 | [diff] [blame] | 4208 | * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, |
| 4209 | * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 4210 | * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or |
| 4211 | * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or |
| 4212 | * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4213 | */ |
| 4214 | public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; |
| 4215 | |
| 4216 | /** |
| 4217 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4218 | * to represent that the phone is not in any dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4219 | */ |
| 4220 | public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; |
| 4221 | |
| 4222 | /** |
| 4223 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4224 | * to represent that the phone is in a desk dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4225 | */ |
| 4226 | public static final int EXTRA_DOCK_STATE_DESK = 1; |
| 4227 | |
| 4228 | /** |
| 4229 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4230 | * to represent that the phone is in a car dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 4231 | */ |
| 4232 | public static final int EXTRA_DOCK_STATE_CAR = 2; |
| 4233 | |
| 4234 | /** |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 4235 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4236 | * to represent that the phone is in a analog (low end) dock. |
| 4237 | */ |
| 4238 | public static final int EXTRA_DOCK_STATE_LE_DESK = 3; |
| 4239 | |
| 4240 | /** |
| 4241 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 4242 | * to represent that the phone is in a digital (high end) dock. |
| 4243 | */ |
| 4244 | public static final int EXTRA_DOCK_STATE_HE_DESK = 4; |
| 4245 | |
| 4246 | /** |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 4247 | * Boolean that can be supplied as meta-data with a dock activity, to |
| 4248 | * indicate that the dock should take over the home key when it is active. |
| 4249 | */ |
| 4250 | public static final String METADATA_DOCK_HOME = "android.dock_home"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4251 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 4252 | /** |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4253 | * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing |
| 4254 | * the bug report. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 4255 | */ |
| 4256 | public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; |
| 4257 | |
| 4258 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 4259 | * Used in the extra field in the remote intent. It's astring token passed with the |
| 4260 | * remote intent. |
| 4261 | */ |
| 4262 | public static final String EXTRA_REMOTE_INTENT_TOKEN = |
| 4263 | "android.intent.extra.remote_intent_token"; |
| 4264 | |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4265 | /** |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 4266 | * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 4267 | * will contain only the first name in the list. |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4268 | */ |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 4269 | @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 4270 | "android.intent.extra.changed_component_name"; |
| 4271 | |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 4272 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4273 | * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 4274 | * and contains a string array of all of the components that have changed. If |
| 4275 | * the state of the overall package has changed, then it will contain an entry |
| 4276 | * with the package name itself. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 4277 | */ |
| 4278 | public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = |
| 4279 | "android.intent.extra.changed_component_name_list"; |
| 4280 | |
| 4281 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4282 | * This field is part of |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 4283 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
Andrei Stingaceanu | 69d5ebc | 2016-01-14 12:59:03 +0000 | [diff] [blame] | 4284 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, |
| 4285 | * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, |
| 4286 | * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4287 | * 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] | 4288 | */ |
| 4289 | public static final String EXTRA_CHANGED_PACKAGE_LIST = |
| 4290 | "android.intent.extra.changed_package_list"; |
| 4291 | |
| 4292 | /** |
| 4293 | * This field is part of |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 4294 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
| 4295 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4296 | * and contains an integer array of uids of all of the components |
| 4297 | * that have changed. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 4298 | */ |
| 4299 | public static final String EXTRA_CHANGED_UID_LIST = |
| 4300 | "android.intent.extra.changed_uid_list"; |
| 4301 | |
| 4302 | /** |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 4303 | * @hide |
| 4304 | * Magic extra system code can use when binding, to give a label for |
| 4305 | * who it is that has bound to a service. This is an integer giving |
| 4306 | * a framework string resource that can be displayed to the user. |
| 4307 | */ |
| 4308 | public static final String EXTRA_CLIENT_LABEL = |
| 4309 | "android.intent.extra.client_label"; |
| 4310 | |
| 4311 | /** |
| 4312 | * @hide |
| 4313 | * Magic extra system code can use when binding, to give a PendingIntent object |
| 4314 | * that can be launched for the user to disable the system's use of this |
| 4315 | * service. |
| 4316 | */ |
| 4317 | public static final String EXTRA_CLIENT_INTENT = |
| 4318 | "android.intent.extra.client_intent"; |
| 4319 | |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 4320 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4321 | * Extra used to indicate that an intent should only return data that is on |
| 4322 | * the local device. This is a boolean extra; the default is false. If true, |
| 4323 | * an implementation should only allow the user to select data that is |
| 4324 | * already on the device, not requiring it be downloaded from a remote |
| 4325 | * service when opened. |
| 4326 | * |
| 4327 | * @see #ACTION_GET_CONTENT |
| 4328 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 4329 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4330 | * @see #ACTION_CREATE_DOCUMENT |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 4331 | */ |
| 4332 | public static final String EXTRA_LOCAL_ONLY = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4333 | "android.intent.extra.LOCAL_ONLY"; |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 4334 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 4335 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4336 | * Extra used to indicate that an intent can allow the user to select and |
| 4337 | * return multiple items. This is a boolean extra; the default is false. If |
| 4338 | * true, an implementation is allowed to present the user with a UI where |
| 4339 | * they can pick multiple items that are all returned to the caller. When |
| 4340 | * this happens, they should be returned as the {@link #getClipData()} part |
| 4341 | * of the result Intent. |
| 4342 | * |
| 4343 | * @see #ACTION_GET_CONTENT |
| 4344 | * @see #ACTION_OPEN_DOCUMENT |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 4345 | */ |
| 4346 | public static final String EXTRA_ALLOW_MULTIPLE = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4347 | "android.intent.extra.ALLOW_MULTIPLE"; |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 4348 | |
| 4349 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 4350 | * The integer userHandle carried with broadcast intents related to addition, removal and |
| 4351 | * switching of users and managed profiles - {@link #ACTION_USER_ADDED}, |
| 4352 | * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. |
| 4353 | * |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 4354 | * @hide |
| 4355 | */ |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 4356 | public static final String EXTRA_USER_HANDLE = |
| 4357 | "android.intent.extra.user_handle"; |
Jean-Michel Trivi | 3114ce3 | 2012-06-11 15:03:52 -0700 | [diff] [blame] | 4358 | |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4359 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 4360 | * The UserHandle carried with broadcasts intents related to addition and removal of managed |
| 4361 | * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}. |
| 4362 | */ |
| 4363 | public static final String EXTRA_USER = |
Alexandra Gherghina | 3315f6b | 2014-09-05 15:48:06 +0100 | [diff] [blame] | 4364 | "android.intent.extra.USER"; |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 4365 | |
| 4366 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4367 | * Extra used in the response from a BroadcastReceiver that handles |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 4368 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is |
| 4369 | * <code>ArrayList<RestrictionEntry></code>. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4370 | */ |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 4371 | public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; |
| 4372 | |
| 4373 | /** |
| 4374 | * Extra sent in the intent to the BroadcastReceiver that handles |
| 4375 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing |
| 4376 | * the restrictions as key/value pairs. |
| 4377 | */ |
| 4378 | public static final String EXTRA_RESTRICTIONS_BUNDLE = |
| 4379 | "android.intent.extra.restrictions_bundle"; |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 4380 | |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 4381 | /** |
| 4382 | * Extra used in the response from a BroadcastReceiver that handles |
| 4383 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. |
| 4384 | */ |
| 4385 | public static final String EXTRA_RESTRICTIONS_INTENT = |
| 4386 | "android.intent.extra.restrictions_intent"; |
| 4387 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 4388 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4389 | * Extra used to communicate a set of acceptable MIME types. The type of the |
| 4390 | * extra is {@code String[]}. Values may be a combination of concrete MIME |
| 4391 | * types (such as "image/png") and/or partial MIME types (such as |
| 4392 | * "audio/*"). |
| 4393 | * |
| 4394 | * @see #ACTION_GET_CONTENT |
| 4395 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 4396 | */ |
| 4397 | public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; |
| 4398 | |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 4399 | /** |
| 4400 | * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that |
| 4401 | * 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] | 4402 | * When this is true, hardware devices can use this information to determine that |
| 4403 | * they shouldn't do a complete shutdown of their device since this is not a |
| 4404 | * complete shutdown down to the kernel, but only user space restarting. |
| 4405 | * The default if not supplied is false. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 4406 | */ |
| 4407 | public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY |
| 4408 | = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; |
| 4409 | |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 4410 | /** |
Neil Fuller | b7146fe | 2016-11-15 16:52:15 +0000 | [diff] [blame] | 4411 | * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the |
| 4412 | * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, |
| 4413 | * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and |
| 4414 | * {@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] | 4415 | * |
| 4416 | * @hide for internal use only. |
| 4417 | */ |
| 4418 | public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = |
| 4419 | "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; |
Neil Fuller | b7146fe | 2016-11-15 16:52:15 +0000 | [diff] [blame] | 4420 | /** @hide */ |
| 4421 | public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; |
| 4422 | /** @hide */ |
| 4423 | public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; |
| 4424 | /** @hide */ |
| 4425 | public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 4426 | |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 4427 | /** {@hide} */ |
| 4428 | public static final String EXTRA_REASON = "android.intent.extra.REASON"; |
| 4429 | |
Rubin Xu | e8490f1 | 2015-06-25 12:17:48 +0100 | [diff] [blame] | 4430 | /** {@hide} */ |
| 4431 | public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; |
| 4432 | |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 4433 | /** |
| 4434 | * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM |
| 4435 | * activation request. |
| 4436 | * TODO: Add information about the structure and response data used with the pending intent. |
| 4437 | * @hide |
| 4438 | */ |
| 4439 | public static final String EXTRA_SIM_ACTIVATION_RESPONSE = |
| 4440 | "android.intent.extra.SIM_ACTIVATION_RESPONSE"; |
| 4441 | |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 4442 | /** |
| 4443 | * Optional index with semantics depending on the intent action. |
Tomasz Mikolajewski | fe02313 | 2016-03-10 17:42:35 +0900 | [diff] [blame] | 4444 | * |
| 4445 | * <p>The value must be an integer greater or equal to 0. |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 4446 | * @see ACTION_QUICK_VIEW |
Tomasz Mikolajewski | 319fb49 | 2016-01-20 12:24:01 +0900 | [diff] [blame] | 4447 | */ |
Steve McKay | 6eaf3863 | 2015-08-04 10:11:01 -0700 | [diff] [blame] | 4448 | public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; |
| 4449 | |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4450 | /** |
Tomasz Mikolajewski | 867addf | 2017-02-01 14:16:39 +0900 | [diff] [blame] | 4451 | * Shows a plain quick viewer UI which doesn't provide any extra features other than |
| 4452 | * quick viewing the items. |
| 4453 | * |
| 4454 | * <p>Especially, the quick viewer should not let users open the quick viewed files |
| 4455 | * in other apps, which includes sharing, opening, editing, printing, etc. |
| 4456 | * |
| 4457 | * <p>This feature is optional, and may not be handled by all quick viewers. |
| 4458 | * |
| 4459 | * <p>The value is boolean. By default false. |
| 4460 | * @see ACTION_QUICK_VIEW |
| 4461 | */ |
| 4462 | public static final String EXTRA_QUICK_VIEW_PLAIN = |
| 4463 | "android.intent.extra.QUICK_VIEW_PLAIN"; |
| 4464 | |
| 4465 | /** |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4466 | * 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] | 4467 | * When a profile goes into quiet mode, all apps in the profile are killed and the |
| 4468 | * profile user is stopped. Widgets originating from the profile are masked, and app |
| 4469 | * launcher icons are grayed out. |
Rubin Xu | 0a29ecd | 2015-11-04 15:11:48 +0000 | [diff] [blame] | 4470 | */ |
| 4471 | public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4472 | |
| 4473 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4474 | * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4475 | * intents to specify the resource type granted. Possible values are |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4476 | * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or |
| 4477 | * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4478 | * |
| 4479 | * @hide |
| 4480 | */ |
| 4481 | public static final String EXTRA_MEDIA_RESOURCE_TYPE = |
| 4482 | "android.intent.extra.MEDIA_RESOURCE_TYPE"; |
| 4483 | |
| 4484 | /** |
Ben Lin | 145b0ca | 2016-10-14 14:23:40 -0700 | [diff] [blame] | 4485 | * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify |
| 4486 | * whether to show the chooser or not when there is only one application available |
| 4487 | * to choose from. |
| 4488 | * |
| 4489 | * @hide |
| 4490 | */ |
| 4491 | public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = |
| 4492 | "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; |
| 4493 | |
| 4494 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4495 | * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4496 | * to represent that a video codec is allowed to use. |
| 4497 | * |
| 4498 | * @hide |
| 4499 | */ |
| 4500 | public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; |
| 4501 | |
| 4502 | /** |
Dongwon Kang | 32cb9ab | 2016-01-13 18:11:10 -0800 | [diff] [blame] | 4503 | * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} |
Dongwon Kang | 2034a4c | 2015-12-14 21:57:34 +0900 | [diff] [blame] | 4504 | * to represent that a audio codec is allowed to use. |
| 4505 | * |
| 4506 | * @hide |
| 4507 | */ |
| 4508 | public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; |
| 4509 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4510 | // --------------------------------------------------------------------- |
| 4511 | // --------------------------------------------------------------------- |
| 4512 | // Intent flags (see mFlags variable). |
| 4513 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4514 | /** @hide */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4515 | @IntDef(flag = true, value = { |
| 4516 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, |
| 4517 | FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4518 | @Retention(RetentionPolicy.SOURCE) |
| 4519 | public @interface GrantUriMode {} |
| 4520 | |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4521 | /** @hide */ |
| 4522 | @IntDef(flag = true, value = { |
| 4523 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) |
| 4524 | @Retention(RetentionPolicy.SOURCE) |
| 4525 | public @interface AccessUriMode {} |
| 4526 | |
| 4527 | /** |
| 4528 | * Test if given mode flags specify an access mode, which must be at least |
| 4529 | * read and/or write. |
| 4530 | * |
| 4531 | * @hide |
| 4532 | */ |
| 4533 | public static boolean isAccessUriMode(int modeFlags) { |
| 4534 | return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION |
| 4535 | | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; |
| 4536 | } |
| 4537 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4538 | /** |
| 4539 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4540 | * 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] | 4541 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 4542 | * all URIs as well as recursive traversals through data or other ClipData |
| 4543 | * in Intent items will be granted; only the grant flags of the top-level |
| 4544 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4545 | */ |
| 4546 | public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; |
| 4547 | /** |
| 4548 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4549 | * 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] | 4550 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 4551 | * all URIs as well as recursive traversals through data or other ClipData |
| 4552 | * in Intent items will be granted; only the grant flags of the top-level |
| 4553 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4554 | */ |
| 4555 | public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; |
| 4556 | /** |
| 4557 | * Can be set by the caller to indicate that this Intent is coming from |
| 4558 | * a background operation, not from direct user interaction. |
| 4559 | */ |
| 4560 | public static final int FLAG_FROM_BACKGROUND = 0x00000004; |
| 4561 | /** |
| 4562 | * A flag you can enable for debugging: when set, log messages will be |
| 4563 | * printed during the resolution of this intent to show you what has |
| 4564 | * been found to create the final resolved list. |
| 4565 | */ |
| 4566 | public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 4567 | /** |
| 4568 | * If set, this intent will not match any components in packages that |
| 4569 | * are currently stopped. If this is not set, then the default behavior |
| 4570 | * is to include such applications in the result. |
| 4571 | */ |
| 4572 | public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; |
| 4573 | /** |
| 4574 | * If set, this intent will always match any components in packages that |
| 4575 | * are currently stopped. This is the default behavior when |
| 4576 | * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these |
| 4577 | * flags are set, this one wins (it allows overriding of exclude for |
| 4578 | * places where the framework may automatically set the exclude flag). |
| 4579 | */ |
| 4580 | public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4581 | |
| 4582 | /** |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 4583 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4584 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 4585 | * persisted across device reboots until explicitly revoked with |
| 4586 | * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the |
| 4587 | * grant for possible persisting; the receiving application must call |
| 4588 | * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to |
| 4589 | * actually persist. |
| 4590 | * |
| 4591 | * @see ContentResolver#takePersistableUriPermission(Uri, int) |
| 4592 | * @see ContentResolver#releasePersistableUriPermission(Uri, int) |
| 4593 | * @see ContentResolver#getPersistedUriPermissions() |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 4594 | * @see ContentResolver#getOutgoingPersistedUriPermissions() |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 4595 | */ |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 4596 | public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 4597 | |
| 4598 | /** |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4599 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 4600 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant |
| 4601 | * applies to any URI that is a prefix match against the original granted |
| 4602 | * URI. (Without this flag, the URI must match exactly for access to be |
| 4603 | * granted.) Another URI is considered a prefix match only when scheme, |
| 4604 | * authority, and all path segments defined by the prefix are an exact |
| 4605 | * match. |
| 4606 | */ |
| 4607 | public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; |
| 4608 | |
| 4609 | /** |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 4610 | * Internal flag used to indicate that a system component has done their |
Jeff Sharkey | 2f3e353 | 2015-12-21 14:16:43 -0700 | [diff] [blame] | 4611 | * homework and verified that they correctly handle packages and components |
| 4612 | * that come and go over time. In particular: |
| 4613 | * <ul> |
| 4614 | * <li>Apps installed on external storage, which will appear to be |
| 4615 | * uninstalled while the the device is ejected. |
| 4616 | * <li>Apps with encryption unaware components, which will appear to not |
| 4617 | * exist while the device is locked. |
| 4618 | * </ul> |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 4619 | * |
| 4620 | * @hide |
| 4621 | */ |
Jeff Sharkey | 2f3e353 | 2015-12-21 14:16:43 -0700 | [diff] [blame] | 4622 | public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100; |
Jeff Sharkey | 2a9e3f8 | 2015-12-18 10:57:58 -0700 | [diff] [blame] | 4623 | |
| 4624 | /** |
Todd Kennedy | 8e2d9d1 | 2016-06-28 14:09:55 -0700 | [diff] [blame] | 4625 | * Internal flag used to indicate ephemeral applications should not be |
| 4626 | * considered when resolving the intent. |
| 4627 | * |
| 4628 | * @hide |
| 4629 | */ |
| 4630 | public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200; |
| 4631 | |
| 4632 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 4633 | * If set, the new activity is not kept in the history stack. As soon as |
| 4634 | * the user navigates away from it, the activity is finished. This may also |
| 4635 | * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory |
| 4636 | * noHistory} attribute. |
Ricardo Cervera | 92f6a74 | 2014-04-04 11:17:06 -0700 | [diff] [blame] | 4637 | * |
| 4638 | * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} |
| 4639 | * is never invoked when the current activity starts a new activity which |
| 4640 | * sets a result and finishes. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4641 | */ |
| 4642 | public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; |
| 4643 | /** |
| 4644 | * If set, the activity will not be launched if it is already running |
| 4645 | * at the top of the history stack. |
| 4646 | */ |
| 4647 | public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; |
| 4648 | /** |
| 4649 | * If set, this activity will become the start of a new task on this |
| 4650 | * history stack. A task (from the activity that started it to the |
| 4651 | * next task activity) defines an atomic group of activities that the |
| 4652 | * user can move to. Tasks can be moved to the foreground and background; |
| 4653 | * 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] | 4654 | * the same order. See |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4655 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4656 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4657 | * |
| 4658 | * <p>This flag is generally used by activities that want |
| 4659 | * to present a "launcher" style behavior: they give the user a list of |
| 4660 | * separate things that can be done, which otherwise run completely |
| 4661 | * independently of the activity launching them. |
| 4662 | * |
| 4663 | * <p>When using this flag, if a task is already running for the activity |
| 4664 | * you are now starting, then a new activity will not be started; instead, |
| 4665 | * the current task will simply be brought to the front of the screen with |
| 4666 | * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag |
| 4667 | * to disable this behavior. |
| 4668 | * |
| 4669 | * <p>This flag can not be used when the caller is requesting a result from |
| 4670 | * the activity being launched. |
| 4671 | */ |
| 4672 | public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; |
| 4673 | /** |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4674 | * This flag is used to create a new task and launch an activity into it. |
| 4675 | * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} |
| 4676 | * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would |
| 4677 | * search through existing tasks for ones matching this Intent. Only if no such |
| 4678 | * task is found would a new task be created. When paired with |
| 4679 | * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip |
| 4680 | * the search for a matching task and unconditionally start a new task. |
| 4681 | * |
| 4682 | * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this |
| 4683 | * flag unless you are implementing your own |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4684 | * top-level application launcher.</strong> Used in conjunction with |
| 4685 | * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the |
| 4686 | * behavior of bringing an existing task to the foreground. When set, |
| 4687 | * a new task is <em>always</em> started to host the Activity for the |
| 4688 | * Intent, regardless of whether there is already an existing task running |
| 4689 | * the same thing. |
| 4690 | * |
| 4691 | * <p><strong>Because the default system does not include graphical task management, |
| 4692 | * you should not use this flag unless you provide some way for a user to |
| 4693 | * return back to the tasks you have launched.</strong> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4694 | * |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4695 | * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for |
| 4696 | * creating new document tasks. |
| 4697 | * |
| 4698 | * <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] | 4699 | * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4700 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4701 | * <p>See |
| 4702 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4703 | * Stack</a> for more information about tasks. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4704 | * |
| 4705 | * @see #FLAG_ACTIVITY_NEW_DOCUMENT |
| 4706 | * @see #FLAG_ACTIVITY_NEW_TASK |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4707 | */ |
| 4708 | public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; |
| 4709 | /** |
| 4710 | * If set, and the activity being launched is already running in the |
| 4711 | * current task, then instead of launching a new instance of that activity, |
| 4712 | * all of the other activities on top of it will be closed and this Intent |
| 4713 | * will be delivered to the (now on top) old activity as a new Intent. |
| 4714 | * |
| 4715 | * <p>For example, consider a task consisting of the activities: A, B, C, D. |
| 4716 | * If D calls startActivity() with an Intent that resolves to the component |
| 4717 | * of activity B, then C and D will be finished and B receive the given |
| 4718 | * Intent, resulting in the stack now being: A, B. |
| 4719 | * |
Dianne Hackborn | aa52f9a | 2009-08-25 16:01:15 -0700 | [diff] [blame] | 4720 | * <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] | 4721 | * either receive the new intent you are starting here in its |
| 4722 | * 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] | 4723 | * 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] | 4724 | * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in |
| 4725 | * the same intent, then it will be finished and re-created; for all other |
| 4726 | * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this |
| 4727 | * 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] | 4728 | * |
| 4729 | * <p>This launch mode can also be used to good effect in conjunction with |
| 4730 | * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity |
| 4731 | * of a task, it will bring any currently running instance of that task |
| 4732 | * to the foreground, and then clear it to its root state. This is |
| 4733 | * especially useful, for example, when launching an activity from the |
| 4734 | * notification manager. |
| 4735 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4736 | * <p>See |
| 4737 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4738 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4739 | */ |
| 4740 | public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; |
| 4741 | /** |
| 4742 | * If set and this intent is being used to launch a new activity from an |
| 4743 | * existing one, then the reply target of the existing activity will be |
| 4744 | * transfered to the new activity. This way the new activity can call |
| 4745 | * {@link android.app.Activity#setResult} and have that result sent back to |
| 4746 | * the reply target of the original activity. |
| 4747 | */ |
| 4748 | public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; |
| 4749 | /** |
| 4750 | * If set and this intent is being used to launch a new activity from an |
| 4751 | * existing one, the current activity will not be counted as the top |
| 4752 | * activity for deciding whether the new intent should be delivered to |
| 4753 | * the top instead of starting a new one. The previous activity will |
| 4754 | * be used as the top, with the assumption being that the current activity |
| 4755 | * will finish itself immediately. |
| 4756 | */ |
| 4757 | public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; |
| 4758 | /** |
| 4759 | * If set, the new activity is not kept in the list of recently launched |
| 4760 | * activities. |
| 4761 | */ |
| 4762 | public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; |
| 4763 | /** |
| 4764 | * This flag is not normally set by application code, but set for you by |
| 4765 | * the system as described in the |
| 4766 | * {@link android.R.styleable#AndroidManifestActivity_launchMode |
| 4767 | * launchMode} documentation for the singleTask mode. |
| 4768 | */ |
| 4769 | public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; |
| 4770 | /** |
| 4771 | * If set, and this activity is either being started in a new task or |
| 4772 | * bringing to the top an existing task, then it will be launched as |
| 4773 | * the front door of the task. This will result in the application of |
| 4774 | * any affinities needed to have that task in the proper state (either |
| 4775 | * moving activities to or from it), or simply resetting that task to |
| 4776 | * its initial state if needed. |
| 4777 | */ |
| 4778 | public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; |
| 4779 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 4780 | * This flag is not normally set by application code, but set for you by |
| 4781 | * the system if this activity is being launched from history |
| 4782 | * (longpress home key). |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4783 | */ |
| 4784 | 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] | 4785 | /** |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 4786 | * @deprecated As of API 21 this performs identically to |
| 4787 | * {@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] | 4788 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 4789 | @Deprecated |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 4790 | 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] | 4791 | /** |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4792 | * This flag is used to open a document into a new task rooted at the activity launched |
| 4793 | * by this Intent. Through the use of this flag, or its equivalent attribute, |
| 4794 | * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 4795 | * containing different documents will appear in the recent tasks list. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4796 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4797 | * <p>The use of the activity attribute form of this, |
| 4798 | * {@link android.R.attr#documentLaunchMode}, is |
| 4799 | * preferred over the Intent flag described here. The attribute form allows the |
| 4800 | * Activity to specify multiple document behavior for all launchers of the Activity |
| 4801 | * 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] | 4802 | * |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4803 | * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for |
| 4804 | * it is kept after the activity is finished is different than the use of |
| 4805 | * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if |
| 4806 | * this flag is being used to create a new recents entry, then by default that entry |
| 4807 | * will be removed once the activity is finished. You can modify this behavior with |
| 4808 | * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. |
| 4809 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4810 | * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link |
| 4811 | * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the |
| 4812 | * equivalent of the Activity manifest specifying {@link |
| 4813 | * android.R.attr#documentLaunchMode}="intoExisting". When used with |
| 4814 | * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying |
| 4815 | * {@link android.R.attr#documentLaunchMode}="always". |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4816 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4817 | * Refer to {@link android.R.attr#documentLaunchMode} for more information. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4818 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4819 | * @see android.R.attr#documentLaunchMode |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4820 | * @see #FLAG_ACTIVITY_MULTIPLE_TASK |
| 4821 | */ |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 4822 | 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] | 4823 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4824 | * 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] | 4825 | * callback from occurring on the current frontmost activity before it is |
| 4826 | * 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] | 4827 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 4828 | * <p>Typically, an activity can rely on that callback to indicate that an |
| 4829 | * explicit user action has caused their activity to be moved out of the |
| 4830 | * foreground. The callback marks an appropriate point in the activity's |
| 4831 | * lifecycle for it to dismiss any notifications that it intends to display |
| 4832 | * "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] | 4833 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 4834 | * <p>If an activity is ever started via any non-user-driven events such as |
| 4835 | * phone-call receipt or an alarm handler, this flag should be passed to {@link |
| 4836 | * Context#startActivity Context.startActivity}, ensuring that the pausing |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4837 | * 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] | 4838 | */ |
| 4839 | 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] | 4840 | /** |
| 4841 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4842 | * this flag will cause the launched activity to be brought to the front of its |
| 4843 | * task's history stack if it is already running. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4844 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4845 | * <p>For example, consider a task consisting of four activities: A, B, C, D. |
| 4846 | * If D calls startActivity() with an Intent that resolves to the component |
| 4847 | * of activity B, then B will be brought to the front of the history stack, |
| 4848 | * with this resulting order: A, C, D, B. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4849 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4850 | * 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] | 4851 | * specified. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4852 | */ |
| 4853 | 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] | 4854 | /** |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 4855 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4856 | * this flag will prevent the system from applying an activity transition |
| 4857 | * animation to go to the next activity state. This doesn't mean an |
| 4858 | * animation will never run -- if another activity change happens that doesn't |
| 4859 | * specify this flag before the activity started here is displayed, then |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 4860 | * 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] | 4861 | * when you are going to do a series of activity operations but the |
| 4862 | * animation seen by the user shouldn't be driven by the first activity |
| 4863 | * change but rather a later one. |
| 4864 | */ |
| 4865 | public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; |
| 4866 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 4867 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4868 | * this flag will cause any existing task that would be associated with the |
| 4869 | * activity to be cleared before the activity is started. That is, the activity |
| 4870 | * becomes the new root of an otherwise empty task, and any old activities |
| 4871 | * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 4872 | */ |
| 4873 | public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; |
| 4874 | /** |
| 4875 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4876 | * this flag will cause a newly launching task to be placed on top of the current |
| 4877 | * home activity task (if there is one). That is, pressing back from the task |
| 4878 | * will always return the user to home even if that was not the last activity they |
| 4879 | * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 4880 | */ |
| 4881 | public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; |
| 4882 | /** |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4883 | * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will |
| 4884 | * 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] | 4885 | * 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] | 4886 | * 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] | 4887 | * this flag. When set and the task's activity is finished, the recents |
| 4888 | * entry will remain in the interface for the user to re-launch it, like a |
| 4889 | * recents entry for a top-level application. |
| 4890 | * <p> |
| 4891 | * The receiving activity can override this request with |
| 4892 | * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling |
| 4893 | * {@link android.app.Activity#finishAndRemoveTask() |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4894 | * Activity.finishAndRemoveTask()}. |
Craig Mautner | 2dac056 | 2014-05-06 09:06:44 -0700 | [diff] [blame] | 4895 | */ |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4896 | public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; |
Craig Mautner | a228ae9 | 2014-07-09 05:44:55 -0700 | [diff] [blame] | 4897 | |
| 4898 | /** |
Wale Ogunwale | 2a25a62 | 2016-01-30 11:27:21 -0800 | [diff] [blame] | 4899 | * This flag is only used in split-screen multi-window mode. The new activity will be displayed |
| 4900 | * 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] | 4901 | * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is |
| 4902 | * 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] | 4903 | */ |
Wale Ogunwale | 2a25a62 | 2016-01-30 11:27:21 -0800 | [diff] [blame] | 4904 | public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; |
Filip Gruszczynski | 80e29f1 | 2015-12-14 14:58:30 -0800 | [diff] [blame] | 4905 | |
| 4906 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4907 | * If set, when sending a broadcast only registered receivers will be |
| 4908 | * called -- no BroadcastReceiver components will be launched. |
| 4909 | */ |
| 4910 | public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4911 | /** |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 4912 | * If set, when sending a broadcast the new broadcast will replace |
| 4913 | * any existing pending broadcast that matches it. Matching is defined |
| 4914 | * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning |
| 4915 | * true for the intents of the two broadcasts. When a match is found, |
| 4916 | * the new broadcast (and receivers associated with it) will replace the |
| 4917 | * existing one in the pending broadcast list, remaining at the same |
| 4918 | * position in the list. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4919 | * |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 4920 | * <p>This flag is most typically used with sticky broadcasts, which |
| 4921 | * only care about delivering the most recent values of the broadcast |
| 4922 | * to their receivers. |
| 4923 | */ |
| 4924 | public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; |
| 4925 | /** |
Christopher Tate | f46723b | 2012-01-26 14:19:24 -0800 | [diff] [blame] | 4926 | * If set, when sending a broadcast the recipient is allowed to run at |
| 4927 | * foreground priority, with a shorter timeout interval. During normal |
| 4928 | * broadcasts the receivers are not automatically hoisted out of the |
| 4929 | * background priority class. |
| 4930 | */ |
| 4931 | public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; |
| 4932 | /** |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4933 | * If this is an ordered broadcast, don't allow receivers to abort the broadcast. |
| 4934 | * They can still propagate results through to later receivers, but they can not prevent |
| 4935 | * later receivers from seeing the broadcast. |
| 4936 | */ |
| 4937 | public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; |
| 4938 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4939 | * If set, when sending a broadcast <i>before boot has completed</i> only |
| 4940 | * registered receivers will be called -- no BroadcastReceiver components |
| 4941 | * will be launched. Sticky intent state will be recorded properly even |
| 4942 | * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} |
| 4943 | * 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] | 4944 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4945 | * <p>This flag is only for use by system sevices as a convenience to |
| 4946 | * avoid having to implement a more complex mechanism around detection |
| 4947 | * of boot completion. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4948 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4949 | * @hide |
| 4950 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4951 | public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 4952 | /** |
| 4953 | * Set when this broadcast is for a boot upgrade, a special mode that |
| 4954 | * allows the broadcast to be sent before the system is ready and launches |
| 4955 | * the app process with no providers running in it. |
| 4956 | * @hide |
| 4957 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4958 | public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; |
Dianne Hackborn | 6ac42ae | 2015-12-08 17:22:10 -0800 | [diff] [blame] | 4959 | /** |
| 4960 | * If set, the broadcast will always go to manifest receivers in background (cached |
| 4961 | * or not running) apps, regardless of whether that would be done by default. By |
| 4962 | * default they will only receive broadcasts if the broadcast has specified an |
| 4963 | * explicit component or package name. |
Christopher Tate | bdc3941 | 2017-01-23 12:21:13 -0800 | [diff] [blame] | 4964 | * |
| 4965 | * NOTE: dumpstate uses this flag numerically, so when its value is changed |
| 4966 | * the broadcast code there must also be changed to match. |
| 4967 | * |
Dianne Hackborn | 6ac42ae | 2015-12-08 17:22:10 -0800 | [diff] [blame] | 4968 | * @hide |
| 4969 | */ |
| 4970 | public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; |
| 4971 | /** |
| 4972 | * If set, the broadcast will never go to manifest receivers in background (cached |
| 4973 | * or not running) apps, regardless of whether that would be done by default. By |
| 4974 | * default they will receive broadcasts if the broadcast has specified an |
| 4975 | * explicit component or package name. |
| 4976 | * @hide |
| 4977 | */ |
| 4978 | public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 4979 | /** |
| 4980 | * If set, this broadcast is being sent from the shell. |
| 4981 | * @hide |
| 4982 | */ |
| 4983 | public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4984 | |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 4985 | /** |
| 4986 | * @hide Flags that can't be changed with PendingIntent. |
| 4987 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4988 | public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION |
| 4989 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 4990 | | FLAG_GRANT_PREFIX_URI_PERMISSION; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4991 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4992 | // --------------------------------------------------------------------- |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4993 | // --------------------------------------------------------------------- |
| 4994 | // toUri() and parseUri() options. |
| 4995 | |
| 4996 | /** |
| 4997 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 4998 | * always has the "intent:" scheme. This syntax can be used when you want |
| 4999 | * to later disambiguate between URIs that are intended to describe an |
| 5000 | * Intent vs. all others that should be treated as raw URIs. When used |
| 5001 | * with {@link #parseUri}, any other scheme will result in a generic |
| 5002 | * VIEW action for that raw URI. |
| 5003 | */ |
| 5004 | public static final int URI_INTENT_SCHEME = 1<<0; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5005 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5006 | /** |
| 5007 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 5008 | * always has the "android-app:" scheme. This is a variation of |
| 5009 | * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an |
| 5010 | * http/https URI being delivered to a specific package name. The format |
| 5011 | * is: |
| 5012 | * |
| 5013 | * <pre class="prettyprint"> |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 5014 | * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5015 | * |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 5016 | * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, |
| 5017 | * you must also include a scheme; including a path also requires both a host and a scheme. |
| 5018 | * The final #Intent; fragment can be used without a scheme, host, or path. |
| 5019 | * Note that this can not be |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5020 | * used with intents that have a {@link #setSelector}, since the base intent |
| 5021 | * will always have an explicit package name.</p> |
| 5022 | * |
| 5023 | * <p>Some examples of how this scheme maps to Intent objects:</p> |
| 5024 | * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> |
| 5025 | * <colgroup align="left" /> |
| 5026 | * <colgroup align="left" /> |
| 5027 | * <thead> |
| 5028 | * <tr><th>URI</th> <th>Intent</th></tr> |
| 5029 | * </thead> |
| 5030 | * |
| 5031 | * <tbody> |
| 5032 | * <tr><td><code>android-app://com.example.app</code></td> |
| 5033 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5034 | * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> |
| 5035 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5036 | * </table></td> |
| 5037 | * </tr> |
| 5038 | * <tr><td><code>android-app://com.example.app/http/example.com</code></td> |
| 5039 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5040 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 5041 | * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> |
| 5042 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5043 | * </table></td> |
| 5044 | * </tr> |
| 5045 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> |
| 5046 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5047 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 5048 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 5049 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5050 | * </table></td> |
| 5051 | * </tr> |
| 5052 | * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 5053 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5054 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 5055 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5056 | * </table></td> |
| 5057 | * </tr> |
| 5058 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 5059 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 5060 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 5061 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 5062 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5063 | * </table></td> |
| 5064 | * </tr> |
| 5065 | * <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> |
| 5066 | * <td><table border="" style="margin:0" > |
| 5067 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 5068 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 5069 | * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> |
| 5070 | * </table></td> |
| 5071 | * </tr> |
| 5072 | * </tbody> |
| 5073 | * </table> |
| 5074 | */ |
| 5075 | public static final int URI_ANDROID_APP_SCHEME = 1<<1; |
| 5076 | |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5077 | /** |
| 5078 | * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing |
| 5079 | * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, |
| 5080 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, |
| 5081 | * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the |
| 5082 | * generated Intent can not cause unexpected data access to happen. |
| 5083 | * |
| 5084 | * <p>If you do not trust the source of the URI being parsed, you should still do further |
| 5085 | * processing to protect yourself from it. In particular, when using it to start an |
| 5086 | * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities |
| 5087 | * that can handle it.</p> |
| 5088 | */ |
| 5089 | public static final int URI_ALLOW_UNSAFE = 1<<2; |
| 5090 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5091 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5092 | |
| 5093 | private String mAction; |
| 5094 | private Uri mData; |
| 5095 | private String mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5096 | private String mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5097 | private ComponentName mComponent; |
| 5098 | private int mFlags; |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 5099 | private ArraySet<String> mCategories; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5100 | private Bundle mExtras; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5101 | private Rect mSourceBounds; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5102 | private Intent mSelector; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5103 | private ClipData mClipData; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 5104 | private int mContentUserHint = UserHandle.USER_CURRENT; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5105 | |
| 5106 | // --------------------------------------------------------------------- |
| 5107 | |
| 5108 | /** |
| 5109 | * Create an empty intent. |
| 5110 | */ |
| 5111 | public Intent() { |
| 5112 | } |
| 5113 | |
| 5114 | /** |
| 5115 | * Copy constructor. |
| 5116 | */ |
| 5117 | public Intent(Intent o) { |
| 5118 | this.mAction = o.mAction; |
| 5119 | this.mData = o.mData; |
| 5120 | this.mType = o.mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5121 | this.mPackage = o.mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5122 | this.mComponent = o.mComponent; |
| 5123 | this.mFlags = o.mFlags; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 5124 | this.mContentUserHint = o.mContentUserHint; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5125 | if (o.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 5126 | this.mCategories = new ArraySet<String>(o.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5127 | } |
| 5128 | if (o.mExtras != null) { |
| 5129 | this.mExtras = new Bundle(o.mExtras); |
| 5130 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5131 | if (o.mSourceBounds != null) { |
| 5132 | this.mSourceBounds = new Rect(o.mSourceBounds); |
| 5133 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5134 | if (o.mSelector != null) { |
| 5135 | this.mSelector = new Intent(o.mSelector); |
| 5136 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5137 | if (o.mClipData != null) { |
| 5138 | this.mClipData = new ClipData(o.mClipData); |
| 5139 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5140 | } |
| 5141 | |
| 5142 | @Override |
| 5143 | public Object clone() { |
| 5144 | return new Intent(this); |
| 5145 | } |
| 5146 | |
| 5147 | private Intent(Intent o, boolean all) { |
| 5148 | this.mAction = o.mAction; |
| 5149 | this.mData = o.mData; |
| 5150 | this.mType = o.mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5151 | this.mPackage = o.mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5152 | this.mComponent = o.mComponent; |
| 5153 | if (o.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 5154 | this.mCategories = new ArraySet<String>(o.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5155 | } |
| 5156 | } |
| 5157 | |
| 5158 | /** |
| 5159 | * Make a clone of only the parts of the Intent that are relevant for |
| 5160 | * filter matching: the action, data, type, component, and categories. |
| 5161 | */ |
| 5162 | public Intent cloneFilter() { |
| 5163 | return new Intent(this, false); |
| 5164 | } |
| 5165 | |
| 5166 | /** |
| 5167 | * Create an intent with a given action. All other fields (data, type, |
| 5168 | * class) are null. Note that the action <em>must</em> be in a |
| 5169 | * namespace because Intents are used globally in the system -- for |
| 5170 | * example the system VIEW action is android.intent.action.VIEW; an |
| 5171 | * application's custom action would be something like |
| 5172 | * com.google.app.myapp.CUSTOM_ACTION. |
| 5173 | * |
| 5174 | * @param action The Intent action, such as ACTION_VIEW. |
| 5175 | */ |
| 5176 | public Intent(String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5177 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5178 | } |
| 5179 | |
| 5180 | /** |
| 5181 | * Create an intent with a given action and for a given data url. Note |
| 5182 | * that the action <em>must</em> be in a namespace because Intents are |
| 5183 | * used globally in the system -- for example the system VIEW action is |
| 5184 | * android.intent.action.VIEW; an application's custom action would be |
| 5185 | * something like com.google.app.myapp.CUSTOM_ACTION. |
| 5186 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 5187 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 5188 | * case-sensitive, unlike the formal RFC. As a result, |
| 5189 | * you should always ensure that you write your Uri with these elements |
| 5190 | * using lower case letters, and normalize any Uris you receive from |
| 5191 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 5192 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5193 | * @param action The Intent action, such as ACTION_VIEW. |
| 5194 | * @param uri The Intent data URI. |
| 5195 | */ |
| 5196 | public Intent(String action, Uri uri) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5197 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5198 | mData = uri; |
| 5199 | } |
| 5200 | |
| 5201 | /** |
| 5202 | * Create an intent for a specific component. All other fields (action, data, |
| 5203 | * type, class) are null, though they can be modified later with explicit |
| 5204 | * calls. This provides a convenient way to create an intent that is |
| 5205 | * intended to execute a hard-coded class name, rather than relying on the |
| 5206 | * system to find an appropriate class for you; see {@link #setComponent} |
| 5207 | * for more information on the repercussions of this. |
| 5208 | * |
| 5209 | * @param packageContext A Context of the application package implementing |
| 5210 | * this class. |
| 5211 | * @param cls The component class that is to be used for the intent. |
| 5212 | * |
| 5213 | * @see #setClass |
| 5214 | * @see #setComponent |
| 5215 | * @see #Intent(String, android.net.Uri , Context, Class) |
| 5216 | */ |
| 5217 | public Intent(Context packageContext, Class<?> cls) { |
| 5218 | mComponent = new ComponentName(packageContext, cls); |
| 5219 | } |
| 5220 | |
| 5221 | /** |
| 5222 | * 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] | 5223 | * 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] | 5224 | * construct the Intent and then calling {@link #setClass} to set its |
| 5225 | * class. |
| 5226 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 5227 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 5228 | * case-sensitive, unlike the formal RFC. As a result, |
| 5229 | * you should always ensure that you write your Uri with these elements |
| 5230 | * using lower case letters, and normalize any Uris you receive from |
| 5231 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 5232 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5233 | * @param action The Intent action, such as ACTION_VIEW. |
| 5234 | * @param uri The Intent data URI. |
| 5235 | * @param packageContext A Context of the application package implementing |
| 5236 | * this class. |
| 5237 | * @param cls The component class that is to be used for the intent. |
| 5238 | * |
| 5239 | * @see #Intent(String, android.net.Uri) |
| 5240 | * @see #Intent(Context, Class) |
| 5241 | * @see #setClass |
| 5242 | * @see #setComponent |
| 5243 | */ |
| 5244 | public Intent(String action, Uri uri, |
| 5245 | Context packageContext, Class<?> cls) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5246 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5247 | mData = uri; |
| 5248 | mComponent = new ComponentName(packageContext, cls); |
| 5249 | } |
| 5250 | |
| 5251 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 5252 | * Create an intent to launch the main (root) activity of a task. This |
| 5253 | * is the Intent that is started when the application's is launched from |
| 5254 | * Home. For anything else that wants to launch an application in the |
| 5255 | * same way, it is important that they use an Intent structured the same |
| 5256 | * way, and can use this function to ensure this is the case. |
| 5257 | * |
| 5258 | * <p>The returned Intent has the given Activity component as its explicit |
| 5259 | * component, {@link #ACTION_MAIN} as its action, and includes the |
| 5260 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 5261 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 5262 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 5263 | * |
| 5264 | * @param mainActivity The main activity component that this Intent will |
| 5265 | * launch. |
| 5266 | * @return Returns a newly created Intent that can be used to launch the |
| 5267 | * activity as a main application entry. |
| 5268 | * |
| 5269 | * @see #setClass |
| 5270 | * @see #setComponent |
| 5271 | */ |
| 5272 | public static Intent makeMainActivity(ComponentName mainActivity) { |
| 5273 | Intent intent = new Intent(ACTION_MAIN); |
| 5274 | intent.setComponent(mainActivity); |
| 5275 | intent.addCategory(CATEGORY_LAUNCHER); |
| 5276 | return intent; |
| 5277 | } |
| 5278 | |
| 5279 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5280 | * Make an Intent for the main activity of an application, without |
| 5281 | * specifying a specific activity to run but giving a selector to find |
| 5282 | * the activity. This results in a final Intent that is structured |
| 5283 | * the same as when the application is launched from |
| 5284 | * Home. For anything else that wants to launch an application in the |
| 5285 | * same way, it is important that they use an Intent structured the same |
| 5286 | * way, and can use this function to ensure this is the case. |
| 5287 | * |
| 5288 | * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the |
| 5289 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 5290 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 5291 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 5292 | * |
| 5293 | * @param selectorAction The action name of the Intent's selector. |
| 5294 | * @param selectorCategory The name of a category to add to the Intent's |
| 5295 | * selector. |
| 5296 | * @return Returns a newly created Intent that can be used to launch the |
| 5297 | * activity as a main application entry. |
| 5298 | * |
| 5299 | * @see #setSelector(Intent) |
| 5300 | */ |
| 5301 | public static Intent makeMainSelectorActivity(String selectorAction, |
| 5302 | String selectorCategory) { |
| 5303 | Intent intent = new Intent(ACTION_MAIN); |
| 5304 | intent.addCategory(CATEGORY_LAUNCHER); |
| 5305 | Intent selector = new Intent(); |
| 5306 | selector.setAction(selectorAction); |
| 5307 | selector.addCategory(selectorCategory); |
| 5308 | intent.setSelector(selector); |
| 5309 | return intent; |
| 5310 | } |
| 5311 | |
| 5312 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 5313 | * Make an Intent that can be used to re-launch an application's task |
| 5314 | * in its base state. This is like {@link #makeMainActivity(ComponentName)}, |
| 5315 | * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and |
| 5316 | * {@link #FLAG_ACTIVITY_CLEAR_TASK}. |
| 5317 | * |
| 5318 | * @param mainActivity The activity component that is the root of the |
| 5319 | * task; this is the activity that has been published in the application's |
| 5320 | * manifest as the main launcher icon. |
| 5321 | * |
| 5322 | * @return Returns a newly created Intent that can be used to relaunch the |
| 5323 | * activity's task in its root state. |
| 5324 | */ |
| 5325 | public static Intent makeRestartActivityTask(ComponentName mainActivity) { |
| 5326 | Intent intent = makeMainActivity(mainActivity); |
| 5327 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 5328 | | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 5329 | return intent; |
| 5330 | } |
| 5331 | |
| 5332 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5333 | * Call {@link #parseUri} with 0 flags. |
| 5334 | * @deprecated Use {@link #parseUri} instead. |
| 5335 | */ |
| 5336 | @Deprecated |
| 5337 | public static Intent getIntent(String uri) throws URISyntaxException { |
| 5338 | return parseUri(uri, 0); |
| 5339 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5340 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5341 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5342 | * Create an intent from a URI. This URI may encode the action, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5343 | * category, and other intent fields, if it was returned by |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 5344 | * {@link #toUri}. If the Intent was not generate by toUri(), its data |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5345 | * 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] | 5346 | * |
| 5347 | * <p>The URI given here must not be relative -- that is, it must include |
| 5348 | * the scheme and full path. |
| 5349 | * |
| 5350 | * @param uri The URI to turn into an Intent. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5351 | * @param flags Additional processing flags. Either 0, |
| 5352 | * {@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] | 5353 | * |
| 5354 | * @return Intent The newly created Intent object. |
| 5355 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5356 | * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax |
| 5357 | * it bad (as parsed by the Uri class) or the Intent data within the |
| 5358 | * URI is invalid. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5359 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5360 | * @see #toUri |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5361 | */ |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5362 | 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] | 5363 | int i = 0; |
| 5364 | try { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5365 | final boolean androidApp = uri.startsWith("android-app:"); |
| 5366 | |
| 5367 | // Validate intent scheme if requested. |
| 5368 | if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { |
| 5369 | if (!uri.startsWith("intent:") && !androidApp) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5370 | Intent intent = new Intent(ACTION_VIEW); |
| 5371 | try { |
| 5372 | intent.setData(Uri.parse(uri)); |
| 5373 | } catch (IllegalArgumentException e) { |
| 5374 | throw new URISyntaxException(uri, e.getMessage()); |
| 5375 | } |
| 5376 | return intent; |
| 5377 | } |
| 5378 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5379 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5380 | i = uri.lastIndexOf("#"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5381 | // simple case |
| 5382 | if (i == -1) { |
| 5383 | if (!androidApp) { |
| 5384 | return new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 5385 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5386 | |
| 5387 | // old format Intent URI |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5388 | } else if (!uri.startsWith("#Intent;", i)) { |
| 5389 | if (!androidApp) { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5390 | return getIntentOld(uri, flags); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5391 | } else { |
| 5392 | i = -1; |
| 5393 | } |
| 5394 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5395 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5396 | // new format |
| 5397 | Intent intent = new Intent(ACTION_VIEW); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5398 | Intent baseIntent = intent; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5399 | boolean explicitAction = false; |
| 5400 | boolean inSelector = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5401 | |
| 5402 | // fetch data part, if present |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5403 | String scheme = null; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5404 | String data; |
| 5405 | if (i >= 0) { |
| 5406 | data = uri.substring(0, i); |
| 5407 | i += 8; // length of "#Intent;" |
| 5408 | } else { |
| 5409 | data = uri; |
| 5410 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5411 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5412 | // loop over contents of Intent, all name=value; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5413 | while (i >= 0 && !uri.startsWith("end", i)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5414 | int eq = uri.indexOf('=', i); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5415 | if (eq < 0) eq = i-1; |
| 5416 | int semi = uri.indexOf(';', i); |
| 5417 | 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] | 5418 | |
| 5419 | // action |
| 5420 | if (uri.startsWith("action=", i)) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5421 | intent.setAction(value); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5422 | if (!inSelector) { |
| 5423 | explicitAction = true; |
| 5424 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5425 | } |
| 5426 | |
| 5427 | // categories |
| 5428 | else if (uri.startsWith("category=", i)) { |
| 5429 | intent.addCategory(value); |
| 5430 | } |
| 5431 | |
| 5432 | // type |
| 5433 | else if (uri.startsWith("type=", i)) { |
| 5434 | intent.mType = value; |
| 5435 | } |
| 5436 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5437 | // launch flags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5438 | else if (uri.startsWith("launchFlags=", i)) { |
| 5439 | intent.mFlags = Integer.decode(value).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5440 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 5441 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 5442 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5443 | } |
| 5444 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5445 | // package |
| 5446 | else if (uri.startsWith("package=", i)) { |
| 5447 | intent.mPackage = value; |
| 5448 | } |
| 5449 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5450 | // component |
| 5451 | else if (uri.startsWith("component=", i)) { |
| 5452 | intent.mComponent = ComponentName.unflattenFromString(value); |
| 5453 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5454 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5455 | // scheme |
| 5456 | else if (uri.startsWith("scheme=", i)) { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5457 | if (inSelector) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 5458 | intent.mData = Uri.parse(value + ":"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5459 | } else { |
| 5460 | scheme = value; |
| 5461 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5462 | } |
| 5463 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5464 | // source bounds |
| 5465 | else if (uri.startsWith("sourceBounds=", i)) { |
| 5466 | intent.mSourceBounds = Rect.unflattenFromString(value); |
| 5467 | } |
| 5468 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5469 | // selector |
| 5470 | else if (semi == (i+3) && uri.startsWith("SEL", i)) { |
| 5471 | intent = new Intent(); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5472 | inSelector = true; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5473 | } |
| 5474 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5475 | // extra |
| 5476 | else { |
| 5477 | String key = Uri.decode(uri.substring(i + 2, eq)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5478 | // create Bundle if it doesn't already exist |
| 5479 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
| 5480 | Bundle b = intent.mExtras; |
| 5481 | // add EXTRA |
| 5482 | if (uri.startsWith("S.", i)) b.putString(key, value); |
| 5483 | else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); |
| 5484 | else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); |
| 5485 | else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); |
| 5486 | else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); |
| 5487 | else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); |
| 5488 | else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); |
| 5489 | else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); |
| 5490 | else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); |
| 5491 | else throw new URISyntaxException(uri, "unknown EXTRA type", i); |
| 5492 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5493 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5494 | // move to the next item |
| 5495 | i = semi + 1; |
| 5496 | } |
| 5497 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5498 | if (inSelector) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5499 | // The Intent had a selector; fix it up. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5500 | if (baseIntent.mPackage == null) { |
| 5501 | baseIntent.setSelector(intent); |
| 5502 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5503 | intent = baseIntent; |
| 5504 | } |
| 5505 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5506 | if (data != null) { |
| 5507 | if (data.startsWith("intent:")) { |
| 5508 | data = data.substring(7); |
| 5509 | if (scheme != null) { |
| 5510 | data = scheme + ':' + data; |
| 5511 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5512 | } else if (data.startsWith("android-app:")) { |
| 5513 | if (data.charAt(12) == '/' && data.charAt(13) == '/') { |
| 5514 | // Correctly formed android-app, first part is package name. |
| 5515 | int end = data.indexOf('/', 14); |
| 5516 | if (end < 0) { |
| 5517 | // All we have is a package name. |
| 5518 | intent.mPackage = data.substring(14); |
| 5519 | if (!explicitAction) { |
| 5520 | intent.setAction(ACTION_MAIN); |
| 5521 | } |
| 5522 | data = ""; |
| 5523 | } else { |
| 5524 | // Target the Intent at the given package name always. |
| 5525 | String authority = null; |
| 5526 | intent.mPackage = data.substring(14, end); |
| 5527 | int newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 5528 | if ((end+1) < data.length()) { |
| 5529 | if ((newEnd=data.indexOf('/', end+1)) >= 0) { |
| 5530 | // Found a scheme, remember it. |
| 5531 | scheme = data.substring(end+1, newEnd); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5532 | end = newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 5533 | if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { |
| 5534 | // Found a authority, remember it. |
| 5535 | authority = data.substring(end+1, newEnd); |
| 5536 | end = newEnd; |
| 5537 | } |
| 5538 | } else { |
| 5539 | // All we have is a scheme. |
| 5540 | scheme = data.substring(end+1); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 5541 | } |
| 5542 | } |
| 5543 | if (scheme == null) { |
| 5544 | // If there was no scheme, then this just targets the package. |
| 5545 | if (!explicitAction) { |
| 5546 | intent.setAction(ACTION_MAIN); |
| 5547 | } |
| 5548 | data = ""; |
| 5549 | } else if (authority == null) { |
| 5550 | data = scheme + ":"; |
| 5551 | } else { |
| 5552 | data = scheme + "://" + authority + data.substring(end); |
| 5553 | } |
| 5554 | } |
| 5555 | } else { |
| 5556 | data = ""; |
| 5557 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5558 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5559 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5560 | if (data.length() > 0) { |
| 5561 | try { |
| 5562 | intent.mData = Uri.parse(data); |
| 5563 | } catch (IllegalArgumentException e) { |
| 5564 | throw new URISyntaxException(uri, e.getMessage()); |
| 5565 | } |
| 5566 | } |
| 5567 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5568 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5569 | return intent; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5570 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5571 | } catch (IndexOutOfBoundsException e) { |
| 5572 | throw new URISyntaxException(uri, "illegal Intent URI format", i); |
| 5573 | } |
| 5574 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5575 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5576 | public static Intent getIntentOld(String uri) throws URISyntaxException { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5577 | return getIntentOld(uri, 0); |
| 5578 | } |
| 5579 | |
| 5580 | 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] | 5581 | Intent intent; |
| 5582 | |
| 5583 | int i = uri.lastIndexOf('#'); |
| 5584 | if (i >= 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5585 | String action = null; |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5586 | final int intentFragmentStart = i; |
| 5587 | boolean isIntentFragment = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5588 | |
| 5589 | i++; |
| 5590 | |
| 5591 | if (uri.regionMatches(i, "action(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5592 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5593 | i += 7; |
| 5594 | int j = uri.indexOf(')', i); |
| 5595 | action = uri.substring(i, j); |
| 5596 | i = j + 1; |
| 5597 | } |
| 5598 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5599 | intent = new Intent(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5600 | |
| 5601 | if (uri.regionMatches(i, "categories(", 0, 11)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5602 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5603 | i += 11; |
| 5604 | int j = uri.indexOf(')', i); |
| 5605 | while (i < j) { |
| 5606 | int sep = uri.indexOf('!', i); |
Alan Viverette | 0adf32b | 2014-09-18 12:53:16 -0700 | [diff] [blame] | 5607 | if (sep < 0 || sep > j) sep = j; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5608 | if (i < sep) { |
| 5609 | intent.addCategory(uri.substring(i, sep)); |
| 5610 | } |
| 5611 | i = sep + 1; |
| 5612 | } |
| 5613 | i = j + 1; |
| 5614 | } |
| 5615 | |
| 5616 | if (uri.regionMatches(i, "type(", 0, 5)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5617 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5618 | i += 5; |
| 5619 | int j = uri.indexOf(')', i); |
| 5620 | intent.mType = uri.substring(i, j); |
| 5621 | i = j + 1; |
| 5622 | } |
| 5623 | |
| 5624 | if (uri.regionMatches(i, "launchFlags(", 0, 12)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5625 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5626 | i += 12; |
| 5627 | int j = uri.indexOf(')', i); |
| 5628 | intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 5629 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 5630 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 5631 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5632 | i = j + 1; |
| 5633 | } |
| 5634 | |
| 5635 | if (uri.regionMatches(i, "component(", 0, 10)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5636 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5637 | i += 10; |
| 5638 | int j = uri.indexOf(')', i); |
| 5639 | int sep = uri.indexOf('!', i); |
| 5640 | if (sep >= 0 && sep < j) { |
| 5641 | String pkg = uri.substring(i, sep); |
| 5642 | String cls = uri.substring(sep + 1, j); |
| 5643 | intent.mComponent = new ComponentName(pkg, cls); |
| 5644 | } |
| 5645 | i = j + 1; |
| 5646 | } |
| 5647 | |
| 5648 | if (uri.regionMatches(i, "extras(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5649 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5650 | i += 7; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5651 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5652 | final int closeParen = uri.indexOf(')', i); |
| 5653 | if (closeParen == -1) throw new URISyntaxException(uri, |
| 5654 | "EXTRA missing trailing ')'", i); |
| 5655 | |
| 5656 | while (i < closeParen) { |
| 5657 | // fetch the key value |
| 5658 | int j = uri.indexOf('=', i); |
| 5659 | if (j <= i + 1 || i >= closeParen) { |
| 5660 | throw new URISyntaxException(uri, "EXTRA missing '='", i); |
| 5661 | } |
| 5662 | char type = uri.charAt(i); |
| 5663 | i++; |
| 5664 | String key = uri.substring(i, j); |
| 5665 | i = j + 1; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5666 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5667 | // get type-value |
| 5668 | j = uri.indexOf('!', i); |
| 5669 | if (j == -1 || j >= closeParen) j = closeParen; |
| 5670 | if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 5671 | String value = uri.substring(i, j); |
| 5672 | i = j; |
| 5673 | |
| 5674 | // create Bundle if it doesn't already exist |
| 5675 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5676 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5677 | // add item to bundle |
| 5678 | try { |
| 5679 | switch (type) { |
| 5680 | case 'S': |
| 5681 | intent.mExtras.putString(key, Uri.decode(value)); |
| 5682 | break; |
| 5683 | case 'B': |
| 5684 | intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); |
| 5685 | break; |
| 5686 | case 'b': |
| 5687 | intent.mExtras.putByte(key, Byte.parseByte(value)); |
| 5688 | break; |
| 5689 | case 'c': |
| 5690 | intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); |
| 5691 | break; |
| 5692 | case 'd': |
| 5693 | intent.mExtras.putDouble(key, Double.parseDouble(value)); |
| 5694 | break; |
| 5695 | case 'f': |
| 5696 | intent.mExtras.putFloat(key, Float.parseFloat(value)); |
| 5697 | break; |
| 5698 | case 'i': |
| 5699 | intent.mExtras.putInt(key, Integer.parseInt(value)); |
| 5700 | break; |
| 5701 | case 'l': |
| 5702 | intent.mExtras.putLong(key, Long.parseLong(value)); |
| 5703 | break; |
| 5704 | case 's': |
| 5705 | intent.mExtras.putShort(key, Short.parseShort(value)); |
| 5706 | break; |
| 5707 | default: |
| 5708 | throw new URISyntaxException(uri, "EXTRA has unknown type", i); |
| 5709 | } |
| 5710 | } catch (NumberFormatException e) { |
| 5711 | throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); |
| 5712 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5713 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5714 | char ch = uri.charAt(i); |
| 5715 | if (ch == ')') break; |
| 5716 | if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 5717 | i++; |
| 5718 | } |
| 5719 | } |
| 5720 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5721 | if (isIntentFragment) { |
| 5722 | intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); |
| 5723 | } else { |
| 5724 | intent.mData = Uri.parse(uri); |
| 5725 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5726 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5727 | if (intent.mAction == null) { |
| 5728 | // By default, if no action is specified, then use VIEW. |
| 5729 | intent.mAction = ACTION_VIEW; |
| 5730 | } |
| 5731 | |
| 5732 | } else { |
| 5733 | intent = new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 5734 | } |
| 5735 | |
| 5736 | return intent; |
| 5737 | } |
| 5738 | |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 5739 | /** @hide */ |
| 5740 | public interface CommandOptionHandler { |
| 5741 | boolean handleOption(String opt, ShellCommand cmd); |
| 5742 | } |
| 5743 | |
| 5744 | /** @hide */ |
| 5745 | public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) |
| 5746 | throws URISyntaxException { |
| 5747 | Intent intent = new Intent(); |
| 5748 | Intent baseIntent = intent; |
| 5749 | boolean hasIntentInfo = false; |
| 5750 | |
| 5751 | Uri data = null; |
| 5752 | String type = null; |
| 5753 | |
| 5754 | String opt; |
| 5755 | while ((opt=cmd.getNextOption()) != null) { |
| 5756 | switch (opt) { |
| 5757 | case "-a": |
| 5758 | intent.setAction(cmd.getNextArgRequired()); |
| 5759 | if (intent == baseIntent) { |
| 5760 | hasIntentInfo = true; |
| 5761 | } |
| 5762 | break; |
| 5763 | case "-d": |
| 5764 | data = Uri.parse(cmd.getNextArgRequired()); |
| 5765 | if (intent == baseIntent) { |
| 5766 | hasIntentInfo = true; |
| 5767 | } |
| 5768 | break; |
| 5769 | case "-t": |
| 5770 | type = cmd.getNextArgRequired(); |
| 5771 | if (intent == baseIntent) { |
| 5772 | hasIntentInfo = true; |
| 5773 | } |
| 5774 | break; |
| 5775 | case "-c": |
| 5776 | intent.addCategory(cmd.getNextArgRequired()); |
| 5777 | if (intent == baseIntent) { |
| 5778 | hasIntentInfo = true; |
| 5779 | } |
| 5780 | break; |
| 5781 | case "-e": |
| 5782 | case "--es": { |
| 5783 | String key = cmd.getNextArgRequired(); |
| 5784 | String value = cmd.getNextArgRequired(); |
| 5785 | intent.putExtra(key, value); |
| 5786 | } |
| 5787 | break; |
| 5788 | case "--esn": { |
| 5789 | String key = cmd.getNextArgRequired(); |
| 5790 | intent.putExtra(key, (String) null); |
| 5791 | } |
| 5792 | break; |
| 5793 | case "--ei": { |
| 5794 | String key = cmd.getNextArgRequired(); |
| 5795 | String value = cmd.getNextArgRequired(); |
| 5796 | intent.putExtra(key, Integer.decode(value)); |
| 5797 | } |
| 5798 | break; |
| 5799 | case "--eu": { |
| 5800 | String key = cmd.getNextArgRequired(); |
| 5801 | String value = cmd.getNextArgRequired(); |
| 5802 | intent.putExtra(key, Uri.parse(value)); |
| 5803 | } |
| 5804 | break; |
| 5805 | case "--ecn": { |
| 5806 | String key = cmd.getNextArgRequired(); |
| 5807 | String value = cmd.getNextArgRequired(); |
| 5808 | ComponentName cn = ComponentName.unflattenFromString(value); |
| 5809 | if (cn == null) |
| 5810 | throw new IllegalArgumentException("Bad component name: " + value); |
| 5811 | intent.putExtra(key, cn); |
| 5812 | } |
| 5813 | break; |
| 5814 | case "--eia": { |
| 5815 | String key = cmd.getNextArgRequired(); |
| 5816 | String value = cmd.getNextArgRequired(); |
| 5817 | String[] strings = value.split(","); |
| 5818 | int[] list = new int[strings.length]; |
| 5819 | for (int i = 0; i < strings.length; i++) { |
| 5820 | list[i] = Integer.decode(strings[i]); |
| 5821 | } |
| 5822 | intent.putExtra(key, list); |
| 5823 | } |
| 5824 | break; |
| 5825 | case "--eial": { |
| 5826 | String key = cmd.getNextArgRequired(); |
| 5827 | String value = cmd.getNextArgRequired(); |
| 5828 | String[] strings = value.split(","); |
| 5829 | ArrayList<Integer> list = new ArrayList<>(strings.length); |
| 5830 | for (int i = 0; i < strings.length; i++) { |
| 5831 | list.add(Integer.decode(strings[i])); |
| 5832 | } |
| 5833 | intent.putExtra(key, list); |
| 5834 | } |
| 5835 | break; |
| 5836 | case "--el": { |
| 5837 | String key = cmd.getNextArgRequired(); |
| 5838 | String value = cmd.getNextArgRequired(); |
| 5839 | intent.putExtra(key, Long.valueOf(value)); |
| 5840 | } |
| 5841 | break; |
| 5842 | case "--ela": { |
| 5843 | String key = cmd.getNextArgRequired(); |
| 5844 | String value = cmd.getNextArgRequired(); |
| 5845 | String[] strings = value.split(","); |
| 5846 | long[] list = new long[strings.length]; |
| 5847 | for (int i = 0; i < strings.length; i++) { |
| 5848 | list[i] = Long.valueOf(strings[i]); |
| 5849 | } |
| 5850 | intent.putExtra(key, list); |
| 5851 | hasIntentInfo = true; |
| 5852 | } |
| 5853 | break; |
| 5854 | case "--elal": { |
| 5855 | String key = cmd.getNextArgRequired(); |
| 5856 | String value = cmd.getNextArgRequired(); |
| 5857 | String[] strings = value.split(","); |
| 5858 | ArrayList<Long> list = new ArrayList<>(strings.length); |
| 5859 | for (int i = 0; i < strings.length; i++) { |
| 5860 | list.add(Long.valueOf(strings[i])); |
| 5861 | } |
| 5862 | intent.putExtra(key, list); |
| 5863 | hasIntentInfo = true; |
| 5864 | } |
| 5865 | break; |
| 5866 | case "--ef": { |
| 5867 | String key = cmd.getNextArgRequired(); |
| 5868 | String value = cmd.getNextArgRequired(); |
| 5869 | intent.putExtra(key, Float.valueOf(value)); |
| 5870 | hasIntentInfo = true; |
| 5871 | } |
| 5872 | break; |
| 5873 | case "--efa": { |
| 5874 | String key = cmd.getNextArgRequired(); |
| 5875 | String value = cmd.getNextArgRequired(); |
| 5876 | String[] strings = value.split(","); |
| 5877 | float[] list = new float[strings.length]; |
| 5878 | for (int i = 0; i < strings.length; i++) { |
| 5879 | list[i] = Float.valueOf(strings[i]); |
| 5880 | } |
| 5881 | intent.putExtra(key, list); |
| 5882 | hasIntentInfo = true; |
| 5883 | } |
| 5884 | break; |
| 5885 | case "--efal": { |
| 5886 | String key = cmd.getNextArgRequired(); |
| 5887 | String value = cmd.getNextArgRequired(); |
| 5888 | String[] strings = value.split(","); |
| 5889 | ArrayList<Float> list = new ArrayList<>(strings.length); |
| 5890 | for (int i = 0; i < strings.length; i++) { |
| 5891 | list.add(Float.valueOf(strings[i])); |
| 5892 | } |
| 5893 | intent.putExtra(key, list); |
| 5894 | hasIntentInfo = true; |
| 5895 | } |
| 5896 | break; |
| 5897 | case "--esa": { |
| 5898 | String key = cmd.getNextArgRequired(); |
| 5899 | String value = cmd.getNextArgRequired(); |
| 5900 | // Split on commas unless they are preceeded by an escape. |
| 5901 | // The escape character must be escaped for the string and |
| 5902 | // again for the regex, thus four escape characters become one. |
| 5903 | String[] strings = value.split("(?<!\\\\),"); |
| 5904 | intent.putExtra(key, strings); |
| 5905 | hasIntentInfo = true; |
| 5906 | } |
| 5907 | break; |
| 5908 | case "--esal": { |
| 5909 | String key = cmd.getNextArgRequired(); |
| 5910 | String value = cmd.getNextArgRequired(); |
| 5911 | // Split on commas unless they are preceeded by an escape. |
| 5912 | // The escape character must be escaped for the string and |
| 5913 | // again for the regex, thus four escape characters become one. |
| 5914 | String[] strings = value.split("(?<!\\\\),"); |
| 5915 | ArrayList<String> list = new ArrayList<>(strings.length); |
| 5916 | for (int i = 0; i < strings.length; i++) { |
| 5917 | list.add(strings[i]); |
| 5918 | } |
| 5919 | intent.putExtra(key, list); |
| 5920 | hasIntentInfo = true; |
| 5921 | } |
| 5922 | break; |
| 5923 | case "--ez": { |
| 5924 | String key = cmd.getNextArgRequired(); |
| 5925 | String value = cmd.getNextArgRequired().toLowerCase(); |
| 5926 | // Boolean.valueOf() results in false for anything that is not "true", which is |
| 5927 | // error-prone in shell commands |
| 5928 | boolean arg; |
| 5929 | if ("true".equals(value) || "t".equals(value)) { |
| 5930 | arg = true; |
| 5931 | } else if ("false".equals(value) || "f".equals(value)) { |
| 5932 | arg = false; |
| 5933 | } else { |
| 5934 | try { |
| 5935 | arg = Integer.decode(value) != 0; |
| 5936 | } catch (NumberFormatException ex) { |
| 5937 | throw new IllegalArgumentException("Invalid boolean value: " + value); |
| 5938 | } |
| 5939 | } |
| 5940 | |
| 5941 | intent.putExtra(key, arg); |
| 5942 | } |
| 5943 | break; |
| 5944 | case "-n": { |
| 5945 | String str = cmd.getNextArgRequired(); |
| 5946 | ComponentName cn = ComponentName.unflattenFromString(str); |
| 5947 | if (cn == null) |
| 5948 | throw new IllegalArgumentException("Bad component name: " + str); |
| 5949 | intent.setComponent(cn); |
| 5950 | if (intent == baseIntent) { |
| 5951 | hasIntentInfo = true; |
| 5952 | } |
| 5953 | } |
| 5954 | break; |
| 5955 | case "-p": { |
| 5956 | String str = cmd.getNextArgRequired(); |
| 5957 | intent.setPackage(str); |
| 5958 | if (intent == baseIntent) { |
| 5959 | hasIntentInfo = true; |
| 5960 | } |
| 5961 | } |
| 5962 | break; |
| 5963 | case "-f": |
| 5964 | String str = cmd.getNextArgRequired(); |
| 5965 | intent.setFlags(Integer.decode(str).intValue()); |
| 5966 | break; |
| 5967 | case "--grant-read-uri-permission": |
| 5968 | intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 5969 | break; |
| 5970 | case "--grant-write-uri-permission": |
| 5971 | intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
| 5972 | break; |
| 5973 | case "--grant-persistable-uri-permission": |
| 5974 | intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); |
| 5975 | break; |
| 5976 | case "--grant-prefix-uri-permission": |
| 5977 | intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); |
| 5978 | break; |
| 5979 | case "--exclude-stopped-packages": |
| 5980 | intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); |
| 5981 | break; |
| 5982 | case "--include-stopped-packages": |
| 5983 | intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| 5984 | break; |
| 5985 | case "--debug-log-resolution": |
| 5986 | intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); |
| 5987 | break; |
| 5988 | case "--activity-brought-to-front": |
| 5989 | intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); |
| 5990 | break; |
| 5991 | case "--activity-clear-top": |
| 5992 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 5993 | break; |
| 5994 | case "--activity-clear-when-task-reset": |
| 5995 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); |
| 5996 | break; |
| 5997 | case "--activity-exclude-from-recents": |
| 5998 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 5999 | break; |
| 6000 | case "--activity-launched-from-history": |
| 6001 | intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); |
| 6002 | break; |
| 6003 | case "--activity-multiple-task": |
| 6004 | intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); |
| 6005 | break; |
| 6006 | case "--activity-no-animation": |
| 6007 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); |
| 6008 | break; |
| 6009 | case "--activity-no-history": |
| 6010 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); |
| 6011 | break; |
| 6012 | case "--activity-no-user-action": |
| 6013 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); |
| 6014 | break; |
| 6015 | case "--activity-previous-is-top": |
| 6016 | intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); |
| 6017 | break; |
| 6018 | case "--activity-reorder-to-front": |
| 6019 | intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); |
| 6020 | break; |
| 6021 | case "--activity-reset-task-if-needed": |
| 6022 | intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 6023 | break; |
| 6024 | case "--activity-single-top": |
| 6025 | intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); |
| 6026 | break; |
| 6027 | case "--activity-clear-task": |
| 6028 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 6029 | break; |
| 6030 | case "--activity-task-on-home": |
| 6031 | intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); |
| 6032 | break; |
| 6033 | case "--receiver-registered-only": |
| 6034 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); |
| 6035 | break; |
| 6036 | case "--receiver-replace-pending": |
| 6037 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| 6038 | break; |
Felipe Leme | 3cb48cd | 2016-01-27 08:39:09 -0800 | [diff] [blame] | 6039 | case "--receiver-foreground": |
| 6040 | intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); |
| 6041 | break; |
Dianne Hackborn | 797772b1 | 2017-02-08 16:33:43 -0800 | [diff] [blame^] | 6042 | case "--receiver-no-abort": |
| 6043 | intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); |
| 6044 | break; |
| 6045 | case "--receiver-include-background": |
| 6046 | intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); |
| 6047 | break; |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6048 | case "--selector": |
| 6049 | intent.setDataAndType(data, type); |
| 6050 | intent = new Intent(); |
| 6051 | break; |
| 6052 | default: |
| 6053 | if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { |
| 6054 | // Okay, caller handled this option. |
| 6055 | } else { |
| 6056 | throw new IllegalArgumentException("Unknown option: " + opt); |
| 6057 | } |
| 6058 | break; |
| 6059 | } |
| 6060 | } |
| 6061 | intent.setDataAndType(data, type); |
| 6062 | |
| 6063 | final boolean hasSelector = intent != baseIntent; |
| 6064 | if (hasSelector) { |
| 6065 | // A selector was specified; fix up. |
| 6066 | baseIntent.setSelector(intent); |
| 6067 | intent = baseIntent; |
| 6068 | } |
| 6069 | |
| 6070 | String arg = cmd.getNextArg(); |
| 6071 | baseIntent = null; |
| 6072 | if (arg == null) { |
| 6073 | if (hasSelector) { |
| 6074 | // If a selector has been specified, and no arguments |
| 6075 | // have been supplied for the main Intent, then we can |
| 6076 | // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't |
| 6077 | // need to have a component name specified yet, the |
| 6078 | // selector will take care of that. |
| 6079 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 6080 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 6081 | } |
| 6082 | } else if (arg.indexOf(':') >= 0) { |
| 6083 | // The argument is a URI. Fully parse it, and use that result |
| 6084 | // to fill in any data not specified so far. |
| 6085 | baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME |
| 6086 | | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); |
| 6087 | } else if (arg.indexOf('/') >= 0) { |
| 6088 | // The argument is a component name. Build an Intent to launch |
| 6089 | // it. |
| 6090 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 6091 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 6092 | baseIntent.setComponent(ComponentName.unflattenFromString(arg)); |
| 6093 | } else { |
| 6094 | // Assume the argument is a package name. |
| 6095 | baseIntent = new Intent(Intent.ACTION_MAIN); |
| 6096 | baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); |
| 6097 | baseIntent.setPackage(arg); |
| 6098 | } |
| 6099 | if (baseIntent != null) { |
| 6100 | Bundle extras = intent.getExtras(); |
| 6101 | intent.replaceExtras((Bundle)null); |
| 6102 | Bundle uriExtras = baseIntent.getExtras(); |
| 6103 | baseIntent.replaceExtras((Bundle)null); |
| 6104 | if (intent.getAction() != null && baseIntent.getCategories() != null) { |
| 6105 | HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); |
| 6106 | for (String c : cats) { |
| 6107 | baseIntent.removeCategory(c); |
| 6108 | } |
| 6109 | } |
| 6110 | intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); |
| 6111 | if (extras == null) { |
| 6112 | extras = uriExtras; |
| 6113 | } else if (uriExtras != null) { |
| 6114 | uriExtras.putAll(extras); |
| 6115 | extras = uriExtras; |
| 6116 | } |
| 6117 | intent.replaceExtras(extras); |
| 6118 | hasIntentInfo = true; |
| 6119 | } |
| 6120 | |
| 6121 | if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); |
| 6122 | return intent; |
| 6123 | } |
| 6124 | |
| 6125 | /** @hide */ |
| 6126 | public static void printIntentArgsHelp(PrintWriter pw, String prefix) { |
| 6127 | final String[] lines = new String[] { |
| 6128 | "<INTENT> specifications include these flags and arguments:", |
| 6129 | " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]", |
| 6130 | " [-c <CATEGORY> [-c <CATEGORY>] ...]", |
| 6131 | " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", |
| 6132 | " [--esn <EXTRA_KEY> ...]", |
| 6133 | " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", |
| 6134 | " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", |
| 6135 | " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", |
| 6136 | " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", |
| 6137 | " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", |
| 6138 | " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", |
| 6139 | " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", |
| 6140 | " (mutiple extras passed as Integer[])", |
| 6141 | " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", |
| 6142 | " (mutiple extras passed as List<Integer>)", |
| 6143 | " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", |
| 6144 | " (mutiple extras passed as Long[])", |
| 6145 | " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", |
| 6146 | " (mutiple extras passed as List<Long>)", |
| 6147 | " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", |
| 6148 | " (mutiple extras passed as Float[])", |
| 6149 | " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", |
| 6150 | " (mutiple extras passed as List<Float>)", |
| 6151 | " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", |
| 6152 | " (mutiple extras passed as String[]; to embed a comma into a string,", |
| 6153 | " escape it using \"\\,\")", |
| 6154 | " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", |
| 6155 | " (mutiple extras passed as List<String>; to embed a comma into a string,", |
| 6156 | " escape it using \"\\,\")", |
Felipe Leme | 545569d | 2016-01-11 16:27:58 -0800 | [diff] [blame] | 6157 | " [-f <FLAG>]", |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6158 | " [--grant-read-uri-permission] [--grant-write-uri-permission]", |
| 6159 | " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", |
| 6160 | " [--debug-log-resolution] [--exclude-stopped-packages]", |
| 6161 | " [--include-stopped-packages]", |
| 6162 | " [--activity-brought-to-front] [--activity-clear-top]", |
| 6163 | " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", |
| 6164 | " [--activity-launched-from-history] [--activity-multiple-task]", |
| 6165 | " [--activity-no-animation] [--activity-no-history]", |
| 6166 | " [--activity-no-user-action] [--activity-previous-is-top]", |
| 6167 | " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", |
| 6168 | " [--activity-single-top] [--activity-clear-task]", |
| 6169 | " [--activity-task-on-home]", |
| 6170 | " [--receiver-registered-only] [--receiver-replace-pending]", |
Dianne Hackborn | 797772b1 | 2017-02-08 16:33:43 -0800 | [diff] [blame^] | 6171 | " [--receiver-foreground] [--receiver-no-abort]", |
| 6172 | " [--receiver-include-background]", |
Dianne Hackborn | 3cdb56e | 2015-11-11 12:45:44 -0800 | [diff] [blame] | 6173 | " [--selector]", |
| 6174 | " [<URI> | <PACKAGE> | <COMPONENT>]" |
| 6175 | }; |
| 6176 | for (String line : lines) { |
| 6177 | pw.print(prefix); |
| 6178 | pw.println(line); |
| 6179 | } |
| 6180 | } |
| 6181 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6182 | /** |
| 6183 | * Retrieve the general action to be performed, such as |
| 6184 | * {@link #ACTION_VIEW}. The action describes the general way the rest of |
| 6185 | * the information in the intent should be interpreted -- most importantly, |
| 6186 | * what to do with the data returned by {@link #getData}. |
| 6187 | * |
| 6188 | * @return The action of this intent or null if none is specified. |
| 6189 | * |
| 6190 | * @see #setAction |
| 6191 | */ |
| 6192 | public String getAction() { |
| 6193 | return mAction; |
| 6194 | } |
| 6195 | |
| 6196 | /** |
| 6197 | * Retrieve data this intent is operating on. This URI specifies the name |
| 6198 | * of the data; often it uses the content: scheme, specifying data in a |
| 6199 | * content provider. Other schemes may be handled by specific activities, |
| 6200 | * such as http: by the web browser. |
| 6201 | * |
| 6202 | * @return The URI of the data this intent is targeting or null. |
| 6203 | * |
| 6204 | * @see #getScheme |
| 6205 | * @see #setData |
| 6206 | */ |
| 6207 | public Uri getData() { |
| 6208 | return mData; |
| 6209 | } |
| 6210 | |
| 6211 | /** |
| 6212 | * The same as {@link #getData()}, but returns the URI as an encoded |
| 6213 | * String. |
| 6214 | */ |
| 6215 | public String getDataString() { |
| 6216 | return mData != null ? mData.toString() : null; |
| 6217 | } |
| 6218 | |
| 6219 | /** |
| 6220 | * Return the scheme portion of the intent's data. If the data is null or |
| 6221 | * does not include a scheme, null is returned. Otherwise, the scheme |
| 6222 | * prefix without the final ':' is returned, i.e. "http". |
| 6223 | * |
| 6224 | * <p>This is the same as calling getData().getScheme() (and checking for |
| 6225 | * null data). |
| 6226 | * |
| 6227 | * @return The scheme of this intent. |
| 6228 | * |
| 6229 | * @see #getData |
| 6230 | */ |
| 6231 | public String getScheme() { |
| 6232 | return mData != null ? mData.getScheme() : null; |
| 6233 | } |
| 6234 | |
| 6235 | /** |
| 6236 | * Retrieve any explicit MIME type included in the intent. This is usually |
| 6237 | * null, as the type is determined by the intent data. |
| 6238 | * |
| 6239 | * @return If a type was manually set, it is returned; else null is |
| 6240 | * returned. |
| 6241 | * |
| 6242 | * @see #resolveType(ContentResolver) |
| 6243 | * @see #setType |
| 6244 | */ |
| 6245 | public String getType() { |
| 6246 | return mType; |
| 6247 | } |
| 6248 | |
| 6249 | /** |
| 6250 | * Return the MIME data type of this intent. If the type field is |
| 6251 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 6252 | * the type of that data is returned. If neither fields are set, a null is |
| 6253 | * returned. |
| 6254 | * |
| 6255 | * @return The MIME type of this intent. |
| 6256 | * |
| 6257 | * @see #getType |
| 6258 | * @see #resolveType(ContentResolver) |
| 6259 | */ |
| 6260 | public String resolveType(Context context) { |
| 6261 | return resolveType(context.getContentResolver()); |
| 6262 | } |
| 6263 | |
| 6264 | /** |
| 6265 | * Return the MIME data type of this intent. If the type field is |
| 6266 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 6267 | * the type of that data is returned. If neither fields are set, a null is |
| 6268 | * returned. |
| 6269 | * |
| 6270 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 6271 | * type of the intent's data. |
| 6272 | * |
| 6273 | * @return The MIME type of this intent. |
| 6274 | * |
| 6275 | * @see #getType |
| 6276 | * @see #resolveType(Context) |
| 6277 | */ |
| 6278 | public String resolveType(ContentResolver resolver) { |
| 6279 | if (mType != null) { |
| 6280 | return mType; |
| 6281 | } |
| 6282 | if (mData != null) { |
| 6283 | if ("content".equals(mData.getScheme())) { |
| 6284 | return resolver.getType(mData); |
| 6285 | } |
| 6286 | } |
| 6287 | return null; |
| 6288 | } |
| 6289 | |
| 6290 | /** |
| 6291 | * Return the MIME data type of this intent, only if it will be needed for |
| 6292 | * intent resolution. This is not generally useful for application code; |
| 6293 | * it is used by the frameworks for communicating with back-end system |
| 6294 | * services. |
| 6295 | * |
| 6296 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 6297 | * type of the intent's data. |
| 6298 | * |
| 6299 | * @return The MIME type of this intent, or null if it is unknown or not |
| 6300 | * needed. |
| 6301 | */ |
| 6302 | public String resolveTypeIfNeeded(ContentResolver resolver) { |
| 6303 | if (mComponent != null) { |
| 6304 | return mType; |
| 6305 | } |
| 6306 | return resolveType(resolver); |
| 6307 | } |
| 6308 | |
| 6309 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 6310 | * Check if a category exists in the intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6311 | * |
| 6312 | * @param category The category to check. |
| 6313 | * |
| 6314 | * @return boolean True if the intent contains the category, else false. |
| 6315 | * |
| 6316 | * @see #getCategories |
| 6317 | * @see #addCategory |
| 6318 | */ |
| 6319 | public boolean hasCategory(String category) { |
| 6320 | return mCategories != null && mCategories.contains(category); |
| 6321 | } |
| 6322 | |
| 6323 | /** |
| 6324 | * Return the set of all categories in the intent. If there are no categories, |
| 6325 | * returns NULL. |
| 6326 | * |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6327 | * @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] | 6328 | * |
| 6329 | * @see #hasCategory |
| 6330 | * @see #addCategory |
| 6331 | */ |
| 6332 | public Set<String> getCategories() { |
| 6333 | return mCategories; |
| 6334 | } |
| 6335 | |
| 6336 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6337 | * Return the specific selector associated with this Intent. If there is |
| 6338 | * none, returns null. See {@link #setSelector} for more information. |
| 6339 | * |
| 6340 | * @see #setSelector |
| 6341 | */ |
| 6342 | public Intent getSelector() { |
| 6343 | return mSelector; |
| 6344 | } |
| 6345 | |
| 6346 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6347 | * Return the {@link ClipData} associated with this Intent. If there is |
| 6348 | * none, returns null. See {@link #setClipData} for more information. |
| 6349 | * |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 6350 | * @see #setClipData |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6351 | */ |
| 6352 | public ClipData getClipData() { |
| 6353 | return mClipData; |
| 6354 | } |
| 6355 | |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 6356 | /** @hide */ |
| 6357 | public int getContentUserHint() { |
| 6358 | return mContentUserHint; |
| 6359 | } |
| 6360 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6361 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6362 | * Sets the ClassLoader that will be used when unmarshalling |
| 6363 | * any Parcelable values from the extras of this Intent. |
| 6364 | * |
| 6365 | * @param loader a ClassLoader, or null to use the default loader |
| 6366 | * at the time of unmarshalling. |
| 6367 | */ |
| 6368 | public void setExtrasClassLoader(ClassLoader loader) { |
| 6369 | if (mExtras != null) { |
| 6370 | mExtras.setClassLoader(loader); |
| 6371 | } |
| 6372 | } |
| 6373 | |
| 6374 | /** |
| 6375 | * Returns true if an extra value is associated with the given name. |
| 6376 | * @param name the extra's name |
| 6377 | * @return true if the given extra is present. |
| 6378 | */ |
| 6379 | public boolean hasExtra(String name) { |
| 6380 | return mExtras != null && mExtras.containsKey(name); |
| 6381 | } |
| 6382 | |
| 6383 | /** |
| 6384 | * Returns true if the Intent's extras contain a parcelled file descriptor. |
| 6385 | * @return true if the Intent contains a parcelled file descriptor. |
| 6386 | */ |
| 6387 | public boolean hasFileDescriptors() { |
| 6388 | return mExtras != null && mExtras.hasFileDescriptors(); |
| 6389 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6390 | |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 6391 | /** {@hide} */ |
Dianne Hackborn | 9ecebbf | 2011-09-28 23:19:47 -0400 | [diff] [blame] | 6392 | public void setAllowFds(boolean allowFds) { |
| 6393 | if (mExtras != null) { |
| 6394 | mExtras.setAllowFds(allowFds); |
| 6395 | } |
| 6396 | } |
| 6397 | |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 6398 | /** {@hide} */ |
| 6399 | public void setDefusable(boolean defusable) { |
| 6400 | if (mExtras != null) { |
| 6401 | mExtras.setDefusable(defusable); |
| 6402 | } |
| 6403 | } |
| 6404 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6405 | /** |
| 6406 | * Retrieve extended data from the intent. |
| 6407 | * |
| 6408 | * @param name The name of the desired item. |
| 6409 | * |
| 6410 | * @return the value of an item that previously added with putExtra() |
| 6411 | * or null if none was found. |
| 6412 | * |
| 6413 | * @deprecated |
| 6414 | * @hide |
| 6415 | */ |
| 6416 | @Deprecated |
| 6417 | public Object getExtra(String name) { |
| 6418 | return getExtra(name, null); |
| 6419 | } |
| 6420 | |
| 6421 | /** |
| 6422 | * Retrieve extended data from the intent. |
| 6423 | * |
| 6424 | * @param name The name of the desired item. |
| 6425 | * @param defaultValue the value to be returned if no value of the desired |
| 6426 | * type is stored with the given name. |
| 6427 | * |
| 6428 | * @return the value of an item that previously added with putExtra() |
| 6429 | * or the default value if none was found. |
| 6430 | * |
| 6431 | * @see #putExtra(String, boolean) |
| 6432 | */ |
| 6433 | public boolean getBooleanExtra(String name, boolean defaultValue) { |
| 6434 | return mExtras == null ? defaultValue : |
| 6435 | mExtras.getBoolean(name, defaultValue); |
| 6436 | } |
| 6437 | |
| 6438 | /** |
| 6439 | * Retrieve extended data from the intent. |
| 6440 | * |
| 6441 | * @param name The name of the desired item. |
| 6442 | * @param defaultValue the value to be returned if no value of the desired |
| 6443 | * type is stored with the given name. |
| 6444 | * |
| 6445 | * @return the value of an item that previously added with putExtra() |
| 6446 | * or the default value if none was found. |
| 6447 | * |
| 6448 | * @see #putExtra(String, byte) |
| 6449 | */ |
| 6450 | public byte getByteExtra(String name, byte defaultValue) { |
| 6451 | return mExtras == null ? defaultValue : |
| 6452 | mExtras.getByte(name, defaultValue); |
| 6453 | } |
| 6454 | |
| 6455 | /** |
| 6456 | * Retrieve extended data from the intent. |
| 6457 | * |
| 6458 | * @param name The name of the desired item. |
| 6459 | * @param defaultValue the value to be returned if no value of the desired |
| 6460 | * type is stored with the given name. |
| 6461 | * |
| 6462 | * @return the value of an item that previously added with putExtra() |
| 6463 | * or the default value if none was found. |
| 6464 | * |
| 6465 | * @see #putExtra(String, short) |
| 6466 | */ |
| 6467 | public short getShortExtra(String name, short defaultValue) { |
| 6468 | return mExtras == null ? defaultValue : |
| 6469 | mExtras.getShort(name, defaultValue); |
| 6470 | } |
| 6471 | |
| 6472 | /** |
| 6473 | * Retrieve extended data from the intent. |
| 6474 | * |
| 6475 | * @param name The name of the desired item. |
| 6476 | * @param defaultValue the value to be returned if no value of the desired |
| 6477 | * type is stored with the given name. |
| 6478 | * |
| 6479 | * @return the value of an item that previously added with putExtra() |
| 6480 | * or the default value if none was found. |
| 6481 | * |
| 6482 | * @see #putExtra(String, char) |
| 6483 | */ |
| 6484 | public char getCharExtra(String name, char defaultValue) { |
| 6485 | return mExtras == null ? defaultValue : |
| 6486 | mExtras.getChar(name, defaultValue); |
| 6487 | } |
| 6488 | |
| 6489 | /** |
| 6490 | * Retrieve extended data from the intent. |
| 6491 | * |
| 6492 | * @param name The name of the desired item. |
| 6493 | * @param defaultValue the value to be returned if no value of the desired |
| 6494 | * type is stored with the given name. |
| 6495 | * |
| 6496 | * @return the value of an item that previously added with putExtra() |
| 6497 | * or the default value if none was found. |
| 6498 | * |
| 6499 | * @see #putExtra(String, int) |
| 6500 | */ |
| 6501 | public int getIntExtra(String name, int defaultValue) { |
| 6502 | return mExtras == null ? defaultValue : |
| 6503 | mExtras.getInt(name, defaultValue); |
| 6504 | } |
| 6505 | |
| 6506 | /** |
| 6507 | * Retrieve extended data from the intent. |
| 6508 | * |
| 6509 | * @param name The name of the desired item. |
| 6510 | * @param defaultValue the value to be returned if no value of the desired |
| 6511 | * type is stored with the given name. |
| 6512 | * |
| 6513 | * @return the value of an item that previously added with putExtra() |
| 6514 | * or the default value if none was found. |
| 6515 | * |
| 6516 | * @see #putExtra(String, long) |
| 6517 | */ |
| 6518 | public long getLongExtra(String name, long defaultValue) { |
| 6519 | return mExtras == null ? defaultValue : |
| 6520 | mExtras.getLong(name, defaultValue); |
| 6521 | } |
| 6522 | |
| 6523 | /** |
| 6524 | * Retrieve extended data from the intent. |
| 6525 | * |
| 6526 | * @param name The name of the desired item. |
| 6527 | * @param defaultValue the value to be returned if no value of the desired |
| 6528 | * type is stored with the given name. |
| 6529 | * |
| 6530 | * @return the value of an item that previously added with putExtra(), |
| 6531 | * or the default value if no such item is present |
| 6532 | * |
| 6533 | * @see #putExtra(String, float) |
| 6534 | */ |
| 6535 | public float getFloatExtra(String name, float defaultValue) { |
| 6536 | return mExtras == null ? defaultValue : |
| 6537 | mExtras.getFloat(name, defaultValue); |
| 6538 | } |
| 6539 | |
| 6540 | /** |
| 6541 | * Retrieve extended data from the intent. |
| 6542 | * |
| 6543 | * @param name The name of the desired item. |
| 6544 | * @param defaultValue the value to be returned if no value of the desired |
| 6545 | * type is stored with the given name. |
| 6546 | * |
| 6547 | * @return the value of an item that previously added with putExtra() |
| 6548 | * or the default value if none was found. |
| 6549 | * |
| 6550 | * @see #putExtra(String, double) |
| 6551 | */ |
| 6552 | public double getDoubleExtra(String name, double defaultValue) { |
| 6553 | return mExtras == null ? defaultValue : |
| 6554 | mExtras.getDouble(name, defaultValue); |
| 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 String value was found. |
| 6564 | * |
| 6565 | * @see #putExtra(String, String) |
| 6566 | */ |
| 6567 | public String getStringExtra(String name) { |
| 6568 | return mExtras == null ? null : mExtras.getString(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 CharSequence value was found. |
| 6578 | * |
| 6579 | * @see #putExtra(String, CharSequence) |
| 6580 | */ |
| 6581 | public CharSequence getCharSequenceExtra(String name) { |
| 6582 | return mExtras == null ? null : mExtras.getCharSequence(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 Parcelable value was found. |
| 6592 | * |
| 6593 | * @see #putExtra(String, Parcelable) |
| 6594 | */ |
| 6595 | public <T extends Parcelable> T getParcelableExtra(String name) { |
| 6596 | return mExtras == null ? null : mExtras.<T>getParcelable(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 Parcelable[] value was found. |
| 6606 | * |
| 6607 | * @see #putExtra(String, Parcelable[]) |
| 6608 | */ |
| 6609 | public Parcelable[] getParcelableArrayExtra(String name) { |
| 6610 | return mExtras == null ? null : mExtras.getParcelableArray(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 ArrayList<Parcelable> value was found. |
| 6620 | * |
| 6621 | * @see #putParcelableArrayListExtra(String, ArrayList) |
| 6622 | */ |
| 6623 | public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { |
| 6624 | return mExtras == null ? null : mExtras.<T>getParcelableArrayList(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 Serializable value was found. |
| 6634 | * |
| 6635 | * @see #putExtra(String, Serializable) |
| 6636 | */ |
| 6637 | public Serializable getSerializableExtra(String name) { |
| 6638 | return mExtras == null ? null : mExtras.getSerializable(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 ArrayList<Integer> value was found. |
| 6648 | * |
| 6649 | * @see #putIntegerArrayListExtra(String, ArrayList) |
| 6650 | */ |
| 6651 | public ArrayList<Integer> getIntegerArrayListExtra(String name) { |
| 6652 | return mExtras == null ? null : mExtras.getIntegerArrayList(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 ArrayList<String> value was found. |
| 6662 | * |
| 6663 | * @see #putStringArrayListExtra(String, ArrayList) |
| 6664 | */ |
| 6665 | public ArrayList<String> getStringArrayListExtra(String name) { |
| 6666 | return mExtras == null ? null : mExtras.getStringArrayList(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 ArrayList<CharSequence> value was found. |
| 6676 | * |
| 6677 | * @see #putCharSequenceArrayListExtra(String, ArrayList) |
| 6678 | */ |
| 6679 | public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { |
| 6680 | return mExtras == null ? null : mExtras.getCharSequenceArrayList(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 boolean array value was found. |
| 6690 | * |
| 6691 | * @see #putExtra(String, boolean[]) |
| 6692 | */ |
| 6693 | public boolean[] getBooleanArrayExtra(String name) { |
| 6694 | return mExtras == null ? null : mExtras.getBooleanArray(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 byte array value was found. |
| 6704 | * |
| 6705 | * @see #putExtra(String, byte[]) |
| 6706 | */ |
| 6707 | public byte[] getByteArrayExtra(String name) { |
| 6708 | return mExtras == null ? null : mExtras.getByteArray(name); |
| 6709 | } |
| 6710 | |
| 6711 | /** |
| 6712 | * Retrieve extended data from the intent. |
| 6713 | * |
| 6714 | * @param name The name of the desired item. |
| 6715 | * |
| 6716 | * @return the value of an item that previously added with putExtra() |
| 6717 | * or null if no short array value was found. |
| 6718 | * |
| 6719 | * @see #putExtra(String, short[]) |
| 6720 | */ |
| 6721 | public short[] getShortArrayExtra(String name) { |
| 6722 | return mExtras == null ? null : mExtras.getShortArray(name); |
| 6723 | } |
| 6724 | |
| 6725 | /** |
| 6726 | * Retrieve extended data from the intent. |
| 6727 | * |
| 6728 | * @param name The name of the desired item. |
| 6729 | * |
| 6730 | * @return the value of an item that previously added with putExtra() |
| 6731 | * or null if no char array value was found. |
| 6732 | * |
| 6733 | * @see #putExtra(String, char[]) |
| 6734 | */ |
| 6735 | public char[] getCharArrayExtra(String name) { |
| 6736 | return mExtras == null ? null : mExtras.getCharArray(name); |
| 6737 | } |
| 6738 | |
| 6739 | /** |
| 6740 | * Retrieve extended data from the intent. |
| 6741 | * |
| 6742 | * @param name The name of the desired item. |
| 6743 | * |
| 6744 | * @return the value of an item that previously added with putExtra() |
| 6745 | * or null if no int array value was found. |
| 6746 | * |
| 6747 | * @see #putExtra(String, int[]) |
| 6748 | */ |
| 6749 | public int[] getIntArrayExtra(String name) { |
| 6750 | return mExtras == null ? null : mExtras.getIntArray(name); |
| 6751 | } |
| 6752 | |
| 6753 | /** |
| 6754 | * Retrieve extended data from the intent. |
| 6755 | * |
| 6756 | * @param name The name of the desired item. |
| 6757 | * |
| 6758 | * @return the value of an item that previously added with putExtra() |
| 6759 | * or null if no long array value was found. |
| 6760 | * |
| 6761 | * @see #putExtra(String, long[]) |
| 6762 | */ |
| 6763 | public long[] getLongArrayExtra(String name) { |
| 6764 | return mExtras == null ? null : mExtras.getLongArray(name); |
| 6765 | } |
| 6766 | |
| 6767 | /** |
| 6768 | * Retrieve extended data from the intent. |
| 6769 | * |
| 6770 | * @param name The name of the desired item. |
| 6771 | * |
| 6772 | * @return the value of an item that previously added with putExtra() |
| 6773 | * or null if no float array value was found. |
| 6774 | * |
| 6775 | * @see #putExtra(String, float[]) |
| 6776 | */ |
| 6777 | public float[] getFloatArrayExtra(String name) { |
| 6778 | return mExtras == null ? null : mExtras.getFloatArray(name); |
| 6779 | } |
| 6780 | |
| 6781 | /** |
| 6782 | * Retrieve extended data from the intent. |
| 6783 | * |
| 6784 | * @param name The name of the desired item. |
| 6785 | * |
| 6786 | * @return the value of an item that previously added with putExtra() |
| 6787 | * or null if no double array value was found. |
| 6788 | * |
| 6789 | * @see #putExtra(String, double[]) |
| 6790 | */ |
| 6791 | public double[] getDoubleArrayExtra(String name) { |
| 6792 | return mExtras == null ? null : mExtras.getDoubleArray(name); |
| 6793 | } |
| 6794 | |
| 6795 | /** |
| 6796 | * Retrieve extended data from the intent. |
| 6797 | * |
| 6798 | * @param name The name of the desired item. |
| 6799 | * |
| 6800 | * @return the value of an item that previously added with putExtra() |
| 6801 | * or null if no String array value was found. |
| 6802 | * |
| 6803 | * @see #putExtra(String, String[]) |
| 6804 | */ |
| 6805 | public String[] getStringArrayExtra(String name) { |
| 6806 | return mExtras == null ? null : mExtras.getStringArray(name); |
| 6807 | } |
| 6808 | |
| 6809 | /** |
| 6810 | * Retrieve extended data from the intent. |
| 6811 | * |
| 6812 | * @param name The name of the desired item. |
| 6813 | * |
| 6814 | * @return the value of an item that previously added with putExtra() |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 6815 | * or null if no CharSequence array value was found. |
| 6816 | * |
| 6817 | * @see #putExtra(String, CharSequence[]) |
| 6818 | */ |
| 6819 | public CharSequence[] getCharSequenceArrayExtra(String name) { |
| 6820 | return mExtras == null ? null : mExtras.getCharSequenceArray(name); |
| 6821 | } |
| 6822 | |
| 6823 | /** |
| 6824 | * Retrieve extended data from the intent. |
| 6825 | * |
| 6826 | * @param name The name of the desired item. |
| 6827 | * |
| 6828 | * @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] | 6829 | * or null if no Bundle value was found. |
| 6830 | * |
| 6831 | * @see #putExtra(String, Bundle) |
| 6832 | */ |
| 6833 | public Bundle getBundleExtra(String name) { |
| 6834 | return mExtras == null ? null : mExtras.getBundle(name); |
| 6835 | } |
| 6836 | |
| 6837 | /** |
| 6838 | * Retrieve extended data from the intent. |
| 6839 | * |
| 6840 | * @param name The name of the desired item. |
| 6841 | * |
| 6842 | * @return the value of an item that previously added with putExtra() |
| 6843 | * or null if no IBinder value was found. |
| 6844 | * |
| 6845 | * @see #putExtra(String, IBinder) |
| 6846 | * |
| 6847 | * @deprecated |
| 6848 | * @hide |
| 6849 | */ |
| 6850 | @Deprecated |
| 6851 | public IBinder getIBinderExtra(String name) { |
| 6852 | return mExtras == null ? null : mExtras.getIBinder(name); |
| 6853 | } |
| 6854 | |
| 6855 | /** |
| 6856 | * Retrieve extended data from the intent. |
| 6857 | * |
| 6858 | * @param name The name of the desired item. |
| 6859 | * @param defaultValue The default value to return in case no item is |
| 6860 | * associated with the key 'name' |
| 6861 | * |
| 6862 | * @return the value of an item that previously added with putExtra() |
| 6863 | * or defaultValue if none was found. |
| 6864 | * |
| 6865 | * @see #putExtra |
| 6866 | * |
| 6867 | * @deprecated |
| 6868 | * @hide |
| 6869 | */ |
| 6870 | @Deprecated |
| 6871 | public Object getExtra(String name, Object defaultValue) { |
| 6872 | Object result = defaultValue; |
| 6873 | if (mExtras != null) { |
| 6874 | Object result2 = mExtras.get(name); |
| 6875 | if (result2 != null) { |
| 6876 | result = result2; |
| 6877 | } |
| 6878 | } |
| 6879 | |
| 6880 | return result; |
| 6881 | } |
| 6882 | |
| 6883 | /** |
| 6884 | * Retrieves a map of extended data from the intent. |
| 6885 | * |
| 6886 | * @return the map of all extras previously added with putExtra(), |
| 6887 | * or null if none have been added. |
| 6888 | */ |
| 6889 | public Bundle getExtras() { |
| 6890 | return (mExtras != null) |
| 6891 | ? new Bundle(mExtras) |
| 6892 | : null; |
| 6893 | } |
| 6894 | |
| 6895 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 6896 | * Filter extras to only basic types. |
| 6897 | * @hide |
| 6898 | */ |
| 6899 | public void removeUnsafeExtras() { |
| 6900 | if (mExtras != null) { |
Dianne Hackborn | 851ec49 | 2016-10-12 17:20:07 -0700 | [diff] [blame] | 6901 | mExtras = mExtras.filterValues(); |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 6902 | } |
| 6903 | } |
| 6904 | |
| 6905 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6906 | * Retrieve any special flags associated with this intent. You will |
| 6907 | * normally just set them with {@link #setFlags} and let the system |
| 6908 | * take the appropriate action with them. |
| 6909 | * |
| 6910 | * @return int The currently set flags. |
| 6911 | * |
| 6912 | * @see #setFlags |
| 6913 | */ |
| 6914 | public int getFlags() { |
| 6915 | return mFlags; |
| 6916 | } |
| 6917 | |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 6918 | /** @hide */ |
| 6919 | public boolean isExcludingStopped() { |
| 6920 | return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) |
| 6921 | == FLAG_EXCLUDE_STOPPED_PACKAGES; |
| 6922 | } |
| 6923 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6924 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 6925 | * Retrieve the application package name this Intent is limited to. When |
| 6926 | * resolving an Intent, if non-null this limits the resolution to only |
| 6927 | * components in the given application package. |
| 6928 | * |
| 6929 | * @return The name of the application package for the Intent. |
| 6930 | * |
| 6931 | * @see #resolveActivity |
| 6932 | * @see #setPackage |
| 6933 | */ |
| 6934 | public String getPackage() { |
| 6935 | return mPackage; |
| 6936 | } |
| 6937 | |
| 6938 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6939 | * Retrieve the concrete component associated with the intent. When receiving |
| 6940 | * an intent, this is the component that was found to best handle it (that is, |
| 6941 | * yourself) and will always be non-null; in all other cases it will be |
| 6942 | * null unless explicitly set. |
| 6943 | * |
| 6944 | * @return The name of the application component to handle the intent. |
| 6945 | * |
| 6946 | * @see #resolveActivity |
| 6947 | * @see #setComponent |
| 6948 | */ |
| 6949 | public ComponentName getComponent() { |
| 6950 | return mComponent; |
| 6951 | } |
| 6952 | |
| 6953 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 6954 | * Get the bounds of the sender of this intent, in screen coordinates. This can be |
| 6955 | * used as a hint to the receiver for animations and the like. Null means that there |
| 6956 | * is no source bounds. |
| 6957 | */ |
| 6958 | public Rect getSourceBounds() { |
| 6959 | return mSourceBounds; |
| 6960 | } |
| 6961 | |
| 6962 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6963 | * Return the Activity component that should be used to handle this intent. |
| 6964 | * The appropriate component is determined based on the information in the |
| 6965 | * intent, evaluated as follows: |
| 6966 | * |
| 6967 | * <p>If {@link #getComponent} returns an explicit class, that is returned |
| 6968 | * without any further consideration. |
| 6969 | * |
| 6970 | * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent |
| 6971 | * category to be considered. |
| 6972 | * |
| 6973 | * <p>If {@link #getAction} is non-NULL, the activity must handle this |
| 6974 | * action. |
| 6975 | * |
| 6976 | * <p>If {@link #resolveType} returns non-NULL, the activity must handle |
| 6977 | * this type. |
| 6978 | * |
| 6979 | * <p>If {@link #addCategory} has added any categories, the activity must |
| 6980 | * handle ALL of the categories specified. |
| 6981 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 6982 | * <p>If {@link #getPackage} is non-NULL, only activity components in |
| 6983 | * that application package will be considered. |
| 6984 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6985 | * <p>If there are no activities that satisfy all of these conditions, a |
| 6986 | * null string is returned. |
| 6987 | * |
| 6988 | * <p>If multiple activities are found to satisfy the intent, the one with |
| 6989 | * the highest priority will be used. If there are multiple activities |
| 6990 | * with the same priority, the system will either pick the best activity |
| 6991 | * based on user preference, or resolve to a system class that will allow |
| 6992 | * the user to pick an activity and forward from there. |
| 6993 | * |
| 6994 | * <p>This method is implemented simply by calling |
| 6995 | * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter |
| 6996 | * true.</p> |
| 6997 | * <p> This API is called for you as part of starting an activity from an |
| 6998 | * intent. You do not normally need to call it yourself.</p> |
| 6999 | * |
| 7000 | * @param pm The package manager with which to resolve the Intent. |
| 7001 | * |
| 7002 | * @return Name of the component implementing an activity that can |
| 7003 | * display the intent. |
| 7004 | * |
| 7005 | * @see #setComponent |
| 7006 | * @see #getComponent |
| 7007 | * @see #resolveActivityInfo |
| 7008 | */ |
| 7009 | public ComponentName resolveActivity(PackageManager pm) { |
| 7010 | if (mComponent != null) { |
| 7011 | return mComponent; |
| 7012 | } |
| 7013 | |
| 7014 | ResolveInfo info = pm.resolveActivity( |
| 7015 | this, PackageManager.MATCH_DEFAULT_ONLY); |
| 7016 | if (info != null) { |
| 7017 | return new ComponentName( |
| 7018 | info.activityInfo.applicationInfo.packageName, |
| 7019 | info.activityInfo.name); |
| 7020 | } |
| 7021 | |
| 7022 | return null; |
| 7023 | } |
| 7024 | |
| 7025 | /** |
| 7026 | * Resolve the Intent into an {@link ActivityInfo} |
| 7027 | * describing the activity that should execute the intent. Resolution |
| 7028 | * follows the same rules as described for {@link #resolveActivity}, but |
| 7029 | * you get back the completely information about the resolved activity |
| 7030 | * instead of just its class name. |
| 7031 | * |
| 7032 | * @param pm The package manager with which to resolve the Intent. |
| 7033 | * @param flags Addition information to retrieve as per |
| 7034 | * {@link PackageManager#getActivityInfo(ComponentName, int) |
| 7035 | * PackageManager.getActivityInfo()}. |
| 7036 | * |
| 7037 | * @return PackageManager.ActivityInfo |
| 7038 | * |
| 7039 | * @see #resolveActivity |
| 7040 | */ |
| 7041 | public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) { |
| 7042 | ActivityInfo ai = null; |
| 7043 | if (mComponent != null) { |
| 7044 | try { |
| 7045 | ai = pm.getActivityInfo(mComponent, flags); |
| 7046 | } catch (PackageManager.NameNotFoundException e) { |
| 7047 | // ignore |
| 7048 | } |
| 7049 | } else { |
| 7050 | ResolveInfo info = pm.resolveActivity( |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 7051 | this, PackageManager.MATCH_DEFAULT_ONLY | flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7052 | if (info != null) { |
| 7053 | ai = info.activityInfo; |
| 7054 | } |
| 7055 | } |
| 7056 | |
| 7057 | return ai; |
| 7058 | } |
| 7059 | |
| 7060 | /** |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 7061 | * Special function for use by the system to resolve service |
| 7062 | * intents to system apps. Throws an exception if there are |
| 7063 | * multiple potential matches to the Intent. Returns null if |
| 7064 | * there are no matches. |
| 7065 | * @hide |
| 7066 | */ |
| 7067 | public ComponentName resolveSystemService(PackageManager pm, int flags) { |
| 7068 | if (mComponent != null) { |
| 7069 | return mComponent; |
| 7070 | } |
| 7071 | |
| 7072 | List<ResolveInfo> results = pm.queryIntentServices(this, flags); |
| 7073 | if (results == null) { |
| 7074 | return null; |
| 7075 | } |
| 7076 | ComponentName comp = null; |
| 7077 | for (int i=0; i<results.size(); i++) { |
| 7078 | ResolveInfo ri = results.get(i); |
| 7079 | if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { |
| 7080 | continue; |
| 7081 | } |
| 7082 | ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, |
| 7083 | ri.serviceInfo.name); |
| 7084 | if (comp != null) { |
| 7085 | throw new IllegalStateException("Multiple system services handle " + this |
| 7086 | + ": " + comp + ", " + foundComp); |
| 7087 | } |
| 7088 | comp = foundComp; |
| 7089 | } |
| 7090 | return comp; |
| 7091 | } |
| 7092 | |
| 7093 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7094 | * Set the general action to be performed. |
| 7095 | * |
| 7096 | * @param action An action name, such as ACTION_VIEW. Application-specific |
| 7097 | * actions should be prefixed with the vendor's package name. |
| 7098 | * |
| 7099 | * @return Returns the same Intent object, for chaining multiple calls |
| 7100 | * into a single statement. |
| 7101 | * |
| 7102 | * @see #getAction |
| 7103 | */ |
| 7104 | public Intent setAction(String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 7105 | mAction = action != null ? action.intern() : null; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7106 | return this; |
| 7107 | } |
| 7108 | |
| 7109 | /** |
| 7110 | * Set the data this intent is operating on. This method automatically |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7111 | * clears any type that was previously set by {@link #setType} or |
| 7112 | * {@link #setTypeAndNormalize}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7113 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7114 | * <p><em>Note: scheme matching in the Android framework is |
| 7115 | * case-sensitive, unlike the formal RFC. As a result, |
| 7116 | * you should always write your Uri with a lower case scheme, |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7117 | * or use {@link Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7118 | * {@link #setDataAndNormalize} |
| 7119 | * to ensure that the scheme is converted to lower case.</em> |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7120 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7121 | * @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] | 7122 | * |
| 7123 | * @return Returns the same Intent object, for chaining multiple calls |
| 7124 | * into a single statement. |
| 7125 | * |
| 7126 | * @see #getData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7127 | * @see #setDataAndNormalize |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 7128 | * @see android.net.Uri#normalizeScheme() |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7129 | */ |
| 7130 | public Intent setData(Uri data) { |
| 7131 | mData = data; |
| 7132 | mType = null; |
| 7133 | return this; |
| 7134 | } |
| 7135 | |
| 7136 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7137 | * Normalize and set the data this intent is operating on. |
| 7138 | * |
| 7139 | * <p>This method automatically clears any type that was |
| 7140 | * previously set (for example, by {@link #setType}). |
| 7141 | * |
| 7142 | * <p>The data Uri is normalized using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7143 | * {@link android.net.Uri#normalizeScheme} before it is set, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7144 | * so really this is just a convenience method for |
| 7145 | * <pre> |
| 7146 | * setData(data.normalize()) |
| 7147 | * </pre> |
| 7148 | * |
| 7149 | * @param data The Uri of the data this intent is now targeting. |
| 7150 | * |
| 7151 | * @return Returns the same Intent object, for chaining multiple calls |
| 7152 | * into a single statement. |
| 7153 | * |
| 7154 | * @see #getData |
| 7155 | * @see #setType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7156 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7157 | */ |
| 7158 | public Intent setDataAndNormalize(Uri data) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7159 | return setData(data.normalizeScheme()); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7160 | } |
| 7161 | |
| 7162 | /** |
| 7163 | * Set an explicit MIME data type. |
| 7164 | * |
| 7165 | * <p>This is used to create intents that only specify a type and not data, |
| 7166 | * for example to indicate the type of data to return. |
| 7167 | * |
| 7168 | * <p>This method automatically clears any data that was |
| 7169 | * previously set (for example by {@link #setData}). |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 7170 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7171 | * <p><em>Note: MIME type matching in the Android framework is |
| 7172 | * case-sensitive, unlike formal RFC MIME types. As a result, |
| 7173 | * you should always write your MIME types with lower case letters, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7174 | * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} |
| 7175 | * 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] | 7176 | * |
| 7177 | * @param type The MIME type of the data being handled by this intent. |
| 7178 | * |
| 7179 | * @return Returns the same Intent object, for chaining multiple calls |
| 7180 | * into a single statement. |
| 7181 | * |
| 7182 | * @see #getType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7183 | * @see #setTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7184 | * @see #setDataAndType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7185 | * @see #normalizeMimeType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7186 | */ |
| 7187 | public Intent setType(String type) { |
| 7188 | mData = null; |
| 7189 | mType = type; |
| 7190 | return this; |
| 7191 | } |
| 7192 | |
| 7193 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7194 | * Normalize and set an explicit MIME data type. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7195 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7196 | * <p>This is used to create intents that only specify a type and not data, |
| 7197 | * for example to indicate the type of data to return. |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 7198 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7199 | * <p>This method automatically clears any data that was |
| 7200 | * previously set (for example by {@link #setData}). |
| 7201 | * |
| 7202 | * <p>The MIME type is normalized using |
| 7203 | * {@link #normalizeMimeType} before it is set, |
| 7204 | * so really this is just a convenience method for |
| 7205 | * <pre> |
| 7206 | * setType(Intent.normalizeMimeType(type)) |
| 7207 | * </pre> |
| 7208 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7209 | * @param type The MIME type of the data being handled by this intent. |
| 7210 | * |
| 7211 | * @return Returns the same Intent object, for chaining multiple calls |
| 7212 | * into a single statement. |
| 7213 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7214 | * @see #getType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7215 | * @see #setData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7216 | * @see #normalizeMimeType |
| 7217 | */ |
| 7218 | public Intent setTypeAndNormalize(String type) { |
| 7219 | return setType(normalizeMimeType(type)); |
| 7220 | } |
| 7221 | |
| 7222 | /** |
| 7223 | * (Usually optional) Set the data for the intent along with an explicit |
| 7224 | * MIME data type. This method should very rarely be used -- it allows you |
| 7225 | * to override the MIME type that would ordinarily be inferred from the |
| 7226 | * data with your own type given here. |
| 7227 | * |
| 7228 | * <p><em>Note: MIME type and Uri scheme matching in the |
| 7229 | * Android framework is case-sensitive, unlike the formal RFC definitions. |
| 7230 | * 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] | 7231 | * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7232 | * {@link #setDataAndTypeAndNormalize} |
| 7233 | * to ensure that they are converted to lower case.</em> |
| 7234 | * |
| 7235 | * @param data The Uri of the data this intent is now targeting. |
| 7236 | * @param type The MIME type of the data being handled by this intent. |
| 7237 | * |
| 7238 | * @return Returns the same Intent object, for chaining multiple calls |
| 7239 | * into a single statement. |
| 7240 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7241 | * @see #setType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7242 | * @see #setData |
| 7243 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7244 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7245 | * @see #setDataAndTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7246 | */ |
| 7247 | public Intent setDataAndType(Uri data, String type) { |
| 7248 | mData = data; |
| 7249 | mType = type; |
| 7250 | return this; |
| 7251 | } |
| 7252 | |
| 7253 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7254 | * (Usually optional) Normalize and set both the data Uri and an explicit |
| 7255 | * MIME data type. This method should very rarely be used -- it allows you |
| 7256 | * to override the MIME type that would ordinarily be inferred from the |
| 7257 | * data with your own type given here. |
| 7258 | * |
| 7259 | * <p>The data Uri and the MIME type are normalize using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7260 | * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7261 | * before they are set, so really this is just a convenience method for |
| 7262 | * <pre> |
| 7263 | * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) |
| 7264 | * </pre> |
| 7265 | * |
| 7266 | * @param data The Uri of the data this intent is now targeting. |
| 7267 | * @param type The MIME type of the data being handled by this intent. |
| 7268 | * |
| 7269 | * @return Returns the same Intent object, for chaining multiple calls |
| 7270 | * into a single statement. |
| 7271 | * |
| 7272 | * @see #setType |
| 7273 | * @see #setData |
| 7274 | * @see #setDataAndType |
| 7275 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7276 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7277 | */ |
| 7278 | public Intent setDataAndTypeAndNormalize(Uri data, String type) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 7279 | return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7280 | } |
| 7281 | |
| 7282 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7283 | * Add a new category to the intent. Categories provide additional detail |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 7284 | * 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] | 7285 | * activities that provide <em>all</em> of the requested categories will be |
| 7286 | * used. |
| 7287 | * |
| 7288 | * @param category The desired category. This can be either one of the |
| 7289 | * predefined Intent categories, or a custom category in your own |
| 7290 | * namespace. |
| 7291 | * |
| 7292 | * @return Returns the same Intent object, for chaining multiple calls |
| 7293 | * into a single statement. |
| 7294 | * |
| 7295 | * @see #hasCategory |
| 7296 | * @see #removeCategory |
| 7297 | */ |
| 7298 | public Intent addCategory(String category) { |
| 7299 | if (mCategories == null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7300 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7301 | } |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 7302 | mCategories.add(category.intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7303 | return this; |
| 7304 | } |
| 7305 | |
| 7306 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 7307 | * Remove a category from an intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7308 | * |
| 7309 | * @param category The category to remove. |
| 7310 | * |
| 7311 | * @see #addCategory |
| 7312 | */ |
| 7313 | public void removeCategory(String category) { |
| 7314 | if (mCategories != null) { |
| 7315 | mCategories.remove(category); |
| 7316 | if (mCategories.size() == 0) { |
| 7317 | mCategories = null; |
| 7318 | } |
| 7319 | } |
| 7320 | } |
| 7321 | |
| 7322 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7323 | * Set a selector for this Intent. This is a modification to the kinds of |
| 7324 | * things the Intent will match. If the selector is set, it will be used |
| 7325 | * when trying to find entities that can handle the Intent, instead of the |
| 7326 | * main contents of the Intent. This allows you build an Intent containing |
| 7327 | * a generic protocol while targeting it more specifically. |
| 7328 | * |
| 7329 | * <p>An example of where this may be used is with things like |
| 7330 | * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an |
| 7331 | * Intent that will launch the Browser application. However, the correct |
| 7332 | * main entry point of an application is actually {@link #ACTION_MAIN} |
| 7333 | * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} |
| 7334 | * used to specify the actual Activity to launch. If you launch the browser |
| 7335 | * with something different, undesired behavior may happen if the user has |
| 7336 | * previously or later launches it the normal way, since they do not match. |
| 7337 | * Instead, you can build an Intent with the MAIN action (but no ComponentName |
| 7338 | * yet specified) and set a selector with {@link #ACTION_MAIN} and |
| 7339 | * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. |
| 7340 | * |
| 7341 | * <p>Setting a selector does not impact the behavior of |
| 7342 | * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the |
| 7343 | * desired behavior of a selector -- it does not impact the base meaning |
| 7344 | * of the Intent, just what kinds of things will be matched against it |
| 7345 | * when determining who can handle it.</p> |
| 7346 | * |
| 7347 | * <p>You can not use both a selector and {@link #setPackage(String)} on |
| 7348 | * the same base Intent.</p> |
| 7349 | * |
| 7350 | * @param selector The desired selector Intent; set to null to not use |
| 7351 | * a special selector. |
| 7352 | */ |
| 7353 | public void setSelector(Intent selector) { |
| 7354 | if (selector == this) { |
| 7355 | throw new IllegalArgumentException( |
| 7356 | "Intent being set as a selector of itself"); |
| 7357 | } |
| 7358 | if (selector != null && mPackage != null) { |
| 7359 | throw new IllegalArgumentException( |
| 7360 | "Can't set selector when package name is already set"); |
| 7361 | } |
| 7362 | mSelector = selector; |
| 7363 | } |
| 7364 | |
| 7365 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7366 | * Set a {@link ClipData} associated with this Intent. This replaces any |
| 7367 | * previously set ClipData. |
| 7368 | * |
| 7369 | * <p>The ClipData in an intent is not used for Intent matching or other |
| 7370 | * such operations. Semantically it is like extras, used to transmit |
| 7371 | * additional data with the Intent. The main feature of using this over |
| 7372 | * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} |
| 7373 | * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI |
| 7374 | * items included in the clip data. This is useful, in particular, if |
| 7375 | * you want to transmit an Intent containing multiple <code>content:</code> |
| 7376 | * URIs for which the recipient may not have global permission to access the |
| 7377 | * content provider. |
| 7378 | * |
| 7379 | * <p>If the ClipData contains items that are themselves Intents, any |
| 7380 | * grant flags in those Intents will be ignored. Only the top-level flags |
| 7381 | * of the main Intent are respected, and will be applied to all Uri or |
| 7382 | * Intent items in the clip (or sub-items of the clip). |
| 7383 | * |
| 7384 | * <p>The MIME type, label, and icon in the ClipData object are not |
| 7385 | * directly used by Intent. Applications should generally rely on the |
| 7386 | * MIME type of the Intent itself, not what it may find in the ClipData. |
| 7387 | * 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] | 7388 | * with a MIME type of "*/*". |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7389 | * |
| 7390 | * @param clip The new clip to set. May be null to clear the current clip. |
| 7391 | */ |
| 7392 | public void setClipData(ClipData clip) { |
| 7393 | mClipData = clip; |
| 7394 | } |
| 7395 | |
| 7396 | /** |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7397 | * This is NOT a secure mechanism to identify the user who sent the intent. |
| 7398 | * When the intent is sent to a different user, it is used to fix uris by adding the userId |
| 7399 | * who sent the intent. |
| 7400 | * @hide |
| 7401 | */ |
Nicolas Prevot | 107f7b7 | 2015-07-01 16:31:48 +0100 | [diff] [blame] | 7402 | public void prepareToLeaveUser(int userId) { |
| 7403 | // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. |
| 7404 | // We want mContentUserHint to refer to the original user, so don't do anything. |
| 7405 | if (mContentUserHint == UserHandle.USER_CURRENT) { |
| 7406 | mContentUserHint = userId; |
| 7407 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7408 | } |
| 7409 | |
| 7410 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7411 | * Add extended data to the intent. The name must include a package |
| 7412 | * prefix, for example the app com.android.contacts would use names |
| 7413 | * like "com.android.contacts.ShowAll". |
| 7414 | * |
| 7415 | * @param name The name of the extra data, with package prefix. |
| 7416 | * @param value The boolean data value. |
| 7417 | * |
| 7418 | * @return Returns the same Intent object, for chaining multiple calls |
| 7419 | * into a single statement. |
| 7420 | * |
| 7421 | * @see #putExtras |
| 7422 | * @see #removeExtra |
| 7423 | * @see #getBooleanExtra(String, boolean) |
| 7424 | */ |
| 7425 | public Intent putExtra(String name, boolean value) { |
| 7426 | if (mExtras == null) { |
| 7427 | mExtras = new Bundle(); |
| 7428 | } |
| 7429 | mExtras.putBoolean(name, value); |
| 7430 | return this; |
| 7431 | } |
| 7432 | |
| 7433 | /** |
| 7434 | * Add extended data to the intent. The name must include a package |
| 7435 | * prefix, for example the app com.android.contacts would use names |
| 7436 | * like "com.android.contacts.ShowAll". |
| 7437 | * |
| 7438 | * @param name The name of the extra data, with package prefix. |
| 7439 | * @param value The byte data value. |
| 7440 | * |
| 7441 | * @return Returns the same Intent object, for chaining multiple calls |
| 7442 | * into a single statement. |
| 7443 | * |
| 7444 | * @see #putExtras |
| 7445 | * @see #removeExtra |
| 7446 | * @see #getByteExtra(String, byte) |
| 7447 | */ |
| 7448 | public Intent putExtra(String name, byte value) { |
| 7449 | if (mExtras == null) { |
| 7450 | mExtras = new Bundle(); |
| 7451 | } |
| 7452 | mExtras.putByte(name, value); |
| 7453 | return this; |
| 7454 | } |
| 7455 | |
| 7456 | /** |
| 7457 | * Add extended data to the intent. The name must include a package |
| 7458 | * prefix, for example the app com.android.contacts would use names |
| 7459 | * like "com.android.contacts.ShowAll". |
| 7460 | * |
| 7461 | * @param name The name of the extra data, with package prefix. |
| 7462 | * @param value The char data value. |
| 7463 | * |
| 7464 | * @return Returns the same Intent object, for chaining multiple calls |
| 7465 | * into a single statement. |
| 7466 | * |
| 7467 | * @see #putExtras |
| 7468 | * @see #removeExtra |
| 7469 | * @see #getCharExtra(String, char) |
| 7470 | */ |
| 7471 | public Intent putExtra(String name, char value) { |
| 7472 | if (mExtras == null) { |
| 7473 | mExtras = new Bundle(); |
| 7474 | } |
| 7475 | mExtras.putChar(name, value); |
| 7476 | return this; |
| 7477 | } |
| 7478 | |
| 7479 | /** |
| 7480 | * Add extended data to the intent. The name must include a package |
| 7481 | * prefix, for example the app com.android.contacts would use names |
| 7482 | * like "com.android.contacts.ShowAll". |
| 7483 | * |
| 7484 | * @param name The name of the extra data, with package prefix. |
| 7485 | * @param value The short data value. |
| 7486 | * |
| 7487 | * @return Returns the same Intent object, for chaining multiple calls |
| 7488 | * into a single statement. |
| 7489 | * |
| 7490 | * @see #putExtras |
| 7491 | * @see #removeExtra |
| 7492 | * @see #getShortExtra(String, short) |
| 7493 | */ |
| 7494 | public Intent putExtra(String name, short value) { |
| 7495 | if (mExtras == null) { |
| 7496 | mExtras = new Bundle(); |
| 7497 | } |
| 7498 | mExtras.putShort(name, value); |
| 7499 | return this; |
| 7500 | } |
| 7501 | |
| 7502 | /** |
| 7503 | * Add extended data to the intent. The name must include a package |
| 7504 | * prefix, for example the app com.android.contacts would use names |
| 7505 | * like "com.android.contacts.ShowAll". |
| 7506 | * |
| 7507 | * @param name The name of the extra data, with package prefix. |
| 7508 | * @param value The integer data value. |
| 7509 | * |
| 7510 | * @return Returns the same Intent object, for chaining multiple calls |
| 7511 | * into a single statement. |
| 7512 | * |
| 7513 | * @see #putExtras |
| 7514 | * @see #removeExtra |
| 7515 | * @see #getIntExtra(String, int) |
| 7516 | */ |
| 7517 | public Intent putExtra(String name, int value) { |
| 7518 | if (mExtras == null) { |
| 7519 | mExtras = new Bundle(); |
| 7520 | } |
| 7521 | mExtras.putInt(name, value); |
| 7522 | return this; |
| 7523 | } |
| 7524 | |
| 7525 | /** |
| 7526 | * Add extended data to the intent. The name must include a package |
| 7527 | * prefix, for example the app com.android.contacts would use names |
| 7528 | * like "com.android.contacts.ShowAll". |
| 7529 | * |
| 7530 | * @param name The name of the extra data, with package prefix. |
| 7531 | * @param value The long data value. |
| 7532 | * |
| 7533 | * @return Returns the same Intent object, for chaining multiple calls |
| 7534 | * into a single statement. |
| 7535 | * |
| 7536 | * @see #putExtras |
| 7537 | * @see #removeExtra |
| 7538 | * @see #getLongExtra(String, long) |
| 7539 | */ |
| 7540 | public Intent putExtra(String name, long value) { |
| 7541 | if (mExtras == null) { |
| 7542 | mExtras = new Bundle(); |
| 7543 | } |
| 7544 | mExtras.putLong(name, value); |
| 7545 | return this; |
| 7546 | } |
| 7547 | |
| 7548 | /** |
| 7549 | * Add extended data to the intent. The name must include a package |
| 7550 | * prefix, for example the app com.android.contacts would use names |
| 7551 | * like "com.android.contacts.ShowAll". |
| 7552 | * |
| 7553 | * @param name The name of the extra data, with package prefix. |
| 7554 | * @param value The float data value. |
| 7555 | * |
| 7556 | * @return Returns the same Intent object, for chaining multiple calls |
| 7557 | * into a single statement. |
| 7558 | * |
| 7559 | * @see #putExtras |
| 7560 | * @see #removeExtra |
| 7561 | * @see #getFloatExtra(String, float) |
| 7562 | */ |
| 7563 | public Intent putExtra(String name, float value) { |
| 7564 | if (mExtras == null) { |
| 7565 | mExtras = new Bundle(); |
| 7566 | } |
| 7567 | mExtras.putFloat(name, value); |
| 7568 | return this; |
| 7569 | } |
| 7570 | |
| 7571 | /** |
| 7572 | * Add extended data to the intent. The name must include a package |
| 7573 | * prefix, for example the app com.android.contacts would use names |
| 7574 | * like "com.android.contacts.ShowAll". |
| 7575 | * |
| 7576 | * @param name The name of the extra data, with package prefix. |
| 7577 | * @param value The double data value. |
| 7578 | * |
| 7579 | * @return Returns the same Intent object, for chaining multiple calls |
| 7580 | * into a single statement. |
| 7581 | * |
| 7582 | * @see #putExtras |
| 7583 | * @see #removeExtra |
| 7584 | * @see #getDoubleExtra(String, double) |
| 7585 | */ |
| 7586 | public Intent putExtra(String name, double value) { |
| 7587 | if (mExtras == null) { |
| 7588 | mExtras = new Bundle(); |
| 7589 | } |
| 7590 | mExtras.putDouble(name, value); |
| 7591 | return this; |
| 7592 | } |
| 7593 | |
| 7594 | /** |
| 7595 | * Add extended data to the intent. The name must include a package |
| 7596 | * prefix, for example the app com.android.contacts would use names |
| 7597 | * like "com.android.contacts.ShowAll". |
| 7598 | * |
| 7599 | * @param name The name of the extra data, with package prefix. |
| 7600 | * @param value The String data value. |
| 7601 | * |
| 7602 | * @return Returns the same Intent object, for chaining multiple calls |
| 7603 | * into a single statement. |
| 7604 | * |
| 7605 | * @see #putExtras |
| 7606 | * @see #removeExtra |
| 7607 | * @see #getStringExtra(String) |
| 7608 | */ |
| 7609 | public Intent putExtra(String name, String value) { |
| 7610 | if (mExtras == null) { |
| 7611 | mExtras = new Bundle(); |
| 7612 | } |
| 7613 | mExtras.putString(name, value); |
| 7614 | return this; |
| 7615 | } |
| 7616 | |
| 7617 | /** |
| 7618 | * Add extended data to the intent. The name must include a package |
| 7619 | * prefix, for example the app com.android.contacts would use names |
| 7620 | * like "com.android.contacts.ShowAll". |
| 7621 | * |
| 7622 | * @param name The name of the extra data, with package prefix. |
| 7623 | * @param value The CharSequence data value. |
| 7624 | * |
| 7625 | * @return Returns the same Intent object, for chaining multiple calls |
| 7626 | * into a single statement. |
| 7627 | * |
| 7628 | * @see #putExtras |
| 7629 | * @see #removeExtra |
| 7630 | * @see #getCharSequenceExtra(String) |
| 7631 | */ |
| 7632 | public Intent putExtra(String name, CharSequence value) { |
| 7633 | if (mExtras == null) { |
| 7634 | mExtras = new Bundle(); |
| 7635 | } |
| 7636 | mExtras.putCharSequence(name, value); |
| 7637 | return this; |
| 7638 | } |
| 7639 | |
| 7640 | /** |
| 7641 | * Add extended data to the intent. The name must include a package |
| 7642 | * prefix, for example the app com.android.contacts would use names |
| 7643 | * like "com.android.contacts.ShowAll". |
| 7644 | * |
| 7645 | * @param name The name of the extra data, with package prefix. |
| 7646 | * @param value The Parcelable data value. |
| 7647 | * |
| 7648 | * @return Returns the same Intent object, for chaining multiple calls |
| 7649 | * into a single statement. |
| 7650 | * |
| 7651 | * @see #putExtras |
| 7652 | * @see #removeExtra |
| 7653 | * @see #getParcelableExtra(String) |
| 7654 | */ |
| 7655 | public Intent putExtra(String name, Parcelable value) { |
| 7656 | if (mExtras == null) { |
| 7657 | mExtras = new Bundle(); |
| 7658 | } |
| 7659 | mExtras.putParcelable(name, value); |
| 7660 | return this; |
| 7661 | } |
| 7662 | |
| 7663 | /** |
| 7664 | * Add extended data to the intent. The name must include a package |
| 7665 | * prefix, for example the app com.android.contacts would use names |
| 7666 | * like "com.android.contacts.ShowAll". |
| 7667 | * |
| 7668 | * @param name The name of the extra data, with package prefix. |
| 7669 | * @param value The Parcelable[] data value. |
| 7670 | * |
| 7671 | * @return Returns the same Intent object, for chaining multiple calls |
| 7672 | * into a single statement. |
| 7673 | * |
| 7674 | * @see #putExtras |
| 7675 | * @see #removeExtra |
| 7676 | * @see #getParcelableArrayExtra(String) |
| 7677 | */ |
| 7678 | public Intent putExtra(String name, Parcelable[] value) { |
| 7679 | if (mExtras == null) { |
| 7680 | mExtras = new Bundle(); |
| 7681 | } |
| 7682 | mExtras.putParcelableArray(name, value); |
| 7683 | return this; |
| 7684 | } |
| 7685 | |
| 7686 | /** |
| 7687 | * Add extended data to the intent. The name must include a package |
| 7688 | * prefix, for example the app com.android.contacts would use names |
| 7689 | * like "com.android.contacts.ShowAll". |
| 7690 | * |
| 7691 | * @param name The name of the extra data, with package prefix. |
| 7692 | * @param value The ArrayList<Parcelable> data value. |
| 7693 | * |
| 7694 | * @return Returns the same Intent object, for chaining multiple calls |
| 7695 | * into a single statement. |
| 7696 | * |
| 7697 | * @see #putExtras |
| 7698 | * @see #removeExtra |
| 7699 | * @see #getParcelableArrayListExtra(String) |
| 7700 | */ |
| 7701 | public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) { |
| 7702 | if (mExtras == null) { |
| 7703 | mExtras = new Bundle(); |
| 7704 | } |
| 7705 | mExtras.putParcelableArrayList(name, value); |
| 7706 | return this; |
| 7707 | } |
| 7708 | |
| 7709 | /** |
| 7710 | * Add extended data to the intent. The name must include a package |
| 7711 | * prefix, for example the app com.android.contacts would use names |
| 7712 | * like "com.android.contacts.ShowAll". |
| 7713 | * |
| 7714 | * @param name The name of the extra data, with package prefix. |
| 7715 | * @param value The ArrayList<Integer> data value. |
| 7716 | * |
| 7717 | * @return Returns the same Intent object, for chaining multiple calls |
| 7718 | * into a single statement. |
| 7719 | * |
| 7720 | * @see #putExtras |
| 7721 | * @see #removeExtra |
| 7722 | * @see #getIntegerArrayListExtra(String) |
| 7723 | */ |
| 7724 | public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) { |
| 7725 | if (mExtras == null) { |
| 7726 | mExtras = new Bundle(); |
| 7727 | } |
| 7728 | mExtras.putIntegerArrayList(name, value); |
| 7729 | return this; |
| 7730 | } |
| 7731 | |
| 7732 | /** |
| 7733 | * Add extended data to the intent. The name must include a package |
| 7734 | * prefix, for example the app com.android.contacts would use names |
| 7735 | * like "com.android.contacts.ShowAll". |
| 7736 | * |
| 7737 | * @param name The name of the extra data, with package prefix. |
| 7738 | * @param value The ArrayList<String> data value. |
| 7739 | * |
| 7740 | * @return Returns the same Intent object, for chaining multiple calls |
| 7741 | * into a single statement. |
| 7742 | * |
| 7743 | * @see #putExtras |
| 7744 | * @see #removeExtra |
| 7745 | * @see #getStringArrayListExtra(String) |
| 7746 | */ |
| 7747 | public Intent putStringArrayListExtra(String name, ArrayList<String> value) { |
| 7748 | if (mExtras == null) { |
| 7749 | mExtras = new Bundle(); |
| 7750 | } |
| 7751 | mExtras.putStringArrayList(name, value); |
| 7752 | return this; |
| 7753 | } |
| 7754 | |
| 7755 | /** |
| 7756 | * Add extended data to the intent. The name must include a package |
| 7757 | * prefix, for example the app com.android.contacts would use names |
| 7758 | * like "com.android.contacts.ShowAll". |
| 7759 | * |
| 7760 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 7761 | * @param value The ArrayList<CharSequence> data value. |
| 7762 | * |
| 7763 | * @return Returns the same Intent object, for chaining multiple calls |
| 7764 | * into a single statement. |
| 7765 | * |
| 7766 | * @see #putExtras |
| 7767 | * @see #removeExtra |
| 7768 | * @see #getCharSequenceArrayListExtra(String) |
| 7769 | */ |
| 7770 | public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) { |
| 7771 | if (mExtras == null) { |
| 7772 | mExtras = new Bundle(); |
| 7773 | } |
| 7774 | mExtras.putCharSequenceArrayList(name, value); |
| 7775 | return this; |
| 7776 | } |
| 7777 | |
| 7778 | /** |
| 7779 | * Add extended data to the intent. The name must include a package |
| 7780 | * prefix, for example the app com.android.contacts would use names |
| 7781 | * like "com.android.contacts.ShowAll". |
| 7782 | * |
| 7783 | * @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] | 7784 | * @param value The Serializable data value. |
| 7785 | * |
| 7786 | * @return Returns the same Intent object, for chaining multiple calls |
| 7787 | * into a single statement. |
| 7788 | * |
| 7789 | * @see #putExtras |
| 7790 | * @see #removeExtra |
| 7791 | * @see #getSerializableExtra(String) |
| 7792 | */ |
| 7793 | public Intent putExtra(String name, Serializable value) { |
| 7794 | if (mExtras == null) { |
| 7795 | mExtras = new Bundle(); |
| 7796 | } |
| 7797 | mExtras.putSerializable(name, value); |
| 7798 | return this; |
| 7799 | } |
| 7800 | |
| 7801 | /** |
| 7802 | * Add extended data to the intent. The name must include a package |
| 7803 | * prefix, for example the app com.android.contacts would use names |
| 7804 | * like "com.android.contacts.ShowAll". |
| 7805 | * |
| 7806 | * @param name The name of the extra data, with package prefix. |
| 7807 | * @param value The boolean array data value. |
| 7808 | * |
| 7809 | * @return Returns the same Intent object, for chaining multiple calls |
| 7810 | * into a single statement. |
| 7811 | * |
| 7812 | * @see #putExtras |
| 7813 | * @see #removeExtra |
| 7814 | * @see #getBooleanArrayExtra(String) |
| 7815 | */ |
| 7816 | public Intent putExtra(String name, boolean[] value) { |
| 7817 | if (mExtras == null) { |
| 7818 | mExtras = new Bundle(); |
| 7819 | } |
| 7820 | mExtras.putBooleanArray(name, value); |
| 7821 | return this; |
| 7822 | } |
| 7823 | |
| 7824 | /** |
| 7825 | * Add extended data to the intent. The name must include a package |
| 7826 | * prefix, for example the app com.android.contacts would use names |
| 7827 | * like "com.android.contacts.ShowAll". |
| 7828 | * |
| 7829 | * @param name The name of the extra data, with package prefix. |
| 7830 | * @param value The byte array data value. |
| 7831 | * |
| 7832 | * @return Returns the same Intent object, for chaining multiple calls |
| 7833 | * into a single statement. |
| 7834 | * |
| 7835 | * @see #putExtras |
| 7836 | * @see #removeExtra |
| 7837 | * @see #getByteArrayExtra(String) |
| 7838 | */ |
| 7839 | public Intent putExtra(String name, byte[] value) { |
| 7840 | if (mExtras == null) { |
| 7841 | mExtras = new Bundle(); |
| 7842 | } |
| 7843 | mExtras.putByteArray(name, value); |
| 7844 | return this; |
| 7845 | } |
| 7846 | |
| 7847 | /** |
| 7848 | * Add extended data to the intent. The name must include a package |
| 7849 | * prefix, for example the app com.android.contacts would use names |
| 7850 | * like "com.android.contacts.ShowAll". |
| 7851 | * |
| 7852 | * @param name The name of the extra data, with package prefix. |
| 7853 | * @param value The short array data value. |
| 7854 | * |
| 7855 | * @return Returns the same Intent object, for chaining multiple calls |
| 7856 | * into a single statement. |
| 7857 | * |
| 7858 | * @see #putExtras |
| 7859 | * @see #removeExtra |
| 7860 | * @see #getShortArrayExtra(String) |
| 7861 | */ |
| 7862 | public Intent putExtra(String name, short[] value) { |
| 7863 | if (mExtras == null) { |
| 7864 | mExtras = new Bundle(); |
| 7865 | } |
| 7866 | mExtras.putShortArray(name, value); |
| 7867 | return this; |
| 7868 | } |
| 7869 | |
| 7870 | /** |
| 7871 | * Add extended data to the intent. The name must include a package |
| 7872 | * prefix, for example the app com.android.contacts would use names |
| 7873 | * like "com.android.contacts.ShowAll". |
| 7874 | * |
| 7875 | * @param name The name of the extra data, with package prefix. |
| 7876 | * @param value The char array data value. |
| 7877 | * |
| 7878 | * @return Returns the same Intent object, for chaining multiple calls |
| 7879 | * into a single statement. |
| 7880 | * |
| 7881 | * @see #putExtras |
| 7882 | * @see #removeExtra |
| 7883 | * @see #getCharArrayExtra(String) |
| 7884 | */ |
| 7885 | public Intent putExtra(String name, char[] value) { |
| 7886 | if (mExtras == null) { |
| 7887 | mExtras = new Bundle(); |
| 7888 | } |
| 7889 | mExtras.putCharArray(name, value); |
| 7890 | return this; |
| 7891 | } |
| 7892 | |
| 7893 | /** |
| 7894 | * Add extended data to the intent. The name must include a package |
| 7895 | * prefix, for example the app com.android.contacts would use names |
| 7896 | * like "com.android.contacts.ShowAll". |
| 7897 | * |
| 7898 | * @param name The name of the extra data, with package prefix. |
| 7899 | * @param value The int array data value. |
| 7900 | * |
| 7901 | * @return Returns the same Intent object, for chaining multiple calls |
| 7902 | * into a single statement. |
| 7903 | * |
| 7904 | * @see #putExtras |
| 7905 | * @see #removeExtra |
| 7906 | * @see #getIntArrayExtra(String) |
| 7907 | */ |
| 7908 | public Intent putExtra(String name, int[] value) { |
| 7909 | if (mExtras == null) { |
| 7910 | mExtras = new Bundle(); |
| 7911 | } |
| 7912 | mExtras.putIntArray(name, value); |
| 7913 | return this; |
| 7914 | } |
| 7915 | |
| 7916 | /** |
| 7917 | * Add extended data to the intent. The name must include a package |
| 7918 | * prefix, for example the app com.android.contacts would use names |
| 7919 | * like "com.android.contacts.ShowAll". |
| 7920 | * |
| 7921 | * @param name The name of the extra data, with package prefix. |
| 7922 | * @param value The byte array data value. |
| 7923 | * |
| 7924 | * @return Returns the same Intent object, for chaining multiple calls |
| 7925 | * into a single statement. |
| 7926 | * |
| 7927 | * @see #putExtras |
| 7928 | * @see #removeExtra |
| 7929 | * @see #getLongArrayExtra(String) |
| 7930 | */ |
| 7931 | public Intent putExtra(String name, long[] value) { |
| 7932 | if (mExtras == null) { |
| 7933 | mExtras = new Bundle(); |
| 7934 | } |
| 7935 | mExtras.putLongArray(name, value); |
| 7936 | return this; |
| 7937 | } |
| 7938 | |
| 7939 | /** |
| 7940 | * Add extended data to the intent. The name must include a package |
| 7941 | * prefix, for example the app com.android.contacts would use names |
| 7942 | * like "com.android.contacts.ShowAll". |
| 7943 | * |
| 7944 | * @param name The name of the extra data, with package prefix. |
| 7945 | * @param value The float array data value. |
| 7946 | * |
| 7947 | * @return Returns the same Intent object, for chaining multiple calls |
| 7948 | * into a single statement. |
| 7949 | * |
| 7950 | * @see #putExtras |
| 7951 | * @see #removeExtra |
| 7952 | * @see #getFloatArrayExtra(String) |
| 7953 | */ |
| 7954 | public Intent putExtra(String name, float[] value) { |
| 7955 | if (mExtras == null) { |
| 7956 | mExtras = new Bundle(); |
| 7957 | } |
| 7958 | mExtras.putFloatArray(name, value); |
| 7959 | return this; |
| 7960 | } |
| 7961 | |
| 7962 | /** |
| 7963 | * Add extended data to the intent. The name must include a package |
| 7964 | * prefix, for example the app com.android.contacts would use names |
| 7965 | * like "com.android.contacts.ShowAll". |
| 7966 | * |
| 7967 | * @param name The name of the extra data, with package prefix. |
| 7968 | * @param value The double array data value. |
| 7969 | * |
| 7970 | * @return Returns the same Intent object, for chaining multiple calls |
| 7971 | * into a single statement. |
| 7972 | * |
| 7973 | * @see #putExtras |
| 7974 | * @see #removeExtra |
| 7975 | * @see #getDoubleArrayExtra(String) |
| 7976 | */ |
| 7977 | public Intent putExtra(String name, double[] value) { |
| 7978 | if (mExtras == null) { |
| 7979 | mExtras = new Bundle(); |
| 7980 | } |
| 7981 | mExtras.putDoubleArray(name, value); |
| 7982 | return this; |
| 7983 | } |
| 7984 | |
| 7985 | /** |
| 7986 | * Add extended data to the intent. The name must include a package |
| 7987 | * prefix, for example the app com.android.contacts would use names |
| 7988 | * like "com.android.contacts.ShowAll". |
| 7989 | * |
| 7990 | * @param name The name of the extra data, with package prefix. |
| 7991 | * @param value The String array data value. |
| 7992 | * |
| 7993 | * @return Returns the same Intent object, for chaining multiple calls |
| 7994 | * into a single statement. |
| 7995 | * |
| 7996 | * @see #putExtras |
| 7997 | * @see #removeExtra |
| 7998 | * @see #getStringArrayExtra(String) |
| 7999 | */ |
| 8000 | public Intent putExtra(String name, String[] value) { |
| 8001 | if (mExtras == null) { |
| 8002 | mExtras = new Bundle(); |
| 8003 | } |
| 8004 | mExtras.putStringArray(name, value); |
| 8005 | return this; |
| 8006 | } |
| 8007 | |
| 8008 | /** |
| 8009 | * Add extended data to the intent. The name must include a package |
| 8010 | * prefix, for example the app com.android.contacts would use names |
| 8011 | * like "com.android.contacts.ShowAll". |
| 8012 | * |
| 8013 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 8014 | * @param value The CharSequence array data value. |
| 8015 | * |
| 8016 | * @return Returns the same Intent object, for chaining multiple calls |
| 8017 | * into a single statement. |
| 8018 | * |
| 8019 | * @see #putExtras |
| 8020 | * @see #removeExtra |
| 8021 | * @see #getCharSequenceArrayExtra(String) |
| 8022 | */ |
| 8023 | public Intent putExtra(String name, CharSequence[] value) { |
| 8024 | if (mExtras == null) { |
| 8025 | mExtras = new Bundle(); |
| 8026 | } |
| 8027 | mExtras.putCharSequenceArray(name, value); |
| 8028 | return this; |
| 8029 | } |
| 8030 | |
| 8031 | /** |
| 8032 | * Add extended data to the intent. The name must include a package |
| 8033 | * prefix, for example the app com.android.contacts would use names |
| 8034 | * like "com.android.contacts.ShowAll". |
| 8035 | * |
| 8036 | * @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] | 8037 | * @param value The Bundle data value. |
| 8038 | * |
| 8039 | * @return Returns the same Intent object, for chaining multiple calls |
| 8040 | * into a single statement. |
| 8041 | * |
| 8042 | * @see #putExtras |
| 8043 | * @see #removeExtra |
| 8044 | * @see #getBundleExtra(String) |
| 8045 | */ |
| 8046 | public Intent putExtra(String name, Bundle value) { |
| 8047 | if (mExtras == null) { |
| 8048 | mExtras = new Bundle(); |
| 8049 | } |
| 8050 | mExtras.putBundle(name, value); |
| 8051 | return this; |
| 8052 | } |
| 8053 | |
| 8054 | /** |
| 8055 | * Add extended data to the intent. The name must include a package |
| 8056 | * prefix, for example the app com.android.contacts would use names |
| 8057 | * like "com.android.contacts.ShowAll". |
| 8058 | * |
| 8059 | * @param name The name of the extra data, with package prefix. |
| 8060 | * @param value The IBinder data value. |
| 8061 | * |
| 8062 | * @return Returns the same Intent object, for chaining multiple calls |
| 8063 | * into a single statement. |
| 8064 | * |
| 8065 | * @see #putExtras |
| 8066 | * @see #removeExtra |
| 8067 | * @see #getIBinderExtra(String) |
| 8068 | * |
| 8069 | * @deprecated |
| 8070 | * @hide |
| 8071 | */ |
| 8072 | @Deprecated |
| 8073 | public Intent putExtra(String name, IBinder value) { |
| 8074 | if (mExtras == null) { |
| 8075 | mExtras = new Bundle(); |
| 8076 | } |
| 8077 | mExtras.putIBinder(name, value); |
| 8078 | return this; |
| 8079 | } |
| 8080 | |
| 8081 | /** |
| 8082 | * Copy all extras in 'src' in to this intent. |
| 8083 | * |
| 8084 | * @param src Contains the extras to copy. |
| 8085 | * |
| 8086 | * @see #putExtra |
| 8087 | */ |
| 8088 | public Intent putExtras(Intent src) { |
| 8089 | if (src.mExtras != null) { |
| 8090 | if (mExtras == null) { |
| 8091 | mExtras = new Bundle(src.mExtras); |
| 8092 | } else { |
| 8093 | mExtras.putAll(src.mExtras); |
| 8094 | } |
| 8095 | } |
| 8096 | return this; |
| 8097 | } |
| 8098 | |
| 8099 | /** |
| 8100 | * Add a set of extended data to the intent. The keys must include a package |
| 8101 | * prefix, for example the app com.android.contacts would use names |
| 8102 | * like "com.android.contacts.ShowAll". |
| 8103 | * |
| 8104 | * @param extras The Bundle of extras to add to this intent. |
| 8105 | * |
| 8106 | * @see #putExtra |
| 8107 | * @see #removeExtra |
| 8108 | */ |
| 8109 | public Intent putExtras(Bundle extras) { |
| 8110 | if (mExtras == null) { |
| 8111 | mExtras = new Bundle(); |
| 8112 | } |
| 8113 | mExtras.putAll(extras); |
| 8114 | return this; |
| 8115 | } |
| 8116 | |
| 8117 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8118 | * Completely replace the extras in the Intent with the extras in the |
| 8119 | * given Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8120 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8121 | * @param src The exact extras contained in this Intent are copied |
| 8122 | * into the target intent, replacing any that were previously there. |
| 8123 | */ |
| 8124 | public Intent replaceExtras(Intent src) { |
| 8125 | mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; |
| 8126 | return this; |
| 8127 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8128 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8129 | /** |
| 8130 | * Completely replace the extras in the Intent with the given Bundle of |
| 8131 | * extras. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8132 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8133 | * @param extras The new set of extras in the Intent, or null to erase |
| 8134 | * all extras. |
| 8135 | */ |
| 8136 | public Intent replaceExtras(Bundle extras) { |
| 8137 | mExtras = extras != null ? new Bundle(extras) : null; |
| 8138 | return this; |
| 8139 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8140 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8141 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8142 | * Remove extended data from the intent. |
| 8143 | * |
| 8144 | * @see #putExtra |
| 8145 | */ |
| 8146 | public void removeExtra(String name) { |
| 8147 | if (mExtras != null) { |
| 8148 | mExtras.remove(name); |
| 8149 | if (mExtras.size() == 0) { |
| 8150 | mExtras = null; |
| 8151 | } |
| 8152 | } |
| 8153 | } |
| 8154 | |
| 8155 | /** |
| 8156 | * Set special flags controlling how this intent is handled. Most values |
| 8157 | * here depend on the type of component being executed by the Intent, |
| 8158 | * specifically the FLAG_ACTIVITY_* flags are all for use with |
| 8159 | * {@link Context#startActivity Context.startActivity()} and the |
| 8160 | * FLAG_RECEIVER_* flags are all for use with |
| 8161 | * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. |
| 8162 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 8163 | * <p>See the |
| 8164 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 8165 | * 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] | 8166 | * the behavior of your application. |
| 8167 | * |
| 8168 | * @param flags The desired flags. |
| 8169 | * |
| 8170 | * @return Returns the same Intent object, for chaining multiple calls |
| 8171 | * into a single statement. |
| 8172 | * |
| 8173 | * @see #getFlags |
| 8174 | * @see #addFlags |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8175 | * @see #removeFlags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8176 | * |
| 8177 | * @see #FLAG_GRANT_READ_URI_PERMISSION |
| 8178 | * @see #FLAG_GRANT_WRITE_URI_PERMISSION |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 8179 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 8180 | * @see #FLAG_GRANT_PREFIX_URI_PERMISSION |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8181 | * @see #FLAG_DEBUG_LOG_RESOLUTION |
| 8182 | * @see #FLAG_FROM_BACKGROUND |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8183 | * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8184 | * @see #FLAG_ACTIVITY_CLEAR_TASK |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8185 | * @see #FLAG_ACTIVITY_CLEAR_TOP |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8186 | * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8187 | * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS |
| 8188 | * @see #FLAG_ACTIVITY_FORWARD_RESULT |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8189 | * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8190 | * @see #FLAG_ACTIVITY_MULTIPLE_TASK |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 8191 | * @see #FLAG_ACTIVITY_NEW_DOCUMENT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8192 | * @see #FLAG_ACTIVITY_NEW_TASK |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8193 | * @see #FLAG_ACTIVITY_NO_ANIMATION |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8194 | * @see #FLAG_ACTIVITY_NO_HISTORY |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 8195 | * @see #FLAG_ACTIVITY_NO_USER_ACTION |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 8196 | * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP |
| 8197 | * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8198 | * @see #FLAG_ACTIVITY_REORDER_TO_FRONT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8199 | * @see #FLAG_ACTIVITY_SINGLE_TOP |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 8200 | * @see #FLAG_ACTIVITY_TASK_ON_HOME |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8201 | * @see #FLAG_RECEIVER_REGISTERED_ONLY |
| 8202 | */ |
| 8203 | public Intent setFlags(int flags) { |
| 8204 | mFlags = flags; |
| 8205 | return this; |
| 8206 | } |
| 8207 | |
| 8208 | /** |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8209 | * 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] | 8210 | * |
| 8211 | * @param flags The new flags to set. |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8212 | * @return Returns the same Intent object, for chaining multiple calls into |
| 8213 | * a single statement. |
| 8214 | * @see #setFlags(int) |
| 8215 | * @see #removeFlags(int) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8216 | */ |
| 8217 | public Intent addFlags(int flags) { |
| 8218 | mFlags |= flags; |
| 8219 | return this; |
| 8220 | } |
| 8221 | |
| 8222 | /** |
Jeff Sharkey | 6a34e56 | 2016-12-21 09:56:00 -0700 | [diff] [blame] | 8223 | * Remove these flags from the intent. |
| 8224 | * |
| 8225 | * @param flags The flags to remove. |
| 8226 | * @see #setFlags(int) |
| 8227 | * @see #addFlags(int) |
| 8228 | */ |
| 8229 | public void removeFlags(int flags) { |
| 8230 | mFlags &= ~flags; |
| 8231 | } |
| 8232 | |
| 8233 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8234 | * (Usually optional) Set an explicit application package name that limits |
| 8235 | * the components this Intent will resolve to. If left to the default |
| 8236 | * value of null, all components in all applications will considered. |
| 8237 | * If non-null, the Intent can only match the components in the given |
| 8238 | * application package. |
| 8239 | * |
| 8240 | * @param packageName The name of the application package to handle the |
| 8241 | * intent, or null to allow any application package. |
| 8242 | * |
| 8243 | * @return Returns the same Intent object, for chaining multiple calls |
| 8244 | * into a single statement. |
| 8245 | * |
| 8246 | * @see #getPackage |
| 8247 | * @see #resolveActivity |
| 8248 | */ |
| 8249 | public Intent setPackage(String packageName) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8250 | if (packageName != null && mSelector != null) { |
| 8251 | throw new IllegalArgumentException( |
| 8252 | "Can't set package name when selector is already set"); |
| 8253 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8254 | mPackage = packageName; |
| 8255 | return this; |
| 8256 | } |
| 8257 | |
| 8258 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8259 | * (Usually optional) Explicitly set the component to handle the intent. |
| 8260 | * If left with the default value of null, the system will determine the |
| 8261 | * appropriate class to use based on the other fields (action, data, |
| 8262 | * type, categories) in the Intent. If this class is defined, the |
| 8263 | * specified class will always be used regardless of the other fields. You |
| 8264 | * should only set this value when you know you absolutely want a specific |
| 8265 | * class to be used; otherwise it is better to let the system find the |
| 8266 | * appropriate class so that you will respect the installed applications |
| 8267 | * and user preferences. |
| 8268 | * |
| 8269 | * @param component The name of the application component to handle the |
| 8270 | * intent, or null to let the system find one for you. |
| 8271 | * |
| 8272 | * @return Returns the same Intent object, for chaining multiple calls |
| 8273 | * into a single statement. |
| 8274 | * |
| 8275 | * @see #setClass |
| 8276 | * @see #setClassName(Context, String) |
| 8277 | * @see #setClassName(String, String) |
| 8278 | * @see #getComponent |
| 8279 | * @see #resolveActivity |
| 8280 | */ |
| 8281 | public Intent setComponent(ComponentName component) { |
| 8282 | mComponent = component; |
| 8283 | return this; |
| 8284 | } |
| 8285 | |
| 8286 | /** |
| 8287 | * Convenience for calling {@link #setComponent} with an |
| 8288 | * explicit class name. |
| 8289 | * |
| 8290 | * @param packageContext A Context of the application package implementing |
| 8291 | * this class. |
| 8292 | * @param className The name of a class inside of the application package |
| 8293 | * that will be used as the component for this Intent. |
| 8294 | * |
| 8295 | * @return Returns the same Intent object, for chaining multiple calls |
| 8296 | * into a single statement. |
| 8297 | * |
| 8298 | * @see #setComponent |
| 8299 | * @see #setClass |
| 8300 | */ |
| 8301 | public Intent setClassName(Context packageContext, String className) { |
| 8302 | mComponent = new ComponentName(packageContext, className); |
| 8303 | return this; |
| 8304 | } |
| 8305 | |
| 8306 | /** |
| 8307 | * Convenience for calling {@link #setComponent} with an |
| 8308 | * explicit application package name and class name. |
| 8309 | * |
| 8310 | * @param packageName The name of the package implementing the desired |
| 8311 | * component. |
| 8312 | * @param className The name of a class inside of the application package |
| 8313 | * that will be used as the component for this Intent. |
| 8314 | * |
| 8315 | * @return Returns the same Intent object, for chaining multiple calls |
| 8316 | * into a single statement. |
| 8317 | * |
| 8318 | * @see #setComponent |
| 8319 | * @see #setClass |
| 8320 | */ |
| 8321 | public Intent setClassName(String packageName, String className) { |
| 8322 | mComponent = new ComponentName(packageName, className); |
| 8323 | return this; |
| 8324 | } |
| 8325 | |
| 8326 | /** |
| 8327 | * Convenience for calling {@link #setComponent(ComponentName)} with the |
| 8328 | * name returned by a {@link Class} object. |
| 8329 | * |
| 8330 | * @param packageContext A Context of the application package implementing |
| 8331 | * this class. |
| 8332 | * @param cls The class name to set, equivalent to |
| 8333 | * <code>setClassName(context, cls.getName())</code>. |
| 8334 | * |
| 8335 | * @return Returns the same Intent object, for chaining multiple calls |
| 8336 | * into a single statement. |
| 8337 | * |
| 8338 | * @see #setComponent |
| 8339 | */ |
| 8340 | public Intent setClass(Context packageContext, Class<?> cls) { |
| 8341 | mComponent = new ComponentName(packageContext, cls); |
| 8342 | return this; |
| 8343 | } |
| 8344 | |
| 8345 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8346 | * Set the bounds of the sender of this intent, in screen coordinates. This can be |
| 8347 | * used as a hint to the receiver for animations and the like. Null means that there |
| 8348 | * is no source bounds. |
| 8349 | */ |
| 8350 | public void setSourceBounds(Rect r) { |
| 8351 | if (r != null) { |
| 8352 | mSourceBounds = new Rect(r); |
| 8353 | } else { |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 8354 | mSourceBounds = null; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8355 | } |
| 8356 | } |
| 8357 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8358 | /** @hide */ |
| 8359 | @IntDef(flag = true, |
| 8360 | value = { |
| 8361 | FILL_IN_ACTION, |
| 8362 | FILL_IN_DATA, |
| 8363 | FILL_IN_CATEGORIES, |
| 8364 | FILL_IN_COMPONENT, |
| 8365 | FILL_IN_PACKAGE, |
| 8366 | FILL_IN_SOURCE_BOUNDS, |
| 8367 | FILL_IN_SELECTOR, |
| 8368 | FILL_IN_CLIP_DATA |
| 8369 | }) |
| 8370 | @Retention(RetentionPolicy.SOURCE) |
| 8371 | public @interface FillInFlags {} |
| 8372 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8373 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8374 | * Use with {@link #fillIn} to allow the current action value to be |
| 8375 | * overwritten, even if it is already set. |
| 8376 | */ |
| 8377 | public static final int FILL_IN_ACTION = 1<<0; |
| 8378 | |
| 8379 | /** |
| 8380 | * Use with {@link #fillIn} to allow the current data or type value |
| 8381 | * overwritten, even if it is already set. |
| 8382 | */ |
| 8383 | public static final int FILL_IN_DATA = 1<<1; |
| 8384 | |
| 8385 | /** |
| 8386 | * Use with {@link #fillIn} to allow the current categories to be |
| 8387 | * overwritten, even if they are already set. |
| 8388 | */ |
| 8389 | public static final int FILL_IN_CATEGORIES = 1<<2; |
| 8390 | |
| 8391 | /** |
| 8392 | * Use with {@link #fillIn} to allow the current component value to be |
| 8393 | * overwritten, even if it is already set. |
| 8394 | */ |
| 8395 | public static final int FILL_IN_COMPONENT = 1<<3; |
| 8396 | |
| 8397 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8398 | * Use with {@link #fillIn} to allow the current package value to be |
| 8399 | * overwritten, even if it is already set. |
| 8400 | */ |
| 8401 | public static final int FILL_IN_PACKAGE = 1<<4; |
| 8402 | |
| 8403 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8404 | * Use with {@link #fillIn} to allow the current bounds rectangle to be |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8405 | * overwritten, even if it is already set. |
| 8406 | */ |
| 8407 | public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; |
| 8408 | |
| 8409 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8410 | * Use with {@link #fillIn} to allow the current selector to be |
| 8411 | * overwritten, even if it is already set. |
| 8412 | */ |
| 8413 | public static final int FILL_IN_SELECTOR = 1<<6; |
| 8414 | |
| 8415 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8416 | * Use with {@link #fillIn} to allow the current ClipData to be |
| 8417 | * overwritten, even if it is already set. |
| 8418 | */ |
| 8419 | public static final int FILL_IN_CLIP_DATA = 1<<7; |
| 8420 | |
| 8421 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8422 | * Copy the contents of <var>other</var> in to this object, but only |
| 8423 | * where fields are not defined by this object. For purposes of a field |
| 8424 | * being defined, the following pieces of data in the Intent are |
| 8425 | * considered to be separate fields: |
| 8426 | * |
| 8427 | * <ul> |
| 8428 | * <li> action, as set by {@link #setAction}. |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 8429 | * <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] | 8430 | * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. |
| 8431 | * <li> categories, as set by {@link #addCategory}. |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8432 | * <li> package, as set by {@link #setPackage}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8433 | * <li> component, as set by {@link #setComponent(ComponentName)} or |
| 8434 | * related methods. |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8435 | * <li> source bounds, as set by {@link #setSourceBounds}. |
| 8436 | * <li> selector, as set by {@link #setSelector(Intent)}. |
| 8437 | * <li> clip data, as set by {@link #setClipData(ClipData)}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8438 | * <li> each top-level name in the associated extras. |
| 8439 | * </ul> |
| 8440 | * |
| 8441 | * <p>In addition, you can use the {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8442 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8443 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
| 8444 | * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override |
| 8445 | * the restriction where the corresponding field will not be replaced if |
| 8446 | * it is already set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8447 | * |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8448 | * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} |
| 8449 | * is explicitly specified. The selector will only be copied if |
| 8450 | * {@link #FILL_IN_SELECTOR} is explicitly specified. |
Brett Chabot | 3e39175 | 2009-07-21 16:07:23 -0700 | [diff] [blame] | 8451 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8452 | * <p>For example, consider Intent A with {data="foo", categories="bar"} |
| 8453 | * and Intent B with {action="gotit", data-type="some/thing", |
| 8454 | * categories="one","two"}. |
| 8455 | * |
| 8456 | * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now |
| 8457 | * containing: {action="gotit", data-type="some/thing", |
| 8458 | * categories="bar"}. |
| 8459 | * |
| 8460 | * @param other Another Intent whose values are to be used to fill in |
| 8461 | * the current one. |
| 8462 | * @param flags Options to control which fields can be filled in. |
| 8463 | * |
| 8464 | * @return Returns a bit mask of {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8465 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8466 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 8467 | * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8468 | * changed. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8469 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 8470 | @FillInFlags |
| 8471 | public int fillIn(Intent other, @FillInFlags int flags) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8472 | int changes = 0; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8473 | boolean mayHaveCopiedUris = false; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8474 | if (other.mAction != null |
| 8475 | && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8476 | mAction = other.mAction; |
| 8477 | changes |= FILL_IN_ACTION; |
| 8478 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8479 | if ((other.mData != null || other.mType != null) |
| 8480 | && ((mData == null && mType == null) |
| 8481 | || (flags&FILL_IN_DATA) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8482 | mData = other.mData; |
| 8483 | mType = other.mType; |
| 8484 | changes |= FILL_IN_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8485 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8486 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8487 | if (other.mCategories != null |
| 8488 | && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8489 | if (other.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8490 | mCategories = new ArraySet<String>(other.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8491 | } |
| 8492 | changes |= FILL_IN_CATEGORIES; |
| 8493 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8494 | if (other.mPackage != null |
| 8495 | && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8496 | // Only do this if mSelector is not set. |
| 8497 | if (mSelector == null) { |
| 8498 | mPackage = other.mPackage; |
| 8499 | changes |= FILL_IN_PACKAGE; |
| 8500 | } |
| 8501 | } |
| 8502 | // Selector is special: it can only be set if explicitly allowed, |
| 8503 | // for the same reason as the component name. |
| 8504 | if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { |
| 8505 | if (mPackage == null) { |
| 8506 | mSelector = new Intent(other.mSelector); |
| 8507 | mPackage = null; |
| 8508 | changes |= FILL_IN_SELECTOR; |
| 8509 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8510 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8511 | if (other.mClipData != null |
| 8512 | && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { |
| 8513 | mClipData = other.mClipData; |
| 8514 | changes |= FILL_IN_CLIP_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8515 | mayHaveCopiedUris = true; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8516 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8517 | // Component is special: it can -only- be set if explicitly allowed, |
| 8518 | // since otherwise the sender could force the intent somewhere the |
| 8519 | // originator didn't intend. |
| 8520 | if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8521 | mComponent = other.mComponent; |
| 8522 | changes |= FILL_IN_COMPONENT; |
| 8523 | } |
| 8524 | mFlags |= other.mFlags; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8525 | if (other.mSourceBounds != null |
| 8526 | && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { |
| 8527 | mSourceBounds = new Rect(other.mSourceBounds); |
| 8528 | changes |= FILL_IN_SOURCE_BOUNDS; |
| 8529 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8530 | if (mExtras == null) { |
| 8531 | if (other.mExtras != null) { |
| 8532 | mExtras = new Bundle(other.mExtras); |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8533 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8534 | } |
| 8535 | } else if (other.mExtras != null) { |
| 8536 | try { |
| 8537 | Bundle newb = new Bundle(other.mExtras); |
| 8538 | newb.putAll(mExtras); |
| 8539 | mExtras = newb; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8540 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8541 | } catch (RuntimeException e) { |
| 8542 | // Modifying the extras can cause us to unparcel the contents |
| 8543 | // of the bundle, and if we do this in the system process that |
| 8544 | // may fail. We really should handle this (i.e., the Bundle |
| 8545 | // impl shouldn't be on top of a plain map), but for now just |
| 8546 | // ignore it and keep the original contents. :( |
| 8547 | Log.w("Intent", "Failure filling in extras", e); |
| 8548 | } |
| 8549 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8550 | if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT |
| 8551 | && other.mContentUserHint != UserHandle.USER_CURRENT) { |
| 8552 | mContentUserHint = other.mContentUserHint; |
| 8553 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8554 | return changes; |
| 8555 | } |
| 8556 | |
| 8557 | /** |
| 8558 | * Wrapper class holding an Intent and implementing comparisons on it for |
| 8559 | * the purpose of filtering. The class implements its |
| 8560 | * {@link #equals equals()} and {@link #hashCode hashCode()} methods as |
| 8561 | * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and |
| 8562 | * {@link android.content.Intent#filterHashCode()} filterHashCode()} |
| 8563 | * on the wrapped Intent. |
| 8564 | */ |
| 8565 | public static final class FilterComparison { |
| 8566 | private final Intent mIntent; |
| 8567 | private final int mHashCode; |
| 8568 | |
| 8569 | public FilterComparison(Intent intent) { |
| 8570 | mIntent = intent; |
| 8571 | mHashCode = intent.filterHashCode(); |
| 8572 | } |
| 8573 | |
| 8574 | /** |
| 8575 | * Return the Intent that this FilterComparison represents. |
| 8576 | * @return Returns the Intent held by the FilterComparison. Do |
| 8577 | * not modify! |
| 8578 | */ |
| 8579 | public Intent getIntent() { |
| 8580 | return mIntent; |
| 8581 | } |
| 8582 | |
| 8583 | @Override |
| 8584 | public boolean equals(Object obj) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 8585 | if (obj instanceof FilterComparison) { |
| 8586 | Intent other = ((FilterComparison)obj).mIntent; |
| 8587 | return mIntent.filterEquals(other); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8588 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 8589 | return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8590 | } |
| 8591 | |
| 8592 | @Override |
| 8593 | public int hashCode() { |
| 8594 | return mHashCode; |
| 8595 | } |
| 8596 | } |
| 8597 | |
| 8598 | /** |
| 8599 | * Determine if two intents are the same for the purposes of intent |
| 8600 | * resolution (filtering). That is, if their action, data, type, |
| 8601 | * class, and categories are the same. This does <em>not</em> compare |
| 8602 | * any extra data included in the intents. |
| 8603 | * |
| 8604 | * @param other The other Intent to compare against. |
| 8605 | * |
| 8606 | * @return Returns true if action, data, type, class, and categories |
| 8607 | * are the same. |
| 8608 | */ |
| 8609 | public boolean filterEquals(Intent other) { |
| 8610 | if (other == null) { |
| 8611 | return false; |
| 8612 | } |
Christopher Tate | 63d9ae1 | 2014-06-19 19:07:26 -0700 | [diff] [blame] | 8613 | if (!Objects.equals(this.mAction, other.mAction)) return false; |
| 8614 | if (!Objects.equals(this.mData, other.mData)) return false; |
| 8615 | if (!Objects.equals(this.mType, other.mType)) return false; |
| 8616 | if (!Objects.equals(this.mPackage, other.mPackage)) return false; |
| 8617 | if (!Objects.equals(this.mComponent, other.mComponent)) return false; |
| 8618 | if (!Objects.equals(this.mCategories, other.mCategories)) return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8619 | |
| 8620 | return true; |
| 8621 | } |
| 8622 | |
| 8623 | /** |
| 8624 | * Generate hash code that matches semantics of filterEquals(). |
| 8625 | * |
| 8626 | * @return Returns the hash value of the action, data, type, class, and |
| 8627 | * categories. |
| 8628 | * |
| 8629 | * @see #filterEquals |
| 8630 | */ |
| 8631 | public int filterHashCode() { |
| 8632 | int code = 0; |
| 8633 | if (mAction != null) { |
| 8634 | code += mAction.hashCode(); |
| 8635 | } |
| 8636 | if (mData != null) { |
| 8637 | code += mData.hashCode(); |
| 8638 | } |
| 8639 | if (mType != null) { |
| 8640 | code += mType.hashCode(); |
| 8641 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8642 | if (mPackage != null) { |
| 8643 | code += mPackage.hashCode(); |
| 8644 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8645 | if (mComponent != null) { |
| 8646 | code += mComponent.hashCode(); |
| 8647 | } |
| 8648 | if (mCategories != null) { |
| 8649 | code += mCategories.hashCode(); |
| 8650 | } |
| 8651 | return code; |
| 8652 | } |
| 8653 | |
| 8654 | @Override |
| 8655 | public String toString() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8656 | StringBuilder b = new StringBuilder(128); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8657 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8658 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8659 | toShortString(b, true, true, true, false); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8660 | b.append(" }"); |
| 8661 | |
| 8662 | return b.toString(); |
| 8663 | } |
| 8664 | |
| 8665 | /** @hide */ |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8666 | public String toInsecureString() { |
| 8667 | StringBuilder b = new StringBuilder(128); |
| 8668 | |
| 8669 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8670 | toShortString(b, false, true, true, false); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8671 | b.append(" }"); |
| 8672 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8673 | return b.toString(); |
| 8674 | } |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 8675 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8676 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8677 | public String toInsecureStringWithClip() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8678 | StringBuilder b = new StringBuilder(128); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8679 | |
| 8680 | b.append("Intent { "); |
| 8681 | toShortString(b, false, true, true, true); |
| 8682 | b.append(" }"); |
| 8683 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8684 | return b.toString(); |
| 8685 | } |
| 8686 | |
| 8687 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8688 | public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { |
| 8689 | StringBuilder b = new StringBuilder(128); |
| 8690 | toShortString(b, secure, comp, extras, clip); |
| 8691 | return b.toString(); |
| 8692 | } |
| 8693 | |
| 8694 | /** @hide */ |
| 8695 | public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, |
| 8696 | boolean clip) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8697 | boolean first = true; |
| 8698 | if (mAction != null) { |
| 8699 | b.append("act=").append(mAction); |
| 8700 | first = false; |
| 8701 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8702 | if (mCategories != null) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8703 | if (!first) { |
| 8704 | b.append(' '); |
| 8705 | } |
| 8706 | first = false; |
| 8707 | b.append("cat=["); |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8708 | for (int i=0; i<mCategories.size(); i++) { |
| 8709 | if (i > 0) b.append(','); |
| 8710 | b.append(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8711 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8712 | b.append("]"); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8713 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8714 | if (mData != null) { |
| 8715 | if (!first) { |
| 8716 | b.append(' '); |
| 8717 | } |
| 8718 | first = false; |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 8719 | b.append("dat="); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 8720 | if (secure) { |
| 8721 | b.append(mData.toSafeString()); |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 8722 | } else { |
| 8723 | b.append(mData); |
| 8724 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8725 | } |
| 8726 | if (mType != null) { |
| 8727 | if (!first) { |
| 8728 | b.append(' '); |
| 8729 | } |
| 8730 | first = false; |
| 8731 | b.append("typ=").append(mType); |
| 8732 | } |
| 8733 | if (mFlags != 0) { |
| 8734 | if (!first) { |
| 8735 | b.append(' '); |
| 8736 | } |
| 8737 | first = false; |
| 8738 | b.append("flg=0x").append(Integer.toHexString(mFlags)); |
| 8739 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8740 | if (mPackage != null) { |
| 8741 | if (!first) { |
| 8742 | b.append(' '); |
| 8743 | } |
| 8744 | first = false; |
| 8745 | b.append("pkg=").append(mPackage); |
| 8746 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8747 | if (comp && mComponent != null) { |
| 8748 | if (!first) { |
| 8749 | b.append(' '); |
| 8750 | } |
| 8751 | first = false; |
| 8752 | b.append("cmp=").append(mComponent.flattenToShortString()); |
| 8753 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8754 | if (mSourceBounds != null) { |
| 8755 | if (!first) { |
| 8756 | b.append(' '); |
| 8757 | } |
| 8758 | first = false; |
| 8759 | b.append("bnds=").append(mSourceBounds.toShortString()); |
| 8760 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8761 | if (mClipData != null) { |
| 8762 | if (!first) { |
| 8763 | b.append(' '); |
| 8764 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 8765 | b.append("clip={"); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8766 | if (clip) { |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8767 | mClipData.toShortString(b); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8768 | } else { |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 8769 | if (mClipData.getDescription() != null) { |
| 8770 | first = !mClipData.getDescription().toShortStringTypesOnly(b); |
| 8771 | } else { |
| 8772 | first = true; |
| 8773 | } |
| 8774 | mClipData.toShortStringShortItems(b, first); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8775 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 8776 | first = false; |
| 8777 | b.append('}'); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8778 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8779 | if (extras && mExtras != null) { |
| 8780 | if (!first) { |
| 8781 | b.append(' '); |
| 8782 | } |
| 8783 | first = false; |
| 8784 | b.append("(has extras)"); |
| 8785 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8786 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
| 8787 | if (!first) { |
| 8788 | b.append(' '); |
| 8789 | } |
| 8790 | first = false; |
| 8791 | b.append("u=").append(mContentUserHint); |
| 8792 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8793 | if (mSelector != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8794 | b.append(" sel="); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 8795 | mSelector.toShortString(b, secure, comp, extras, clip); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8796 | b.append("}"); |
| 8797 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8798 | } |
| 8799 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8800 | /** |
| 8801 | * Call {@link #toUri} with 0 flags. |
| 8802 | * @deprecated Use {@link #toUri} instead. |
| 8803 | */ |
| 8804 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8805 | public String toURI() { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8806 | return toUri(0); |
| 8807 | } |
| 8808 | |
| 8809 | /** |
| 8810 | * Convert this Intent into a String holding a URI representation of it. |
| 8811 | * The returned URI string has been properly URI encoded, so it can be |
| 8812 | * used with {@link Uri#parse Uri.parse(String)}. The URI contains the |
| 8813 | * Intent's data as the base URI, with an additional fragment describing |
| 8814 | * the action, categories, type, flags, package, component, and extras. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8815 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8816 | * <p>You can convert the returned string back to an Intent with |
| 8817 | * {@link #getIntent}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8818 | * |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8819 | * @param flags Additional operating flags. Either 0, |
| 8820 | * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8821 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8822 | * @return Returns a URI encoding URI string describing the entire contents |
| 8823 | * of the Intent. |
| 8824 | */ |
| 8825 | public String toUri(int flags) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 8826 | StringBuilder uri = new StringBuilder(128); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8827 | if ((flags&URI_ANDROID_APP_SCHEME) != 0) { |
| 8828 | if (mPackage == null) { |
| 8829 | throw new IllegalArgumentException( |
| 8830 | "Intent must include an explicit package name to build an android-app: " |
| 8831 | + this); |
| 8832 | } |
| 8833 | uri.append("android-app://"); |
| 8834 | uri.append(mPackage); |
| 8835 | String scheme = null; |
| 8836 | if (mData != null) { |
| 8837 | scheme = mData.getScheme(); |
| 8838 | if (scheme != null) { |
| 8839 | uri.append('/'); |
| 8840 | uri.append(scheme); |
| 8841 | String authority = mData.getEncodedAuthority(); |
| 8842 | if (authority != null) { |
| 8843 | uri.append('/'); |
| 8844 | uri.append(authority); |
| 8845 | String path = mData.getEncodedPath(); |
| 8846 | if (path != null) { |
| 8847 | uri.append(path); |
| 8848 | } |
| 8849 | String queryParams = mData.getEncodedQuery(); |
| 8850 | if (queryParams != null) { |
| 8851 | uri.append('?'); |
| 8852 | uri.append(queryParams); |
| 8853 | } |
| 8854 | String fragment = mData.getEncodedFragment(); |
| 8855 | if (fragment != null) { |
| 8856 | uri.append('#'); |
| 8857 | uri.append(fragment); |
| 8858 | } |
| 8859 | } |
| 8860 | } |
| 8861 | } |
| 8862 | toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, |
| 8863 | mPackage, flags); |
| 8864 | return uri.toString(); |
| 8865 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8866 | String scheme = null; |
| 8867 | if (mData != null) { |
| 8868 | String data = mData.toString(); |
| 8869 | if ((flags&URI_INTENT_SCHEME) != 0) { |
| 8870 | final int N = data.length(); |
| 8871 | for (int i=0; i<N; i++) { |
| 8872 | char c = data.charAt(i); |
| 8873 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') |
| 8874 | || c == '.' || c == '-') { |
| 8875 | continue; |
| 8876 | } |
| 8877 | if (c == ':' && i > 0) { |
| 8878 | // Valid scheme. |
| 8879 | scheme = data.substring(0, i); |
| 8880 | uri.append("intent:"); |
| 8881 | data = data.substring(i+1); |
| 8882 | break; |
| 8883 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8884 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8885 | // No scheme. |
| 8886 | break; |
| 8887 | } |
| 8888 | } |
| 8889 | uri.append(data); |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 8890 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8891 | } else if ((flags&URI_INTENT_SCHEME) != 0) { |
| 8892 | uri.append("intent:"); |
| 8893 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8894 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8895 | toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8896 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8897 | return uri.toString(); |
| 8898 | } |
| 8899 | |
| 8900 | private void toUriFragment(StringBuilder uri, String scheme, String defAction, |
| 8901 | String defPackage, int flags) { |
| 8902 | StringBuilder frag = new StringBuilder(128); |
| 8903 | |
| 8904 | toUriInner(frag, scheme, defAction, defPackage, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8905 | if (mSelector != null) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 8906 | frag.append("SEL;"); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8907 | // Note that for now we are not going to try to handle the |
| 8908 | // data part; not clear how to represent this as a URI, and |
| 8909 | // not much utility in it. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8910 | mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, |
| 8911 | null, null, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8912 | } |
| 8913 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8914 | if (frag.length() > 0) { |
| 8915 | uri.append("#Intent;"); |
| 8916 | uri.append(frag); |
| 8917 | uri.append("end"); |
| 8918 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 8919 | } |
| 8920 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8921 | private void toUriInner(StringBuilder uri, String scheme, String defAction, |
| 8922 | String defPackage, int flags) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8923 | if (scheme != null) { |
| 8924 | uri.append("scheme=").append(scheme).append(';'); |
| 8925 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8926 | if (mAction != null && !mAction.equals(defAction)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8927 | uri.append("action=").append(Uri.encode(mAction)).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8928 | } |
| 8929 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8930 | for (int i=0; i<mCategories.size(); i++) { |
| 8931 | 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] | 8932 | } |
| 8933 | } |
| 8934 | if (mType != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8935 | uri.append("type=").append(Uri.encode(mType, "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8936 | } |
| 8937 | if (mFlags != 0) { |
| 8938 | uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); |
| 8939 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 8940 | if (mPackage != null && !mPackage.equals(defPackage)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8941 | uri.append("package=").append(Uri.encode(mPackage)).append(';'); |
| 8942 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8943 | if (mComponent != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8944 | uri.append("component=").append(Uri.encode( |
| 8945 | mComponent.flattenToShortString(), "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8946 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8947 | if (mSourceBounds != null) { |
| 8948 | uri.append("sourceBounds=") |
| 8949 | .append(Uri.encode(mSourceBounds.flattenToString())) |
| 8950 | .append(';'); |
| 8951 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8952 | if (mExtras != null) { |
| 8953 | for (String key : mExtras.keySet()) { |
| 8954 | final Object value = mExtras.get(key); |
| 8955 | char entryType = |
| 8956 | value instanceof String ? 'S' : |
| 8957 | value instanceof Boolean ? 'B' : |
| 8958 | value instanceof Byte ? 'b' : |
| 8959 | value instanceof Character ? 'c' : |
| 8960 | value instanceof Double ? 'd' : |
| 8961 | value instanceof Float ? 'f' : |
| 8962 | value instanceof Integer ? 'i' : |
| 8963 | value instanceof Long ? 'l' : |
| 8964 | value instanceof Short ? 's' : |
| 8965 | '\0'; |
| 8966 | |
| 8967 | if (entryType != '\0') { |
| 8968 | uri.append(entryType); |
| 8969 | uri.append('.'); |
| 8970 | uri.append(Uri.encode(key)); |
| 8971 | uri.append('='); |
| 8972 | uri.append(Uri.encode(value.toString())); |
| 8973 | uri.append(';'); |
| 8974 | } |
| 8975 | } |
| 8976 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8977 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 8978 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8979 | public int describeContents() { |
| 8980 | return (mExtras != null) ? mExtras.describeContents() : 0; |
| 8981 | } |
| 8982 | |
| 8983 | public void writeToParcel(Parcel out, int flags) { |
| 8984 | out.writeString(mAction); |
| 8985 | Uri.writeToParcel(out, mData); |
| 8986 | out.writeString(mType); |
| 8987 | out.writeInt(mFlags); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 8988 | out.writeString(mPackage); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8989 | ComponentName.writeToParcel(mComponent, out); |
| 8990 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 8991 | if (mSourceBounds != null) { |
| 8992 | out.writeInt(1); |
| 8993 | mSourceBounds.writeToParcel(out, flags); |
| 8994 | } else { |
| 8995 | out.writeInt(0); |
| 8996 | } |
| 8997 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8998 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 8999 | final int N = mCategories.size(); |
| 9000 | out.writeInt(N); |
| 9001 | for (int i=0; i<N; i++) { |
| 9002 | out.writeString(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9003 | } |
| 9004 | } else { |
| 9005 | out.writeInt(0); |
| 9006 | } |
| 9007 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9008 | if (mSelector != null) { |
| 9009 | out.writeInt(1); |
| 9010 | mSelector.writeToParcel(out, flags); |
| 9011 | } else { |
| 9012 | out.writeInt(0); |
| 9013 | } |
| 9014 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9015 | if (mClipData != null) { |
| 9016 | out.writeInt(1); |
| 9017 | mClipData.writeToParcel(out, flags); |
| 9018 | } else { |
| 9019 | out.writeInt(0); |
| 9020 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9021 | out.writeInt(mContentUserHint); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9022 | out.writeBundle(mExtras); |
| 9023 | } |
| 9024 | |
| 9025 | public static final Parcelable.Creator<Intent> CREATOR |
| 9026 | = new Parcelable.Creator<Intent>() { |
| 9027 | public Intent createFromParcel(Parcel in) { |
| 9028 | return new Intent(in); |
| 9029 | } |
| 9030 | public Intent[] newArray(int size) { |
| 9031 | return new Intent[size]; |
| 9032 | } |
| 9033 | }; |
| 9034 | |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 9035 | /** @hide */ |
| 9036 | protected Intent(Parcel in) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9037 | readFromParcel(in); |
| 9038 | } |
| 9039 | |
| 9040 | public void readFromParcel(Parcel in) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 9041 | setAction(in.readString()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9042 | mData = Uri.CREATOR.createFromParcel(in); |
| 9043 | mType = in.readString(); |
| 9044 | mFlags = in.readInt(); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 9045 | mPackage = in.readString(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9046 | mComponent = ComponentName.readFromParcel(in); |
| 9047 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 9048 | if (in.readInt() != 0) { |
| 9049 | mSourceBounds = Rect.CREATOR.createFromParcel(in); |
| 9050 | } |
| 9051 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9052 | int N = in.readInt(); |
| 9053 | if (N > 0) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 9054 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9055 | int i; |
| 9056 | for (i=0; i<N; i++) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 9057 | mCategories.add(in.readString().intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9058 | } |
| 9059 | } else { |
| 9060 | mCategories = null; |
| 9061 | } |
| 9062 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 9063 | if (in.readInt() != 0) { |
| 9064 | mSelector = new Intent(in); |
| 9065 | } |
| 9066 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 9067 | if (in.readInt() != 0) { |
| 9068 | mClipData = new ClipData(in); |
| 9069 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9070 | mContentUserHint = in.readInt(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9071 | mExtras = in.readBundle(); |
| 9072 | } |
| 9073 | |
| 9074 | /** |
| 9075 | * Parses the "intent" element (and its children) from XML and instantiates |
| 9076 | * an Intent object. The given XML parser should be located at the tag |
| 9077 | * where parsing should start (often named "intent"), from which the |
| 9078 | * basic action, data, type, and package and class name will be |
| 9079 | * retrieved. The function will then parse in to any child elements, |
| 9080 | * looking for <category android:name="xxx"> tags to add categories and |
| 9081 | * <extra android:name="xxx" android:value="yyy"> to attach extra data |
| 9082 | * to the intent. |
| 9083 | * |
| 9084 | * @param resources The Resources to use when inflating resources. |
| 9085 | * @param parser The XML parser pointing at an "intent" tag. |
| 9086 | * @param attrs The AttributeSet interface for retrieving extended |
| 9087 | * attribute data at the current <var>parser</var> location. |
| 9088 | * @return An Intent object matching the XML data. |
| 9089 | * @throws XmlPullParserException If there was an XML parsing error. |
| 9090 | * @throws IOException If there was an I/O error. |
| 9091 | */ |
| 9092 | public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs) |
| 9093 | throws XmlPullParserException, IOException { |
| 9094 | Intent intent = new Intent(); |
| 9095 | |
| 9096 | TypedArray sa = resources.obtainAttributes(attrs, |
| 9097 | com.android.internal.R.styleable.Intent); |
| 9098 | |
| 9099 | intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); |
| 9100 | |
| 9101 | String data = sa.getString(com.android.internal.R.styleable.Intent_data); |
| 9102 | String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); |
| 9103 | intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); |
| 9104 | |
| 9105 | String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); |
| 9106 | String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); |
| 9107 | if (packageName != null && className != null) { |
| 9108 | intent.setComponent(new ComponentName(packageName, className)); |
| 9109 | } |
| 9110 | |
| 9111 | sa.recycle(); |
| 9112 | |
| 9113 | int outerDepth = parser.getDepth(); |
| 9114 | int type; |
| 9115 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 9116 | && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { |
| 9117 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 9118 | continue; |
| 9119 | } |
| 9120 | |
| 9121 | String nodeName = parser.getName(); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9122 | if (nodeName.equals(TAG_CATEGORIES)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9123 | sa = resources.obtainAttributes(attrs, |
| 9124 | com.android.internal.R.styleable.IntentCategory); |
| 9125 | String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); |
| 9126 | sa.recycle(); |
| 9127 | |
| 9128 | if (cat != null) { |
| 9129 | intent.addCategory(cat); |
| 9130 | } |
| 9131 | XmlUtils.skipCurrentTag(parser); |
| 9132 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9133 | } else if (nodeName.equals(TAG_EXTRA)) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 9134 | if (intent.mExtras == null) { |
| 9135 | intent.mExtras = new Bundle(); |
| 9136 | } |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9137 | resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 9138 | XmlUtils.skipCurrentTag(parser); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9139 | |
| 9140 | } else { |
| 9141 | XmlUtils.skipCurrentTag(parser); |
| 9142 | } |
| 9143 | } |
| 9144 | |
| 9145 | return intent; |
| 9146 | } |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9147 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9148 | /** @hide */ |
| 9149 | public void saveToXml(XmlSerializer out) throws IOException { |
| 9150 | if (mAction != null) { |
| 9151 | out.attribute(null, ATTR_ACTION, mAction); |
| 9152 | } |
| 9153 | if (mData != null) { |
| 9154 | out.attribute(null, ATTR_DATA, mData.toString()); |
| 9155 | } |
| 9156 | if (mType != null) { |
| 9157 | out.attribute(null, ATTR_TYPE, mType); |
| 9158 | } |
| 9159 | if (mComponent != null) { |
| 9160 | out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); |
| 9161 | } |
| 9162 | out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); |
| 9163 | |
| 9164 | if (mCategories != null) { |
| 9165 | out.startTag(null, TAG_CATEGORIES); |
| 9166 | for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { |
| 9167 | out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); |
| 9168 | } |
Craig Mautner | 43e52ed | 2014-06-16 17:18:52 -0700 | [diff] [blame] | 9169 | out.endTag(null, TAG_CATEGORIES); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9170 | } |
| 9171 | } |
| 9172 | |
| 9173 | /** @hide */ |
| 9174 | public static Intent restoreFromXml(XmlPullParser in) throws IOException, |
| 9175 | XmlPullParserException { |
| 9176 | Intent intent = new Intent(); |
| 9177 | final int outerDepth = in.getDepth(); |
| 9178 | |
| 9179 | int attrCount = in.getAttributeCount(); |
| 9180 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 9181 | final String attrName = in.getAttributeName(attrNdx); |
| 9182 | final String attrValue = in.getAttributeValue(attrNdx); |
| 9183 | if (ATTR_ACTION.equals(attrName)) { |
| 9184 | intent.setAction(attrValue); |
| 9185 | } else if (ATTR_DATA.equals(attrName)) { |
| 9186 | intent.setData(Uri.parse(attrValue)); |
| 9187 | } else if (ATTR_TYPE.equals(attrName)) { |
| 9188 | intent.setType(attrValue); |
| 9189 | } else if (ATTR_COMPONENT.equals(attrName)) { |
| 9190 | intent.setComponent(ComponentName.unflattenFromString(attrValue)); |
| 9191 | } else if (ATTR_FLAGS.equals(attrName)) { |
Narayan Kamath | a09b4d2 | 2016-04-15 18:32:45 +0100 | [diff] [blame] | 9192 | intent.setFlags(Integer.parseInt(attrValue, 16)); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 9193 | } else { |
| 9194 | Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName); |
| 9195 | } |
| 9196 | } |
| 9197 | |
| 9198 | int event; |
| 9199 | String name; |
| 9200 | while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && |
| 9201 | (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { |
| 9202 | if (event == XmlPullParser.START_TAG) { |
| 9203 | name = in.getName(); |
| 9204 | if (TAG_CATEGORIES.equals(name)) { |
| 9205 | attrCount = in.getAttributeCount(); |
| 9206 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 9207 | intent.addCategory(in.getAttributeValue(attrNdx)); |
| 9208 | } |
| 9209 | } else { |
| 9210 | Log.w("Intent", "restoreFromXml: unknown name=" + name); |
| 9211 | XmlUtils.skipCurrentTag(in); |
| 9212 | } |
| 9213 | } |
| 9214 | } |
| 9215 | |
| 9216 | return intent; |
| 9217 | } |
| 9218 | |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9219 | /** |
| 9220 | * Normalize a MIME data type. |
| 9221 | * |
| 9222 | * <p>A normalized MIME type has white-space trimmed, |
| 9223 | * content-type parameters removed, and is lower-case. |
| 9224 | * This aligns the type with Android best practices for |
| 9225 | * intent filtering. |
| 9226 | * |
| 9227 | * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". |
| 9228 | * "text/x-vCard" becomes "text/x-vcard". |
| 9229 | * |
| 9230 | * <p>All MIME types received from outside Android (such as user input, |
| 9231 | * or external sources like Bluetooth, NFC, or the Internet) should |
| 9232 | * be normalized before they are used to create an Intent. |
| 9233 | * |
| 9234 | * @param type MIME data type to normalize |
| 9235 | * @return normalized MIME data type, or null if the input was null |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 9236 | * @see #setType |
| 9237 | * @see #setTypeAndNormalize |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9238 | */ |
| 9239 | public static String normalizeMimeType(String type) { |
| 9240 | if (type == null) { |
| 9241 | return null; |
| 9242 | } |
| 9243 | |
Elliott Hughes | cb64d43 | 2013-08-02 10:00:44 -0700 | [diff] [blame] | 9244 | type = type.trim().toLowerCase(Locale.ROOT); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 9245 | |
| 9246 | final int semicolonIndex = type.indexOf(';'); |
| 9247 | if (semicolonIndex != -1) { |
| 9248 | type = type.substring(0, semicolonIndex); |
| 9249 | } |
| 9250 | return type; |
| 9251 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9252 | |
| 9253 | /** |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9254 | * Prepare this {@link Intent} to leave an app process. |
| 9255 | * |
| 9256 | * @hide |
| 9257 | */ |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9258 | public void prepareToLeaveProcess(Context context) { |
| 9259 | final boolean leavingPackage = (mComponent == null) |
| 9260 | || !Objects.equals(mComponent.getPackageName(), context.getPackageName()); |
| 9261 | prepareToLeaveProcess(leavingPackage); |
| 9262 | } |
| 9263 | |
| 9264 | /** |
| 9265 | * Prepare this {@link Intent} to leave an app process. |
| 9266 | * |
| 9267 | * @hide |
| 9268 | */ |
| 9269 | public void prepareToLeaveProcess(boolean leavingPackage) { |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9270 | setAllowFds(false); |
| 9271 | |
| 9272 | if (mSelector != null) { |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9273 | mSelector.prepareToLeaveProcess(leavingPackage); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9274 | } |
| 9275 | if (mClipData != null) { |
Jeff Sharkey | fb833f3 | 2016-12-01 14:59:59 -0700 | [diff] [blame] | 9276 | mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9277 | } |
| 9278 | |
Jeff Sharkey | a8b4278 | 2016-01-30 17:58:09 -0700 | [diff] [blame] | 9279 | if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() |
| 9280 | && leavingPackage) { |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9281 | switch (mAction) { |
| 9282 | case ACTION_MEDIA_REMOVED: |
| 9283 | case ACTION_MEDIA_UNMOUNTED: |
| 9284 | case ACTION_MEDIA_CHECKING: |
| 9285 | case ACTION_MEDIA_NOFS: |
| 9286 | case ACTION_MEDIA_MOUNTED: |
| 9287 | case ACTION_MEDIA_SHARED: |
| 9288 | case ACTION_MEDIA_UNSHARED: |
| 9289 | case ACTION_MEDIA_BAD_REMOVAL: |
| 9290 | case ACTION_MEDIA_UNMOUNTABLE: |
| 9291 | case ACTION_MEDIA_EJECT: |
| 9292 | case ACTION_MEDIA_SCANNER_STARTED: |
| 9293 | case ACTION_MEDIA_SCANNER_FINISHED: |
| 9294 | case ACTION_MEDIA_SCANNER_SCAN_FILE: |
Jeff Sharkey | 37355a9 | 2016-02-05 16:19:10 -0700 | [diff] [blame] | 9295 | case ACTION_PACKAGE_NEEDS_VERIFICATION: |
| 9296 | case ACTION_PACKAGE_VERIFIED: |
Jeff Sharkey | 344744b | 2016-01-28 19:03:30 -0700 | [diff] [blame] | 9297 | // Ignore legacy actions |
| 9298 | break; |
| 9299 | default: |
| 9300 | mData.checkFileUriExposed("Intent.getData()"); |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9301 | } |
| 9302 | } |
Jeff Sharkey | fb833f3 | 2016-12-01 14:59:59 -0700 | [diff] [blame] | 9303 | |
| 9304 | if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() |
| 9305 | && leavingPackage) { |
| 9306 | switch (mAction) { |
| 9307 | case ACTION_PROVIDER_CHANGED: |
| 9308 | // Ignore actions that don't need to grant |
| 9309 | break; |
| 9310 | default: |
| 9311 | mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); |
| 9312 | } |
| 9313 | } |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 9314 | } |
| 9315 | |
| 9316 | /** |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9317 | * @hide |
| 9318 | */ |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9319 | public void prepareToEnterProcess() { |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 9320 | // We just entered destination process, so we should be able to read all |
| 9321 | // parcelables inside. |
| 9322 | setDefusable(true); |
| 9323 | |
| 9324 | if (mSelector != null) { |
| 9325 | mSelector.prepareToEnterProcess(); |
| 9326 | } |
| 9327 | if (mClipData != null) { |
| 9328 | mClipData.prepareToEnterProcess(); |
| 9329 | } |
| 9330 | |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9331 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
Nicolas Prevot | c4fc00a | 2014-10-31 12:01:32 +0000 | [diff] [blame] | 9332 | if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { |
| 9333 | fixUris(mContentUserHint); |
| 9334 | mContentUserHint = UserHandle.USER_CURRENT; |
| 9335 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9336 | } |
| 9337 | } |
| 9338 | |
| 9339 | /** |
| 9340 | * @hide |
| 9341 | */ |
| 9342 | public void fixUris(int contentUserHint) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9343 | Uri data = getData(); |
| 9344 | if (data != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9345 | mData = maybeAddUserId(data, contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9346 | } |
| 9347 | if (mClipData != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9348 | mClipData.fixUris(contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9349 | } |
| 9350 | String action = getAction(); |
| 9351 | if (ACTION_SEND.equals(action)) { |
| 9352 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 9353 | if (stream != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9354 | putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9355 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9356 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9357 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 9358 | if (streams != null) { |
| 9359 | ArrayList<Uri> newStreams = new ArrayList<Uri>(); |
| 9360 | for (int i = 0; i < streams.size(); i++) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9361 | newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9362 | } |
| 9363 | putParcelableArrayListExtra(EXTRA_STREAM, newStreams); |
| 9364 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9365 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 9366 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 9367 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 9368 | final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 9369 | if (output != null) { |
| 9370 | putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); |
| 9371 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9372 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9373 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 9374 | |
| 9375 | /** |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9376 | * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9377 | * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested |
| 9378 | * intents in {@link #ACTION_CHOOSER}. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9379 | * |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9380 | * @return Whether any contents were migrated. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9381 | * @hide |
| 9382 | */ |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9383 | public boolean migrateExtraStreamToClipData() { |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9384 | // Refuse to touch if extras already parcelled |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9385 | if (mExtras != null && mExtras.isParcelled()) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9386 | |
| 9387 | // Bail when someone already gave us ClipData |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9388 | if (getClipData() != null) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9389 | |
| 9390 | final String action = getAction(); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9391 | if (ACTION_CHOOSER.equals(action)) { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9392 | // Inspect contained intents to see if we need to migrate extras. We |
| 9393 | // don't promote ClipData to the parent, since ChooserActivity will |
| 9394 | // already start the picked item as the caller, and we can't combine |
| 9395 | // the flags in a safe way. |
| 9396 | |
| 9397 | boolean migrated = false; |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 9398 | try { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9399 | final Intent intent = getParcelableExtra(EXTRA_INTENT); |
| 9400 | if (intent != null) { |
| 9401 | migrated |= intent.migrateExtraStreamToClipData(); |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 9402 | } |
| 9403 | } catch (ClassCastException e) { |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9404 | } |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 9405 | try { |
| 9406 | final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); |
| 9407 | if (intents != null) { |
| 9408 | for (int i = 0; i < intents.length; i++) { |
| 9409 | final Intent intent = (Intent) intents[i]; |
| 9410 | if (intent != null) { |
| 9411 | migrated |= intent.migrateExtraStreamToClipData(); |
| 9412 | } |
| 9413 | } |
| 9414 | } |
| 9415 | } catch (ClassCastException e) { |
| 9416 | } |
| 9417 | return migrated; |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9418 | |
| 9419 | } else if (ACTION_SEND.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9420 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9421 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 9422 | final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); |
| 9423 | final String htmlText = getStringExtra(EXTRA_HTML_TEXT); |
| 9424 | if (stream != null || text != null || htmlText != null) { |
| 9425 | final ClipData clipData = new ClipData( |
| 9426 | null, new String[] { getType() }, |
| 9427 | new ClipData.Item(text, htmlText, null, stream)); |
| 9428 | setClipData(clipData); |
| 9429 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9430 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9431 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9432 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9433 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9434 | |
| 9435 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9436 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9437 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 9438 | final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); |
| 9439 | final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); |
| 9440 | int num = -1; |
| 9441 | if (streams != null) { |
| 9442 | num = streams.size(); |
| 9443 | } |
| 9444 | if (texts != null) { |
| 9445 | if (num >= 0 && num != texts.size()) { |
| 9446 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9447 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9448 | } |
| 9449 | num = texts.size(); |
| 9450 | } |
| 9451 | if (htmlTexts != null) { |
| 9452 | if (num >= 0 && num != htmlTexts.size()) { |
| 9453 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9454 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9455 | } |
| 9456 | num = htmlTexts.size(); |
| 9457 | } |
| 9458 | if (num > 0) { |
| 9459 | final ClipData clipData = new ClipData( |
| 9460 | null, new String[] { getType() }, |
| 9461 | makeClipItem(streams, texts, htmlTexts, 0)); |
| 9462 | |
| 9463 | for (int i = 1; i < num; i++) { |
| 9464 | clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); |
| 9465 | } |
| 9466 | |
| 9467 | setClipData(clipData); |
| 9468 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9469 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 9470 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9471 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 9472 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 9473 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 9474 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 9475 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 9476 | final Uri output; |
| 9477 | try { |
| 9478 | output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 9479 | } catch (ClassCastException e) { |
| 9480 | return false; |
| 9481 | } |
| 9482 | if (output != null) { |
| 9483 | setClipData(ClipData.newRawUri("", output)); |
| 9484 | addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); |
| 9485 | return true; |
| 9486 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9487 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 9488 | |
| 9489 | return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 9490 | } |
Dianne Hackborn | ac4243f | 2012-04-13 17:32:18 -0700 | [diff] [blame] | 9491 | |
| 9492 | private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, |
| 9493 | ArrayList<String> htmlTexts, int which) { |
| 9494 | Uri uri = streams != null ? streams.get(which) : null; |
| 9495 | CharSequence text = texts != null ? texts.get(which) : null; |
| 9496 | String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; |
| 9497 | return new ClipData.Item(text, htmlText, null, uri); |
| 9498 | } |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 9499 | |
| 9500 | /** @hide */ |
| 9501 | public boolean isDocument() { |
| 9502 | return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; |
| 9503 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9504 | } |