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 | |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 19 | import android.content.pm.ApplicationInfo; |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 20 | import android.os.ResultReceiver; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 21 | import android.provider.MediaStore; |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 22 | import android.util.ArraySet; |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 23 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 24 | import org.xmlpull.v1.XmlPullParser; |
| 25 | import org.xmlpull.v1.XmlPullParserException; |
| 26 | |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 27 | import android.annotation.AnyRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 28 | import android.annotation.IntDef; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 29 | import android.annotation.SdkConstant; |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 30 | import android.annotation.SystemApi; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 31 | import android.annotation.SdkConstant.SdkConstantType; |
| 32 | import android.content.pm.ActivityInfo; |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 33 | |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 34 | import static android.content.ContentProvider.maybeAddUserId; |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 35 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 36 | import android.content.pm.PackageManager; |
| 37 | import android.content.pm.ResolveInfo; |
| 38 | import android.content.res.Resources; |
| 39 | import android.content.res.TypedArray; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 40 | import android.graphics.Rect; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 41 | import android.net.Uri; |
| 42 | import android.os.Bundle; |
| 43 | import android.os.IBinder; |
| 44 | import android.os.Parcel; |
| 45 | import android.os.Parcelable; |
Nicolas Prevot | c4fc00a | 2014-10-31 12:01:32 +0000 | [diff] [blame] | 46 | import android.os.Process; |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 47 | import android.os.StrictMode; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 48 | import android.os.UserHandle; |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 49 | import android.provider.DocumentsContract; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 50 | import android.provider.DocumentsProvider; |
| 51 | import android.provider.OpenableColumns; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 52 | import android.util.AttributeSet; |
| 53 | import android.util.Log; |
Dianne Hackborn | 2269d157 | 2010-02-24 19:54:22 -0800 | [diff] [blame] | 54 | |
| 55 | import com.android.internal.util.XmlUtils; |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 56 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 57 | import org.xmlpull.v1.XmlSerializer; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 58 | |
| 59 | import java.io.IOException; |
| 60 | import java.io.Serializable; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 61 | import java.lang.annotation.Retention; |
| 62 | import java.lang.annotation.RetentionPolicy; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 63 | import java.net.URISyntaxException; |
| 64 | import java.util.ArrayList; |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 65 | import java.util.List; |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 66 | import java.util.Locale; |
Christopher Tate | 63d9ae1 | 2014-06-19 19:07:26 -0700 | [diff] [blame] | 67 | import java.util.Objects; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 68 | import java.util.Set; |
| 69 | |
| 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 |
| 118 | * VIEW action does what what is considered the most reasonable thing for |
| 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 |
| 131 | * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> } |
| 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. |
| 189 | * These strings use java style scoping, to ensure they are unique -- for |
| 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}" /> |
| 342 | * <data mimeType:name="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> |
| 361 | * <p>This filter describes the ability return to the caller a note selected by |
| 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} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 541 | * <li> {@link #ACTION_UID_REMOVED} |
| 542 | * <li> {@link #ACTION_BATTERY_CHANGED} |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 543 | * <li> {@link #ACTION_POWER_CONNECTED} |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 544 | * <li> {@link #ACTION_POWER_DISCONNECTED} |
| 545 | * <li> {@link #ACTION_SHUTDOWN} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 546 | * </ul> |
| 547 | * |
| 548 | * <h3>Standard Categories</h3> |
| 549 | * |
| 550 | * <p>These are the current standard categories that can be used to further |
| 551 | * clarify an Intent via {@link #addCategory}. |
| 552 | * |
| 553 | * <ul> |
| 554 | * <li> {@link #CATEGORY_DEFAULT} |
| 555 | * <li> {@link #CATEGORY_BROWSABLE} |
| 556 | * <li> {@link #CATEGORY_TAB} |
| 557 | * <li> {@link #CATEGORY_ALTERNATIVE} |
| 558 | * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} |
| 559 | * <li> {@link #CATEGORY_LAUNCHER} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 560 | * <li> {@link #CATEGORY_INFO} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 561 | * <li> {@link #CATEGORY_HOME} |
| 562 | * <li> {@link #CATEGORY_PREFERENCE} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 563 | * <li> {@link #CATEGORY_TEST} |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 564 | * <li> {@link #CATEGORY_CAR_DOCK} |
| 565 | * <li> {@link #CATEGORY_DESK_DOCK} |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 566 | * <li> {@link #CATEGORY_LE_DESK_DOCK} |
| 567 | * <li> {@link #CATEGORY_HE_DESK_DOCK} |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 568 | * <li> {@link #CATEGORY_CAR_MODE} |
Patrick Dubroy | 6dabe24 | 2010-08-30 10:43:47 -0700 | [diff] [blame] | 569 | * <li> {@link #CATEGORY_APP_MARKET} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 570 | * </ul> |
| 571 | * |
| 572 | * <h3>Standard Extra Data</h3> |
| 573 | * |
| 574 | * <p>These are the current standard fields that can be used as extra data via |
| 575 | * {@link #putExtra}. |
| 576 | * |
| 577 | * <ul> |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 578 | * <li> {@link #EXTRA_ALARM_COUNT} |
| 579 | * <li> {@link #EXTRA_BCC} |
| 580 | * <li> {@link #EXTRA_CC} |
| 581 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} |
| 582 | * <li> {@link #EXTRA_DATA_REMOVED} |
| 583 | * <li> {@link #EXTRA_DOCK_STATE} |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 584 | * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} |
| 585 | * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 586 | * <li> {@link #EXTRA_DOCK_STATE_CAR} |
| 587 | * <li> {@link #EXTRA_DOCK_STATE_DESK} |
| 588 | * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} |
| 589 | * <li> {@link #EXTRA_DONT_KILL_APP} |
| 590 | * <li> {@link #EXTRA_EMAIL} |
| 591 | * <li> {@link #EXTRA_INITIAL_INTENTS} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 592 | * <li> {@link #EXTRA_INTENT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 593 | * <li> {@link #EXTRA_KEY_EVENT} |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 594 | * <li> {@link #EXTRA_ORIGINATING_URI} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 595 | * <li> {@link #EXTRA_PHONE_NUMBER} |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 596 | * <li> {@link #EXTRA_REFERRER} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 597 | * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} |
| 598 | * <li> {@link #EXTRA_REPLACING} |
| 599 | * <li> {@link #EXTRA_SHORTCUT_ICON} |
| 600 | * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} |
| 601 | * <li> {@link #EXTRA_SHORTCUT_INTENT} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 602 | * <li> {@link #EXTRA_STREAM} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 603 | * <li> {@link #EXTRA_SHORTCUT_NAME} |
| 604 | * <li> {@link #EXTRA_SUBJECT} |
| 605 | * <li> {@link #EXTRA_TEMPLATE} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 606 | * <li> {@link #EXTRA_TEXT} |
Trevor Johns | d59fb6e | 2009-11-20 12:54:57 -0800 | [diff] [blame] | 607 | * <li> {@link #EXTRA_TITLE} |
| 608 | * <li> {@link #EXTRA_UID} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 609 | * </ul> |
| 610 | * |
| 611 | * <h3>Flags</h3> |
| 612 | * |
| 613 | * <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] | 614 | * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list |
| 615 | * of all possible flags. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 616 | */ |
Dianne Hackborn | ee0511d | 2009-12-21 18:08:13 -0800 | [diff] [blame] | 617 | public class Intent implements Parcelable, Cloneable { |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 618 | private static final String ATTR_ACTION = "action"; |
| 619 | private static final String TAG_CATEGORIES = "categories"; |
| 620 | private static final String ATTR_CATEGORY = "category"; |
| 621 | private static final String TAG_EXTRA = "extra"; |
| 622 | private static final String ATTR_TYPE = "type"; |
| 623 | private static final String ATTR_COMPONENT = "component"; |
| 624 | private static final String ATTR_DATA = "data"; |
| 625 | private static final String ATTR_FLAGS = "flags"; |
| 626 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 627 | // --------------------------------------------------------------------- |
| 628 | // --------------------------------------------------------------------- |
| 629 | // Standard intent activity actions (see action variable). |
| 630 | |
| 631 | /** |
| 632 | * Activity Action: Start as a main entry point, does not expect to |
| 633 | * receive data. |
| 634 | * <p>Input: nothing |
| 635 | * <p>Output: nothing |
| 636 | */ |
| 637 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 638 | 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] | 639 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 640 | /** |
| 641 | * Activity Action: Display the data to the user. This is the most common |
| 642 | * action performed on data -- it is the generic action you can use on |
| 643 | * a piece of data to get the most reasonable thing to occur. For example, |
| 644 | * when used on a contacts entry it will view the entry; when used on a |
| 645 | * mailto: URI it will bring up a compose window filled with the information |
| 646 | * supplied by the URI; when used with a tel: URI it will invoke the |
| 647 | * dialer. |
| 648 | * <p>Input: {@link #getData} is URI from which to retrieve data. |
| 649 | * <p>Output: nothing. |
| 650 | */ |
| 651 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 652 | 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] | 653 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 654 | /** |
| 655 | * A synonym for {@link #ACTION_VIEW}, the "standard" action that is |
| 656 | * performed on a piece of data. |
| 657 | */ |
| 658 | public static final String ACTION_DEFAULT = ACTION_VIEW; |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 659 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 660 | /** |
| 661 | * Used to indicate that some piece of data should be attached to some other |
| 662 | * place. For example, image data could be attached to a contact. It is up |
| 663 | * to the recipient to decide where the data should be attached; the intent |
| 664 | * does not specify the ultimate destination. |
| 665 | * <p>Input: {@link #getData} is URI of data to be attached. |
| 666 | * <p>Output: nothing. |
| 667 | */ |
| 668 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 669 | 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] | 670 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 671 | /** |
| 672 | * Activity Action: Provide explicit editable access to the given data. |
| 673 | * <p>Input: {@link #getData} is URI of data to be edited. |
| 674 | * <p>Output: nothing. |
| 675 | */ |
| 676 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 677 | 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] | 678 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 679 | /** |
| 680 | * Activity Action: Pick an existing item, or insert a new item, and then edit it. |
| 681 | * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. |
| 682 | * The extras can contain type specific data to pass through to the editing/creating |
| 683 | * activity. |
| 684 | * <p>Output: The URI of the item that was picked. This must be a content: |
| 685 | * URI so that any receiver can access it. |
| 686 | */ |
| 687 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 688 | 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] | 689 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 690 | /** |
| 691 | * Activity Action: Pick an item from the data, returning what was selected. |
| 692 | * <p>Input: {@link #getData} is URI containing a directory of data |
| 693 | * (vnd.android.cursor.dir/*) from which to pick an item. |
| 694 | * <p>Output: The URI of the item that was picked. |
| 695 | */ |
| 696 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 697 | 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] | 698 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 699 | /** |
| 700 | * Activity Action: Creates a shortcut. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 701 | * <p>Input: Nothing.</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 702 | * <p>Output: An Intent representing the shortcut. The intent must contain three |
| 703 | * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), |
| 704 | * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 705 | * (value: ShortcutIconResource).</p> |
| 706 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 707 | * @see #EXTRA_SHORTCUT_INTENT |
| 708 | * @see #EXTRA_SHORTCUT_NAME |
| 709 | * @see #EXTRA_SHORTCUT_ICON |
| 710 | * @see #EXTRA_SHORTCUT_ICON_RESOURCE |
| 711 | * @see android.content.Intent.ShortcutIconResource |
| 712 | */ |
| 713 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 714 | public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; |
| 715 | |
| 716 | /** |
| 717 | * The name of the extra used to define the Intent of a shortcut. |
| 718 | * |
| 719 | * @see #ACTION_CREATE_SHORTCUT |
| 720 | */ |
| 721 | public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; |
| 722 | /** |
| 723 | * The name of the extra used to define the name of a shortcut. |
| 724 | * |
| 725 | * @see #ACTION_CREATE_SHORTCUT |
| 726 | */ |
| 727 | public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; |
| 728 | /** |
| 729 | * The name of the extra used to define the icon, as a Bitmap, of a shortcut. |
| 730 | * |
| 731 | * @see #ACTION_CREATE_SHORTCUT |
| 732 | */ |
| 733 | public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; |
| 734 | /** |
| 735 | * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. |
| 736 | * |
| 737 | * @see #ACTION_CREATE_SHORTCUT |
| 738 | * @see android.content.Intent.ShortcutIconResource |
| 739 | */ |
| 740 | public static final String EXTRA_SHORTCUT_ICON_RESOURCE = |
| 741 | "android.intent.extra.shortcut.ICON_RESOURCE"; |
| 742 | |
| 743 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 744 | * Represents a shortcut/live folder icon resource. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 745 | * |
| 746 | * @see Intent#ACTION_CREATE_SHORTCUT |
| 747 | * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 748 | * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER |
| 749 | * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 750 | */ |
| 751 | public static class ShortcutIconResource implements Parcelable { |
| 752 | /** |
| 753 | * The package name of the application containing the icon. |
| 754 | */ |
| 755 | public String packageName; |
| 756 | |
| 757 | /** |
| 758 | * The resource name of the icon, including package, name and type. |
| 759 | */ |
| 760 | public String resourceName; |
| 761 | |
| 762 | /** |
| 763 | * Creates a new ShortcutIconResource for the specified context and resource |
| 764 | * identifier. |
| 765 | * |
| 766 | * @param context The context of the application. |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 767 | * @param resourceId The resource identifier for the icon. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 768 | * @return A new ShortcutIconResource with the specified's context package name |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 769 | * and icon resource identifier.`` |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 770 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 771 | public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 772 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 773 | icon.packageName = context.getPackageName(); |
| 774 | icon.resourceName = context.getResources().getResourceName(resourceId); |
| 775 | return icon; |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * Used to read a ShortcutIconResource from a Parcel. |
| 780 | */ |
| 781 | public static final Parcelable.Creator<ShortcutIconResource> CREATOR = |
| 782 | new Parcelable.Creator<ShortcutIconResource>() { |
| 783 | |
| 784 | public ShortcutIconResource createFromParcel(Parcel source) { |
| 785 | ShortcutIconResource icon = new ShortcutIconResource(); |
| 786 | icon.packageName = source.readString(); |
| 787 | icon.resourceName = source.readString(); |
| 788 | return icon; |
| 789 | } |
| 790 | |
| 791 | public ShortcutIconResource[] newArray(int size) { |
| 792 | return new ShortcutIconResource[size]; |
| 793 | } |
| 794 | }; |
| 795 | |
| 796 | /** |
| 797 | * No special parcel contents. |
| 798 | */ |
| 799 | public int describeContents() { |
| 800 | return 0; |
| 801 | } |
| 802 | |
| 803 | public void writeToParcel(Parcel dest, int flags) { |
| 804 | dest.writeString(packageName); |
| 805 | dest.writeString(resourceName); |
| 806 | } |
| 807 | |
| 808 | @Override |
| 809 | public String toString() { |
| 810 | return resourceName; |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | /** |
| 815 | * Activity Action: Display an activity chooser, allowing the user to pick |
| 816 | * what they want to before proceeding. This can be used as an alternative |
| 817 | * to the standard activity picker that is displayed by the system when |
| 818 | * you try to start an activity with multiple possible matches, with these |
| 819 | * differences in behavior: |
| 820 | * <ul> |
| 821 | * <li>You can specify the title that will appear in the activity chooser. |
| 822 | * <li>The user does not have the option to make one of the matching |
| 823 | * activities a preferred activity, and all possible activities will |
| 824 | * always be shown even if one of them is currently marked as the |
| 825 | * preferred activity. |
| 826 | * </ul> |
| 827 | * <p> |
| 828 | * This action should be used when the user will naturally expect to |
| 829 | * select an activity in order to proceed. An example if when not to use |
| 830 | * it is when the user clicks on a "mailto:" link. They would naturally |
| 831 | * expect to go directly to their mail app, so startActivity() should be |
| 832 | * called directly: it will |
| 833 | * either launch the current preferred app, or put up a dialog allowing the |
| 834 | * user to pick an app to use and optionally marking that as preferred. |
| 835 | * <p> |
| 836 | * In contrast, if the user is selecting a menu item to send a picture |
| 837 | * they are viewing to someone else, there are many different things they |
| 838 | * may want to do at this point: send it through e-mail, upload it to a |
| 839 | * web service, etc. In this case the CHOOSER action should be used, to |
| 840 | * always present to the user a list of the things they can do, with a |
| 841 | * nice title given by the caller such as "Send this photo with:". |
| 842 | * <p> |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 843 | * If you need to grant URI permissions through a chooser, you must specify |
| 844 | * the permissions to be granted on the ACTION_CHOOSER Intent |
| 845 | * <em>in addition</em> to the EXTRA_INTENT inside. This means using |
| 846 | * {@link #setClipData} to specify the URIs to be granted as well as |
| 847 | * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 848 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. |
| 849 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 850 | * As a convenience, an Intent of this form can be created with the |
| 851 | * {@link #createChooser} function. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 852 | * <p> |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 853 | * 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] | 854 | * a {@link #EXTRA_INTENT} field containing the Intent being executed, |
| 855 | * and can optionally have a {@link #EXTRA_TITLE} field containing the |
| 856 | * title text to display in the chooser. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 857 | * <p> |
| 858 | * Output: Depends on the protocol of {@link #EXTRA_INTENT}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 859 | */ |
| 860 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 861 | public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; |
| 862 | |
| 863 | /** |
| 864 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 865 | * |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 866 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 867 | * target intent, also optionally supplying a title. If the target |
| 868 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 869 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 870 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 871 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
John Spurlock | 3390018 | 2014-01-02 11:04:18 -0500 | [diff] [blame] | 872 | * or a new ClipData built from {@link #getData()}. |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 873 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 874 | * @param target The Intent that the user will be selecting an activity |
| 875 | * to perform. |
| 876 | * @param title Optional title that will be displayed in the chooser. |
| 877 | * @return Return a new Intent object that you can hand to |
| 878 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 879 | * related methods. |
| 880 | */ |
| 881 | public static Intent createChooser(Intent target, CharSequence title) { |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 882 | return createChooser(target, title, null); |
| 883 | } |
| 884 | |
| 885 | /** |
| 886 | * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. |
| 887 | * |
| 888 | * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given |
| 889 | * target intent, also optionally supplying a title. If the target |
| 890 | * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or |
| 891 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be |
| 892 | * set in the returned chooser intent, with its ClipData set appropriately: |
| 893 | * either a direct reflection of {@link #getClipData()} if that is non-null, |
| 894 | * or a new ClipData built from {@link #getData()}.</p> |
| 895 | * |
| 896 | * <p>The caller may optionally supply an {@link IntentSender} to receive a callback |
| 897 | * when the user makes a choice. This can be useful if the calling application wants |
| 898 | * to remember the last chosen target and surface it as a more prominent or one-touch |
| 899 | * affordance elsewhere in the UI for next time.</p> |
| 900 | * |
| 901 | * @param target The Intent that the user will be selecting an activity |
| 902 | * to perform. |
| 903 | * @param title Optional title that will be displayed in the chooser. |
| 904 | * @param sender Optional IntentSender to be called when a choice is made. |
| 905 | * @return Return a new Intent object that you can hand to |
| 906 | * {@link Context#startActivity(Intent) Context.startActivity()} and |
| 907 | * related methods. |
| 908 | */ |
| 909 | 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] | 910 | Intent intent = new Intent(ACTION_CHOOSER); |
| 911 | intent.putExtra(EXTRA_INTENT, target); |
| 912 | if (title != null) { |
| 913 | intent.putExtra(EXTRA_TITLE, title); |
| 914 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 915 | |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 916 | if (sender != null) { |
| 917 | intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); |
| 918 | } |
| 919 | |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 920 | // Migrate any clip data and flags from target. |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 921 | int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION |
| 922 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 923 | | FLAG_GRANT_PREFIX_URI_PERMISSION); |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 924 | if (permFlags != 0) { |
| 925 | ClipData targetClipData = target.getClipData(); |
| 926 | if (targetClipData == null && target.getData() != null) { |
| 927 | ClipData.Item item = new ClipData.Item(target.getData()); |
| 928 | String[] mimeTypes; |
| 929 | if (target.getType() != null) { |
| 930 | mimeTypes = new String[] { target.getType() }; |
| 931 | } else { |
| 932 | mimeTypes = new String[] { }; |
| 933 | } |
| 934 | targetClipData = new ClipData(null, mimeTypes, item); |
| 935 | } |
| 936 | if (targetClipData != null) { |
| 937 | intent.setClipData(targetClipData); |
| 938 | intent.addFlags(permFlags); |
| 939 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 940 | } |
Dianne Hackborn | e302a16 | 2012-05-15 14:58:32 -0700 | [diff] [blame] | 941 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 942 | return intent; |
| 943 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 944 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 945 | /** |
| 946 | * Activity Action: Allow the user to select a particular kind of data and |
| 947 | * return it. This is different than {@link #ACTION_PICK} in that here we |
| 948 | * 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] | 949 | * 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] | 950 | * 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] | 951 | * 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] | 952 | * etc. |
| 953 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 954 | * 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] | 955 | * of data, such as a person contact, you set the MIME type to the kind of |
| 956 | * data you want and launch it with {@link Context#startActivity(Intent)}. |
| 957 | * The system will then launch the best application to select that kind |
| 958 | * of data for you. |
| 959 | * <p> |
| 960 | * You may also be interested in any of a set of types of content the user |
| 961 | * can pick. For example, an e-mail application that wants to allow the |
| 962 | * user to add an attachment to an e-mail message can use this action to |
| 963 | * bring up a list of all of the types of content the user can attach. |
| 964 | * <p> |
| 965 | * In this case, you should wrap the GET_CONTENT intent with a chooser |
| 966 | * (through {@link #createChooser}), which will give the proper interface |
| 967 | * for the user to pick how to send your data and allow you to specify |
| 968 | * a prompt indicating what they are doing. You will usually specify a |
| 969 | * broad MIME type (such as image/* or {@literal *}/*), resulting in a |
| 970 | * broad range of content types the user can select from. |
| 971 | * <p> |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 972 | * 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] | 973 | * only pick from data that can be represented as a stream. This is |
| 974 | * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. |
| 975 | * <p> |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 976 | * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 977 | * the launched content chooser only returns results representing data that |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 978 | * is locally available on the device. For example, if this extra is set |
| 979 | * to true then an image picker should not show any pictures that are available |
| 980 | * from a remote server but not already on the local device (thus requiring |
| 981 | * they be downloaded when opened). |
| 982 | * <p> |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 983 | * If the caller can handle multiple returned items (the user performing |
| 984 | * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 985 | * to indicate this. |
| 986 | * <p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 987 | * Input: {@link #getType} is the desired MIME type to retrieve. Note |
| 988 | * that no URI is supplied in the intent, as there are no constraints on |
| 989 | * where the returned data originally comes from. You may also include the |
| 990 | * {@link #CATEGORY_OPENABLE} if you can only accept data that can be |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 991 | * 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] | 992 | * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to |
| 993 | * allow the user to select multiple items. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 994 | * <p> |
| 995 | * Output: The URI of the item that was picked. This must be a content: |
| 996 | * URI so that any receiver can access it. |
| 997 | */ |
| 998 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 999 | public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; |
| 1000 | /** |
| 1001 | * Activity Action: Dial a number as specified by the data. This shows a |
| 1002 | * UI with the number being dialed, allowing the user to explicitly |
| 1003 | * initiate the call. |
| 1004 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1005 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1006 | * number. |
| 1007 | * <p>Output: nothing. |
| 1008 | */ |
| 1009 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1010 | public static final String ACTION_DIAL = "android.intent.action.DIAL"; |
| 1011 | /** |
| 1012 | * Activity Action: Perform a call to someone specified by the data. |
| 1013 | * <p>Input: If nothing, an empty dialer is started; else {@link #getData} |
| 1014 | * is URI of a phone number to be dialed or a tel: URI of an explicit phone |
| 1015 | * number. |
| 1016 | * <p>Output: nothing. |
| 1017 | * |
| 1018 | * <p>Note: there will be restrictions on which applications can initiate a |
| 1019 | * call; most applications should use the {@link #ACTION_DIAL}. |
| 1020 | * <p>Note: this Intent <strong>cannot</strong> be used to call emergency |
| 1021 | * numbers. Applications can <strong>dial</strong> emergency numbers using |
| 1022 | * {@link #ACTION_DIAL}, however. |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1023 | * |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 1024 | * <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] | 1025 | * 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] | 1026 | * permission which is not granted, then attempting to use this action will |
Svetoslav | 7008b51 | 2015-06-24 18:47:07 -0700 | [diff] [blame] | 1027 | * result in a {@link java.lang.SecurityException}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1028 | */ |
| 1029 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1030 | public static final String ACTION_CALL = "android.intent.action.CALL"; |
| 1031 | /** |
| 1032 | * Activity Action: Perform a call to an emergency number specified by the |
| 1033 | * data. |
| 1034 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1035 | * tel: URI of an explicit phone number. |
| 1036 | * <p>Output: nothing. |
| 1037 | * @hide |
| 1038 | */ |
| 1039 | public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; |
| 1040 | /** |
| 1041 | * Activity action: Perform a call to any number (emergency or not) |
| 1042 | * specified by the data. |
| 1043 | * <p>Input: {@link #getData} is URI of a phone number to be dialed or a |
| 1044 | * tel: URI of an explicit phone number. |
| 1045 | * <p>Output: nothing. |
| 1046 | * @hide |
| 1047 | */ |
| 1048 | public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; |
| 1049 | /** |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 1050 | * Activity action: Activate the current SIM card. If SIM cards do not require activation, |
| 1051 | * sending this intent is a no-op. |
| 1052 | * <p>Input: No data should be specified. get*Extra may have an optional |
| 1053 | * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to |
| 1054 | * send the activation result. |
| 1055 | * <p>Output: nothing. |
| 1056 | * @hide |
| 1057 | */ |
| 1058 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1059 | public static final String ACTION_SIM_ACTIVATION_REQUEST = |
| 1060 | "android.intent.action.SIM_ACTIVATION_REQUEST"; |
| 1061 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1062 | * Activity Action: Send a message to someone specified by the data. |
| 1063 | * <p>Input: {@link #getData} is URI describing the target. |
| 1064 | * <p>Output: nothing. |
| 1065 | */ |
| 1066 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1067 | public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; |
| 1068 | /** |
| 1069 | * Activity Action: Deliver some data to someone else. Who the data is |
| 1070 | * being delivered to is not specified; it is up to the receiver of this |
| 1071 | * action to ask the user where the data should be sent. |
| 1072 | * <p> |
| 1073 | * When launching a SEND intent, you should usually wrap it in a chooser |
| 1074 | * (through {@link #createChooser}), which will give the proper interface |
| 1075 | * for the user to pick how to send your data and allow you to specify |
| 1076 | * a prompt indicating what they are doing. |
| 1077 | * <p> |
| 1078 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1079 | * get*Extra can have either a {@link #EXTRA_TEXT} |
| 1080 | * or {@link #EXTRA_STREAM} field, containing the data to be sent. If |
| 1081 | * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it |
| 1082 | * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* |
| 1083 | * 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] | 1084 | * handle generic data streams). If using {@link #EXTRA_TEXT}, you can |
| 1085 | * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve |
| 1086 | * your text with HTML formatting. |
| 1087 | * <p> |
| 1088 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1089 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1090 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1091 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1092 | * using this approach, you still must supply the same data through the |
| 1093 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1094 | * for compatibility with old applications. If you don't set a ClipData, |
| 1095 | * 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] | 1096 | * <p> |
| 1097 | * Optional standard extras, which may be interpreted by some recipients as |
| 1098 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1099 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1100 | * <p> |
| 1101 | * Output: nothing. |
| 1102 | */ |
| 1103 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1104 | public static final String ACTION_SEND = "android.intent.action.SEND"; |
| 1105 | /** |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1106 | * Activity Action: Deliver multiple data to someone else. |
| 1107 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1108 | * Like {@link #ACTION_SEND}, except the data is multiple. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1109 | * <p> |
| 1110 | * Input: {@link #getType} is the MIME type of the data being sent. |
| 1111 | * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1112 | * #EXTRA_STREAM} field, containing the data to be sent. If using |
| 1113 | * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} |
| 1114 | * for clients to retrieve your text with HTML formatting. |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1115 | * <p> |
Chih-Chung Chang | 5962d27 | 2009-09-04 14:36:01 +0800 | [diff] [blame] | 1116 | * Multiple types are supported, and receivers should handle mixed types |
| 1117 | * whenever possible. The right way for the receiver to check them is to |
| 1118 | * use the content resolver on each URI. The intent sender should try to |
| 1119 | * put the most concrete mime type in the intent type, but it can fall |
| 1120 | * back to {@literal <type>/*} or {@literal *}/* as needed. |
| 1121 | * <p> |
| 1122 | * e.g. if you are sending image/jpg and image/jpg, the intent's type can |
| 1123 | * be image/jpg, but if you are sending image/jpg and image/png, then the |
| 1124 | * intent's type should be image/*. |
| 1125 | * <p> |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 1126 | * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data |
| 1127 | * being sent can be supplied through {@link #setClipData(ClipData)}. This |
| 1128 | * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing |
| 1129 | * content: URIs and other advanced features of {@link ClipData}. If |
| 1130 | * using this approach, you still must supply the same data through the |
| 1131 | * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below |
| 1132 | * for compatibility with old applications. If you don't set a ClipData, |
| 1133 | * it will be copied there for you when calling {@link Context#startActivity(Intent)}. |
| 1134 | * <p> |
Wu-cheng Li | 649f99e | 2009-06-17 14:29:57 +0800 | [diff] [blame] | 1135 | * Optional standard extras, which may be interpreted by some recipients as |
| 1136 | * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, |
| 1137 | * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. |
| 1138 | * <p> |
| 1139 | * Output: nothing. |
| 1140 | */ |
| 1141 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1142 | public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; |
| 1143 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1144 | * Activity Action: Handle an incoming phone call. |
| 1145 | * <p>Input: nothing. |
| 1146 | * <p>Output: nothing. |
| 1147 | */ |
| 1148 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1149 | public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; |
| 1150 | /** |
| 1151 | * Activity Action: Insert an empty item into the given container. |
| 1152 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1153 | * in which to place the data. |
| 1154 | * <p>Output: URI of the new data that was created. |
| 1155 | */ |
| 1156 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1157 | public static final String ACTION_INSERT = "android.intent.action.INSERT"; |
| 1158 | /** |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 1159 | * Activity Action: Create a new item in the given container, initializing it |
| 1160 | * from the current contents of the clipboard. |
| 1161 | * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) |
| 1162 | * in which to place the data. |
| 1163 | * <p>Output: URI of the new data that was created. |
| 1164 | */ |
| 1165 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1166 | public static final String ACTION_PASTE = "android.intent.action.PASTE"; |
| 1167 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1168 | * Activity Action: Delete the given data from its container. |
| 1169 | * <p>Input: {@link #getData} is URI of data to be deleted. |
| 1170 | * <p>Output: nothing. |
| 1171 | */ |
| 1172 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1173 | public static final String ACTION_DELETE = "android.intent.action.DELETE"; |
| 1174 | /** |
| 1175 | * Activity Action: Run the data, whatever that means. |
| 1176 | * <p>Input: ? (Note: this is currently specific to the test harness.) |
| 1177 | * <p>Output: nothing. |
| 1178 | */ |
| 1179 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1180 | public static final String ACTION_RUN = "android.intent.action.RUN"; |
| 1181 | /** |
| 1182 | * Activity Action: Perform a data synchronization. |
| 1183 | * <p>Input: ? |
| 1184 | * <p>Output: ? |
| 1185 | */ |
| 1186 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1187 | public static final String ACTION_SYNC = "android.intent.action.SYNC"; |
| 1188 | /** |
| 1189 | * Activity Action: Pick an activity given an intent, returning the class |
| 1190 | * selected. |
| 1191 | * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent |
| 1192 | * used with {@link PackageManager#queryIntentActivities} to determine the |
| 1193 | * set of activities from which to pick. |
| 1194 | * <p>Output: Class name of the activity that was selected. |
| 1195 | */ |
| 1196 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1197 | public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; |
| 1198 | /** |
| 1199 | * Activity Action: Perform a search. |
| 1200 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1201 | * is the text to search for. If empty, simply |
| 1202 | * enter your search results Activity with the search UI activated. |
| 1203 | * <p>Output: nothing. |
| 1204 | */ |
| 1205 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1206 | public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; |
| 1207 | /** |
Jim Miller | 7e4ad35 | 2009-03-25 18:16:41 -0700 | [diff] [blame] | 1208 | * Activity Action: Start the platform-defined tutorial |
| 1209 | * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} |
| 1210 | * is the text to search for. If empty, simply |
| 1211 | * enter your search results Activity with the search UI activated. |
| 1212 | * <p>Output: nothing. |
| 1213 | */ |
| 1214 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1215 | public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; |
| 1216 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1217 | * Activity Action: Perform a web search. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1218 | * <p> |
| 1219 | * Input: {@link android.app.SearchManager#QUERY |
| 1220 | * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is |
| 1221 | * a url starts with http or https, the site will be opened. If it is plain |
| 1222 | * text, Google search will be applied. |
| 1223 | * <p> |
| 1224 | * Output: nothing. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1225 | */ |
| 1226 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1227 | public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1228 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1229 | /** |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1230 | * Activity Action: Perform assist action. |
| 1231 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1232 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1233 | * additional optional contextual information about where the user was when they |
Dianne Hackborn | a3acdb3 | 2015-06-08 17:07:40 -0700 | [diff] [blame] | 1234 | * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer |
| 1235 | * information. |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1236 | * Output: nothing. |
| 1237 | */ |
| 1238 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1239 | public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1240 | |
| 1241 | /** |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1242 | * Activity Action: Perform voice assist action. |
| 1243 | * <p> |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1244 | * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide |
| 1245 | * additional optional contextual information about where the user was when they |
Adam Skory | dfc7fd7 | 2013-08-05 19:23:41 -0700 | [diff] [blame] | 1246 | * requested the voice assist. |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1247 | * Output: nothing. |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1248 | * @hide |
Bjorn Bringert | bc08686 | 2013-03-01 12:59:24 +0000 | [diff] [blame] | 1249 | */ |
| 1250 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1251 | public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; |
| 1252 | |
| 1253 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1254 | * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground |
| 1255 | * application package at the time the assist was invoked. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1256 | */ |
| 1257 | public static final String EXTRA_ASSIST_PACKAGE |
| 1258 | = "android.intent.extra.ASSIST_PACKAGE"; |
| 1259 | |
| 1260 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 1261 | * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground |
| 1262 | * application package at the time the assist was invoked. |
| 1263 | */ |
| 1264 | public static final String EXTRA_ASSIST_UID |
| 1265 | = "android.intent.extra.ASSIST_UID"; |
| 1266 | |
| 1267 | /** |
Adam Skory | 7140a25 | 2013-09-11 12:04:58 +0100 | [diff] [blame] | 1268 | * An optional field on {@link #ACTION_ASSIST} and containing additional contextual |
| 1269 | * information supplied by the current foreground app at the time of the assist request. |
| 1270 | * This is a {@link Bundle} of additional data. |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1271 | */ |
| 1272 | public static final String EXTRA_ASSIST_CONTEXT |
| 1273 | = "android.intent.extra.ASSIST_CONTEXT"; |
| 1274 | |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 1275 | /** |
Michael Wright | 8ab940a | 2014-09-01 11:01:27 -0700 | [diff] [blame] | 1276 | * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a |
| 1277 | * keyboard as the primary input device for assistance. |
| 1278 | */ |
| 1279 | public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = |
| 1280 | "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; |
| 1281 | |
| 1282 | /** |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 1283 | * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id |
| 1284 | * that was used to invoke the assist. |
| 1285 | */ |
| 1286 | public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = |
| 1287 | "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; |
| 1288 | |
| 1289 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1290 | * Activity Action: List all available applications |
| 1291 | * <p>Input: Nothing. |
| 1292 | * <p>Output: nothing. |
| 1293 | */ |
| 1294 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1295 | public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; |
| 1296 | /** |
| 1297 | * Activity Action: Show settings for choosing wallpaper |
| 1298 | * <p>Input: Nothing. |
| 1299 | * <p>Output: Nothing. |
| 1300 | */ |
| 1301 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1302 | public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; |
| 1303 | |
| 1304 | /** |
| 1305 | * Activity Action: Show activity for reporting a bug. |
| 1306 | * <p>Input: Nothing. |
| 1307 | * <p>Output: Nothing. |
| 1308 | */ |
| 1309 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1310 | public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; |
| 1311 | |
| 1312 | /** |
| 1313 | * Activity Action: Main entry point for factory tests. Only used when |
| 1314 | * the device is booting in factory test node. The implementing package |
| 1315 | * must be installed in the system image. |
| 1316 | * <p>Input: nothing |
| 1317 | * <p>Output: nothing |
| 1318 | */ |
| 1319 | public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; |
| 1320 | |
| 1321 | /** |
| 1322 | * Activity Action: The user pressed the "call" button to go to the dialer |
| 1323 | * or other appropriate UI for placing a call. |
| 1324 | * <p>Input: Nothing. |
| 1325 | * <p>Output: Nothing. |
| 1326 | */ |
| 1327 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1328 | public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; |
| 1329 | |
| 1330 | /** |
| 1331 | * Activity Action: Start Voice Command. |
| 1332 | * <p>Input: Nothing. |
| 1333 | * <p>Output: Nothing. |
| 1334 | */ |
| 1335 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1336 | 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] | 1337 | |
| 1338 | /** |
| 1339 | * Activity Action: Start action associated with long pressing on the |
| 1340 | * search key. |
| 1341 | * <p>Input: Nothing. |
| 1342 | * <p>Output: Nothing. |
| 1343 | */ |
| 1344 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1345 | 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] | 1346 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1347 | /** |
| 1348 | * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. |
| 1349 | * This intent is delivered to the package which installed the application, usually |
Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 1350 | * Google Play. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1351 | * <p>Input: No data is specified. The bug report is passed in using |
| 1352 | * an {@link #EXTRA_BUG_REPORT} field. |
| 1353 | * <p>Output: Nothing. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1354 | * |
| 1355 | * @see #EXTRA_BUG_REPORT |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 1356 | */ |
| 1357 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1358 | public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; |
Dianne Hackborn | 3d74bb4 | 2009-06-19 10:35:21 -0700 | [diff] [blame] | 1359 | |
| 1360 | /** |
| 1361 | * Activity Action: Show power usage information to the user. |
| 1362 | * <p>Input: Nothing. |
| 1363 | * <p>Output: Nothing. |
| 1364 | */ |
| 1365 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1366 | 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] | 1367 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1368 | /** |
| 1369 | * Activity Action: Setup wizard to launch after a platform update. This |
| 1370 | * activity should have a string meta-data field associated with it, |
| 1371 | * {@link #METADATA_SETUP_VERSION}, which defines the current version of |
| 1372 | * the platform for setup. The activity will be launched only if |
| 1373 | * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the |
| 1374 | * same value. |
| 1375 | * <p>Input: Nothing. |
| 1376 | * <p>Output: Nothing. |
| 1377 | * @hide |
| 1378 | */ |
| 1379 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1380 | public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1381 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1382 | /** |
Jeff Sharkey | 7f86827 | 2011-06-05 16:05:02 -0700 | [diff] [blame] | 1383 | * Activity Action: Show settings for managing network data usage of a |
| 1384 | * specific application. Applications should define an activity that offers |
| 1385 | * options to control data usage. |
| 1386 | */ |
| 1387 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1388 | public static final String ACTION_MANAGE_NETWORK_USAGE = |
| 1389 | "android.intent.action.MANAGE_NETWORK_USAGE"; |
| 1390 | |
| 1391 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1392 | * Activity Action: Launch application installer. |
| 1393 | * <p> |
| 1394 | * Input: The data must be a content: or file: URI at which the application |
Dianne Hackborn | eba784ff | 2012-09-19 12:42:37 -0700 | [diff] [blame] | 1395 | * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, |
| 1396 | * you can also use "package:<package-name>" to install an application for the |
| 1397 | * 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] | 1398 | * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, |
| 1399 | * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. |
| 1400 | * <p> |
| 1401 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1402 | * succeeded. |
Svet Ganov | 86877e4 | 2015-05-28 08:19:48 -0700 | [diff] [blame] | 1403 | * <p> |
| 1404 | * <strong>Note:</strong>If your app is targeting API level higher than 22 you |
| 1405 | * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} |
| 1406 | * in order to launch the application installer. |
| 1407 | * </p> |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1408 | * |
| 1409 | * @see #EXTRA_INSTALLER_PACKAGE_NAME |
| 1410 | * @see #EXTRA_NOT_UNKNOWN_SOURCE |
| 1411 | * @see #EXTRA_RETURN_RESULT |
| 1412 | */ |
| 1413 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1414 | public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; |
| 1415 | |
| 1416 | /** |
| 1417 | * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1418 | * package. Specifies the installer package name; this package will receive the |
| 1419 | * {@link #ACTION_APP_ERROR} intent. |
| 1420 | */ |
| 1421 | public static final String EXTRA_INSTALLER_PACKAGE_NAME |
| 1422 | = "android.intent.extra.INSTALLER_PACKAGE_NAME"; |
| 1423 | |
| 1424 | /** |
| 1425 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1426 | * package. Specifies that the application being installed should not be |
| 1427 | * treated as coming from an unknown source, but as coming from the app |
| 1428 | * invoking the Intent. For this to work you must start the installer with |
| 1429 | * startActivityForResult(). |
| 1430 | */ |
| 1431 | public static final String EXTRA_NOT_UNKNOWN_SOURCE |
| 1432 | = "android.intent.extra.NOT_UNKNOWN_SOURCE"; |
| 1433 | |
| 1434 | /** |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1435 | * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and |
| 1436 | * {@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] | 1437 | * data field originated from. |
| 1438 | */ |
rich cannings | 706e8ba | 2012-08-20 13:20:14 -0700 | [diff] [blame] | 1439 | public static final String EXTRA_ORIGINATING_URI |
| 1440 | = "android.intent.extra.ORIGINATING_URI"; |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1441 | |
| 1442 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1443 | * This extra can be used with any Intent used to launch an activity, supplying information |
| 1444 | * about who is launching that activity. This field contains a {@link android.net.Uri} |
| 1445 | * object, typically an http: or https: URI of the web site that the referral came from; |
| 1446 | * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify |
| 1447 | * a native application that it came from. |
| 1448 | * |
| 1449 | * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} |
| 1450 | * instead of directly retrieving the extra. It is also valid for applications to |
| 1451 | * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create |
| 1452 | * a string, not a Uri; the field here, if supplied, will always take precedence, |
| 1453 | * however.</p> |
| 1454 | * |
| 1455 | * @see #EXTRA_REFERRER_NAME |
rich cannings | 368ed01 | 2012-06-07 15:37:57 -0700 | [diff] [blame] | 1456 | */ |
| 1457 | public static final String EXTRA_REFERRER |
| 1458 | = "android.intent.extra.REFERRER"; |
| 1459 | |
| 1460 | /** |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 1461 | * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather |
| 1462 | * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can |
| 1463 | * not be created, in particular when Intent extras are supplied through the |
| 1464 | * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} |
| 1465 | * schemes. |
| 1466 | * |
| 1467 | * @see #EXTRA_REFERRER |
| 1468 | */ |
| 1469 | public static final String EXTRA_REFERRER_NAME |
| 1470 | = "android.intent.extra.REFERRER_NAME"; |
| 1471 | |
| 1472 | /** |
Ben Gruver | 37d83a3 | 2012-09-27 13:02:06 -0700 | [diff] [blame] | 1473 | * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and |
| 1474 | * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install |
| 1475 | * @hide |
| 1476 | */ |
| 1477 | public static final String EXTRA_ORIGINATING_UID |
| 1478 | = "android.intent.extra.ORIGINATING_UID"; |
| 1479 | |
| 1480 | /** |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1481 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a |
| 1482 | * package. Tells the installer UI to skip the confirmation with the user |
| 1483 | * if the .apk is replacing an existing one. |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1484 | * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android |
| 1485 | * will no longer show an interstitial message about updating existing |
| 1486 | * applications so this is no longer needed. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1487 | */ |
Dianne Hackborn | 0e128bb | 2012-05-01 14:40:15 -0700 | [diff] [blame] | 1488 | @Deprecated |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1489 | public static final String EXTRA_ALLOW_REPLACE |
| 1490 | = "android.intent.extra.ALLOW_REPLACE"; |
| 1491 | |
| 1492 | /** |
| 1493 | * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or |
| 1494 | * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should |
| 1495 | * return to the application the result code of the install/uninstall. The returned result |
| 1496 | * code will be {@link android.app.Activity#RESULT_OK} on success or |
| 1497 | * {@link android.app.Activity#RESULT_FIRST_USER} on failure. |
| 1498 | */ |
| 1499 | public static final String EXTRA_RETURN_RESULT |
| 1500 | = "android.intent.extra.RETURN_RESULT"; |
| 1501 | |
| 1502 | /** |
| 1503 | * Package manager install result code. @hide because result codes are not |
| 1504 | * yet ready to be exposed. |
| 1505 | */ |
| 1506 | public static final String EXTRA_INSTALL_RESULT |
| 1507 | = "android.intent.extra.INSTALL_RESULT"; |
| 1508 | |
| 1509 | /** |
| 1510 | * Activity Action: Launch application uninstaller. |
| 1511 | * <p> |
| 1512 | * Input: The data must be a package: URI whose scheme specific part is |
| 1513 | * the package name of the current installed package to be uninstalled. |
| 1514 | * You can optionally supply {@link #EXTRA_RETURN_RESULT}. |
| 1515 | * <p> |
| 1516 | * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install |
| 1517 | * succeeded. |
| 1518 | */ |
| 1519 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1520 | public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; |
| 1521 | |
| 1522 | /** |
Dianne Hackborn | 6d235d8 | 2012-09-16 18:25:40 -0700 | [diff] [blame] | 1523 | * Specify whether the package should be uninstalled for all users. |
| 1524 | * @hide because these should not be part of normal application flow. |
| 1525 | */ |
| 1526 | public static final String EXTRA_UNINSTALL_ALL_USERS |
| 1527 | = "android.intent.extra.UNINSTALL_ALL_USERS"; |
| 1528 | |
| 1529 | /** |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 1530 | * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity |
| 1531 | * describing the last run version of the platform that was setup. |
| 1532 | * @hide |
| 1533 | */ |
| 1534 | public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; |
| 1535 | |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1536 | /** |
| 1537 | * Activity action: Launch UI to manage the permissions of an app. |
| 1538 | * <p> |
| 1539 | * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions |
| 1540 | * will be managed by the launched UI. |
| 1541 | * </p> |
| 1542 | * <p> |
| 1543 | * Output: Nothing. |
| 1544 | * </p> |
| 1545 | * |
| 1546 | * @see #EXTRA_PACKAGE_NAME |
| 1547 | * |
| 1548 | * @hide |
| 1549 | */ |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1550 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1551 | public static final String ACTION_MANAGE_APP_PERMISSIONS = |
| 1552 | "android.intent.action.MANAGE_APP_PERMISSIONS"; |
| 1553 | |
| 1554 | /** |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1555 | * Activity action: Launch UI to manage permissions. |
| 1556 | * <p> |
| 1557 | * Input: Nothing. |
| 1558 | * </p> |
| 1559 | * <p> |
| 1560 | * Output: Nothing. |
| 1561 | * </p> |
| 1562 | * |
| 1563 | * @hide |
| 1564 | */ |
Svet Ganov | 321f015 | 2015-05-16 22:51:50 -0700 | [diff] [blame] | 1565 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1566 | public static final String ACTION_MANAGE_PERMISSIONS = |
| 1567 | "android.intent.action.MANAGE_PERMISSIONS"; |
| 1568 | |
| 1569 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1570 | * Intent extra: An app package name. |
| 1571 | * <p> |
| 1572 | * Type: String |
Svet Ganov | 0b31670 | 2015-05-23 13:25:11 -0700 | [diff] [blame] | 1573 | * </p> |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1574 | * |
| 1575 | * @hide |
| 1576 | */ |
| 1577 | @SystemApi |
| 1578 | public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; |
| 1579 | |
| 1580 | /** |
Jason Monk | 9cfa0cc | 2015-05-22 14:50:21 -0400 | [diff] [blame] | 1581 | * Broadcast action that requests current permission granted information. It will respond |
| 1582 | * to the request by sending a broadcast with action defined by |
| 1583 | * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain |
Makoto Onuki | bbb912a | 2015-06-05 16:27:23 -0700 | [diff] [blame] | 1584 | * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as |
| 1585 | * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or |
| 1586 | * a null upon failure. |
Jason Monk | 9cfa0cc | 2015-05-22 14:50:21 -0400 | [diff] [blame] | 1587 | * |
Makoto Onuki | bbb912a | 2015-06-05 16:27:23 -0700 | [diff] [blame] | 1588 | * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the |
| 1589 | * number of permissions requested and the number of granted additional permissions |
| 1590 | * by that package will be calculated and included as the first |
Jason Monk | 9cfa0cc | 2015-05-22 14:50:21 -0400 | [diff] [blame] | 1591 | * and second elements respectively of an int[] in the response as |
Makoto Onuki | bbb912a | 2015-06-05 16:27:23 -0700 | [diff] [blame] | 1592 | * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list |
| 1593 | * of localized permission group names that are granted in |
| 1594 | * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}. |
Jason Monk | 9cfa0cc | 2015-05-22 14:50:21 -0400 | [diff] [blame] | 1595 | * |
| 1596 | * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime |
| 1597 | * permissions and the total number of apps requesting runtime permissions will be the first |
| 1598 | * and second elements respectively of an int[] in the response as |
| 1599 | * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. |
| 1600 | * |
| 1601 | * @hide |
| 1602 | */ |
| 1603 | public static final String ACTION_GET_PERMISSIONS_COUNT |
| 1604 | = "android.intent.action.GET_PERMISSIONS_COUNT"; |
| 1605 | |
| 1606 | /** |
Vinod Krishnan | 61665cc | 2015-08-31 19:30:20 -0700 | [diff] [blame] | 1607 | * Broadcast action that requests list of all apps that have runtime permissions. It will |
| 1608 | * respond to the request by sending a broadcast with action defined by |
| 1609 | * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain |
| 1610 | * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as |
| 1611 | * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or |
| 1612 | * a null upon failure. |
| 1613 | * |
| 1614 | * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of |
| 1615 | * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT} |
| 1616 | * will contain the list of app labels corresponding ot the apps in the first list. |
| 1617 | * |
| 1618 | * @hide |
| 1619 | */ |
| 1620 | public static final String ACTION_GET_PERMISSIONS_PACKAGES |
| 1621 | = "android.intent.action.GET_PERMISSIONS_PACKAGES"; |
| 1622 | |
| 1623 | /** |
Jason Monk | 9cfa0cc | 2015-05-22 14:50:21 -0400 | [diff] [blame] | 1624 | * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}. |
| 1625 | * @hide |
| 1626 | */ |
| 1627 | public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT |
| 1628 | = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT"; |
| 1629 | |
| 1630 | /** |
Makoto Onuki | bbb912a | 2015-06-05 16:27:23 -0700 | [diff] [blame] | 1631 | * List of CharSequence of localized permission group labels. |
| 1632 | * @hide |
| 1633 | */ |
| 1634 | public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT |
| 1635 | = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT"; |
| 1636 | |
| 1637 | /** |
Vinod Krishnan | 61665cc | 2015-08-31 19:30:20 -0700 | [diff] [blame] | 1638 | * String list of apps that have one or more runtime permissions. |
| 1639 | * @hide |
| 1640 | */ |
| 1641 | public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT |
| 1642 | = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT"; |
| 1643 | |
| 1644 | /** |
| 1645 | * String list of app labels for apps that have one or more runtime permissions. |
| 1646 | * @hide |
| 1647 | */ |
| 1648 | public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT |
| 1649 | = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT"; |
| 1650 | |
| 1651 | /** |
Anthony Hugh | 3575a40 | 2015-10-26 17:47:05 -0700 | [diff] [blame] | 1652 | * Boolean list describing if the app is a system app for apps that have one or more runtime |
| 1653 | * permissions. |
| 1654 | * @hide |
| 1655 | */ |
| 1656 | public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT |
| 1657 | = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT"; |
| 1658 | |
| 1659 | /** |
Makoto Onuki | bbb912a | 2015-06-05 16:27:23 -0700 | [diff] [blame] | 1660 | * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts. |
Jason Monk | 9cfa0cc | 2015-05-22 14:50:21 -0400 | [diff] [blame] | 1661 | * @hide |
| 1662 | */ |
| 1663 | public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT |
| 1664 | = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT"; |
| 1665 | |
| 1666 | /** |
Vinod Krishnan | 61665cc | 2015-08-31 19:30:20 -0700 | [diff] [blame] | 1667 | * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts. |
| 1668 | * @hide |
| 1669 | */ |
| 1670 | public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT |
| 1671 | = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT"; |
| 1672 | |
| 1673 | /** |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1674 | * Activity action: Launch UI to manage which apps have a given permission. |
| 1675 | * <p> |
| 1676 | * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access |
| 1677 | * to which will be managed by the launched UI. |
| 1678 | * </p> |
| 1679 | * <p> |
| 1680 | * Output: Nothing. |
| 1681 | * </p> |
| 1682 | * |
| 1683 | * @see #EXTRA_PERMISSION_NAME |
| 1684 | * |
| 1685 | * @hide |
| 1686 | */ |
Svet Ganov | 3695b8a | 2015-03-24 16:30:25 -0700 | [diff] [blame] | 1687 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 1688 | public static final String ACTION_MANAGE_PERMISSION_APPS = |
| 1689 | "android.intent.action.MANAGE_PERMISSION_APPS"; |
| 1690 | |
| 1691 | /** |
| 1692 | * Intent extra: The name of a permission. |
| 1693 | * <p> |
| 1694 | * Type: String |
| 1695 | * </p> |
| 1696 | * |
| 1697 | * @hide |
| 1698 | */ |
| 1699 | @SystemApi |
| 1700 | public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; |
| 1701 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1702 | // --------------------------------------------------------------------- |
| 1703 | // --------------------------------------------------------------------- |
| 1704 | // Standard intent broadcast actions (see action variable). |
| 1705 | |
| 1706 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1707 | * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. |
| 1708 | * <p> |
| 1709 | * For historical reasons, the name of this broadcast action refers to the power |
| 1710 | * state of the screen but it is actually sent in response to changes in the |
| 1711 | * overall interactive state of the device. |
| 1712 | * </p><p> |
| 1713 | * This broadcast is sent when the device becomes non-interactive which may have |
| 1714 | * nothing to do with the screen turning off. To determine the |
| 1715 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1716 | * </p><p> |
| 1717 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1718 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1719 | * You <em>cannot</em> receive this through components declared in |
| 1720 | * manifests, only by explicitly registering for it with |
| 1721 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1722 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1723 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1724 | * <p class="note">This is a protected intent that can only be sent |
| 1725 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1726 | */ |
| 1727 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1728 | public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1729 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1730 | /** |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1731 | * Broadcast Action: Sent when the device wakes up and becomes interactive. |
| 1732 | * <p> |
| 1733 | * For historical reasons, the name of this broadcast action refers to the power |
| 1734 | * state of the screen but it is actually sent in response to changes in the |
| 1735 | * overall interactive state of the device. |
| 1736 | * </p><p> |
| 1737 | * This broadcast is sent when the device becomes interactive which may have |
| 1738 | * nothing to do with the screen turning on. To determine the |
| 1739 | * actual state of the screen, use {@link android.view.Display#getState}. |
| 1740 | * </p><p> |
| 1741 | * See {@link android.os.PowerManager#isInteractive} for details. |
| 1742 | * </p> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1743 | * You <em>cannot</em> receive this through components declared in |
| 1744 | * manifests, only by explicitly registering for it with |
| 1745 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1746 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1747 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1748 | * <p class="note">This is a protected intent that can only be sent |
| 1749 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1750 | */ |
| 1751 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1752 | 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] | 1753 | |
| 1754 | /** |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 1755 | * Broadcast Action: Sent after the system stops dreaming. |
| 1756 | * |
| 1757 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1758 | * It is only sent to registered receivers.</p> |
| 1759 | */ |
| 1760 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1761 | public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; |
| 1762 | |
| 1763 | /** |
| 1764 | * Broadcast Action: Sent after the system starts dreaming. |
| 1765 | * |
| 1766 | * <p class="note">This is a protected intent that can only be sent by the system. |
| 1767 | * It is only sent to registered receivers.</p> |
| 1768 | */ |
| 1769 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1770 | public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; |
| 1771 | |
| 1772 | /** |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1773 | * 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] | 1774 | * keyguard is gone). |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1775 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1776 | * <p class="note">This is a protected intent that can only be sent |
| 1777 | * by the system. |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 1778 | */ |
| 1779 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 1780 | 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] | 1781 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1782 | /** |
| 1783 | * Broadcast Action: The current time has changed. Sent every |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 1784 | * minute. You <em>cannot</em> receive this through components declared |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1785 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1786 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 1787 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1788 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1789 | * <p class="note">This is a protected intent that can only be sent |
| 1790 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1791 | */ |
| 1792 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1793 | public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; |
| 1794 | /** |
| 1795 | * Broadcast Action: The time was set. |
| 1796 | */ |
| 1797 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1798 | public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; |
| 1799 | /** |
| 1800 | * Broadcast Action: The date has changed. |
| 1801 | */ |
| 1802 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1803 | public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; |
| 1804 | /** |
| 1805 | * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> |
| 1806 | * <ul> |
| 1807 | * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li> |
| 1808 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1809 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1810 | * <p class="note">This is a protected intent that can only be sent |
| 1811 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1812 | */ |
| 1813 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1814 | public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; |
| 1815 | /** |
Robert Greenwalt | 03595d0 | 2010-11-02 14:08:23 -0700 | [diff] [blame] | 1816 | * Clear DNS Cache Action: This is broadcast when networks have changed and old |
| 1817 | * DNS entries should be tossed. |
| 1818 | * @hide |
| 1819 | */ |
| 1820 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1821 | public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE"; |
| 1822 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1823 | * Alarm Changed Action: This is broadcast when the AlarmClock |
| 1824 | * application's alarm is set or unset. It is used by the |
| 1825 | * AlarmClock application and the StatusBar service. |
| 1826 | * @hide |
| 1827 | */ |
| 1828 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1829 | public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; |
| 1830 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1831 | * Broadcast Action: This is broadcast once, after the system has finished |
| 1832 | * booting. It can be used to perform application-specific initialization, |
| 1833 | * such as installing alarms. You must hold the |
| 1834 | * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission |
| 1835 | * in order to receive this broadcast. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1836 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1837 | * <p class="note">This is a protected intent that can only be sent |
| 1838 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1839 | */ |
| 1840 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1841 | public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; |
| 1842 | /** |
| 1843 | * Broadcast Action: This is broadcast when a user action should request a |
| 1844 | * temporary system dialog to dismiss. Some examples of temporary system |
| 1845 | * dialogs are the notification window-shade and the recent tasks dialog. |
| 1846 | */ |
| 1847 | public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; |
| 1848 | /** |
| 1849 | * Broadcast Action: Trigger the download and eventual installation |
| 1850 | * of a package. |
| 1851 | * <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] | 1852 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1853 | * <p class="note">This is a protected intent that can only be sent |
| 1854 | * by the system. |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1855 | * |
| 1856 | * @deprecated This constant has never been used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1857 | */ |
Dianne Hackborn | 271c2fe | 2011-08-09 19:35:13 -0700 | [diff] [blame] | 1858 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1859 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1860 | public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; |
| 1861 | /** |
| 1862 | * 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] | 1863 | * device. The data contains the name of the package. Note that the |
| 1864 | * newly installed package does <em>not</em> receive this broadcast. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 1865 | * <p>May include the following extras: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1866 | * <ul> |
| 1867 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 1868 | * <li> {@link #EXTRA_REPLACING} is set to true if this is following |
| 1869 | * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. |
| 1870 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1871 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1872 | * <p class="note">This is a protected intent that can only be sent |
| 1873 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1874 | */ |
| 1875 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1876 | public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; |
| 1877 | /** |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 1878 | * Broadcast Action: A new version of an application package has been |
| 1879 | * installed, replacing an existing version that was previously installed. |
| 1880 | * The data contains the name of the package. |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 1881 | * <p>May include the following extras: |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 1882 | * <ul> |
| 1883 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. |
| 1884 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1885 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1886 | * <p class="note">This is a protected intent that can only be sent |
| 1887 | * by the system. |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 1888 | */ |
| 1889 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1890 | public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; |
| 1891 | /** |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 1892 | * Broadcast Action: A new version of your application has been installed |
| 1893 | * over an existing one. This is only sent to the application that was |
| 1894 | * replaced. It does not contain any additional data; to receive it, just |
| 1895 | * use an intent filter for this action. |
| 1896 | * |
| 1897 | * <p class="note">This is a protected intent that can only be sent |
| 1898 | * by the system. |
| 1899 | */ |
| 1900 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1901 | public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; |
| 1902 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1903 | * Broadcast Action: An existing application package has been removed from |
| 1904 | * the device. The data contains the name of the package. The package |
| 1905 | * that is being installed does <em>not</em> receive this Intent. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1906 | * <ul> |
| 1907 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 1908 | * to the package. |
| 1909 | * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire |
| 1910 | * application -- data and code -- is being removed. |
| 1911 | * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed |
| 1912 | * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. |
| 1913 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1914 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1915 | * <p class="note">This is a protected intent that can only be sent |
| 1916 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1917 | */ |
| 1918 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1919 | public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; |
| 1920 | /** |
Dianne Hackborn | f9abb40 | 2011-08-10 15:00:59 -0700 | [diff] [blame] | 1921 | * Broadcast Action: An existing application package has been completely |
| 1922 | * removed from the device. The data contains the name of the package. |
| 1923 | * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when |
| 1924 | * {@link #EXTRA_DATA_REMOVED} is true and |
| 1925 | * {@link #EXTRA_REPLACING} is false of that broadcast. |
| 1926 | * |
| 1927 | * <ul> |
| 1928 | * <li> {@link #EXTRA_UID} containing the integer uid previously assigned |
| 1929 | * to the package. |
| 1930 | * </ul> |
| 1931 | * |
| 1932 | * <p class="note">This is a protected intent that can only be sent |
| 1933 | * by the system. |
| 1934 | */ |
| 1935 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1936 | public static final String ACTION_PACKAGE_FULLY_REMOVED |
| 1937 | = "android.intent.action.PACKAGE_FULLY_REMOVED"; |
| 1938 | /** |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 1939 | * Broadcast Action: An existing application package has been changed (e.g. |
| 1940 | * a component has been enabled or disabled). The data contains the name of |
| 1941 | * the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1942 | * <ul> |
| 1943 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 1944 | * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 1945 | * of the changed components (or the package name itself). |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 1946 | * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the |
| 1947 | * default action of restarting the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1948 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1949 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1950 | * <p class="note">This is a protected intent that can only be sent |
| 1951 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1952 | */ |
| 1953 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1954 | public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; |
| 1955 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1956 | * @hide |
| 1957 | * Broadcast Action: Ask system services if there is any reason to |
| 1958 | * restart the given package. The data contains the name of the |
| 1959 | * package. |
| 1960 | * <ul> |
| 1961 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 1962 | * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. |
| 1963 | * </ul> |
| 1964 | * |
| 1965 | * <p class="note">This is a protected intent that can only be sent |
| 1966 | * by the system. |
| 1967 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 1968 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1969 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1970 | public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; |
| 1971 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1972 | * Broadcast Action: The user has restarted a package, and all of its |
| 1973 | * processes have been killed. All runtime state |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1974 | * associated with it (processes, alarms, notifications, etc) should |
The Android Open Source Project | c2ad241 | 2009-03-19 23:08:54 -0700 | [diff] [blame] | 1975 | * be removed. Note that the restarted package does <em>not</em> |
| 1976 | * receive this broadcast. |
| 1977 | * The data contains the name of the package. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1978 | * <ul> |
| 1979 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 1980 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1981 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1982 | * <p class="note">This is a protected intent that can only be sent |
| 1983 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1984 | */ |
| 1985 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 1986 | public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; |
| 1987 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1988 | * Broadcast Action: The user has cleared the data of a package. This should |
| 1989 | * 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] | 1990 | * its persistent data is erased and this broadcast sent. |
| 1991 | * Note that the cleared package does <em>not</em> |
| 1992 | * 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] | 1993 | * <ul> |
| 1994 | * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. |
| 1995 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 1996 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 1997 | * <p class="note">This is a protected intent that can only be sent |
| 1998 | * by the system. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1999 | */ |
| 2000 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2001 | public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; |
| 2002 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2003 | * Broadcast Action: A user ID has been removed from the system. The user |
| 2004 | * ID number is stored in the extra data under {@link #EXTRA_UID}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2005 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2006 | * <p class="note">This is a protected intent that can only be sent |
| 2007 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2008 | */ |
| 2009 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2010 | public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2011 | |
| 2012 | /** |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 2013 | * Broadcast Action: Sent to the installer package of an application |
| 2014 | * when that application is first launched (that is the first time it |
| 2015 | * is moved out of the stopped state). The data contains the name of the package. |
| 2016 | * |
| 2017 | * <p class="note">This is a protected intent that can only be sent |
| 2018 | * by the system. |
| 2019 | */ |
| 2020 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2021 | public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; |
| 2022 | |
| 2023 | /** |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2024 | * Broadcast Action: Sent to the system package verifier when a package |
| 2025 | * needs to be verified. The data contains the package URI. |
| 2026 | * <p class="note"> |
| 2027 | * This is a protected intent that can only be sent by the system. |
| 2028 | * </p> |
Kenny Root | 5ab2157 | 2011-07-27 11:11:19 -0700 | [diff] [blame] | 2029 | */ |
| 2030 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2031 | public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; |
| 2032 | |
| 2033 | /** |
rich cannings | d1b5cfc | 2012-08-29 14:49:51 -0700 | [diff] [blame] | 2034 | * Broadcast Action: Sent to the system package verifier when a package is |
| 2035 | * verified. The data contains the package URI. |
| 2036 | * <p class="note"> |
| 2037 | * This is a protected intent that can only be sent by the system. |
| 2038 | */ |
| 2039 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2040 | public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; |
| 2041 | |
| 2042 | /** |
Fabrice Di Meglio | 1c1b471 | 2014-11-19 17:12:32 -0800 | [diff] [blame] | 2043 | * Broadcast Action: Sent to the system intent filter verifier when an intent filter |
| 2044 | * needs to be verified. The data contains the filter data hosts to be verified against. |
| 2045 | * <p class="note"> |
| 2046 | * This is a protected intent that can only be sent by the system. |
| 2047 | * </p> |
| 2048 | * |
| 2049 | * @hide |
| 2050 | */ |
| 2051 | @SystemApi |
| 2052 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2053 | public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; |
| 2054 | |
| 2055 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2056 | * Broadcast Action: Resources for a set of packages (which were |
| 2057 | * previously unavailable) are currently |
| 2058 | * available since the media on which they exist is available. |
| 2059 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2060 | * list of packages whose availability changed. |
| 2061 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2062 | * list of uids of packages whose availability changed. |
| 2063 | * Note that the |
| 2064 | * packages in this list do <em>not</em> receive this broadcast. |
| 2065 | * The specified set of packages are now available on the system. |
| 2066 | * <p>Includes the following extras: |
| 2067 | * <ul> |
| 2068 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2069 | * whose resources(were previously unavailable) are currently available. |
| 2070 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the |
| 2071 | * packages whose resources(were previously unavailable) |
| 2072 | * are currently available. |
| 2073 | * </ul> |
| 2074 | * |
| 2075 | * <p class="note">This is a protected intent that can only be sent |
| 2076 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2077 | */ |
| 2078 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2079 | public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = |
| 2080 | "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2081 | |
| 2082 | /** |
| 2083 | * Broadcast Action: Resources for a set of packages are currently |
| 2084 | * unavailable since the media on which they exist is unavailable. |
| 2085 | * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a |
| 2086 | * list of packages whose availability changed. |
| 2087 | * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a |
| 2088 | * list of uids of packages whose availability changed. |
| 2089 | * The specified set of packages can no longer be |
| 2090 | * launched and are practically unavailable on the system. |
| 2091 | * <p>Inclues the following extras: |
| 2092 | * <ul> |
| 2093 | * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages |
| 2094 | * whose resources are no longer available. |
| 2095 | * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages |
| 2096 | * whose resources are no longer available. |
| 2097 | * </ul> |
| 2098 | * |
| 2099 | * <p class="note">This is a protected intent that can only be sent |
| 2100 | * by the system. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2101 | */ |
| 2102 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 2103 | public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = |
Joe Onorato | 8a051a4 | 2010-03-04 15:54:50 -0500 | [diff] [blame] | 2104 | "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 2105 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2106 | /** |
| 2107 | * Broadcast Action: The current system wallpaper has changed. See |
Scott Main | 8b2e000 | 2009-09-29 18:17:31 -0700 | [diff] [blame] | 2108 | * {@link android.app.WallpaperManager} for retrieving the new wallpaper. |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2109 | * This should <em>only</em> be used to determine when the wallpaper |
| 2110 | * has changed to show the new wallpaper to the user. You should certainly |
| 2111 | * never, in response to this, change the wallpaper or other attributes of |
| 2112 | * it such as the suggested size. That would be crazy, right? You'd cause |
| 2113 | * all kinds of loops, especially if other apps are doing similar things, |
| 2114 | * right? Of course. So please don't do this. |
| 2115 | * |
| 2116 | * @deprecated Modern applications should use |
| 2117 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER |
| 2118 | * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper |
| 2119 | * shown behind their UI, rather than watching for this broadcast and |
| 2120 | * rendering the wallpaper on their own. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2121 | */ |
Dianne Hackborn | c5bf758 | 2012-04-25 19:12:07 -0700 | [diff] [blame] | 2122 | @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2123 | public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; |
| 2124 | /** |
| 2125 | * Broadcast Action: The current device {@link android.content.res.Configuration} |
| 2126 | * (orientation, locale, etc) has changed. When such a change happens, the |
| 2127 | * UIs (view hierarchy) will need to be rebuilt based on this new |
| 2128 | * information; for the most part, applications don't need to worry about |
| 2129 | * this, because the system will take care of stopping and restarting the |
| 2130 | * application to make sure it sees the new changes. Some system code that |
| 2131 | * can not be restarted will need to watch for this action and handle it |
| 2132 | * appropriately. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2133 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2134 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2135 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2136 | * in manifests, only by explicitly registering for it with |
| 2137 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2138 | * Context.registerReceiver()}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2139 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2140 | * <p class="note">This is a protected intent that can only be sent |
| 2141 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2142 | * |
| 2143 | * @see android.content.res.Configuration |
| 2144 | */ |
| 2145 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2146 | public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; |
| 2147 | /** |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2148 | * Broadcast Action: The current device's locale has changed. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2149 | * |
Dianne Hackborn | 362d5b9 | 2009-11-11 18:04:39 -0800 | [diff] [blame] | 2150 | * <p class="note">This is a protected intent that can only be sent |
| 2151 | * by the system. |
| 2152 | */ |
| 2153 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2154 | public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; |
| 2155 | /** |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2156 | * Broadcast Action: This is a <em>sticky broadcast</em> containing the |
| 2157 | * charging state, level, and other information about the battery. |
| 2158 | * See {@link android.os.BatteryManager} for documentation on the |
| 2159 | * contents of the Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2160 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2161 | * <p class="note"> |
Casey Ho | dbf6785c | 2015-03-17 15:59:39 -0700 | [diff] [blame] | 2162 | * You <em>cannot</em> receive this through components declared |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2163 | * in manifests, only by explicitly registering for it with |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2164 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2165 | * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, |
| 2166 | * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, |
| 2167 | * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related |
| 2168 | * broadcasts that are sent and can be received through manifest |
| 2169 | * receivers. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2170 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2171 | * <p class="note">This is a protected intent that can only be sent |
| 2172 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2173 | */ |
| 2174 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2175 | public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; |
| 2176 | /** |
| 2177 | * Broadcast Action: Indicates low battery condition on the device. |
| 2178 | * This broadcast corresponds to the "Low battery warning" system dialog. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2179 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2180 | * <p class="note">This is a protected intent that can only be sent |
| 2181 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2182 | */ |
| 2183 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2184 | public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; |
| 2185 | /** |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2186 | * Broadcast Action: Indicates the battery is now okay after being low. |
| 2187 | * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has |
| 2188 | * gone back up to an okay state. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2189 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2190 | * <p class="note">This is a protected intent that can only be sent |
| 2191 | * by the system. |
Dianne Hackborn | 1dac277 | 2009-06-26 18:16:48 -0700 | [diff] [blame] | 2192 | */ |
| 2193 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2194 | public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; |
| 2195 | /** |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2196 | * Broadcast Action: External power has been connected to the device. |
| 2197 | * This is intended for applications that wish to register specifically to this notification. |
| 2198 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2199 | * stay active to receive this notification. This action can be used to implement actions |
| 2200 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2201 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2202 | * <p class="note">This is a protected intent that can only be sent |
| 2203 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2204 | */ |
| 2205 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2206 | 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] | 2207 | /** |
| 2208 | * Broadcast Action: External power has been removed from the device. |
| 2209 | * This is intended for applications that wish to register specifically to this notification. |
| 2210 | * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to |
| 2211 | * 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] | 2212 | * that wait until power is available to trigger. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2213 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2214 | * <p class="note">This is a protected intent that can only be sent |
| 2215 | * by the system. |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2216 | */ |
| 2217 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Baptiste Queru | 1ef4564 | 2008-10-24 11:49:25 -0700 | [diff] [blame] | 2218 | public static final String ACTION_POWER_DISCONNECTED = |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2219 | "android.intent.action.ACTION_POWER_DISCONNECTED"; |
Cliff Spradlin | fda6fae | 2008-10-22 20:29:16 -0700 | [diff] [blame] | 2220 | /** |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2221 | * Broadcast Action: Device is shutting down. |
| 2222 | * This is broadcast when the device is being shut down (completely turned |
| 2223 | * off, not sleeping). Once the broadcast is complete, the final shutdown |
| 2224 | * will proceed and all unsaved data lost. Apps will not normally need |
Dianne Hackborn | fe240ec | 2009-08-27 12:51:11 -0700 | [diff] [blame] | 2225 | * to handle this, since the foreground activity will be paused as well. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2226 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2227 | * <p class="note">This is a protected intent that can only be sent |
| 2228 | * by the system. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 2229 | * <p>May include the following extras: |
| 2230 | * <ul> |
| 2231 | * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this |
| 2232 | * shutdown is only for userspace processes. If not set, assumed to be false. |
| 2233 | * </ul> |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2234 | */ |
| 2235 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 2236 | public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 2237 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 2238 | * Activity Action: Start this activity to request system shutdown. |
| 2239 | * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true |
| 2240 | * to request confirmation from the user before shutting down. |
| 2241 | * |
| 2242 | * <p class="note">This is a protected intent that can only be sent |
| 2243 | * by the system. |
| 2244 | * |
| 2245 | * {@hide} |
| 2246 | */ |
| 2247 | public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN"; |
| 2248 | /** |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2249 | * Broadcast Action: A sticky broadcast that indicates low memory |
| 2250 | * condition on the device |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2251 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2252 | * <p class="note">This is a protected intent that can only be sent |
| 2253 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2254 | */ |
| 2255 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2256 | public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; |
| 2257 | /** |
| 2258 | * Broadcast Action: Indicates low memory condition on the device no longer exists |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2259 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2260 | * <p class="note">This is a protected intent that can only be sent |
| 2261 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2262 | */ |
| 2263 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2264 | public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; |
| 2265 | /** |
Jake Hamby | bb37163 | 2010-08-23 18:16:48 -0700 | [diff] [blame] | 2266 | * Broadcast Action: A sticky broadcast that indicates a memory full |
| 2267 | * condition on the device. This is intended for activities that want |
| 2268 | * to be able to fill the data partition completely, leaving only |
| 2269 | * enough free space to prevent system-wide SQLite failures. |
| 2270 | * |
| 2271 | * <p class="note">This is a protected intent that can only be sent |
| 2272 | * by the system. |
| 2273 | * |
| 2274 | * {@hide} |
| 2275 | */ |
| 2276 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2277 | public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; |
| 2278 | /** |
| 2279 | * Broadcast Action: Indicates memory full condition on the device |
| 2280 | * no longer exists. |
| 2281 | * |
| 2282 | * <p class="note">This is a protected intent that can only be sent |
| 2283 | * by the system. |
| 2284 | * |
| 2285 | * {@hide} |
| 2286 | */ |
| 2287 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2288 | public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; |
| 2289 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2290 | * Broadcast Action: Indicates low memory condition notification acknowledged by user |
| 2291 | * and package management should be started. |
| 2292 | * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW |
| 2293 | * notification. |
| 2294 | */ |
| 2295 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2296 | public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; |
| 2297 | /** |
| 2298 | * Broadcast Action: The device has entered USB Mass Storage mode. |
| 2299 | * This is used mainly for the USB Settings panel. |
| 2300 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2301 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2302 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2303 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2304 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2305 | public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; |
| 2306 | |
| 2307 | /** |
| 2308 | * Broadcast Action: The device has exited USB Mass Storage mode. |
| 2309 | * This is used mainly for the USB Settings panel. |
| 2310 | * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified |
| 2311 | * when the SD card file system is mounted or unmounted |
Mike Lockwood | 7e4db37 | 2011-06-07 11:23:44 -0700 | [diff] [blame] | 2312 | * @deprecated replaced by android.os.storage.StorageEventListener |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2313 | */ |
Mike Lockwood | da85e52 | 2011-06-07 09:08:34 -0700 | [diff] [blame] | 2314 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2315 | public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; |
| 2316 | |
| 2317 | /** |
| 2318 | * Broadcast Action: External media has been removed. |
| 2319 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2320 | */ |
| 2321 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2322 | public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; |
| 2323 | |
| 2324 | /** |
| 2325 | * 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] | 2326 | * 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] | 2327 | */ |
| 2328 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2329 | public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; |
| 2330 | |
| 2331 | /** |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 2332 | * Broadcast Action: External media is present, and being disk-checked |
| 2333 | * 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] | 2334 | */ |
| 2335 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2336 | public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; |
| 2337 | |
| 2338 | /** |
| 2339 | * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) |
| 2340 | * 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] | 2341 | */ |
| 2342 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2343 | public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; |
| 2344 | |
| 2345 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2346 | * Broadcast Action: External media is present and mounted at its mount point. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2347 | * 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] | 2348 | * The Intent contains an extra with name "read-only" and Boolean value to indicate if the |
| 2349 | * media was mounted read only. |
| 2350 | */ |
| 2351 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2352 | public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; |
| 2353 | |
| 2354 | /** |
| 2355 | * 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] | 2356 | * 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] | 2357 | */ |
| 2358 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2359 | public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; |
| 2360 | |
| 2361 | /** |
Mike Lockwood | bf2dd44 | 2010-03-03 06:16:52 -0500 | [diff] [blame] | 2362 | * Broadcast Action: External media is no longer being shared via USB mass storage. |
| 2363 | * The path to the mount point for the previously shared media is contained in the Intent.mData field. |
| 2364 | * |
| 2365 | * @hide |
| 2366 | */ |
| 2367 | public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; |
| 2368 | |
| 2369 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2370 | * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. |
| 2371 | * The path to the mount point for the removed media is contained in the Intent.mData field. |
| 2372 | */ |
| 2373 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2374 | public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; |
| 2375 | |
| 2376 | /** |
| 2377 | * Broadcast Action: External media is present but cannot be mounted. |
suyi Yuan | be7af83 | 2013-01-04 21:21:59 +0800 | [diff] [blame] | 2378 | * 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] | 2379 | */ |
| 2380 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2381 | public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; |
| 2382 | |
| 2383 | /** |
| 2384 | * Broadcast Action: User has expressed the desire to remove the external storage media. |
| 2385 | * Applications should close all files they have open within the mount point when they receive this intent. |
| 2386 | * The path to the mount point for the media to be ejected is contained in the Intent.mData field. |
| 2387 | */ |
| 2388 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2389 | public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; |
| 2390 | |
| 2391 | /** |
| 2392 | * Broadcast Action: The media scanner has started scanning a directory. |
| 2393 | * The path to the directory being scanned is contained in the Intent.mData field. |
| 2394 | */ |
| 2395 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2396 | public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; |
| 2397 | |
| 2398 | /** |
| 2399 | * Broadcast Action: The media scanner has finished scanning a directory. |
| 2400 | * The path to the scanned directory is contained in the Intent.mData field. |
| 2401 | */ |
| 2402 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2403 | public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; |
| 2404 | |
| 2405 | /** |
| 2406 | * Broadcast Action: Request the media scanner to scan a file and add it to the media database. |
| 2407 | * The path to the file is contained in the Intent.mData field. |
| 2408 | */ |
| 2409 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2410 | public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; |
| 2411 | |
| 2412 | /** |
| 2413 | * Broadcast Action: The "Media Button" was pressed. Includes a single |
| 2414 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2415 | * caused the broadcast. |
| 2416 | */ |
| 2417 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2418 | public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; |
| 2419 | |
| 2420 | /** |
| 2421 | * Broadcast Action: The "Camera Button" was pressed. Includes a single |
| 2422 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2423 | * caused the broadcast. |
| 2424 | */ |
| 2425 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2426 | public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; |
| 2427 | |
| 2428 | // *** NOTE: @todo(*) The following really should go into a more domain-specific |
| 2429 | // location; they are not general-purpose actions. |
| 2430 | |
| 2431 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2432 | * Broadcast Action: A GTalk connection has been established. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2433 | */ |
| 2434 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2435 | public static final String ACTION_GTALK_SERVICE_CONNECTED = |
| 2436 | "android.intent.action.GTALK_CONNECTED"; |
| 2437 | |
| 2438 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2439 | * Broadcast Action: A GTalk connection has been disconnected. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2440 | */ |
| 2441 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2442 | public static final String ACTION_GTALK_SERVICE_DISCONNECTED = |
| 2443 | "android.intent.action.GTALK_DISCONNECTED"; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2444 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2445 | /** |
| 2446 | * Broadcast Action: An input method has been changed. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2447 | */ |
| 2448 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2449 | public static final String ACTION_INPUT_METHOD_CHANGED = |
| 2450 | "android.intent.action.INPUT_METHOD_CHANGED"; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2451 | |
| 2452 | /** |
| 2453 | * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or |
| 2454 | * more radios have been turned off or on. The intent will have the following extra value:</p> |
| 2455 | * <ul> |
| 2456 | * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, |
| 2457 | * then cell radio and possibly other radios such as bluetooth or WiFi may have also been |
| 2458 | * turned off</li> |
| 2459 | * </ul> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2460 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2461 | * <p class="note">This is a protected intent that can only be sent |
| 2462 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2463 | */ |
| 2464 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2465 | public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; |
| 2466 | |
| 2467 | /** |
| 2468 | * Broadcast Action: Some content providers have parts of their namespace |
| 2469 | * where they publish new events or items that the user may be especially |
| 2470 | * interested in. For these things, they may broadcast this action when the |
| 2471 | * set of interesting items change. |
| 2472 | * |
| 2473 | * For example, GmailProvider sends this notification when the set of unread |
| 2474 | * mail in the inbox changes. |
| 2475 | * |
| 2476 | * <p>The data of the intent identifies which part of which provider |
| 2477 | * changed. When queried through the content resolver, the data URI will |
| 2478 | * return the data set in question. |
| 2479 | * |
| 2480 | * <p>The intent will have the following extra values: |
| 2481 | * <ul> |
| 2482 | * <li><em>count</em> - The number of items in the data set. This is the |
| 2483 | * same as the number of items in the cursor returned by querying the |
| 2484 | * data URI. </li> |
| 2485 | * </ul> |
| 2486 | * |
| 2487 | * This intent will be sent at boot (if the count is non-zero) and when the |
| 2488 | * data set changes. It is possible for the data set to change without the |
| 2489 | * count changing (for example, if a new unread message arrives in the same |
| 2490 | * sync operation in which a message is archived). The phone should still |
| 2491 | * ring/vibrate/etc as normal in this case. |
| 2492 | */ |
| 2493 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2494 | public static final String ACTION_PROVIDER_CHANGED = |
| 2495 | "android.intent.action.PROVIDER_CHANGED"; |
| 2496 | |
| 2497 | /** |
| 2498 | * Broadcast Action: Wired Headset plugged in or unplugged. |
| 2499 | * |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2500 | * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value |
| 2501 | * and documentation. |
| 2502 | * <p>If the minimum SDK version of your application is |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 2503 | * {@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] | 2504 | * 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] | 2505 | */ |
| 2506 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jean-Michel Trivi | c525843 | 2014-08-27 15:46:54 -0700 | [diff] [blame] | 2507 | 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] | 2508 | |
| 2509 | /** |
Joe Onorato | 9cdffa1 | 2011-04-06 18:27:27 -0700 | [diff] [blame] | 2510 | * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> |
| 2511 | * <ul> |
| 2512 | * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> |
| 2513 | * </ul> |
| 2514 | * |
| 2515 | * <p class="note">This is a protected intent that can only be sent |
| 2516 | * by the system. |
| 2517 | * |
| 2518 | * @hide |
| 2519 | */ |
| 2520 | //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2521 | public static final String ACTION_ADVANCED_SETTINGS_CHANGED |
| 2522 | = "android.intent.action.ADVANCED_SETTINGS"; |
| 2523 | |
| 2524 | /** |
Robin Lee | 66e5d96 | 2014-04-09 16:44:21 +0100 | [diff] [blame] | 2525 | * Broadcast Action: Sent after application restrictions are changed. |
| 2526 | * |
| 2527 | * <p class="note">This is a protected intent that can only be sent |
| 2528 | * by the system.</p> |
| 2529 | */ |
| 2530 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2531 | public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = |
| 2532 | "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; |
| 2533 | |
| 2534 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2535 | * Broadcast Action: An outgoing call is about to be placed. |
| 2536 | * |
Dirk Dougherty | 367ce90 | 2013-05-28 17:37:12 -0700 | [diff] [blame] | 2537 | * <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] | 2538 | * <ul> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2539 | * <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] | 2540 | * the phone number originally intended to be dialed.</li> |
| 2541 | * </ul> |
| 2542 | * <p>Once the broadcast is finished, the resultData is used as the actual |
| 2543 | * 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] | 2544 | * <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] | 2545 | * outgoing call in turn: for example, a parental control application |
| 2546 | * might verify that the user is authorized to place the call at that |
| 2547 | * time, then a number-rewriting application might add an area code if |
| 2548 | * one was not specified.</p> |
| 2549 | * <p>For consistency, any receiver whose purpose is to prohibit phone |
| 2550 | * calls should have a priority of 0, to ensure it will see the final |
| 2551 | * phone number to be dialed. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2552 | * 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] | 2553 | * should have a positive priority. |
| 2554 | * Negative priorities are reserved for the system for this broadcast; |
| 2555 | * using them may cause problems.</p> |
Dirk Dougherty | 932fbcc | 2013-05-29 15:19:14 -0700 | [diff] [blame] | 2556 | * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> |
| 2557 | * abort the broadcast.</p> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2558 | * <p>Emergency calls cannot be intercepted using this mechanism, and |
| 2559 | * other calls cannot be modified to call emergency numbers using this |
| 2560 | * mechanism. |
Santos Cordon | ba70136 | 2013-05-17 14:48:54 -0700 | [diff] [blame] | 2561 | * <p>Some apps (such as VoIP apps) may want to redirect the outgoing |
| 2562 | * call to use their own service instead. Those apps should first prevent |
| 2563 | * the call from being placed by setting resultData to <code>null</code> |
| 2564 | * 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] | 2565 | * <p>You must hold the |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2566 | * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} |
| 2567 | * permission to receive this Intent.</p> |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2568 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2569 | * <p class="note">This is a protected intent that can only be sent |
| 2570 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2571 | */ |
| 2572 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2573 | public static final String ACTION_NEW_OUTGOING_CALL = |
| 2574 | "android.intent.action.NEW_OUTGOING_CALL"; |
| 2575 | |
| 2576 | /** |
| 2577 | * Broadcast Action: Have the device reboot. This is only for use by |
| 2578 | * system code. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 2579 | * |
Dianne Hackborn | 854060af | 2009-07-09 18:14:31 -0700 | [diff] [blame] | 2580 | * <p class="note">This is a protected intent that can only be sent |
| 2581 | * by the system. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2582 | */ |
| 2583 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2584 | public static final String ACTION_REBOOT = |
| 2585 | "android.intent.action.REBOOT"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2586 | |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2587 | /** |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2588 | * Broadcast Action: A sticky broadcast for changes in the physical |
| 2589 | * docking state of the device. |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2590 | * |
| 2591 | * <p>The intent will have the following extra values: |
| 2592 | * <ul> |
| 2593 | * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2594 | * state, indicating which dock the device is physically in.</li> |
Tobias Haamel | 154f7a1 | 2010-02-17 11:56:39 -0800 | [diff] [blame] | 2595 | * </ul> |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 2596 | * <p>This is intended for monitoring the current physical dock state. |
| 2597 | * See {@link android.app.UiModeManager} for the normal API dealing with |
| 2598 | * dock mode changes. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2599 | */ |
| 2600 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2601 | public static final String ACTION_DOCK_EVENT = |
| 2602 | "android.intent.action.DOCK_EVENT"; |
| 2603 | |
| 2604 | /** |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2605 | * Broadcast Action: A broadcast when idle maintenance can be started. |
| 2606 | * This means that the user is not interacting with the device and is |
| 2607 | * not expected to do so soon. Typical use of the idle maintenance is |
| 2608 | * to perform somehow expensive tasks that can be postponed at a moment |
| 2609 | * when they will not degrade user experience. |
| 2610 | * <p> |
| 2611 | * <p class="note">In order to keep the device responsive in case of an |
| 2612 | * unexpected user interaction, implementations of a maintenance task |
| 2613 | * should be interruptible. In such a scenario a broadcast with action |
| 2614 | * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you |
| 2615 | * should not do the maintenance work in |
| 2616 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a |
| 2617 | * maintenance service by {@link Context#startService(Intent)}. Also |
| 2618 | * you should hold a wake lock while your maintenance service is running |
| 2619 | * to prevent the device going to sleep. |
| 2620 | * </p> |
| 2621 | * <p> |
| 2622 | * <p class="note">This is a protected intent that can only be sent by |
| 2623 | * the system. |
| 2624 | * </p> |
| 2625 | * |
| 2626 | * @see #ACTION_IDLE_MAINTENANCE_END |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2627 | * |
| 2628 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2629 | */ |
| 2630 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2631 | public static final String ACTION_IDLE_MAINTENANCE_START = |
| 2632 | "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; |
| 2633 | |
| 2634 | /** |
| 2635 | * Broadcast Action: A broadcast when idle maintenance should be stopped. |
| 2636 | * This means that the user was not interacting with the device as a result |
| 2637 | * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} |
| 2638 | * was sent and now the user started interacting with the device. Typical |
| 2639 | * use of the idle maintenance is to perform somehow expensive tasks that |
| 2640 | * can be postponed at a moment when they will not degrade user experience. |
| 2641 | * <p> |
| 2642 | * <p class="note">In order to keep the device responsive in case of an |
| 2643 | * unexpected user interaction, implementations of a maintenance task |
| 2644 | * should be interruptible. Hence, on receiving a broadcast with this |
| 2645 | * action, the maintenance task should be interrupted as soon as possible. |
| 2646 | * In other words, you should not do the maintenance work in |
| 2647 | * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the |
| 2648 | * maintenance service that was started on receiving of |
| 2649 | * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake |
| 2650 | * lock you acquired when your maintenance service started. |
| 2651 | * </p> |
| 2652 | * <p class="note">This is a protected intent that can only be sent |
| 2653 | * by the system. |
| 2654 | * |
| 2655 | * @see #ACTION_IDLE_MAINTENANCE_START |
Svetoslav | 6a08a12 | 2013-05-03 11:24:26 -0700 | [diff] [blame] | 2656 | * |
| 2657 | * @hide |
Svetoslav | b3038ec | 2013-02-13 14:39:30 -0800 | [diff] [blame] | 2658 | */ |
| 2659 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 2660 | public static final String ACTION_IDLE_MAINTENANCE_END = |
| 2661 | "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; |
| 2662 | |
| 2663 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2664 | * Broadcast Action: a remote intent is to be broadcasted. |
| 2665 | * |
| 2666 | * A remote intent is used for remote RPC between devices. The remote intent |
| 2667 | * is serialized and sent from one device to another device. The receiving |
| 2668 | * device parses the remote intent and broadcasts it. Note that anyone can |
| 2669 | * broadcast a remote intent. However, if the intent receiver of the remote intent |
| 2670 | * does not trust intent broadcasts from arbitrary intent senders, it should require |
| 2671 | * the sender to hold certain permissions so only trusted sender's broadcast will be |
| 2672 | * let through. |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 2673 | * @hide |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2674 | */ |
| 2675 | public static final String ACTION_REMOTE_INTENT = |
Costin Manolache | 8d83f9e | 2010-05-12 16:04:10 -0700 | [diff] [blame] | 2676 | "com.google.android.c2dm.intent.RECEIVE"; |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 2677 | |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 2678 | /** |
| 2679 | * Broadcast Action: hook for permforming cleanup after a system update. |
| 2680 | * |
| 2681 | * The broadcast is sent when the system is booting, before the |
| 2682 | * BOOT_COMPLETED broadcast. It is only sent to receivers in the system |
| 2683 | * image. A receiver for this should do its work and then disable itself |
| 2684 | * so that it does not get run again at the next boot. |
| 2685 | * @hide |
| 2686 | */ |
| 2687 | public static final String ACTION_PRE_BOOT_COMPLETED = |
| 2688 | "android.intent.action.PRE_BOOT_COMPLETED"; |
| 2689 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2690 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2691 | * Broadcast to a specific application to query any supported restrictions to impose |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 2692 | * on restricted users. The broadcast intent contains an extra |
| 2693 | * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted |
| 2694 | * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or |
| 2695 | * String[] depending on the restriction type.<p/> |
| 2696 | * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 2697 | * which is of type <code>ArrayList<RestrictionEntry></code>. It can also |
| 2698 | * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. |
| 2699 | * 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] | 2700 | * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. |
| 2701 | * The keys and values of the returned restrictions will be persisted. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 2702 | * @see RestrictionEntry |
| 2703 | */ |
| 2704 | public static final String ACTION_GET_RESTRICTION_ENTRIES = |
| 2705 | "android.intent.action.GET_RESTRICTION_ENTRIES"; |
| 2706 | |
| 2707 | /** |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2708 | * Sent the first time a user is starting, to allow system apps to |
| 2709 | * perform one time initialization. (This will not be seen by third |
| 2710 | * party applications because a newly initialized user does not have any |
| 2711 | * third party applications installed for it.) This is sent early in |
| 2712 | * starting the user, around the time the home app is started, before |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2713 | * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground |
| 2714 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2715 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2716 | */ |
| 2717 | public static final String ACTION_USER_INITIALIZE = |
| 2718 | "android.intent.action.USER_INITIALIZE"; |
| 2719 | |
| 2720 | /** |
| 2721 | * Sent when a user switch is happening, causing the process's user to be |
| 2722 | * brought to the foreground. This is only sent to receivers registered |
| 2723 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2724 | * 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] | 2725 | * foreground. This is sent as a foreground |
| 2726 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2727 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2728 | */ |
| 2729 | public static final String ACTION_USER_FOREGROUND = |
| 2730 | "android.intent.action.USER_FOREGROUND"; |
| 2731 | |
| 2732 | /** |
| 2733 | * Sent when a user switch is happening, causing the process's user to be |
| 2734 | * sent to the background. This is only sent to receivers registered |
| 2735 | * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) |
| 2736 | * 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] | 2737 | * background. This is sent as a foreground |
| 2738 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2739 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2740 | */ |
| 2741 | public static final String ACTION_USER_BACKGROUND = |
| 2742 | "android.intent.action.USER_BACKGROUND"; |
| 2743 | |
| 2744 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2745 | * Broadcast sent to the system when a user is added. Carries an extra |
| 2746 | * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to |
| 2747 | * all running users. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2748 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2749 | * @hide |
| 2750 | */ |
| 2751 | public static final String ACTION_USER_ADDED = |
| 2752 | "android.intent.action.USER_ADDED"; |
| 2753 | |
| 2754 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2755 | * Broadcast sent by the system when a user is started. Carries an extra |
| 2756 | * 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] | 2757 | * registered receivers, not manifest receivers. It is sent to the user |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2758 | * that has been started. This is sent as a foreground |
| 2759 | * broadcast, since it is part of a visible user interaction; be as quick |
| 2760 | * as possible when handling it. |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2761 | * @hide |
| 2762 | */ |
| 2763 | public static final String ACTION_USER_STARTED = |
| 2764 | "android.intent.action.USER_STARTED"; |
| 2765 | |
| 2766 | /** |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 2767 | * Broadcast sent when a user is in the process of starting. Carries an extra |
| 2768 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 2769 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 2770 | * users (including the one that is being started). You must hold |
| 2771 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 2772 | * this broadcast. This is sent as a background broadcast, since |
| 2773 | * its result is not part of the primary UX flow; to safely keep track of |
| 2774 | * started/stopped state of a user you can use this in conjunction with |
| 2775 | * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with |
| 2776 | * other user state broadcasts since those are foreground broadcasts so can |
| 2777 | * execute in a different order. |
| 2778 | * @hide |
| 2779 | */ |
| 2780 | public static final String ACTION_USER_STARTING = |
| 2781 | "android.intent.action.USER_STARTING"; |
| 2782 | |
| 2783 | /** |
| 2784 | * Broadcast sent when a user is going to be stopped. Carries an extra |
| 2785 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is only |
| 2786 | * sent to registered receivers, not manifest receivers. It is sent to all |
| 2787 | * users (including the one that is being stopped). You must hold |
| 2788 | * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive |
| 2789 | * this broadcast. The user will not stop until all receivers have |
| 2790 | * handled the broadcast. This is sent as a background broadcast, since |
| 2791 | * its result is not part of the primary UX flow; to safely keep track of |
| 2792 | * started/stopped state of a user you can use this in conjunction with |
| 2793 | * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with |
| 2794 | * other user state broadcasts since those are foreground broadcasts so can |
| 2795 | * execute in a different order. |
| 2796 | * @hide |
| 2797 | */ |
| 2798 | public static final String ACTION_USER_STOPPING = |
| 2799 | "android.intent.action.USER_STOPPING"; |
| 2800 | |
| 2801 | /** |
| 2802 | * Broadcast sent to the system when a user is stopped. Carries an extra |
| 2803 | * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to |
| 2804 | * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a |
| 2805 | * specific package. This is only sent to registered receivers, not manifest |
| 2806 | * receivers. It is sent to all running users <em>except</em> the one that |
| 2807 | * has just been stopped (which is no longer running). |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 2808 | * @hide |
| 2809 | */ |
| 2810 | public static final String ACTION_USER_STOPPED = |
| 2811 | "android.intent.action.USER_STOPPED"; |
| 2812 | |
| 2813 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 2814 | * 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] | 2815 | * 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] | 2816 | * one that has been removed. The user will not be completely removed until all receivers have |
| 2817 | * handled the broadcast. You must hold |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 2818 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2819 | * @hide |
| 2820 | */ |
| 2821 | public static final String ACTION_USER_REMOVED = |
| 2822 | "android.intent.action.USER_REMOVED"; |
| 2823 | |
| 2824 | /** |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 2825 | * 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] | 2826 | * the userHandle of the user to become the current one. This is only sent to |
| 2827 | * registered receivers, not manifest receivers. It is sent to all running users. |
| 2828 | * You must hold |
| 2829 | * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 2830 | * @hide |
| 2831 | */ |
| 2832 | public static final String ACTION_USER_SWITCHED = |
| 2833 | "android.intent.action.USER_SWITCHED"; |
| 2834 | |
Amith Yamasani | e928d7d | 2012-09-17 21:46:51 -0700 | [diff] [blame] | 2835 | /** |
| 2836 | * Broadcast sent to the system when a user's information changes. Carries an extra |
| 2837 | * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 2838 | * 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] | 2839 | * @hide |
| 2840 | */ |
| 2841 | public static final String ACTION_USER_INFO_CHANGED = |
| 2842 | "android.intent.action.USER_INFO_CHANGED"; |
| 2843 | |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 2844 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 2845 | * Broadcast sent to the primary user when an associated managed profile is added (the profile |
| 2846 | * 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] | 2847 | * the UserHandle of the profile that was added. Only applications (for example Launchers) |
| 2848 | * that need to display merged content across both primary and managed profiles need to |
| 2849 | * worry about this broadcast. This is only sent to registered receivers, |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 2850 | * not manifest receivers. |
| 2851 | */ |
| 2852 | public static final String ACTION_MANAGED_PROFILE_ADDED = |
| 2853 | "android.intent.action.MANAGED_PROFILE_ADDED"; |
| 2854 | |
| 2855 | /** |
| 2856 | * 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] | 2857 | * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. |
| 2858 | * Only applications (for example Launchers) that need to display merged content across both |
| 2859 | * primary and managed profiles need to worry about this broadcast. This is only sent to |
| 2860 | * registered receivers, not manifest receivers. |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 2861 | */ |
| 2862 | public static final String ACTION_MANAGED_PROFILE_REMOVED = |
| 2863 | "android.intent.action.MANAGED_PROFILE_REMOVED"; |
| 2864 | |
| 2865 | /** |
Daniel Sandler | 2e7d25b | 2012-10-01 16:43:26 -0400 | [diff] [blame] | 2866 | * Sent when the user taps on the clock widget in the system's "quick settings" area. |
| 2867 | */ |
| 2868 | public static final String ACTION_QUICK_CLOCK = |
| 2869 | "android.intent.action.QUICK_CLOCK"; |
| 2870 | |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 2871 | /** |
Alan Viverette | 5a39949 | 2014-07-14 16:19:38 -0700 | [diff] [blame] | 2872 | * Activity Action: Shows the brightness setting dialog. |
Michael Wright | 0087a14 | 2013-02-05 16:29:39 -0800 | [diff] [blame] | 2873 | * @hide |
| 2874 | */ |
| 2875 | public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = |
| 2876 | "android.intent.action.SHOW_BRIGHTNESS_DIALOG"; |
| 2877 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2878 | /** |
| 2879 | * Broadcast Action: A global button was pressed. Includes a single |
| 2880 | * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that |
| 2881 | * caused the broadcast. |
| 2882 | * @hide |
| 2883 | */ |
| 2884 | public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; |
| 2885 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2886 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2887 | * Activity Action: Allow the user to select and return one or more existing |
| 2888 | * documents. When invoked, the system will display the various |
| 2889 | * {@link DocumentsProvider} instances installed on the device, letting the |
| 2890 | * user interactively navigate through them. These documents include local |
| 2891 | * media, such as photos and video, and documents provided by installed |
| 2892 | * cloud storage providers. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2893 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2894 | * Each document is represented as a {@code content://} URI backed by a |
| 2895 | * {@link DocumentsProvider}, which can be opened as a stream with |
| 2896 | * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for |
| 2897 | * {@link android.provider.DocumentsContract.Document} metadata. |
| 2898 | * <p> |
| 2899 | * All selected documents are returned to the calling application with |
| 2900 | * persistable read and write permission grants. If you want to maintain |
| 2901 | * access to the documents across device reboots, you need to explicitly |
| 2902 | * take the persistable permissions using |
| 2903 | * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. |
| 2904 | * <p> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 2905 | * Callers must indicate the acceptable document MIME types through |
| 2906 | * {@link #setType(String)}. For example, to select photos, use |
| 2907 | * {@code image/*}. If multiple disjoint MIME types are acceptable, define |
| 2908 | * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to |
| 2909 | * {@literal *}/*. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2910 | * <p> |
| 2911 | * If the caller can handle multiple returned items (the user performing |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2912 | * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} |
| 2913 | * to indicate this. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2914 | * <p> |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 2915 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that |
| 2916 | * returned URIs can be opened with |
| 2917 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2918 | * <p> |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 2919 | * Output: The URI of the item that was picked, returned in |
| 2920 | * {@link #getData()}. This must be a {@code content://} URI so that any |
| 2921 | * receiver can access it. If multiple documents were selected, they are |
| 2922 | * returned in {@link #getClipData()}. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 2923 | * |
| 2924 | * @see DocumentsContract |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 2925 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2926 | * @see #ACTION_CREATE_DOCUMENT |
| 2927 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2928 | */ |
| 2929 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 2930 | public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; |
| 2931 | |
| 2932 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2933 | * Activity Action: Allow the user to create a new document. When invoked, |
| 2934 | * the system will display the various {@link DocumentsProvider} instances |
| 2935 | * installed on the device, letting the user navigate through them. The |
| 2936 | * returned document may be a newly created document with no content, or it |
| 2937 | * may be an existing document with the requested MIME type. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2938 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2939 | * Each document is represented as a {@code content://} URI backed by a |
| 2940 | * {@link DocumentsProvider}, which can be opened as a stream with |
| 2941 | * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for |
| 2942 | * {@link android.provider.DocumentsContract.Document} metadata. |
| 2943 | * <p> |
| 2944 | * Callers must indicate the concrete MIME type of the document being |
| 2945 | * created by setting {@link #setType(String)}. This MIME type cannot be |
| 2946 | * changed after the document is created. |
| 2947 | * <p> |
| 2948 | * Callers can provide an initial display name through {@link #EXTRA_TITLE}, |
| 2949 | * but the user may change this value before creating the file. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2950 | * <p> |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 2951 | * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that |
| 2952 | * returned URIs can be opened with |
| 2953 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2954 | * <p> |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2955 | * Output: The URI of the item that was created. This must be a |
| 2956 | * {@code content://} URI so that any receiver can access it. |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 2957 | * |
| 2958 | * @see DocumentsContract |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2959 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 2960 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 2961 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 2962 | */ |
| 2963 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 2964 | public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; |
| 2965 | |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 2966 | /** |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 2967 | * Activity Action: Allow the user to pick a directory subtree. When |
| 2968 | * invoked, the system will display the various {@link DocumentsProvider} |
| 2969 | * instances installed on the device, letting the user navigate through |
| 2970 | * them. Apps can fully manage documents within the returned directory. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 2971 | * <p> |
| 2972 | * To gain access to descendant (child, grandchild, etc) documents, use |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 2973 | * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and |
| 2974 | * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} |
| 2975 | * with the returned URI. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 2976 | * <p> |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 2977 | * Output: The URI representing the selected directory tree. |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 2978 | * |
| 2979 | * @see DocumentsContract |
| 2980 | */ |
| 2981 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 2982 | public static final String |
| 2983 | ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; |
Jeff Sharkey | 21de56a | 2014-04-05 19:05:24 -0700 | [diff] [blame] | 2984 | |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 2985 | /** {@hide} */ |
| 2986 | public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; |
| 2987 | |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 2988 | /** |
| 2989 | * Broadcast action: report that a settings element is being restored from backup. The intent |
| 2990 | * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting, |
| 2991 | * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE |
| 2992 | * is the value of that settings entry prior to the restore operation. All of these values are |
| 2993 | * represented as strings. |
| 2994 | * |
| 2995 | * <p>This broadcast is sent only for settings provider entries known to require special handling |
| 2996 | * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within |
| 2997 | * the provider's backup agent implementation. |
| 2998 | * |
| 2999 | * @see #EXTRA_SETTING_NAME |
| 3000 | * @see #EXTRA_SETTING_PREVIOUS_VALUE |
| 3001 | * @see #EXTRA_SETTING_NEW_VALUE |
| 3002 | * {@hide} |
| 3003 | */ |
| 3004 | public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; |
| 3005 | |
| 3006 | /** {@hide} */ |
| 3007 | public static final String EXTRA_SETTING_NAME = "setting_name"; |
| 3008 | /** {@hide} */ |
| 3009 | public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; |
| 3010 | /** {@hide} */ |
| 3011 | public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; |
| 3012 | |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3013 | /** |
| 3014 | * Activity Action: Process a piece of text. |
| 3015 | * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. |
| 3016 | * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> |
| 3017 | * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> |
| 3018 | */ |
| 3019 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3020 | public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; |
| 3021 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3022 | * The name of the extra used to define the text to be processed, as a |
| 3023 | * CharSequence. Note that this may be a styled CharSequence, so you must use |
| 3024 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. |
Clara Bayarri | 0a26157a | 2015-03-26 18:38:55 +0000 | [diff] [blame] | 3025 | */ |
| 3026 | public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; |
| 3027 | /** |
Clara Bayarri | 92c8e6f | 2015-05-21 17:50:08 +0100 | [diff] [blame] | 3028 | * 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] | 3029 | */ |
| 3030 | public static final String EXTRA_PROCESS_TEXT_READONLY = |
| 3031 | "android.intent.extra.PROCESS_TEXT_READONLY"; |
| 3032 | |
Bryce Lee | bc58f59 | 2015-09-25 16:43:01 -0700 | [diff] [blame] | 3033 | /** |
| 3034 | * Broadcast action: reports when a new thermal event has been reached. When the device |
| 3035 | * is reaching its maximum temperatue, the thermal level reported |
| 3036 | * {@hide} |
| 3037 | */ |
| 3038 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 3039 | public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; |
| 3040 | |
| 3041 | /** {@hide} */ |
| 3042 | public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; |
| 3043 | |
| 3044 | /** |
| 3045 | * Thermal state when the device is normal. This state is sent in the |
| 3046 | * {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}. |
| 3047 | * {@hide} |
| 3048 | */ |
| 3049 | public static final int EXTRA_THERMAL_STATE_NORMAL = 0; |
| 3050 | |
| 3051 | /** |
| 3052 | * Thermal state where the device is approaching its maximum threshold. This state is sent in |
| 3053 | * the {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}. |
| 3054 | * {@hide} |
| 3055 | */ |
| 3056 | public static final int EXTRA_THERMAL_STATE_WARNING = 1; |
| 3057 | |
| 3058 | /** |
| 3059 | * Thermal state where the device has reached its maximum threshold. This state is sent in the |
| 3060 | * {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}. |
| 3061 | * {@hide} |
| 3062 | */ |
| 3063 | public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; |
| 3064 | |
| 3065 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3066 | // --------------------------------------------------------------------- |
| 3067 | // --------------------------------------------------------------------- |
| 3068 | // Standard intent categories (see addCategory()). |
| 3069 | |
| 3070 | /** |
| 3071 | * Set if the activity should be an option for the default action |
| 3072 | * (center press) to perform on a piece of data. Setting this will |
| 3073 | * hide from the user any activities without it set when performing an |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3074 | * 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] | 3075 | * Intent when initiating an action -- it is for use in intent filters |
| 3076 | * specified in packages. |
| 3077 | */ |
| 3078 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3079 | public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; |
| 3080 | /** |
| 3081 | * Activities that can be safely invoked from a browser must support this |
| 3082 | * category. For example, if the user is viewing a web page or an e-mail |
| 3083 | * and clicks on a link in the text, the Intent generated execute that |
| 3084 | * link will require the BROWSABLE category, so that only activities |
| 3085 | * supporting this category will be considered as possible actions. By |
| 3086 | * supporting this category, you are promising that there is nothing |
| 3087 | * damaging (without user intervention) that can happen by invoking any |
| 3088 | * matching Intent. |
| 3089 | */ |
| 3090 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3091 | public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; |
| 3092 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3093 | * Categories for activities that can participate in voice interaction. |
| 3094 | * An activity that supports this category must be prepared to run with |
| 3095 | * no UI shown at all (though in some case it may have a UI shown), and |
| 3096 | * rely on {@link android.app.VoiceInteractor} to interact with the user. |
| 3097 | */ |
| 3098 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3099 | public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; |
| 3100 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3101 | * Set if the activity should be considered as an alternative action to |
| 3102 | * the data the user is currently viewing. See also |
| 3103 | * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that |
| 3104 | * applies to the selection in a list of items. |
| 3105 | * |
| 3106 | * <p>Supporting this category means that you would like your activity to be |
| 3107 | * displayed in the set of alternative things the user can do, usually as |
| 3108 | * part of the current activity's options menu. You will usually want to |
| 3109 | * include a specific label in the <intent-filter> of this action |
| 3110 | * describing to the user what it does. |
| 3111 | * |
| 3112 | * <p>The action of IntentFilter with this category is important in that it |
| 3113 | * describes the specific action the target will perform. This generally |
| 3114 | * should not be a generic action (such as {@link #ACTION_VIEW}, but rather |
| 3115 | * a specific name such as "com.android.camera.action.CROP. Only one |
| 3116 | * alternative of any particular action will be shown to the user, so using |
| 3117 | * a specific action like this makes sure that your alternative will be |
| 3118 | * displayed while also allowing other applications to provide their own |
| 3119 | * overrides of that particular action. |
| 3120 | */ |
| 3121 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3122 | public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; |
| 3123 | /** |
| 3124 | * Set if the activity should be considered as an alternative selection |
| 3125 | * action to the data the user has currently selected. This is like |
| 3126 | * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list |
| 3127 | * of items from which the user can select, giving them alternatives to the |
| 3128 | * default action that will be performed on it. |
| 3129 | */ |
| 3130 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3131 | public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; |
| 3132 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3133 | * 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] | 3134 | */ |
| 3135 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3136 | public static final String CATEGORY_TAB = "android.intent.category.TAB"; |
| 3137 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3138 | * Should be displayed in the top-level launcher. |
| 3139 | */ |
| 3140 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3141 | public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; |
| 3142 | /** |
Jose Lima | 38b75b6 | 2014-03-11 10:41:39 -0700 | [diff] [blame] | 3143 | * Indicates an activity optimized for Leanback mode, and that should |
| 3144 | * be displayed in the Leanback launcher. |
| 3145 | */ |
| 3146 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3147 | public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; |
| 3148 | /** |
Jose Lima | 73915cf | 2014-07-29 17:16:31 -0700 | [diff] [blame] | 3149 | * Indicates a Leanback settings activity to be displayed in the Leanback launcher. |
| 3150 | * @hide |
| 3151 | */ |
| 3152 | @SystemApi |
| 3153 | public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; |
| 3154 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3155 | * Provides information about the package it is in; typically used if |
| 3156 | * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide |
| 3157 | * a front-door to the user without having to be shown in the all apps list. |
| 3158 | */ |
| 3159 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3160 | public static final String CATEGORY_INFO = "android.intent.category.INFO"; |
| 3161 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3162 | * This is the home activity, that is the first activity that is displayed |
| 3163 | * when the device boots. |
| 3164 | */ |
| 3165 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3166 | public static final String CATEGORY_HOME = "android.intent.category.HOME"; |
| 3167 | /** |
Anthony Hugh | 979b81a | 2015-09-29 16:50:35 -0700 | [diff] [blame] | 3168 | * This is the home activity that is displayed when the device is finished setting up and ready |
| 3169 | * for use. |
| 3170 | * @hide |
| 3171 | */ |
| 3172 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3173 | public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; |
| 3174 | /** |
Svet Ganov | 50a8bf4 | 2015-07-15 11:04:18 -0700 | [diff] [blame] | 3175 | * This is the setup wizard activity, that is the first activity that is displayed |
| 3176 | * when the user sets up the device for the first time. |
| 3177 | * @hide |
| 3178 | */ |
| 3179 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3180 | public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; |
| 3181 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3182 | * This activity is a preference panel. |
| 3183 | */ |
| 3184 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3185 | public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; |
| 3186 | /** |
| 3187 | * This activity is a development preference panel. |
| 3188 | */ |
| 3189 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3190 | public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; |
| 3191 | /** |
| 3192 | * Capable of running inside a parent activity container. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3193 | */ |
| 3194 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3195 | public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; |
| 3196 | /** |
Patrick Dubroy | 6dabe24 | 2010-08-30 10:43:47 -0700 | [diff] [blame] | 3197 | * This activity allows the user to browse and download new applications. |
| 3198 | */ |
| 3199 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3200 | public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; |
| 3201 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3202 | * This activity may be exercised by the monkey or other automated test tools. |
| 3203 | */ |
| 3204 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3205 | public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; |
| 3206 | /** |
| 3207 | * To be used as a test (not part of the normal user experience). |
| 3208 | */ |
| 3209 | public static final String CATEGORY_TEST = "android.intent.category.TEST"; |
| 3210 | /** |
| 3211 | * To be used as a unit test (run through the Test Harness). |
| 3212 | */ |
| 3213 | public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; |
| 3214 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3215 | * 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] | 3216 | * experience). |
| 3217 | */ |
| 3218 | public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3219 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3220 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3221 | * Used to indicate that an intent only wants URIs that can be opened with |
| 3222 | * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs |
| 3223 | * must support at least the columns defined in {@link OpenableColumns} when |
| 3224 | * queried. |
| 3225 | * |
| 3226 | * @see #ACTION_GET_CONTENT |
| 3227 | * @see #ACTION_OPEN_DOCUMENT |
| 3228 | * @see #ACTION_CREATE_DOCUMENT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3229 | */ |
| 3230 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3231 | public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; |
| 3232 | |
| 3233 | /** |
| 3234 | * To be used as code under test for framework instrumentation tests. |
| 3235 | */ |
| 3236 | public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = |
| 3237 | "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3238 | /** |
| 3239 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3240 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3241 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3242 | */ |
| 3243 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3244 | public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; |
| 3245 | /** |
| 3246 | * An activity to run when device is inserted into a car dock. |
Dianne Hackborn | 7299c41 | 2010-03-04 18:41:49 -0800 | [diff] [blame] | 3247 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3248 | * information, see {@link android.app.UiModeManager}. |
Mike Lockwood | 9092ab4 | 2009-09-16 13:01:32 -0400 | [diff] [blame] | 3249 | */ |
| 3250 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3251 | public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 3252 | /** |
| 3253 | * An activity to run when device is inserted into a analog (low end) dock. |
| 3254 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3255 | * information, see {@link android.app.UiModeManager}. |
| 3256 | */ |
| 3257 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3258 | public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; |
| 3259 | |
| 3260 | /** |
| 3261 | * An activity to run when device is inserted into a digital (high end) dock. |
| 3262 | * Used with {@link #ACTION_MAIN} to launch an activity. For more |
| 3263 | * information, see {@link android.app.UiModeManager}. |
| 3264 | */ |
| 3265 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3266 | 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] | 3267 | |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 3268 | /** |
| 3269 | * Used to indicate that the activity can be used in a car environment. |
| 3270 | */ |
| 3271 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3272 | public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; |
| 3273 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3274 | // --------------------------------------------------------------------- |
| 3275 | // --------------------------------------------------------------------- |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3276 | // Application launch intent categories (see addCategory()). |
| 3277 | |
| 3278 | /** |
| 3279 | * Used with {@link #ACTION_MAIN} to launch the browser application. |
| 3280 | * The activity should be able to browse the Internet. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3281 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3282 | * since it will not result in the app launching with the correct |
| 3283 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3284 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3285 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3286 | */ |
| 3287 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3288 | public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; |
| 3289 | |
| 3290 | /** |
| 3291 | * Used with {@link #ACTION_MAIN} to launch the calculator application. |
| 3292 | * The activity should be able to perform standard arithmetic operations. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3293 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3294 | * since it will not result in the app launching with the correct |
| 3295 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3296 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3297 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3298 | */ |
| 3299 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3300 | public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; |
| 3301 | |
| 3302 | /** |
| 3303 | * Used with {@link #ACTION_MAIN} to launch the calendar application. |
| 3304 | * The activity should be able to view and manipulate calendar entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3305 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3306 | * since it will not result in the app launching with the correct |
| 3307 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3308 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3309 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3310 | */ |
| 3311 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3312 | public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; |
| 3313 | |
| 3314 | /** |
| 3315 | * Used with {@link #ACTION_MAIN} to launch the contacts application. |
| 3316 | * The activity should be able to view and manipulate address book entries. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3317 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3318 | * since it will not result in the app launching with the correct |
| 3319 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3320 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3321 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3322 | */ |
| 3323 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3324 | public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; |
| 3325 | |
| 3326 | /** |
| 3327 | * Used with {@link #ACTION_MAIN} to launch the email application. |
| 3328 | * The activity should be able to send and receive email. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3329 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3330 | * since it will not result in the app launching with the correct |
| 3331 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3332 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3333 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3334 | */ |
| 3335 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3336 | public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; |
| 3337 | |
| 3338 | /** |
| 3339 | * Used with {@link #ACTION_MAIN} to launch the gallery application. |
| 3340 | * The activity should be able to view and manipulate image and video files |
| 3341 | * stored on the device. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3342 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3343 | * since it will not result in the app launching with the correct |
| 3344 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3345 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3346 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3347 | */ |
| 3348 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3349 | public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; |
| 3350 | |
| 3351 | /** |
| 3352 | * Used with {@link #ACTION_MAIN} to launch the maps application. |
| 3353 | * 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] | 3354 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3355 | * since it will not result in the app launching with the correct |
| 3356 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3357 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3358 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3359 | */ |
| 3360 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3361 | public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; |
| 3362 | |
| 3363 | /** |
| 3364 | * Used with {@link #ACTION_MAIN} to launch the messaging application. |
| 3365 | * The activity should be able to send and receive text messages. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3366 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3367 | * since it will not result in the app launching with the correct |
| 3368 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3369 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3370 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3371 | */ |
| 3372 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3373 | public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; |
| 3374 | |
| 3375 | /** |
| 3376 | * Used with {@link #ACTION_MAIN} to launch the music application. |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3377 | * The activity should be able to play, browse, or manipulate music files |
| 3378 | * stored on the device. |
| 3379 | * <p>NOTE: This should not be used as the primary key of an Intent, |
| 3380 | * since it will not result in the app launching with the correct |
| 3381 | * action and category. Instead, use this with |
Dianne Hackborn | 251fe26 | 2011-12-14 17:20:54 -0800 | [diff] [blame] | 3382 | * {@link #makeMainSelectorActivity(String, String)} to generate a main |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3383 | * Intent with this category in the selector.</p> |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3384 | */ |
| 3385 | @SdkConstant(SdkConstantType.INTENT_CATEGORY) |
| 3386 | public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; |
| 3387 | |
| 3388 | // --------------------------------------------------------------------- |
| 3389 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3390 | // Standard extra data keys. |
| 3391 | |
| 3392 | /** |
| 3393 | * The initial data to place in a newly created record. Use with |
| 3394 | * {@link #ACTION_INSERT}. The data here is a Map containing the same |
| 3395 | * fields as would be given to the underlying ContentProvider.insert() |
| 3396 | * call. |
| 3397 | */ |
| 3398 | public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; |
| 3399 | |
| 3400 | /** |
| 3401 | * A constant CharSequence that is associated with the Intent, used with |
| 3402 | * {@link #ACTION_SEND} to supply the literal data to be sent. Note that |
| 3403 | * this may be a styled CharSequence, so you must use |
| 3404 | * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to |
| 3405 | * retrieve it. |
| 3406 | */ |
| 3407 | public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; |
| 3408 | |
| 3409 | /** |
Dianne Hackborn | acb69bb | 2012-04-13 15:36:06 -0700 | [diff] [blame] | 3410 | * A constant String that is associated with the Intent, used with |
| 3411 | * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} |
| 3412 | * as HTML formatted text. Note that you <em>must</em> also supply |
| 3413 | * {@link #EXTRA_TEXT}. |
| 3414 | */ |
| 3415 | public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; |
| 3416 | |
| 3417 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3418 | * A content: URI holding a stream of data associated with the Intent, |
| 3419 | * used with {@link #ACTION_SEND} to supply the data being sent. |
| 3420 | */ |
| 3421 | public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; |
| 3422 | |
| 3423 | /** |
| 3424 | * A String[] holding e-mail addresses that should be delivered to. |
| 3425 | */ |
| 3426 | public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; |
| 3427 | |
| 3428 | /** |
| 3429 | * A String[] holding e-mail addresses that should be carbon copied. |
| 3430 | */ |
| 3431 | public static final String EXTRA_CC = "android.intent.extra.CC"; |
| 3432 | |
| 3433 | /** |
| 3434 | * A String[] holding e-mail addresses that should be blind carbon copied. |
| 3435 | */ |
| 3436 | public static final String EXTRA_BCC = "android.intent.extra.BCC"; |
| 3437 | |
| 3438 | /** |
| 3439 | * A constant string holding the desired subject line of a message. |
| 3440 | */ |
| 3441 | public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; |
| 3442 | |
| 3443 | /** |
| 3444 | * An Intent describing the choices you would like shown with |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3445 | * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3446 | */ |
| 3447 | public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; |
| 3448 | |
| 3449 | /** |
Adam Powell | 2ed547e | 2015-04-29 18:45:04 -0700 | [diff] [blame] | 3450 | * An Intent[] describing additional, alternate choices you would like shown with |
| 3451 | * {@link #ACTION_CHOOSER}. |
| 3452 | * |
| 3453 | * <p>An app may be capable of providing several different payload types to complete a |
| 3454 | * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos |
| 3455 | * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer |
| 3456 | * several different supported sending mechanisms for sharing, such as the actual "image/*" |
| 3457 | * photo data or a hosted link where the photos can be viewed.</p> |
| 3458 | * |
| 3459 | * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the |
| 3460 | * first/primary/preferred intent in the set. Additional intents specified in |
| 3461 | * this extra are ordered; by default intents that appear earlier in the array will be |
| 3462 | * preferred over intents that appear later in the array as matches for the same |
| 3463 | * target component. To alter this preference, a calling app may also supply |
| 3464 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> |
| 3465 | */ |
| 3466 | public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; |
| 3467 | |
| 3468 | /** |
| 3469 | * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection |
| 3470 | * from the chooser activity presented by {@link #ACTION_CHOOSER}. |
| 3471 | * |
| 3472 | * <p>An app preparing an action for another app to complete may wish to allow the user to |
| 3473 | * disambiguate between several options for completing the action based on the chosen target |
| 3474 | * or otherwise refine the action before it is invoked. |
| 3475 | * </p> |
| 3476 | * |
| 3477 | * <p>When sent, this IntentSender may be filled in with the following extras:</p> |
| 3478 | * <ul> |
| 3479 | * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> |
| 3480 | * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's |
| 3481 | * chosen target beyond the first</li> |
| 3482 | * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity |
| 3483 | * should fill in and send once the disambiguation is complete</li> |
| 3484 | * </ul> |
| 3485 | */ |
| 3486 | public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER |
| 3487 | = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; |
| 3488 | |
| 3489 | /** |
| 3490 | * A {@link ResultReceiver} used to return data back to the sender. |
| 3491 | * |
| 3492 | * <p>Used to complete an app-specific |
| 3493 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> |
| 3494 | * |
| 3495 | * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent |
| 3496 | * used to start a {@link #ACTION_CHOOSER} activity this extra will be |
| 3497 | * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent |
| 3498 | * when the user selects a target component from the chooser. It is up to the recipient |
| 3499 | * to send a result to this ResultReceiver to signal that disambiguation is complete |
| 3500 | * and that the chooser should invoke the user's choice.</p> |
| 3501 | * |
| 3502 | * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent |
| 3503 | * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser |
| 3504 | * to match and fill in the final Intent or ChooserTarget before starting it. |
| 3505 | * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from |
| 3506 | * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to |
| 3507 | * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> |
| 3508 | * |
| 3509 | * <p>The result code passed to the ResultReceiver should be |
| 3510 | * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's |
| 3511 | * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if |
| 3512 | * the chooser should finish without starting a target.</p> |
| 3513 | */ |
| 3514 | public static final String EXTRA_RESULT_RECEIVER |
| 3515 | = "android.intent.extra.RESULT_RECEIVER"; |
| 3516 | |
| 3517 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3518 | * 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] | 3519 | * {@link #ACTION_CHOOSER}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3520 | */ |
| 3521 | public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; |
| 3522 | |
| 3523 | /** |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 3524 | * A Parcelable[] of {@link Intent} or |
| 3525 | * {@link android.content.pm.LabeledIntent} objects as set with |
| 3526 | * {@link #putExtra(String, Parcelable[])} of additional activities to place |
| 3527 | * a the front of the list of choices, when shown to the user with a |
| 3528 | * {@link #ACTION_CHOOSER}. |
| 3529 | */ |
| 3530 | public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; |
| 3531 | |
| 3532 | /** |
Adam Powell | e49d939 | 2014-07-17 18:45:19 -0700 | [diff] [blame] | 3533 | * A Bundle forming a mapping of potential target package names to different extras Bundles |
| 3534 | * to add to the default intent extras in {@link #EXTRA_INTENT} when used with |
| 3535 | * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not |
| 3536 | * be currently installed on the device. |
| 3537 | * |
| 3538 | * <p>An application may choose to provide alternate extras for the case where a user |
| 3539 | * selects an activity from a predetermined set of target packages. If the activity |
| 3540 | * the user selects from the chooser belongs to a package with its package name as |
| 3541 | * a key in this bundle, the corresponding extras for that package will be merged with |
| 3542 | * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement |
| 3543 | * extra has the same key as an extra already present in the intent it will overwrite |
| 3544 | * the extra from the intent.</p> |
| 3545 | * |
| 3546 | * <p><em>Examples:</em> |
| 3547 | * <ul> |
| 3548 | * <li>An application may offer different {@link #EXTRA_TEXT} to an application |
| 3549 | * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query |
| 3550 | * parameters for that target.</li> |
| 3551 | * <li>An application may offer additional metadata for known targets of a given intent |
| 3552 | * to pass along information only relevant to that target such as account or content |
| 3553 | * identifiers already known to that application.</li> |
| 3554 | * </ul></p> |
| 3555 | */ |
| 3556 | public static final String EXTRA_REPLACEMENT_EXTRAS = |
| 3557 | "android.intent.extra.REPLACEMENT_EXTRAS"; |
| 3558 | |
| 3559 | /** |
Adam Powell | 0b3c112 | 2014-10-09 12:50:14 -0700 | [diff] [blame] | 3560 | * An {@link IntentSender} that will be notified if a user successfully chooses a target |
| 3561 | * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender |
| 3562 | * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the |
| 3563 | * {@link ComponentName} of the chosen component. |
| 3564 | * |
| 3565 | * <p>In some situations this callback may never come, for example if the user abandons |
| 3566 | * the chooser, switches to another task or any number of other reasons. Apps should not |
| 3567 | * be written assuming that this callback will always occur.</p> |
| 3568 | */ |
| 3569 | public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = |
| 3570 | "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; |
| 3571 | |
| 3572 | /** |
| 3573 | * The {@link ComponentName} chosen by the user to complete an action. |
| 3574 | * |
| 3575 | * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER |
| 3576 | */ |
| 3577 | public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; |
| 3578 | |
| 3579 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3580 | * A {@link android.view.KeyEvent} object containing the event that |
| 3581 | * triggered the creation of the Intent it is in. |
| 3582 | */ |
| 3583 | public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; |
| 3584 | |
| 3585 | /** |
Mike Lockwood | bad80e0 | 2009-07-30 01:21:08 -0700 | [diff] [blame] | 3586 | * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user |
| 3587 | * before shutting down. |
| 3588 | * |
| 3589 | * {@hide} |
| 3590 | */ |
| 3591 | public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; |
| 3592 | |
| 3593 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3594 | * 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] | 3595 | * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action |
| 3596 | * of restarting the application. |
| 3597 | */ |
| 3598 | public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; |
| 3599 | |
| 3600 | /** |
| 3601 | * A String holding the phone number originally entered in |
| 3602 | * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual |
| 3603 | * number to call in a {@link android.content.Intent#ACTION_CALL}. |
| 3604 | */ |
| 3605 | public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; |
Bernd Holzhey | aea4b67 | 2010-03-31 09:46:13 +0200 | [diff] [blame] | 3606 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3607 | /** |
| 3608 | * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} |
| 3609 | * intents to supply the uid the package had been assigned. Also an optional |
| 3610 | * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or |
| 3611 | * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same |
| 3612 | * purpose. |
| 3613 | */ |
| 3614 | public static final String EXTRA_UID = "android.intent.extra.UID"; |
| 3615 | |
| 3616 | /** |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 3617 | * @hide String array of package names. |
| 3618 | */ |
Soonil Nagarkar | 0e8fd09 | 2015-02-10 10:37:36 -0800 | [diff] [blame] | 3619 | @SystemApi |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 3620 | public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; |
| 3621 | |
| 3622 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3623 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 3624 | * intents to indicate whether this represents a full uninstall (removing |
| 3625 | * both the code and its data) or a partial uninstall (leaving its data, |
| 3626 | * implying that this is an update). |
| 3627 | */ |
| 3628 | 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] | 3629 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3630 | /** |
Dianne Hackborn | c72fc67 | 2012-09-20 13:12:03 -0700 | [diff] [blame] | 3631 | * @hide |
| 3632 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 3633 | * intents to indicate that at this point the package has been removed for |
| 3634 | * all users on the device. |
| 3635 | */ |
| 3636 | public static final String EXTRA_REMOVED_FOR_ALL_USERS |
| 3637 | = "android.intent.extra.REMOVED_FOR_ALL_USERS"; |
| 3638 | |
| 3639 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3640 | * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} |
| 3641 | * intents to indicate that this is a replacement of the package, so this |
| 3642 | * broadcast will immediately be followed by an add broadcast for a |
| 3643 | * different version of the same package. |
| 3644 | */ |
| 3645 | 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] | 3646 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3647 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3648 | * Used as an int extra field in {@link android.app.AlarmManager} intents |
| 3649 | * to tell the application being invoked how many pending alarms are being |
| 3650 | * delievered with the intent. For one-shot alarms this will always be 1. |
| 3651 | * For recurring alarms, this might be greater than 1 if the device was |
| 3652 | * asleep or powered off at the time an earlier alarm would have been |
| 3653 | * delivered. |
| 3654 | */ |
| 3655 | public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 3656 | |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 3657 | /** |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 3658 | * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} |
| 3659 | * intents to request the dock state. Possible values are |
Mike Lockwood | 725fcbf | 2009-08-24 13:09:20 -0700 | [diff] [blame] | 3660 | * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, |
| 3661 | * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 3662 | * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or |
| 3663 | * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or |
| 3664 | * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 3665 | */ |
| 3666 | public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; |
| 3667 | |
| 3668 | /** |
| 3669 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 3670 | * to represent that the phone is not in any dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 3671 | */ |
| 3672 | public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; |
| 3673 | |
| 3674 | /** |
| 3675 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 3676 | * to represent that the phone is in a desk dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 3677 | */ |
| 3678 | public static final int EXTRA_DOCK_STATE_DESK = 1; |
| 3679 | |
| 3680 | /** |
| 3681 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 3682 | * to represent that the phone is in a car dock. |
Dan Murphy | c9f4eaf | 2009-08-12 15:15:43 -0500 | [diff] [blame] | 3683 | */ |
| 3684 | public static final int EXTRA_DOCK_STATE_CAR = 2; |
| 3685 | |
| 3686 | /** |
Praveen Bharathi | 21e941b | 2010-10-06 15:23:14 -0500 | [diff] [blame] | 3687 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 3688 | * to represent that the phone is in a analog (low end) dock. |
| 3689 | */ |
| 3690 | public static final int EXTRA_DOCK_STATE_LE_DESK = 3; |
| 3691 | |
| 3692 | /** |
| 3693 | * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} |
| 3694 | * to represent that the phone is in a digital (high end) dock. |
| 3695 | */ |
| 3696 | public static final int EXTRA_DOCK_STATE_HE_DESK = 4; |
| 3697 | |
| 3698 | /** |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 3699 | * Boolean that can be supplied as meta-data with a dock activity, to |
| 3700 | * indicate that the dock should take over the home key when it is active. |
| 3701 | */ |
| 3702 | public static final String METADATA_DOCK_HOME = "android.dock_home"; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 3703 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 3704 | /** |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 3705 | * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing |
| 3706 | * the bug report. |
Jacek Surazski | 86b6c53 | 2009-05-13 14:38:28 +0200 | [diff] [blame] | 3707 | */ |
| 3708 | public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; |
| 3709 | |
| 3710 | /** |
Wei Huang | 97ecc9c | 2009-05-11 17:44:20 -0700 | [diff] [blame] | 3711 | * Used in the extra field in the remote intent. It's astring token passed with the |
| 3712 | * remote intent. |
| 3713 | */ |
| 3714 | public static final String EXTRA_REMOTE_INTENT_TOKEN = |
| 3715 | "android.intent.extra.remote_intent_token"; |
| 3716 | |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 3717 | /** |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 3718 | * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 3719 | * will contain only the first name in the list. |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 3720 | */ |
Dianne Hackborn | 1d62ea9 | 2009-11-17 12:49:50 -0800 | [diff] [blame] | 3721 | @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = |
Suchi Amalapurapu | 0214e94 | 2009-09-02 11:03:18 -0700 | [diff] [blame] | 3722 | "android.intent.extra.changed_component_name"; |
| 3723 | |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 3724 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 3725 | * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, |
Dianne Hackborn | fd7aded | 2013-01-22 17:10:23 -0800 | [diff] [blame] | 3726 | * and contains a string array of all of the components that have changed. If |
| 3727 | * the state of the overall package has changed, then it will contain an entry |
| 3728 | * with the package name itself. |
Dianne Hackborn | 86a72da | 2009-11-11 20:12:41 -0800 | [diff] [blame] | 3729 | */ |
| 3730 | public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = |
| 3731 | "android.intent.extra.changed_component_name_list"; |
| 3732 | |
| 3733 | /** |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 3734 | * This field is part of |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 3735 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
| 3736 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 3737 | * 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] | 3738 | */ |
| 3739 | public static final String EXTRA_CHANGED_PACKAGE_LIST = |
| 3740 | "android.intent.extra.changed_package_list"; |
| 3741 | |
| 3742 | /** |
| 3743 | * This field is part of |
Suchi Amalapurapu | b56ae20 | 2010-02-04 22:51:07 -0800 | [diff] [blame] | 3744 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, |
| 3745 | * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 3746 | * and contains an integer array of uids of all of the components |
| 3747 | * that have changed. |
Suchi Amalapurapu | 08675a3 | 2010-01-28 09:57:30 -0800 | [diff] [blame] | 3748 | */ |
| 3749 | public static final String EXTRA_CHANGED_UID_LIST = |
| 3750 | "android.intent.extra.changed_uid_list"; |
| 3751 | |
| 3752 | /** |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 3753 | * @hide |
| 3754 | * Magic extra system code can use when binding, to give a label for |
| 3755 | * who it is that has bound to a service. This is an integer giving |
| 3756 | * a framework string resource that can be displayed to the user. |
| 3757 | */ |
| 3758 | public static final String EXTRA_CLIENT_LABEL = |
| 3759 | "android.intent.extra.client_label"; |
| 3760 | |
| 3761 | /** |
| 3762 | * @hide |
| 3763 | * Magic extra system code can use when binding, to give a PendingIntent object |
| 3764 | * that can be launched for the user to disable the system's use of this |
| 3765 | * service. |
| 3766 | */ |
| 3767 | public static final String EXTRA_CLIENT_INTENT = |
| 3768 | "android.intent.extra.client_intent"; |
| 3769 | |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 3770 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3771 | * Extra used to indicate that an intent should only return data that is on |
| 3772 | * the local device. This is a boolean extra; the default is false. If true, |
| 3773 | * an implementation should only allow the user to select data that is |
| 3774 | * already on the device, not requiring it be downloaded from a remote |
| 3775 | * service when opened. |
| 3776 | * |
| 3777 | * @see #ACTION_GET_CONTENT |
| 3778 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | b9fbb72 | 2014-06-04 16:42:47 -0700 | [diff] [blame] | 3779 | * @see #ACTION_OPEN_DOCUMENT_TREE |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3780 | * @see #ACTION_CREATE_DOCUMENT |
Dianne Hackborn | c4d0e6f | 2011-01-25 14:55:06 -0800 | [diff] [blame] | 3781 | */ |
| 3782 | public static final String EXTRA_LOCAL_ONLY = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3783 | "android.intent.extra.LOCAL_ONLY"; |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 3784 | |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3785 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3786 | * Extra used to indicate that an intent can allow the user to select and |
| 3787 | * return multiple items. This is a boolean extra; the default is false. If |
| 3788 | * true, an implementation is allowed to present the user with a UI where |
| 3789 | * they can pick multiple items that are all returned to the caller. When |
| 3790 | * this happens, they should be returned as the {@link #getClipData()} part |
| 3791 | * of the result Intent. |
| 3792 | * |
| 3793 | * @see #ACTION_GET_CONTENT |
| 3794 | * @see #ACTION_OPEN_DOCUMENT |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 3795 | */ |
| 3796 | public static final String EXTRA_ALLOW_MULTIPLE = |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3797 | "android.intent.extra.ALLOW_MULTIPLE"; |
Dianne Hackborn | fdb3f09 | 2013-01-28 15:10:48 -0800 | [diff] [blame] | 3798 | |
| 3799 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3800 | * The integer userHandle carried with broadcast intents related to addition, removal and |
| 3801 | * switching of users and managed profiles - {@link #ACTION_USER_ADDED}, |
| 3802 | * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. |
| 3803 | * |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 3804 | * @hide |
| 3805 | */ |
Amith Yamasani | 2a00329 | 2012-08-14 18:25:45 -0700 | [diff] [blame] | 3806 | public static final String EXTRA_USER_HANDLE = |
| 3807 | "android.intent.extra.user_handle"; |
Jean-Michel Trivi | 3114ce3 | 2012-06-11 15:03:52 -0700 | [diff] [blame] | 3808 | |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 3809 | /** |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3810 | * The UserHandle carried with broadcasts intents related to addition and removal of managed |
| 3811 | * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}. |
| 3812 | */ |
| 3813 | public static final String EXTRA_USER = |
Alexandra Gherghina | 3315f6b | 2014-09-05 15:48:06 +0100 | [diff] [blame] | 3814 | "android.intent.extra.USER"; |
Alexandra Gherghina | c17d7e0 | 2014-04-04 16:27:28 +0100 | [diff] [blame] | 3815 | |
| 3816 | /** |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 3817 | * Extra used in the response from a BroadcastReceiver that handles |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 3818 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is |
| 3819 | * <code>ArrayList<RestrictionEntry></code>. |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 3820 | */ |
Amith Yamasani | 7e99bc0 | 2013-04-16 18:24:51 -0700 | [diff] [blame] | 3821 | public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; |
| 3822 | |
| 3823 | /** |
| 3824 | * Extra sent in the intent to the BroadcastReceiver that handles |
| 3825 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing |
| 3826 | * the restrictions as key/value pairs. |
| 3827 | */ |
| 3828 | public static final String EXTRA_RESTRICTIONS_BUNDLE = |
| 3829 | "android.intent.extra.restrictions_bundle"; |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 3830 | |
Amith Yamasani | 86118ba | 2013-03-28 14:33:16 -0700 | [diff] [blame] | 3831 | /** |
| 3832 | * Extra used in the response from a BroadcastReceiver that handles |
| 3833 | * {@link #ACTION_GET_RESTRICTION_ENTRIES}. |
| 3834 | */ |
| 3835 | public static final String EXTRA_RESTRICTIONS_INTENT = |
| 3836 | "android.intent.extra.restrictions_intent"; |
| 3837 | |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3838 | /** |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3839 | * Extra used to communicate a set of acceptable MIME types. The type of the |
| 3840 | * extra is {@code String[]}. Values may be a combination of concrete MIME |
| 3841 | * types (such as "image/png") and/or partial MIME types (such as |
| 3842 | * "audio/*"). |
| 3843 | * |
| 3844 | * @see #ACTION_GET_CONTENT |
| 3845 | * @see #ACTION_OPEN_DOCUMENT |
Jeff Sharkey | 9ecfee0 | 2013-04-19 14:05:03 -0700 | [diff] [blame] | 3846 | */ |
| 3847 | public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; |
| 3848 | |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 3849 | /** |
| 3850 | * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that |
| 3851 | * 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] | 3852 | * When this is true, hardware devices can use this information to determine that |
| 3853 | * they shouldn't do a complete shutdown of their device since this is not a |
| 3854 | * complete shutdown down to the kernel, but only user space restarting. |
| 3855 | * The default if not supplied is false. |
Dianne Hackborn | 57a7f59 | 2013-07-22 18:21:32 -0700 | [diff] [blame] | 3856 | */ |
| 3857 | public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY |
| 3858 | = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; |
| 3859 | |
Narayan Kamath | ccb2a086 | 2013-12-19 14:49:36 +0000 | [diff] [blame] | 3860 | /** |
| 3861 | * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the |
| 3862 | * user has set their time format preferences to the 24 hour format. |
| 3863 | * |
| 3864 | * @hide for internal use only. |
| 3865 | */ |
| 3866 | public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = |
| 3867 | "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; |
| 3868 | |
Jeff Sharkey | 004a4b2 | 2014-09-24 11:45:24 -0700 | [diff] [blame] | 3869 | /** {@hide} */ |
| 3870 | public static final String EXTRA_REASON = "android.intent.extra.REASON"; |
| 3871 | |
Rubin Xu | e8490f1 | 2015-06-25 12:17:48 +0100 | [diff] [blame] | 3872 | /** {@hide} */ |
| 3873 | public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; |
| 3874 | |
Santos Cordon | 15a1378 | 2015-03-31 18:32:31 -0700 | [diff] [blame] | 3875 | /** |
| 3876 | * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM |
| 3877 | * activation request. |
| 3878 | * TODO: Add information about the structure and response data used with the pending intent. |
| 3879 | * @hide |
| 3880 | */ |
| 3881 | public static final String EXTRA_SIM_ACTIVATION_RESPONSE = |
| 3882 | "android.intent.extra.SIM_ACTIVATION_RESPONSE"; |
| 3883 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3884 | // --------------------------------------------------------------------- |
| 3885 | // --------------------------------------------------------------------- |
| 3886 | // Intent flags (see mFlags variable). |
| 3887 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3888 | /** @hide */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3889 | @IntDef(flag = true, value = { |
| 3890 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, |
| 3891 | FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3892 | @Retention(RetentionPolicy.SOURCE) |
| 3893 | public @interface GrantUriMode {} |
| 3894 | |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3895 | /** @hide */ |
| 3896 | @IntDef(flag = true, value = { |
| 3897 | FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) |
| 3898 | @Retention(RetentionPolicy.SOURCE) |
| 3899 | public @interface AccessUriMode {} |
| 3900 | |
| 3901 | /** |
| 3902 | * Test if given mode flags specify an access mode, which must be at least |
| 3903 | * read and/or write. |
| 3904 | * |
| 3905 | * @hide |
| 3906 | */ |
| 3907 | public static boolean isAccessUriMode(int modeFlags) { |
| 3908 | return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION |
| 3909 | | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; |
| 3910 | } |
| 3911 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3912 | /** |
| 3913 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3914 | * 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] | 3915 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 3916 | * all URIs as well as recursive traversals through data or other ClipData |
| 3917 | * in Intent items will be granted; only the grant flags of the top-level |
| 3918 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3919 | */ |
| 3920 | public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; |
| 3921 | /** |
| 3922 | * If set, the recipient of this Intent will be granted permission to |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3923 | * 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] | 3924 | * specified in its ClipData. When applying to an Intent's ClipData, |
| 3925 | * all URIs as well as recursive traversals through data or other ClipData |
| 3926 | * in Intent items will be granted; only the grant flags of the top-level |
| 3927 | * Intent are used. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3928 | */ |
| 3929 | public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; |
| 3930 | /** |
| 3931 | * Can be set by the caller to indicate that this Intent is coming from |
| 3932 | * a background operation, not from direct user interaction. |
| 3933 | */ |
| 3934 | public static final int FLAG_FROM_BACKGROUND = 0x00000004; |
| 3935 | /** |
| 3936 | * A flag you can enable for debugging: when set, log messages will be |
| 3937 | * printed during the resolution of this intent to show you what has |
| 3938 | * been found to create the final resolved list. |
| 3939 | */ |
| 3940 | public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 3941 | /** |
| 3942 | * If set, this intent will not match any components in packages that |
| 3943 | * are currently stopped. If this is not set, then the default behavior |
| 3944 | * is to include such applications in the result. |
| 3945 | */ |
| 3946 | public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; |
| 3947 | /** |
| 3948 | * If set, this intent will always match any components in packages that |
| 3949 | * are currently stopped. This is the default behavior when |
| 3950 | * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these |
| 3951 | * flags are set, this one wins (it allows overriding of exclude for |
| 3952 | * places where the framework may automatically set the exclude flag). |
| 3953 | */ |
| 3954 | public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3955 | |
| 3956 | /** |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 3957 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3958 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 3959 | * persisted across device reboots until explicitly revoked with |
| 3960 | * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the |
| 3961 | * grant for possible persisting; the receiving application must call |
| 3962 | * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to |
| 3963 | * actually persist. |
| 3964 | * |
| 3965 | * @see ContentResolver#takePersistableUriPermission(Uri, int) |
| 3966 | * @see ContentResolver#releasePersistableUriPermission(Uri, int) |
| 3967 | * @see ContentResolver#getPersistedUriPermissions() |
Jeff Sharkey | adef88a | 2013-10-15 13:54:44 -0700 | [diff] [blame] | 3968 | * @see ContentResolver#getOutgoingPersistedUriPermissions() |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 3969 | */ |
Jeff Sharkey | e66c177 | 2013-09-20 14:30:59 -0700 | [diff] [blame] | 3970 | public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 3971 | |
| 3972 | /** |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3973 | * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or |
| 3974 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant |
| 3975 | * applies to any URI that is a prefix match against the original granted |
| 3976 | * URI. (Without this flag, the URI must match exactly for access to be |
| 3977 | * granted.) Another URI is considered a prefix match only when scheme, |
| 3978 | * authority, and all path segments defined by the prefix are an exact |
| 3979 | * match. |
| 3980 | */ |
| 3981 | public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; |
| 3982 | |
| 3983 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 3984 | * If set, the new activity is not kept in the history stack. As soon as |
| 3985 | * the user navigates away from it, the activity is finished. This may also |
| 3986 | * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory |
| 3987 | * noHistory} attribute. |
Ricardo Cervera | 92f6a74 | 2014-04-04 11:17:06 -0700 | [diff] [blame] | 3988 | * |
| 3989 | * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} |
| 3990 | * is never invoked when the current activity starts a new activity which |
| 3991 | * sets a result and finishes. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 3992 | */ |
| 3993 | public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; |
| 3994 | /** |
| 3995 | * If set, the activity will not be launched if it is already running |
| 3996 | * at the top of the history stack. |
| 3997 | */ |
| 3998 | public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; |
| 3999 | /** |
| 4000 | * If set, this activity will become the start of a new task on this |
| 4001 | * history stack. A task (from the activity that started it to the |
| 4002 | * next task activity) defines an atomic group of activities that the |
| 4003 | * user can move to. Tasks can be moved to the foreground and background; |
| 4004 | * 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] | 4005 | * the same order. See |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4006 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4007 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4008 | * |
| 4009 | * <p>This flag is generally used by activities that want |
| 4010 | * to present a "launcher" style behavior: they give the user a list of |
| 4011 | * separate things that can be done, which otherwise run completely |
| 4012 | * independently of the activity launching them. |
| 4013 | * |
| 4014 | * <p>When using this flag, if a task is already running for the activity |
| 4015 | * you are now starting, then a new activity will not be started; instead, |
| 4016 | * the current task will simply be brought to the front of the screen with |
| 4017 | * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag |
| 4018 | * to disable this behavior. |
| 4019 | * |
| 4020 | * <p>This flag can not be used when the caller is requesting a result from |
| 4021 | * the activity being launched. |
| 4022 | */ |
| 4023 | public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; |
| 4024 | /** |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4025 | * This flag is used to create a new task and launch an activity into it. |
| 4026 | * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} |
| 4027 | * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would |
| 4028 | * search through existing tasks for ones matching this Intent. Only if no such |
| 4029 | * task is found would a new task be created. When paired with |
| 4030 | * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip |
| 4031 | * the search for a matching task and unconditionally start a new task. |
| 4032 | * |
| 4033 | * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this |
| 4034 | * flag unless you are implementing your own |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4035 | * top-level application launcher.</strong> Used in conjunction with |
| 4036 | * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the |
| 4037 | * behavior of bringing an existing task to the foreground. When set, |
| 4038 | * a new task is <em>always</em> started to host the Activity for the |
| 4039 | * Intent, regardless of whether there is already an existing task running |
| 4040 | * the same thing. |
| 4041 | * |
| 4042 | * <p><strong>Because the default system does not include graphical task management, |
| 4043 | * you should not use this flag unless you provide some way for a user to |
| 4044 | * return back to the tasks you have launched.</strong> |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4045 | * |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4046 | * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for |
| 4047 | * creating new document tasks. |
| 4048 | * |
| 4049 | * <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] | 4050 | * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4051 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4052 | * <p>See |
| 4053 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4054 | * Stack</a> for more information about tasks. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4055 | * |
| 4056 | * @see #FLAG_ACTIVITY_NEW_DOCUMENT |
| 4057 | * @see #FLAG_ACTIVITY_NEW_TASK |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4058 | */ |
| 4059 | public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; |
| 4060 | /** |
| 4061 | * If set, and the activity being launched is already running in the |
| 4062 | * current task, then instead of launching a new instance of that activity, |
| 4063 | * all of the other activities on top of it will be closed and this Intent |
| 4064 | * will be delivered to the (now on top) old activity as a new Intent. |
| 4065 | * |
| 4066 | * <p>For example, consider a task consisting of the activities: A, B, C, D. |
| 4067 | * If D calls startActivity() with an Intent that resolves to the component |
| 4068 | * of activity B, then C and D will be finished and B receive the given |
| 4069 | * Intent, resulting in the stack now being: A, B. |
| 4070 | * |
Dianne Hackborn | aa52f9a | 2009-08-25 16:01:15 -0700 | [diff] [blame] | 4071 | * <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] | 4072 | * either receive the new intent you are starting here in its |
| 4073 | * 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] | 4074 | * 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] | 4075 | * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in |
| 4076 | * the same intent, then it will be finished and re-created; for all other |
| 4077 | * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this |
| 4078 | * 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] | 4079 | * |
| 4080 | * <p>This launch mode can also be used to good effect in conjunction with |
| 4081 | * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity |
| 4082 | * of a task, it will bring any currently running instance of that task |
| 4083 | * to the foreground, and then clear it to its root state. This is |
| 4084 | * especially useful, for example, when launching an activity from the |
| 4085 | * notification manager. |
| 4086 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 4087 | * <p>See |
| 4088 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 4089 | * Stack</a> for more information about tasks. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4090 | */ |
| 4091 | public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; |
| 4092 | /** |
| 4093 | * If set and this intent is being used to launch a new activity from an |
| 4094 | * existing one, then the reply target of the existing activity will be |
| 4095 | * transfered to the new activity. This way the new activity can call |
| 4096 | * {@link android.app.Activity#setResult} and have that result sent back to |
| 4097 | * the reply target of the original activity. |
| 4098 | */ |
| 4099 | public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; |
| 4100 | /** |
| 4101 | * If set and this intent is being used to launch a new activity from an |
| 4102 | * existing one, the current activity will not be counted as the top |
| 4103 | * activity for deciding whether the new intent should be delivered to |
| 4104 | * the top instead of starting a new one. The previous activity will |
| 4105 | * be used as the top, with the assumption being that the current activity |
| 4106 | * will finish itself immediately. |
| 4107 | */ |
| 4108 | public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; |
| 4109 | /** |
| 4110 | * If set, the new activity is not kept in the list of recently launched |
| 4111 | * activities. |
| 4112 | */ |
| 4113 | public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; |
| 4114 | /** |
| 4115 | * This flag is not normally set by application code, but set for you by |
| 4116 | * the system as described in the |
| 4117 | * {@link android.R.styleable#AndroidManifestActivity_launchMode |
| 4118 | * launchMode} documentation for the singleTask mode. |
| 4119 | */ |
| 4120 | public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; |
| 4121 | /** |
| 4122 | * If set, and this activity is either being started in a new task or |
| 4123 | * bringing to the top an existing task, then it will be launched as |
| 4124 | * the front door of the task. This will result in the application of |
| 4125 | * any affinities needed to have that task in the proper state (either |
| 4126 | * moving activities to or from it), or simply resetting that task to |
| 4127 | * its initial state if needed. |
| 4128 | */ |
| 4129 | public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; |
| 4130 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 4131 | * This flag is not normally set by application code, but set for you by |
| 4132 | * the system if this activity is being launched from history |
| 4133 | * (longpress home key). |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4134 | */ |
| 4135 | 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] | 4136 | /** |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 4137 | * @deprecated As of API 21 this performs identically to |
| 4138 | * {@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] | 4139 | */ |
| 4140 | 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] | 4141 | /** |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4142 | * This flag is used to open a document into a new task rooted at the activity launched |
| 4143 | * by this Intent. Through the use of this flag, or its equivalent attribute, |
| 4144 | * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 4145 | * containing different documents will appear in the recent tasks list. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4146 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4147 | * <p>The use of the activity attribute form of this, |
| 4148 | * {@link android.R.attr#documentLaunchMode}, is |
| 4149 | * preferred over the Intent flag described here. The attribute form allows the |
| 4150 | * Activity to specify multiple document behavior for all launchers of the Activity |
| 4151 | * 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] | 4152 | * |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4153 | * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for |
| 4154 | * it is kept after the activity is finished is different than the use of |
| 4155 | * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if |
| 4156 | * this flag is being used to create a new recents entry, then by default that entry |
| 4157 | * will be removed once the activity is finished. You can modify this behavior with |
| 4158 | * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. |
| 4159 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4160 | * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link |
| 4161 | * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the |
| 4162 | * equivalent of the Activity manifest specifying {@link |
| 4163 | * android.R.attr#documentLaunchMode}="intoExisting". When used with |
| 4164 | * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying |
| 4165 | * {@link android.R.attr#documentLaunchMode}="always". |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4166 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4167 | * Refer to {@link android.R.attr#documentLaunchMode} for more information. |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4168 | * |
Craig Mautner | 026596b | 2014-05-21 15:35:44 -0700 | [diff] [blame] | 4169 | * @see android.R.attr#documentLaunchMode |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 4170 | * @see #FLAG_ACTIVITY_MULTIPLE_TASK |
| 4171 | */ |
Craig Mautner | f357c0c | 2014-06-09 09:23:27 -0700 | [diff] [blame] | 4172 | 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] | 4173 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4174 | * 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] | 4175 | * callback from occurring on the current frontmost activity before it is |
| 4176 | * 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] | 4177 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 4178 | * <p>Typically, an activity can rely on that callback to indicate that an |
| 4179 | * explicit user action has caused their activity to be moved out of the |
| 4180 | * foreground. The callback marks an appropriate point in the activity's |
| 4181 | * lifecycle for it to dismiss any notifications that it intends to display |
| 4182 | * "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] | 4183 | * |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 4184 | * <p>If an activity is ever started via any non-user-driven events such as |
| 4185 | * phone-call receipt or an alarm handler, this flag should be passed to {@link |
| 4186 | * Context#startActivity Context.startActivity}, ensuring that the pausing |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4187 | * 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] | 4188 | */ |
| 4189 | 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] | 4190 | /** |
| 4191 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4192 | * this flag will cause the launched activity to be brought to the front of its |
| 4193 | * task's history stack if it is already running. |
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 | * <p>For example, consider a task consisting of four activities: A, B, C, D. |
| 4196 | * If D calls startActivity() with an Intent that resolves to the component |
| 4197 | * of activity B, then B will be brought to the front of the history stack, |
| 4198 | * with this resulting order: A, C, D, B. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4199 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4200 | * 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] | 4201 | * specified. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4202 | */ |
| 4203 | 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] | 4204 | /** |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 4205 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4206 | * this flag will prevent the system from applying an activity transition |
| 4207 | * animation to go to the next activity state. This doesn't mean an |
| 4208 | * animation will never run -- if another activity change happens that doesn't |
| 4209 | * specify this flag before the activity started here is displayed, then |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 4210 | * 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] | 4211 | * when you are going to do a series of activity operations but the |
| 4212 | * animation seen by the user shouldn't be driven by the first activity |
| 4213 | * change but rather a later one. |
| 4214 | */ |
| 4215 | public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; |
| 4216 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 4217 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4218 | * this flag will cause any existing task that would be associated with the |
| 4219 | * activity to be cleared before the activity is started. That is, the activity |
| 4220 | * becomes the new root of an otherwise empty task, and any old activities |
| 4221 | * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 4222 | */ |
| 4223 | public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; |
| 4224 | /** |
| 4225 | * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, |
| 4226 | * this flag will cause a newly launching task to be placed on top of the current |
| 4227 | * home activity task (if there is one). That is, pressing back from the task |
| 4228 | * will always return the user to home even if that was not the last activity they |
| 4229 | * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. |
| 4230 | */ |
| 4231 | public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; |
| 4232 | /** |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4233 | * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will |
| 4234 | * 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] | 4235 | * 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] | 4236 | * 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] | 4237 | * this flag. When set and the task's activity is finished, the recents |
| 4238 | * entry will remain in the interface for the user to re-launch it, like a |
| 4239 | * recents entry for a top-level application. |
| 4240 | * <p> |
| 4241 | * The receiving activity can override this request with |
| 4242 | * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling |
| 4243 | * {@link android.app.Activity#finishAndRemoveTask() |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4244 | * Activity.finishAndRemoveTask()}. |
Craig Mautner | 2dac056 | 2014-05-06 09:06:44 -0700 | [diff] [blame] | 4245 | */ |
Dianne Hackborn | 13420f2 | 2014-07-18 15:43:56 -0700 | [diff] [blame] | 4246 | public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; |
Craig Mautner | a228ae9 | 2014-07-09 05:44:55 -0700 | [diff] [blame] | 4247 | |
| 4248 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4249 | * If set, when sending a broadcast only registered receivers will be |
| 4250 | * called -- no BroadcastReceiver components will be launched. |
| 4251 | */ |
| 4252 | public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4253 | /** |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 4254 | * If set, when sending a broadcast the new broadcast will replace |
| 4255 | * any existing pending broadcast that matches it. Matching is defined |
| 4256 | * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning |
| 4257 | * true for the intents of the two broadcasts. When a match is found, |
| 4258 | * the new broadcast (and receivers associated with it) will replace the |
| 4259 | * existing one in the pending broadcast list, remaining at the same |
| 4260 | * position in the list. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4261 | * |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 4262 | * <p>This flag is most typically used with sticky broadcasts, which |
| 4263 | * only care about delivering the most recent values of the broadcast |
| 4264 | * to their receivers. |
| 4265 | */ |
| 4266 | public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; |
| 4267 | /** |
Christopher Tate | f46723b | 2012-01-26 14:19:24 -0800 | [diff] [blame] | 4268 | * If set, when sending a broadcast the recipient is allowed to run at |
| 4269 | * foreground priority, with a shorter timeout interval. During normal |
| 4270 | * broadcasts the receivers are not automatically hoisted out of the |
| 4271 | * background priority class. |
| 4272 | */ |
| 4273 | public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; |
| 4274 | /** |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4275 | * If this is an ordered broadcast, don't allow receivers to abort the broadcast. |
| 4276 | * They can still propagate results through to later receivers, but they can not prevent |
| 4277 | * later receivers from seeing the broadcast. |
| 4278 | */ |
| 4279 | public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; |
| 4280 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4281 | * If set, when sending a broadcast <i>before boot has completed</i> only |
| 4282 | * registered receivers will be called -- no BroadcastReceiver components |
| 4283 | * will be launched. Sticky intent state will be recorded properly even |
| 4284 | * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} |
| 4285 | * 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] | 4286 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4287 | * <p>This flag is only for use by system sevices as a convenience to |
| 4288 | * avoid having to implement a more complex mechanism around detection |
| 4289 | * of boot completion. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4290 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4291 | * @hide |
| 4292 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4293 | public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; |
Dianne Hackborn | 9acc030 | 2009-08-25 00:27:12 -0700 | [diff] [blame] | 4294 | /** |
| 4295 | * Set when this broadcast is for a boot upgrade, a special mode that |
| 4296 | * allows the broadcast to be sent before the system is ready and launches |
| 4297 | * the app process with no providers running in it. |
| 4298 | * @hide |
| 4299 | */ |
Dianne Hackborn | 6285a32 | 2013-09-18 12:09:47 -0700 | [diff] [blame] | 4300 | public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4301 | |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 4302 | /** |
| 4303 | * @hide Flags that can't be changed with PendingIntent. |
| 4304 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4305 | public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION |
| 4306 | | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 4307 | | FLAG_GRANT_PREFIX_URI_PERMISSION; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4308 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4309 | // --------------------------------------------------------------------- |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4310 | // --------------------------------------------------------------------- |
| 4311 | // toUri() and parseUri() options. |
| 4312 | |
| 4313 | /** |
| 4314 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 4315 | * always has the "intent:" scheme. This syntax can be used when you want |
| 4316 | * to later disambiguate between URIs that are intended to describe an |
| 4317 | * Intent vs. all others that should be treated as raw URIs. When used |
| 4318 | * with {@link #parseUri}, any other scheme will result in a generic |
| 4319 | * VIEW action for that raw URI. |
| 4320 | */ |
| 4321 | public static final int URI_INTENT_SCHEME = 1<<0; |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4322 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4323 | /** |
| 4324 | * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string |
| 4325 | * always has the "android-app:" scheme. This is a variation of |
| 4326 | * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an |
| 4327 | * http/https URI being delivered to a specific package name. The format |
| 4328 | * is: |
| 4329 | * |
| 4330 | * <pre class="prettyprint"> |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 4331 | * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4332 | * |
Dianne Hackborn | 0ee10f6 | 2015-01-14 16:16:13 -0800 | [diff] [blame] | 4333 | * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, |
| 4334 | * you must also include a scheme; including a path also requires both a host and a scheme. |
| 4335 | * The final #Intent; fragment can be used without a scheme, host, or path. |
| 4336 | * Note that this can not be |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4337 | * used with intents that have a {@link #setSelector}, since the base intent |
| 4338 | * will always have an explicit package name.</p> |
| 4339 | * |
| 4340 | * <p>Some examples of how this scheme maps to Intent objects:</p> |
| 4341 | * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> |
| 4342 | * <colgroup align="left" /> |
| 4343 | * <colgroup align="left" /> |
| 4344 | * <thead> |
| 4345 | * <tr><th>URI</th> <th>Intent</th></tr> |
| 4346 | * </thead> |
| 4347 | * |
| 4348 | * <tbody> |
| 4349 | * <tr><td><code>android-app://com.example.app</code></td> |
| 4350 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4351 | * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> |
| 4352 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4353 | * </table></td> |
| 4354 | * </tr> |
| 4355 | * <tr><td><code>android-app://com.example.app/http/example.com</code></td> |
| 4356 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4357 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 4358 | * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> |
| 4359 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4360 | * </table></td> |
| 4361 | * </tr> |
| 4362 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> |
| 4363 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4364 | * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> |
| 4365 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 4366 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4367 | * </table></td> |
| 4368 | * </tr> |
| 4369 | * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 4370 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4371 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 4372 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4373 | * </table></td> |
| 4374 | * </tr> |
| 4375 | * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> |
| 4376 | * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> |
| 4377 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 4378 | * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> |
| 4379 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4380 | * </table></td> |
| 4381 | * </tr> |
| 4382 | * <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> |
| 4383 | * <td><table border="" style="margin:0" > |
| 4384 | * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> |
| 4385 | * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> |
| 4386 | * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> |
| 4387 | * </table></td> |
| 4388 | * </tr> |
| 4389 | * </tbody> |
| 4390 | * </table> |
| 4391 | */ |
| 4392 | public static final int URI_ANDROID_APP_SCHEME = 1<<1; |
| 4393 | |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 4394 | /** |
| 4395 | * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing |
| 4396 | * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, |
| 4397 | * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, |
| 4398 | * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the |
| 4399 | * generated Intent can not cause unexpected data access to happen. |
| 4400 | * |
| 4401 | * <p>If you do not trust the source of the URI being parsed, you should still do further |
| 4402 | * processing to protect yourself from it. In particular, when using it to start an |
| 4403 | * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities |
| 4404 | * that can handle it.</p> |
| 4405 | */ |
| 4406 | public static final int URI_ALLOW_UNSAFE = 1<<2; |
| 4407 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4408 | // --------------------------------------------------------------------- |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4409 | |
| 4410 | private String mAction; |
| 4411 | private Uri mData; |
| 4412 | private String mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4413 | private String mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4414 | private ComponentName mComponent; |
| 4415 | private int mFlags; |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 4416 | private ArraySet<String> mCategories; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4417 | private Bundle mExtras; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 4418 | private Rect mSourceBounds; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4419 | private Intent mSelector; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 4420 | private ClipData mClipData; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 4421 | private int mContentUserHint = UserHandle.USER_CURRENT; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4422 | |
| 4423 | // --------------------------------------------------------------------- |
| 4424 | |
| 4425 | /** |
| 4426 | * Create an empty intent. |
| 4427 | */ |
| 4428 | public Intent() { |
| 4429 | } |
| 4430 | |
| 4431 | /** |
| 4432 | * Copy constructor. |
| 4433 | */ |
| 4434 | public Intent(Intent o) { |
| 4435 | this.mAction = o.mAction; |
| 4436 | this.mData = o.mData; |
| 4437 | this.mType = o.mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4438 | this.mPackage = o.mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4439 | this.mComponent = o.mComponent; |
| 4440 | this.mFlags = o.mFlags; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 4441 | this.mContentUserHint = o.mContentUserHint; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4442 | if (o.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 4443 | this.mCategories = new ArraySet<String>(o.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4444 | } |
| 4445 | if (o.mExtras != null) { |
| 4446 | this.mExtras = new Bundle(o.mExtras); |
| 4447 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 4448 | if (o.mSourceBounds != null) { |
| 4449 | this.mSourceBounds = new Rect(o.mSourceBounds); |
| 4450 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4451 | if (o.mSelector != null) { |
| 4452 | this.mSelector = new Intent(o.mSelector); |
| 4453 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 4454 | if (o.mClipData != null) { |
| 4455 | this.mClipData = new ClipData(o.mClipData); |
| 4456 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4457 | } |
| 4458 | |
| 4459 | @Override |
| 4460 | public Object clone() { |
| 4461 | return new Intent(this); |
| 4462 | } |
| 4463 | |
| 4464 | private Intent(Intent o, boolean all) { |
| 4465 | this.mAction = o.mAction; |
| 4466 | this.mData = o.mData; |
| 4467 | this.mType = o.mType; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4468 | this.mPackage = o.mPackage; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4469 | this.mComponent = o.mComponent; |
| 4470 | if (o.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 4471 | this.mCategories = new ArraySet<String>(o.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4472 | } |
| 4473 | } |
| 4474 | |
| 4475 | /** |
| 4476 | * Make a clone of only the parts of the Intent that are relevant for |
| 4477 | * filter matching: the action, data, type, component, and categories. |
| 4478 | */ |
| 4479 | public Intent cloneFilter() { |
| 4480 | return new Intent(this, false); |
| 4481 | } |
| 4482 | |
| 4483 | /** |
| 4484 | * Create an intent with a given action. All other fields (data, type, |
| 4485 | * class) are null. Note that the action <em>must</em> be in a |
| 4486 | * namespace because Intents are used globally in the system -- for |
| 4487 | * example the system VIEW action is android.intent.action.VIEW; an |
| 4488 | * application's custom action would be something like |
| 4489 | * com.google.app.myapp.CUSTOM_ACTION. |
| 4490 | * |
| 4491 | * @param action The Intent action, such as ACTION_VIEW. |
| 4492 | */ |
| 4493 | public Intent(String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 4494 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4495 | } |
| 4496 | |
| 4497 | /** |
| 4498 | * Create an intent with a given action and for a given data url. Note |
| 4499 | * that the action <em>must</em> be in a namespace because Intents are |
| 4500 | * used globally in the system -- for example the system VIEW action is |
| 4501 | * android.intent.action.VIEW; an application's custom action would be |
| 4502 | * something like com.google.app.myapp.CUSTOM_ACTION. |
| 4503 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 4504 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 4505 | * case-sensitive, unlike the formal RFC. As a result, |
| 4506 | * you should always ensure that you write your Uri with these elements |
| 4507 | * using lower case letters, and normalize any Uris you receive from |
| 4508 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 4509 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4510 | * @param action The Intent action, such as ACTION_VIEW. |
| 4511 | * @param uri The Intent data URI. |
| 4512 | */ |
| 4513 | public Intent(String action, Uri uri) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 4514 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4515 | mData = uri; |
| 4516 | } |
| 4517 | |
| 4518 | /** |
| 4519 | * Create an intent for a specific component. All other fields (action, data, |
| 4520 | * type, class) are null, though they can be modified later with explicit |
| 4521 | * calls. This provides a convenient way to create an intent that is |
| 4522 | * intended to execute a hard-coded class name, rather than relying on the |
| 4523 | * system to find an appropriate class for you; see {@link #setComponent} |
| 4524 | * for more information on the repercussions of this. |
| 4525 | * |
| 4526 | * @param packageContext A Context of the application package implementing |
| 4527 | * this class. |
| 4528 | * @param cls The component class that is to be used for the intent. |
| 4529 | * |
| 4530 | * @see #setClass |
| 4531 | * @see #setComponent |
| 4532 | * @see #Intent(String, android.net.Uri , Context, Class) |
| 4533 | */ |
| 4534 | public Intent(Context packageContext, Class<?> cls) { |
| 4535 | mComponent = new ComponentName(packageContext, cls); |
| 4536 | } |
| 4537 | |
| 4538 | /** |
| 4539 | * 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] | 4540 | * 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] | 4541 | * construct the Intent and then calling {@link #setClass} to set its |
| 4542 | * class. |
| 4543 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 4544 | * <p><em>Note: scheme and host name matching in the Android framework is |
| 4545 | * case-sensitive, unlike the formal RFC. As a result, |
| 4546 | * you should always ensure that you write your Uri with these elements |
| 4547 | * using lower case letters, and normalize any Uris you receive from |
| 4548 | * outside of Android to ensure the scheme and host is lower case.</em></p> |
| 4549 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4550 | * @param action The Intent action, such as ACTION_VIEW. |
| 4551 | * @param uri The Intent data URI. |
| 4552 | * @param packageContext A Context of the application package implementing |
| 4553 | * this class. |
| 4554 | * @param cls The component class that is to be used for the intent. |
| 4555 | * |
| 4556 | * @see #Intent(String, android.net.Uri) |
| 4557 | * @see #Intent(Context, Class) |
| 4558 | * @see #setClass |
| 4559 | * @see #setComponent |
| 4560 | */ |
| 4561 | public Intent(String action, Uri uri, |
| 4562 | Context packageContext, Class<?> cls) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 4563 | setAction(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4564 | mData = uri; |
| 4565 | mComponent = new ComponentName(packageContext, cls); |
| 4566 | } |
| 4567 | |
| 4568 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 4569 | * Create an intent to launch the main (root) activity of a task. This |
| 4570 | * is the Intent that is started when the application's is launched from |
| 4571 | * Home. For anything else that wants to launch an application in the |
| 4572 | * same way, it is important that they use an Intent structured the same |
| 4573 | * way, and can use this function to ensure this is the case. |
| 4574 | * |
| 4575 | * <p>The returned Intent has the given Activity component as its explicit |
| 4576 | * component, {@link #ACTION_MAIN} as its action, and includes the |
| 4577 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 4578 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 4579 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 4580 | * |
| 4581 | * @param mainActivity The main activity component that this Intent will |
| 4582 | * launch. |
| 4583 | * @return Returns a newly created Intent that can be used to launch the |
| 4584 | * activity as a main application entry. |
| 4585 | * |
| 4586 | * @see #setClass |
| 4587 | * @see #setComponent |
| 4588 | */ |
| 4589 | public static Intent makeMainActivity(ComponentName mainActivity) { |
| 4590 | Intent intent = new Intent(ACTION_MAIN); |
| 4591 | intent.setComponent(mainActivity); |
| 4592 | intent.addCategory(CATEGORY_LAUNCHER); |
| 4593 | return intent; |
| 4594 | } |
| 4595 | |
| 4596 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4597 | * Make an Intent for the main activity of an application, without |
| 4598 | * specifying a specific activity to run but giving a selector to find |
| 4599 | * the activity. This results in a final Intent that is structured |
| 4600 | * the same as when the application is launched from |
| 4601 | * Home. For anything else that wants to launch an application in the |
| 4602 | * same way, it is important that they use an Intent structured the same |
| 4603 | * way, and can use this function to ensure this is the case. |
| 4604 | * |
| 4605 | * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the |
| 4606 | * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have |
| 4607 | * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want |
| 4608 | * to do that through {@link #addFlags(int)} on the returned Intent. |
| 4609 | * |
| 4610 | * @param selectorAction The action name of the Intent's selector. |
| 4611 | * @param selectorCategory The name of a category to add to the Intent's |
| 4612 | * selector. |
| 4613 | * @return Returns a newly created Intent that can be used to launch the |
| 4614 | * activity as a main application entry. |
| 4615 | * |
| 4616 | * @see #setSelector(Intent) |
| 4617 | */ |
| 4618 | public static Intent makeMainSelectorActivity(String selectorAction, |
| 4619 | String selectorCategory) { |
| 4620 | Intent intent = new Intent(ACTION_MAIN); |
| 4621 | intent.addCategory(CATEGORY_LAUNCHER); |
| 4622 | Intent selector = new Intent(); |
| 4623 | selector.setAction(selectorAction); |
| 4624 | selector.addCategory(selectorCategory); |
| 4625 | intent.setSelector(selector); |
| 4626 | return intent; |
| 4627 | } |
| 4628 | |
| 4629 | /** |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 4630 | * Make an Intent that can be used to re-launch an application's task |
| 4631 | * in its base state. This is like {@link #makeMainActivity(ComponentName)}, |
| 4632 | * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and |
| 4633 | * {@link #FLAG_ACTIVITY_CLEAR_TASK}. |
| 4634 | * |
| 4635 | * @param mainActivity The activity component that is the root of the |
| 4636 | * task; this is the activity that has been published in the application's |
| 4637 | * manifest as the main launcher icon. |
| 4638 | * |
| 4639 | * @return Returns a newly created Intent that can be used to relaunch the |
| 4640 | * activity's task in its root state. |
| 4641 | */ |
| 4642 | public static Intent makeRestartActivityTask(ComponentName mainActivity) { |
| 4643 | Intent intent = makeMainActivity(mainActivity); |
| 4644 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 4645 | | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| 4646 | return intent; |
| 4647 | } |
| 4648 | |
| 4649 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4650 | * Call {@link #parseUri} with 0 flags. |
| 4651 | * @deprecated Use {@link #parseUri} instead. |
| 4652 | */ |
| 4653 | @Deprecated |
| 4654 | public static Intent getIntent(String uri) throws URISyntaxException { |
| 4655 | return parseUri(uri, 0); |
| 4656 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4657 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4658 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4659 | * Create an intent from a URI. This URI may encode the action, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4660 | * category, and other intent fields, if it was returned by |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 4661 | * {@link #toUri}. If the Intent was not generate by toUri(), its data |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4662 | * 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] | 4663 | * |
| 4664 | * <p>The URI given here must not be relative -- that is, it must include |
| 4665 | * the scheme and full path. |
| 4666 | * |
| 4667 | * @param uri The URI to turn into an Intent. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4668 | * @param flags Additional processing flags. Either 0, |
| 4669 | * {@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] | 4670 | * |
| 4671 | * @return Intent The newly created Intent object. |
| 4672 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4673 | * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax |
| 4674 | * it bad (as parsed by the Uri class) or the Intent data within the |
| 4675 | * URI is invalid. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4676 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4677 | * @see #toUri |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4678 | */ |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4679 | 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] | 4680 | int i = 0; |
| 4681 | try { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4682 | final boolean androidApp = uri.startsWith("android-app:"); |
| 4683 | |
| 4684 | // Validate intent scheme if requested. |
| 4685 | if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { |
| 4686 | if (!uri.startsWith("intent:") && !androidApp) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4687 | Intent intent = new Intent(ACTION_VIEW); |
| 4688 | try { |
| 4689 | intent.setData(Uri.parse(uri)); |
| 4690 | } catch (IllegalArgumentException e) { |
| 4691 | throw new URISyntaxException(uri, e.getMessage()); |
| 4692 | } |
| 4693 | return intent; |
| 4694 | } |
| 4695 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4696 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4697 | i = uri.lastIndexOf("#"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4698 | // simple case |
| 4699 | if (i == -1) { |
| 4700 | if (!androidApp) { |
| 4701 | return new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 4702 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4703 | |
| 4704 | // old format Intent URI |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4705 | } else if (!uri.startsWith("#Intent;", i)) { |
| 4706 | if (!androidApp) { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 4707 | return getIntentOld(uri, flags); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4708 | } else { |
| 4709 | i = -1; |
| 4710 | } |
| 4711 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4712 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4713 | // new format |
| 4714 | Intent intent = new Intent(ACTION_VIEW); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4715 | Intent baseIntent = intent; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4716 | boolean explicitAction = false; |
| 4717 | boolean inSelector = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4718 | |
| 4719 | // fetch data part, if present |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4720 | String scheme = null; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4721 | String data; |
| 4722 | if (i >= 0) { |
| 4723 | data = uri.substring(0, i); |
| 4724 | i += 8; // length of "#Intent;" |
| 4725 | } else { |
| 4726 | data = uri; |
| 4727 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4728 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4729 | // loop over contents of Intent, all name=value; |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4730 | while (i >= 0 && !uri.startsWith("end", i)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4731 | int eq = uri.indexOf('=', i); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4732 | if (eq < 0) eq = i-1; |
| 4733 | int semi = uri.indexOf(';', i); |
| 4734 | 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] | 4735 | |
| 4736 | // action |
| 4737 | if (uri.startsWith("action=", i)) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 4738 | intent.setAction(value); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4739 | if (!inSelector) { |
| 4740 | explicitAction = true; |
| 4741 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4742 | } |
| 4743 | |
| 4744 | // categories |
| 4745 | else if (uri.startsWith("category=", i)) { |
| 4746 | intent.addCategory(value); |
| 4747 | } |
| 4748 | |
| 4749 | // type |
| 4750 | else if (uri.startsWith("type=", i)) { |
| 4751 | intent.mType = value; |
| 4752 | } |
| 4753 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 4754 | // launch flags |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4755 | else if (uri.startsWith("launchFlags=", i)) { |
| 4756 | intent.mFlags = Integer.decode(value).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 4757 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 4758 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 4759 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4760 | } |
| 4761 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4762 | // package |
| 4763 | else if (uri.startsWith("package=", i)) { |
| 4764 | intent.mPackage = value; |
| 4765 | } |
| 4766 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4767 | // component |
| 4768 | else if (uri.startsWith("component=", i)) { |
| 4769 | intent.mComponent = ComponentName.unflattenFromString(value); |
| 4770 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4771 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4772 | // scheme |
| 4773 | else if (uri.startsWith("scheme=", i)) { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4774 | if (inSelector) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 4775 | intent.mData = Uri.parse(value + ":"); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4776 | } else { |
| 4777 | scheme = value; |
| 4778 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4779 | } |
| 4780 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 4781 | // source bounds |
| 4782 | else if (uri.startsWith("sourceBounds=", i)) { |
| 4783 | intent.mSourceBounds = Rect.unflattenFromString(value); |
| 4784 | } |
| 4785 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4786 | // selector |
| 4787 | else if (semi == (i+3) && uri.startsWith("SEL", i)) { |
| 4788 | intent = new Intent(); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4789 | inSelector = true; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4790 | } |
| 4791 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4792 | // extra |
| 4793 | else { |
| 4794 | String key = Uri.decode(uri.substring(i + 2, eq)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4795 | // create Bundle if it doesn't already exist |
| 4796 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
| 4797 | Bundle b = intent.mExtras; |
| 4798 | // add EXTRA |
| 4799 | if (uri.startsWith("S.", i)) b.putString(key, value); |
| 4800 | else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); |
| 4801 | else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); |
| 4802 | else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); |
| 4803 | else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); |
| 4804 | else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); |
| 4805 | else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); |
| 4806 | else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); |
| 4807 | else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); |
| 4808 | else throw new URISyntaxException(uri, "unknown EXTRA type", i); |
| 4809 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4810 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4811 | // move to the next item |
| 4812 | i = semi + 1; |
| 4813 | } |
| 4814 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4815 | if (inSelector) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4816 | // The Intent had a selector; fix it up. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4817 | if (baseIntent.mPackage == null) { |
| 4818 | baseIntent.setSelector(intent); |
| 4819 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 4820 | intent = baseIntent; |
| 4821 | } |
| 4822 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4823 | if (data != null) { |
| 4824 | if (data.startsWith("intent:")) { |
| 4825 | data = data.substring(7); |
| 4826 | if (scheme != null) { |
| 4827 | data = scheme + ':' + data; |
| 4828 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4829 | } else if (data.startsWith("android-app:")) { |
| 4830 | if (data.charAt(12) == '/' && data.charAt(13) == '/') { |
| 4831 | // Correctly formed android-app, first part is package name. |
| 4832 | int end = data.indexOf('/', 14); |
| 4833 | if (end < 0) { |
| 4834 | // All we have is a package name. |
| 4835 | intent.mPackage = data.substring(14); |
| 4836 | if (!explicitAction) { |
| 4837 | intent.setAction(ACTION_MAIN); |
| 4838 | } |
| 4839 | data = ""; |
| 4840 | } else { |
| 4841 | // Target the Intent at the given package name always. |
| 4842 | String authority = null; |
| 4843 | intent.mPackage = data.substring(14, end); |
| 4844 | int newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 4845 | if ((end+1) < data.length()) { |
| 4846 | if ((newEnd=data.indexOf('/', end+1)) >= 0) { |
| 4847 | // Found a scheme, remember it. |
| 4848 | scheme = data.substring(end+1, newEnd); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4849 | end = newEnd; |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 4850 | if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { |
| 4851 | // Found a authority, remember it. |
| 4852 | authority = data.substring(end+1, newEnd); |
| 4853 | end = newEnd; |
| 4854 | } |
| 4855 | } else { |
| 4856 | // All we have is a scheme. |
| 4857 | scheme = data.substring(end+1); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 4858 | } |
| 4859 | } |
| 4860 | if (scheme == null) { |
| 4861 | // If there was no scheme, then this just targets the package. |
| 4862 | if (!explicitAction) { |
| 4863 | intent.setAction(ACTION_MAIN); |
| 4864 | } |
| 4865 | data = ""; |
| 4866 | } else if (authority == null) { |
| 4867 | data = scheme + ":"; |
| 4868 | } else { |
| 4869 | data = scheme + "://" + authority + data.substring(end); |
| 4870 | } |
| 4871 | } |
| 4872 | } else { |
| 4873 | data = ""; |
| 4874 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4875 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4876 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 4877 | if (data.length() > 0) { |
| 4878 | try { |
| 4879 | intent.mData = Uri.parse(data); |
| 4880 | } catch (IllegalArgumentException e) { |
| 4881 | throw new URISyntaxException(uri, e.getMessage()); |
| 4882 | } |
| 4883 | } |
| 4884 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 4885 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4886 | return intent; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4887 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4888 | } catch (IndexOutOfBoundsException e) { |
| 4889 | throw new URISyntaxException(uri, "illegal Intent URI format", i); |
| 4890 | } |
| 4891 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4892 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4893 | public static Intent getIntentOld(String uri) throws URISyntaxException { |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 4894 | return getIntentOld(uri, 0); |
| 4895 | } |
| 4896 | |
| 4897 | 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] | 4898 | Intent intent; |
| 4899 | |
| 4900 | int i = uri.lastIndexOf('#'); |
| 4901 | if (i >= 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4902 | String action = null; |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4903 | final int intentFragmentStart = i; |
| 4904 | boolean isIntentFragment = false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4905 | |
| 4906 | i++; |
| 4907 | |
| 4908 | if (uri.regionMatches(i, "action(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4909 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4910 | i += 7; |
| 4911 | int j = uri.indexOf(')', i); |
| 4912 | action = uri.substring(i, j); |
| 4913 | i = j + 1; |
| 4914 | } |
| 4915 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4916 | intent = new Intent(action); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4917 | |
| 4918 | if (uri.regionMatches(i, "categories(", 0, 11)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4919 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4920 | i += 11; |
| 4921 | int j = uri.indexOf(')', i); |
| 4922 | while (i < j) { |
| 4923 | int sep = uri.indexOf('!', i); |
Alan Viverette | 0adf32b | 2014-09-18 12:53:16 -0700 | [diff] [blame] | 4924 | if (sep < 0 || sep > j) sep = j; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4925 | if (i < sep) { |
| 4926 | intent.addCategory(uri.substring(i, sep)); |
| 4927 | } |
| 4928 | i = sep + 1; |
| 4929 | } |
| 4930 | i = j + 1; |
| 4931 | } |
| 4932 | |
| 4933 | if (uri.regionMatches(i, "type(", 0, 5)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4934 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4935 | i += 5; |
| 4936 | int j = uri.indexOf(')', i); |
| 4937 | intent.mType = uri.substring(i, j); |
| 4938 | i = j + 1; |
| 4939 | } |
| 4940 | |
| 4941 | if (uri.regionMatches(i, "launchFlags(", 0, 12)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4942 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4943 | i += 12; |
| 4944 | int j = uri.indexOf(')', i); |
| 4945 | intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); |
Dianne Hackborn | 24b1c23 | 2014-11-20 17:17:39 -0800 | [diff] [blame] | 4946 | if ((flags& URI_ALLOW_UNSAFE) == 0) { |
| 4947 | intent.mFlags &= ~IMMUTABLE_FLAGS; |
| 4948 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4949 | i = j + 1; |
| 4950 | } |
| 4951 | |
| 4952 | if (uri.regionMatches(i, "component(", 0, 10)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4953 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4954 | i += 10; |
| 4955 | int j = uri.indexOf(')', i); |
| 4956 | int sep = uri.indexOf('!', i); |
| 4957 | if (sep >= 0 && sep < j) { |
| 4958 | String pkg = uri.substring(i, sep); |
| 4959 | String cls = uri.substring(sep + 1, j); |
| 4960 | intent.mComponent = new ComponentName(pkg, cls); |
| 4961 | } |
| 4962 | i = j + 1; |
| 4963 | } |
| 4964 | |
| 4965 | if (uri.regionMatches(i, "extras(", 0, 7)) { |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 4966 | isIntentFragment = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4967 | i += 7; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4968 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4969 | final int closeParen = uri.indexOf(')', i); |
| 4970 | if (closeParen == -1) throw new URISyntaxException(uri, |
| 4971 | "EXTRA missing trailing ')'", i); |
| 4972 | |
| 4973 | while (i < closeParen) { |
| 4974 | // fetch the key value |
| 4975 | int j = uri.indexOf('=', i); |
| 4976 | if (j <= i + 1 || i >= closeParen) { |
| 4977 | throw new URISyntaxException(uri, "EXTRA missing '='", i); |
| 4978 | } |
| 4979 | char type = uri.charAt(i); |
| 4980 | i++; |
| 4981 | String key = uri.substring(i, j); |
| 4982 | i = j + 1; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4983 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4984 | // get type-value |
| 4985 | j = uri.indexOf('!', i); |
| 4986 | if (j == -1 || j >= closeParen) j = closeParen; |
| 4987 | if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 4988 | String value = uri.substring(i, j); |
| 4989 | i = j; |
| 4990 | |
| 4991 | // create Bundle if it doesn't already exist |
| 4992 | if (intent.mExtras == null) intent.mExtras = new Bundle(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 4993 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4994 | // add item to bundle |
| 4995 | try { |
| 4996 | switch (type) { |
| 4997 | case 'S': |
| 4998 | intent.mExtras.putString(key, Uri.decode(value)); |
| 4999 | break; |
| 5000 | case 'B': |
| 5001 | intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); |
| 5002 | break; |
| 5003 | case 'b': |
| 5004 | intent.mExtras.putByte(key, Byte.parseByte(value)); |
| 5005 | break; |
| 5006 | case 'c': |
| 5007 | intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); |
| 5008 | break; |
| 5009 | case 'd': |
| 5010 | intent.mExtras.putDouble(key, Double.parseDouble(value)); |
| 5011 | break; |
| 5012 | case 'f': |
| 5013 | intent.mExtras.putFloat(key, Float.parseFloat(value)); |
| 5014 | break; |
| 5015 | case 'i': |
| 5016 | intent.mExtras.putInt(key, Integer.parseInt(value)); |
| 5017 | break; |
| 5018 | case 'l': |
| 5019 | intent.mExtras.putLong(key, Long.parseLong(value)); |
| 5020 | break; |
| 5021 | case 's': |
| 5022 | intent.mExtras.putShort(key, Short.parseShort(value)); |
| 5023 | break; |
| 5024 | default: |
| 5025 | throw new URISyntaxException(uri, "EXTRA has unknown type", i); |
| 5026 | } |
| 5027 | } catch (NumberFormatException e) { |
| 5028 | throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); |
| 5029 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5030 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5031 | char ch = uri.charAt(i); |
| 5032 | if (ch == ')') break; |
| 5033 | if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); |
| 5034 | i++; |
| 5035 | } |
| 5036 | } |
| 5037 | |
Dianne Hackborn | 6cca159 | 2009-09-20 12:40:03 -0700 | [diff] [blame] | 5038 | if (isIntentFragment) { |
| 5039 | intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); |
| 5040 | } else { |
| 5041 | intent.mData = Uri.parse(uri); |
| 5042 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 5043 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5044 | if (intent.mAction == null) { |
| 5045 | // By default, if no action is specified, then use VIEW. |
| 5046 | intent.mAction = ACTION_VIEW; |
| 5047 | } |
| 5048 | |
| 5049 | } else { |
| 5050 | intent = new Intent(ACTION_VIEW, Uri.parse(uri)); |
| 5051 | } |
| 5052 | |
| 5053 | return intent; |
| 5054 | } |
| 5055 | |
| 5056 | /** |
| 5057 | * Retrieve the general action to be performed, such as |
| 5058 | * {@link #ACTION_VIEW}. The action describes the general way the rest of |
| 5059 | * the information in the intent should be interpreted -- most importantly, |
| 5060 | * what to do with the data returned by {@link #getData}. |
| 5061 | * |
| 5062 | * @return The action of this intent or null if none is specified. |
| 5063 | * |
| 5064 | * @see #setAction |
| 5065 | */ |
| 5066 | public String getAction() { |
| 5067 | return mAction; |
| 5068 | } |
| 5069 | |
| 5070 | /** |
| 5071 | * Retrieve data this intent is operating on. This URI specifies the name |
| 5072 | * of the data; often it uses the content: scheme, specifying data in a |
| 5073 | * content provider. Other schemes may be handled by specific activities, |
| 5074 | * such as http: by the web browser. |
| 5075 | * |
| 5076 | * @return The URI of the data this intent is targeting or null. |
| 5077 | * |
| 5078 | * @see #getScheme |
| 5079 | * @see #setData |
| 5080 | */ |
| 5081 | public Uri getData() { |
| 5082 | return mData; |
| 5083 | } |
| 5084 | |
| 5085 | /** |
| 5086 | * The same as {@link #getData()}, but returns the URI as an encoded |
| 5087 | * String. |
| 5088 | */ |
| 5089 | public String getDataString() { |
| 5090 | return mData != null ? mData.toString() : null; |
| 5091 | } |
| 5092 | |
| 5093 | /** |
| 5094 | * Return the scheme portion of the intent's data. If the data is null or |
| 5095 | * does not include a scheme, null is returned. Otherwise, the scheme |
| 5096 | * prefix without the final ':' is returned, i.e. "http". |
| 5097 | * |
| 5098 | * <p>This is the same as calling getData().getScheme() (and checking for |
| 5099 | * null data). |
| 5100 | * |
| 5101 | * @return The scheme of this intent. |
| 5102 | * |
| 5103 | * @see #getData |
| 5104 | */ |
| 5105 | public String getScheme() { |
| 5106 | return mData != null ? mData.getScheme() : null; |
| 5107 | } |
| 5108 | |
| 5109 | /** |
| 5110 | * Retrieve any explicit MIME type included in the intent. This is usually |
| 5111 | * null, as the type is determined by the intent data. |
| 5112 | * |
| 5113 | * @return If a type was manually set, it is returned; else null is |
| 5114 | * returned. |
| 5115 | * |
| 5116 | * @see #resolveType(ContentResolver) |
| 5117 | * @see #setType |
| 5118 | */ |
| 5119 | public String getType() { |
| 5120 | return mType; |
| 5121 | } |
| 5122 | |
| 5123 | /** |
| 5124 | * Return the MIME data type of this intent. If the type field is |
| 5125 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 5126 | * the type of that data is returned. If neither fields are set, a null is |
| 5127 | * returned. |
| 5128 | * |
| 5129 | * @return The MIME type of this intent. |
| 5130 | * |
| 5131 | * @see #getType |
| 5132 | * @see #resolveType(ContentResolver) |
| 5133 | */ |
| 5134 | public String resolveType(Context context) { |
| 5135 | return resolveType(context.getContentResolver()); |
| 5136 | } |
| 5137 | |
| 5138 | /** |
| 5139 | * Return the MIME data type of this intent. If the type field is |
| 5140 | * explicitly set, that is simply returned. Otherwise, if the data is set, |
| 5141 | * the type of that data is returned. If neither fields are set, a null is |
| 5142 | * returned. |
| 5143 | * |
| 5144 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 5145 | * type of the intent's data. |
| 5146 | * |
| 5147 | * @return The MIME type of this intent. |
| 5148 | * |
| 5149 | * @see #getType |
| 5150 | * @see #resolveType(Context) |
| 5151 | */ |
| 5152 | public String resolveType(ContentResolver resolver) { |
| 5153 | if (mType != null) { |
| 5154 | return mType; |
| 5155 | } |
| 5156 | if (mData != null) { |
| 5157 | if ("content".equals(mData.getScheme())) { |
| 5158 | return resolver.getType(mData); |
| 5159 | } |
| 5160 | } |
| 5161 | return null; |
| 5162 | } |
| 5163 | |
| 5164 | /** |
| 5165 | * Return the MIME data type of this intent, only if it will be needed for |
| 5166 | * intent resolution. This is not generally useful for application code; |
| 5167 | * it is used by the frameworks for communicating with back-end system |
| 5168 | * services. |
| 5169 | * |
| 5170 | * @param resolver A ContentResolver that can be used to determine the MIME |
| 5171 | * type of the intent's data. |
| 5172 | * |
| 5173 | * @return The MIME type of this intent, or null if it is unknown or not |
| 5174 | * needed. |
| 5175 | */ |
| 5176 | public String resolveTypeIfNeeded(ContentResolver resolver) { |
| 5177 | if (mComponent != null) { |
| 5178 | return mType; |
| 5179 | } |
| 5180 | return resolveType(resolver); |
| 5181 | } |
| 5182 | |
| 5183 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 5184 | * Check if a category exists in the intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5185 | * |
| 5186 | * @param category The category to check. |
| 5187 | * |
| 5188 | * @return boolean True if the intent contains the category, else false. |
| 5189 | * |
| 5190 | * @see #getCategories |
| 5191 | * @see #addCategory |
| 5192 | */ |
| 5193 | public boolean hasCategory(String category) { |
| 5194 | return mCategories != null && mCategories.contains(category); |
| 5195 | } |
| 5196 | |
| 5197 | /** |
| 5198 | * Return the set of all categories in the intent. If there are no categories, |
| 5199 | * returns NULL. |
| 5200 | * |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5201 | * @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] | 5202 | * |
| 5203 | * @see #hasCategory |
| 5204 | * @see #addCategory |
| 5205 | */ |
| 5206 | public Set<String> getCategories() { |
| 5207 | return mCategories; |
| 5208 | } |
| 5209 | |
| 5210 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 5211 | * Return the specific selector associated with this Intent. If there is |
| 5212 | * none, returns null. See {@link #setSelector} for more information. |
| 5213 | * |
| 5214 | * @see #setSelector |
| 5215 | */ |
| 5216 | public Intent getSelector() { |
| 5217 | return mSelector; |
| 5218 | } |
| 5219 | |
| 5220 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5221 | * Return the {@link ClipData} associated with this Intent. If there is |
| 5222 | * none, returns null. See {@link #setClipData} for more information. |
| 5223 | * |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 5224 | * @see #setClipData |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5225 | */ |
| 5226 | public ClipData getClipData() { |
| 5227 | return mClipData; |
| 5228 | } |
| 5229 | |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 5230 | /** @hide */ |
| 5231 | public int getContentUserHint() { |
| 5232 | return mContentUserHint; |
| 5233 | } |
| 5234 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 5235 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5236 | * Sets the ClassLoader that will be used when unmarshalling |
| 5237 | * any Parcelable values from the extras of this Intent. |
| 5238 | * |
| 5239 | * @param loader a ClassLoader, or null to use the default loader |
| 5240 | * at the time of unmarshalling. |
| 5241 | */ |
| 5242 | public void setExtrasClassLoader(ClassLoader loader) { |
| 5243 | if (mExtras != null) { |
| 5244 | mExtras.setClassLoader(loader); |
| 5245 | } |
| 5246 | } |
| 5247 | |
| 5248 | /** |
| 5249 | * Returns true if an extra value is associated with the given name. |
| 5250 | * @param name the extra's name |
| 5251 | * @return true if the given extra is present. |
| 5252 | */ |
| 5253 | public boolean hasExtra(String name) { |
| 5254 | return mExtras != null && mExtras.containsKey(name); |
| 5255 | } |
| 5256 | |
| 5257 | /** |
| 5258 | * Returns true if the Intent's extras contain a parcelled file descriptor. |
| 5259 | * @return true if the Intent contains a parcelled file descriptor. |
| 5260 | */ |
| 5261 | public boolean hasFileDescriptors() { |
| 5262 | return mExtras != null && mExtras.hasFileDescriptors(); |
| 5263 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 5264 | |
Dianne Hackborn | 9ecebbf | 2011-09-28 23:19:47 -0400 | [diff] [blame] | 5265 | /** @hide */ |
| 5266 | public void setAllowFds(boolean allowFds) { |
| 5267 | if (mExtras != null) { |
| 5268 | mExtras.setAllowFds(allowFds); |
| 5269 | } |
| 5270 | } |
| 5271 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5272 | /** |
| 5273 | * Retrieve extended data from the intent. |
| 5274 | * |
| 5275 | * @param name The name of the desired item. |
| 5276 | * |
| 5277 | * @return the value of an item that previously added with putExtra() |
| 5278 | * or null if none was found. |
| 5279 | * |
| 5280 | * @deprecated |
| 5281 | * @hide |
| 5282 | */ |
| 5283 | @Deprecated |
| 5284 | public Object getExtra(String name) { |
| 5285 | return getExtra(name, null); |
| 5286 | } |
| 5287 | |
| 5288 | /** |
| 5289 | * Retrieve extended data from the intent. |
| 5290 | * |
| 5291 | * @param name The name of the desired item. |
| 5292 | * @param defaultValue the value to be returned if no value of the desired |
| 5293 | * type is stored with the given name. |
| 5294 | * |
| 5295 | * @return the value of an item that previously added with putExtra() |
| 5296 | * or the default value if none was found. |
| 5297 | * |
| 5298 | * @see #putExtra(String, boolean) |
| 5299 | */ |
| 5300 | public boolean getBooleanExtra(String name, boolean defaultValue) { |
| 5301 | return mExtras == null ? defaultValue : |
| 5302 | mExtras.getBoolean(name, defaultValue); |
| 5303 | } |
| 5304 | |
| 5305 | /** |
| 5306 | * Retrieve extended data from the intent. |
| 5307 | * |
| 5308 | * @param name The name of the desired item. |
| 5309 | * @param defaultValue the value to be returned if no value of the desired |
| 5310 | * type is stored with the given name. |
| 5311 | * |
| 5312 | * @return the value of an item that previously added with putExtra() |
| 5313 | * or the default value if none was found. |
| 5314 | * |
| 5315 | * @see #putExtra(String, byte) |
| 5316 | */ |
| 5317 | public byte getByteExtra(String name, byte defaultValue) { |
| 5318 | return mExtras == null ? defaultValue : |
| 5319 | mExtras.getByte(name, defaultValue); |
| 5320 | } |
| 5321 | |
| 5322 | /** |
| 5323 | * Retrieve extended data from the intent. |
| 5324 | * |
| 5325 | * @param name The name of the desired item. |
| 5326 | * @param defaultValue the value to be returned if no value of the desired |
| 5327 | * type is stored with the given name. |
| 5328 | * |
| 5329 | * @return the value of an item that previously added with putExtra() |
| 5330 | * or the default value if none was found. |
| 5331 | * |
| 5332 | * @see #putExtra(String, short) |
| 5333 | */ |
| 5334 | public short getShortExtra(String name, short defaultValue) { |
| 5335 | return mExtras == null ? defaultValue : |
| 5336 | mExtras.getShort(name, defaultValue); |
| 5337 | } |
| 5338 | |
| 5339 | /** |
| 5340 | * Retrieve extended data from the intent. |
| 5341 | * |
| 5342 | * @param name The name of the desired item. |
| 5343 | * @param defaultValue the value to be returned if no value of the desired |
| 5344 | * type is stored with the given name. |
| 5345 | * |
| 5346 | * @return the value of an item that previously added with putExtra() |
| 5347 | * or the default value if none was found. |
| 5348 | * |
| 5349 | * @see #putExtra(String, char) |
| 5350 | */ |
| 5351 | public char getCharExtra(String name, char defaultValue) { |
| 5352 | return mExtras == null ? defaultValue : |
| 5353 | mExtras.getChar(name, defaultValue); |
| 5354 | } |
| 5355 | |
| 5356 | /** |
| 5357 | * Retrieve extended data from the intent. |
| 5358 | * |
| 5359 | * @param name The name of the desired item. |
| 5360 | * @param defaultValue the value to be returned if no value of the desired |
| 5361 | * type is stored with the given name. |
| 5362 | * |
| 5363 | * @return the value of an item that previously added with putExtra() |
| 5364 | * or the default value if none was found. |
| 5365 | * |
| 5366 | * @see #putExtra(String, int) |
| 5367 | */ |
| 5368 | public int getIntExtra(String name, int defaultValue) { |
| 5369 | return mExtras == null ? defaultValue : |
| 5370 | mExtras.getInt(name, defaultValue); |
| 5371 | } |
| 5372 | |
| 5373 | /** |
| 5374 | * Retrieve extended data from the intent. |
| 5375 | * |
| 5376 | * @param name The name of the desired item. |
| 5377 | * @param defaultValue the value to be returned if no value of the desired |
| 5378 | * type is stored with the given name. |
| 5379 | * |
| 5380 | * @return the value of an item that previously added with putExtra() |
| 5381 | * or the default value if none was found. |
| 5382 | * |
| 5383 | * @see #putExtra(String, long) |
| 5384 | */ |
| 5385 | public long getLongExtra(String name, long defaultValue) { |
| 5386 | return mExtras == null ? defaultValue : |
| 5387 | mExtras.getLong(name, defaultValue); |
| 5388 | } |
| 5389 | |
| 5390 | /** |
| 5391 | * Retrieve extended data from the intent. |
| 5392 | * |
| 5393 | * @param name The name of the desired item. |
| 5394 | * @param defaultValue the value to be returned if no value of the desired |
| 5395 | * type is stored with the given name. |
| 5396 | * |
| 5397 | * @return the value of an item that previously added with putExtra(), |
| 5398 | * or the default value if no such item is present |
| 5399 | * |
| 5400 | * @see #putExtra(String, float) |
| 5401 | */ |
| 5402 | public float getFloatExtra(String name, float defaultValue) { |
| 5403 | return mExtras == null ? defaultValue : |
| 5404 | mExtras.getFloat(name, defaultValue); |
| 5405 | } |
| 5406 | |
| 5407 | /** |
| 5408 | * Retrieve extended data from the intent. |
| 5409 | * |
| 5410 | * @param name The name of the desired item. |
| 5411 | * @param defaultValue the value to be returned if no value of the desired |
| 5412 | * type is stored with the given name. |
| 5413 | * |
| 5414 | * @return the value of an item that previously added with putExtra() |
| 5415 | * or the default value if none was found. |
| 5416 | * |
| 5417 | * @see #putExtra(String, double) |
| 5418 | */ |
| 5419 | public double getDoubleExtra(String name, double defaultValue) { |
| 5420 | return mExtras == null ? defaultValue : |
| 5421 | mExtras.getDouble(name, defaultValue); |
| 5422 | } |
| 5423 | |
| 5424 | /** |
| 5425 | * Retrieve extended data from the intent. |
| 5426 | * |
| 5427 | * @param name The name of the desired item. |
| 5428 | * |
| 5429 | * @return the value of an item that previously added with putExtra() |
| 5430 | * or null if no String value was found. |
| 5431 | * |
| 5432 | * @see #putExtra(String, String) |
| 5433 | */ |
| 5434 | public String getStringExtra(String name) { |
| 5435 | return mExtras == null ? null : mExtras.getString(name); |
| 5436 | } |
| 5437 | |
| 5438 | /** |
| 5439 | * Retrieve extended data from the intent. |
| 5440 | * |
| 5441 | * @param name The name of the desired item. |
| 5442 | * |
| 5443 | * @return the value of an item that previously added with putExtra() |
| 5444 | * or null if no CharSequence value was found. |
| 5445 | * |
| 5446 | * @see #putExtra(String, CharSequence) |
| 5447 | */ |
| 5448 | public CharSequence getCharSequenceExtra(String name) { |
| 5449 | return mExtras == null ? null : mExtras.getCharSequence(name); |
| 5450 | } |
| 5451 | |
| 5452 | /** |
| 5453 | * Retrieve extended data from the intent. |
| 5454 | * |
| 5455 | * @param name The name of the desired item. |
| 5456 | * |
| 5457 | * @return the value of an item that previously added with putExtra() |
| 5458 | * or null if no Parcelable value was found. |
| 5459 | * |
| 5460 | * @see #putExtra(String, Parcelable) |
| 5461 | */ |
| 5462 | public <T extends Parcelable> T getParcelableExtra(String name) { |
| 5463 | return mExtras == null ? null : mExtras.<T>getParcelable(name); |
| 5464 | } |
| 5465 | |
| 5466 | /** |
| 5467 | * Retrieve extended data from the intent. |
| 5468 | * |
| 5469 | * @param name The name of the desired item. |
| 5470 | * |
| 5471 | * @return the value of an item that previously added with putExtra() |
| 5472 | * or null if no Parcelable[] value was found. |
| 5473 | * |
| 5474 | * @see #putExtra(String, Parcelable[]) |
| 5475 | */ |
| 5476 | public Parcelable[] getParcelableArrayExtra(String name) { |
| 5477 | return mExtras == null ? null : mExtras.getParcelableArray(name); |
| 5478 | } |
| 5479 | |
| 5480 | /** |
| 5481 | * Retrieve extended data from the intent. |
| 5482 | * |
| 5483 | * @param name The name of the desired item. |
| 5484 | * |
| 5485 | * @return the value of an item that previously added with putExtra() |
| 5486 | * or null if no ArrayList<Parcelable> value was found. |
| 5487 | * |
| 5488 | * @see #putParcelableArrayListExtra(String, ArrayList) |
| 5489 | */ |
| 5490 | public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { |
| 5491 | return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); |
| 5492 | } |
| 5493 | |
| 5494 | /** |
| 5495 | * Retrieve extended data from the intent. |
| 5496 | * |
| 5497 | * @param name The name of the desired item. |
| 5498 | * |
| 5499 | * @return the value of an item that previously added with putExtra() |
| 5500 | * or null if no Serializable value was found. |
| 5501 | * |
| 5502 | * @see #putExtra(String, Serializable) |
| 5503 | */ |
| 5504 | public Serializable getSerializableExtra(String name) { |
| 5505 | return mExtras == null ? null : mExtras.getSerializable(name); |
| 5506 | } |
| 5507 | |
| 5508 | /** |
| 5509 | * Retrieve extended data from the intent. |
| 5510 | * |
| 5511 | * @param name The name of the desired item. |
| 5512 | * |
| 5513 | * @return the value of an item that previously added with putExtra() |
| 5514 | * or null if no ArrayList<Integer> value was found. |
| 5515 | * |
| 5516 | * @see #putIntegerArrayListExtra(String, ArrayList) |
| 5517 | */ |
| 5518 | public ArrayList<Integer> getIntegerArrayListExtra(String name) { |
| 5519 | return mExtras == null ? null : mExtras.getIntegerArrayList(name); |
| 5520 | } |
| 5521 | |
| 5522 | /** |
| 5523 | * Retrieve extended data from the intent. |
| 5524 | * |
| 5525 | * @param name The name of the desired item. |
| 5526 | * |
| 5527 | * @return the value of an item that previously added with putExtra() |
| 5528 | * or null if no ArrayList<String> value was found. |
| 5529 | * |
| 5530 | * @see #putStringArrayListExtra(String, ArrayList) |
| 5531 | */ |
| 5532 | public ArrayList<String> getStringArrayListExtra(String name) { |
| 5533 | return mExtras == null ? null : mExtras.getStringArrayList(name); |
| 5534 | } |
| 5535 | |
| 5536 | /** |
| 5537 | * Retrieve extended data from the intent. |
| 5538 | * |
| 5539 | * @param name The name of the desired item. |
| 5540 | * |
| 5541 | * @return the value of an item that previously added with putExtra() |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 5542 | * or null if no ArrayList<CharSequence> value was found. |
| 5543 | * |
| 5544 | * @see #putCharSequenceArrayListExtra(String, ArrayList) |
| 5545 | */ |
| 5546 | public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { |
| 5547 | return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); |
| 5548 | } |
| 5549 | |
| 5550 | /** |
| 5551 | * Retrieve extended data from the intent. |
| 5552 | * |
| 5553 | * @param name The name of the desired item. |
| 5554 | * |
| 5555 | * @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] | 5556 | * or null if no boolean array value was found. |
| 5557 | * |
| 5558 | * @see #putExtra(String, boolean[]) |
| 5559 | */ |
| 5560 | public boolean[] getBooleanArrayExtra(String name) { |
| 5561 | return mExtras == null ? null : mExtras.getBooleanArray(name); |
| 5562 | } |
| 5563 | |
| 5564 | /** |
| 5565 | * Retrieve extended data from the intent. |
| 5566 | * |
| 5567 | * @param name The name of the desired item. |
| 5568 | * |
| 5569 | * @return the value of an item that previously added with putExtra() |
| 5570 | * or null if no byte array value was found. |
| 5571 | * |
| 5572 | * @see #putExtra(String, byte[]) |
| 5573 | */ |
| 5574 | public byte[] getByteArrayExtra(String name) { |
| 5575 | return mExtras == null ? null : mExtras.getByteArray(name); |
| 5576 | } |
| 5577 | |
| 5578 | /** |
| 5579 | * Retrieve extended data from the intent. |
| 5580 | * |
| 5581 | * @param name The name of the desired item. |
| 5582 | * |
| 5583 | * @return the value of an item that previously added with putExtra() |
| 5584 | * or null if no short array value was found. |
| 5585 | * |
| 5586 | * @see #putExtra(String, short[]) |
| 5587 | */ |
| 5588 | public short[] getShortArrayExtra(String name) { |
| 5589 | return mExtras == null ? null : mExtras.getShortArray(name); |
| 5590 | } |
| 5591 | |
| 5592 | /** |
| 5593 | * Retrieve extended data from the intent. |
| 5594 | * |
| 5595 | * @param name The name of the desired item. |
| 5596 | * |
| 5597 | * @return the value of an item that previously added with putExtra() |
| 5598 | * or null if no char array value was found. |
| 5599 | * |
| 5600 | * @see #putExtra(String, char[]) |
| 5601 | */ |
| 5602 | public char[] getCharArrayExtra(String name) { |
| 5603 | return mExtras == null ? null : mExtras.getCharArray(name); |
| 5604 | } |
| 5605 | |
| 5606 | /** |
| 5607 | * Retrieve extended data from the intent. |
| 5608 | * |
| 5609 | * @param name The name of the desired item. |
| 5610 | * |
| 5611 | * @return the value of an item that previously added with putExtra() |
| 5612 | * or null if no int array value was found. |
| 5613 | * |
| 5614 | * @see #putExtra(String, int[]) |
| 5615 | */ |
| 5616 | public int[] getIntArrayExtra(String name) { |
| 5617 | return mExtras == null ? null : mExtras.getIntArray(name); |
| 5618 | } |
| 5619 | |
| 5620 | /** |
| 5621 | * Retrieve extended data from the intent. |
| 5622 | * |
| 5623 | * @param name The name of the desired item. |
| 5624 | * |
| 5625 | * @return the value of an item that previously added with putExtra() |
| 5626 | * or null if no long array value was found. |
| 5627 | * |
| 5628 | * @see #putExtra(String, long[]) |
| 5629 | */ |
| 5630 | public long[] getLongArrayExtra(String name) { |
| 5631 | return mExtras == null ? null : mExtras.getLongArray(name); |
| 5632 | } |
| 5633 | |
| 5634 | /** |
| 5635 | * Retrieve extended data from the intent. |
| 5636 | * |
| 5637 | * @param name The name of the desired item. |
| 5638 | * |
| 5639 | * @return the value of an item that previously added with putExtra() |
| 5640 | * or null if no float array value was found. |
| 5641 | * |
| 5642 | * @see #putExtra(String, float[]) |
| 5643 | */ |
| 5644 | public float[] getFloatArrayExtra(String name) { |
| 5645 | return mExtras == null ? null : mExtras.getFloatArray(name); |
| 5646 | } |
| 5647 | |
| 5648 | /** |
| 5649 | * Retrieve extended data from the intent. |
| 5650 | * |
| 5651 | * @param name The name of the desired item. |
| 5652 | * |
| 5653 | * @return the value of an item that previously added with putExtra() |
| 5654 | * or null if no double array value was found. |
| 5655 | * |
| 5656 | * @see #putExtra(String, double[]) |
| 5657 | */ |
| 5658 | public double[] getDoubleArrayExtra(String name) { |
| 5659 | return mExtras == null ? null : mExtras.getDoubleArray(name); |
| 5660 | } |
| 5661 | |
| 5662 | /** |
| 5663 | * Retrieve extended data from the intent. |
| 5664 | * |
| 5665 | * @param name The name of the desired item. |
| 5666 | * |
| 5667 | * @return the value of an item that previously added with putExtra() |
| 5668 | * or null if no String array value was found. |
| 5669 | * |
| 5670 | * @see #putExtra(String, String[]) |
| 5671 | */ |
| 5672 | public String[] getStringArrayExtra(String name) { |
| 5673 | return mExtras == null ? null : mExtras.getStringArray(name); |
| 5674 | } |
| 5675 | |
| 5676 | /** |
| 5677 | * Retrieve extended data from the intent. |
| 5678 | * |
| 5679 | * @param name The name of the desired item. |
| 5680 | * |
| 5681 | * @return the value of an item that previously added with putExtra() |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 5682 | * or null if no CharSequence array value was found. |
| 5683 | * |
| 5684 | * @see #putExtra(String, CharSequence[]) |
| 5685 | */ |
| 5686 | public CharSequence[] getCharSequenceArrayExtra(String name) { |
| 5687 | return mExtras == null ? null : mExtras.getCharSequenceArray(name); |
| 5688 | } |
| 5689 | |
| 5690 | /** |
| 5691 | * Retrieve extended data from the intent. |
| 5692 | * |
| 5693 | * @param name The name of the desired item. |
| 5694 | * |
| 5695 | * @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] | 5696 | * or null if no Bundle value was found. |
| 5697 | * |
| 5698 | * @see #putExtra(String, Bundle) |
| 5699 | */ |
| 5700 | public Bundle getBundleExtra(String name) { |
| 5701 | return mExtras == null ? null : mExtras.getBundle(name); |
| 5702 | } |
| 5703 | |
| 5704 | /** |
| 5705 | * Retrieve extended data from the intent. |
| 5706 | * |
| 5707 | * @param name The name of the desired item. |
| 5708 | * |
| 5709 | * @return the value of an item that previously added with putExtra() |
| 5710 | * or null if no IBinder value was found. |
| 5711 | * |
| 5712 | * @see #putExtra(String, IBinder) |
| 5713 | * |
| 5714 | * @deprecated |
| 5715 | * @hide |
| 5716 | */ |
| 5717 | @Deprecated |
| 5718 | public IBinder getIBinderExtra(String name) { |
| 5719 | return mExtras == null ? null : mExtras.getIBinder(name); |
| 5720 | } |
| 5721 | |
| 5722 | /** |
| 5723 | * Retrieve extended data from the intent. |
| 5724 | * |
| 5725 | * @param name The name of the desired item. |
| 5726 | * @param defaultValue The default value to return in case no item is |
| 5727 | * associated with the key 'name' |
| 5728 | * |
| 5729 | * @return the value of an item that previously added with putExtra() |
| 5730 | * or defaultValue if none was found. |
| 5731 | * |
| 5732 | * @see #putExtra |
| 5733 | * |
| 5734 | * @deprecated |
| 5735 | * @hide |
| 5736 | */ |
| 5737 | @Deprecated |
| 5738 | public Object getExtra(String name, Object defaultValue) { |
| 5739 | Object result = defaultValue; |
| 5740 | if (mExtras != null) { |
| 5741 | Object result2 = mExtras.get(name); |
| 5742 | if (result2 != null) { |
| 5743 | result = result2; |
| 5744 | } |
| 5745 | } |
| 5746 | |
| 5747 | return result; |
| 5748 | } |
| 5749 | |
| 5750 | /** |
| 5751 | * Retrieves a map of extended data from the intent. |
| 5752 | * |
| 5753 | * @return the map of all extras previously added with putExtra(), |
| 5754 | * or null if none have been added. |
| 5755 | */ |
| 5756 | public Bundle getExtras() { |
| 5757 | return (mExtras != null) |
| 5758 | ? new Bundle(mExtras) |
| 5759 | : null; |
| 5760 | } |
| 5761 | |
| 5762 | /** |
Dianne Hackborn | a83ce1d | 2015-03-11 15:16:13 -0700 | [diff] [blame] | 5763 | * Filter extras to only basic types. |
| 5764 | * @hide |
| 5765 | */ |
| 5766 | public void removeUnsafeExtras() { |
| 5767 | if (mExtras != null) { |
| 5768 | mExtras.filterValues(); |
| 5769 | } |
| 5770 | } |
| 5771 | |
| 5772 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5773 | * Retrieve any special flags associated with this intent. You will |
| 5774 | * normally just set them with {@link #setFlags} and let the system |
| 5775 | * take the appropriate action with them. |
| 5776 | * |
| 5777 | * @return int The currently set flags. |
| 5778 | * |
| 5779 | * @see #setFlags |
| 5780 | */ |
| 5781 | public int getFlags() { |
| 5782 | return mFlags; |
| 5783 | } |
| 5784 | |
Dianne Hackborn | e7f9721 | 2011-02-24 14:40:20 -0800 | [diff] [blame] | 5785 | /** @hide */ |
| 5786 | public boolean isExcludingStopped() { |
| 5787 | return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) |
| 5788 | == FLAG_EXCLUDE_STOPPED_PACKAGES; |
| 5789 | } |
| 5790 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5791 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5792 | * Retrieve the application package name this Intent is limited to. When |
| 5793 | * resolving an Intent, if non-null this limits the resolution to only |
| 5794 | * components in the given application package. |
| 5795 | * |
| 5796 | * @return The name of the application package for the Intent. |
| 5797 | * |
| 5798 | * @see #resolveActivity |
| 5799 | * @see #setPackage |
| 5800 | */ |
| 5801 | public String getPackage() { |
| 5802 | return mPackage; |
| 5803 | } |
| 5804 | |
| 5805 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5806 | * Retrieve the concrete component associated with the intent. When receiving |
| 5807 | * an intent, this is the component that was found to best handle it (that is, |
| 5808 | * yourself) and will always be non-null; in all other cases it will be |
| 5809 | * null unless explicitly set. |
| 5810 | * |
| 5811 | * @return The name of the application component to handle the intent. |
| 5812 | * |
| 5813 | * @see #resolveActivity |
| 5814 | * @see #setComponent |
| 5815 | */ |
| 5816 | public ComponentName getComponent() { |
| 5817 | return mComponent; |
| 5818 | } |
| 5819 | |
| 5820 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 5821 | * Get the bounds of the sender of this intent, in screen coordinates. This can be |
| 5822 | * used as a hint to the receiver for animations and the like. Null means that there |
| 5823 | * is no source bounds. |
| 5824 | */ |
| 5825 | public Rect getSourceBounds() { |
| 5826 | return mSourceBounds; |
| 5827 | } |
| 5828 | |
| 5829 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5830 | * Return the Activity component that should be used to handle this intent. |
| 5831 | * The appropriate component is determined based on the information in the |
| 5832 | * intent, evaluated as follows: |
| 5833 | * |
| 5834 | * <p>If {@link #getComponent} returns an explicit class, that is returned |
| 5835 | * without any further consideration. |
| 5836 | * |
| 5837 | * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent |
| 5838 | * category to be considered. |
| 5839 | * |
| 5840 | * <p>If {@link #getAction} is non-NULL, the activity must handle this |
| 5841 | * action. |
| 5842 | * |
| 5843 | * <p>If {@link #resolveType} returns non-NULL, the activity must handle |
| 5844 | * this type. |
| 5845 | * |
| 5846 | * <p>If {@link #addCategory} has added any categories, the activity must |
| 5847 | * handle ALL of the categories specified. |
| 5848 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 5849 | * <p>If {@link #getPackage} is non-NULL, only activity components in |
| 5850 | * that application package will be considered. |
| 5851 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5852 | * <p>If there are no activities that satisfy all of these conditions, a |
| 5853 | * null string is returned. |
| 5854 | * |
| 5855 | * <p>If multiple activities are found to satisfy the intent, the one with |
| 5856 | * the highest priority will be used. If there are multiple activities |
| 5857 | * with the same priority, the system will either pick the best activity |
| 5858 | * based on user preference, or resolve to a system class that will allow |
| 5859 | * the user to pick an activity and forward from there. |
| 5860 | * |
| 5861 | * <p>This method is implemented simply by calling |
| 5862 | * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter |
| 5863 | * true.</p> |
| 5864 | * <p> This API is called for you as part of starting an activity from an |
| 5865 | * intent. You do not normally need to call it yourself.</p> |
| 5866 | * |
| 5867 | * @param pm The package manager with which to resolve the Intent. |
| 5868 | * |
| 5869 | * @return Name of the component implementing an activity that can |
| 5870 | * display the intent. |
| 5871 | * |
| 5872 | * @see #setComponent |
| 5873 | * @see #getComponent |
| 5874 | * @see #resolveActivityInfo |
| 5875 | */ |
| 5876 | public ComponentName resolveActivity(PackageManager pm) { |
| 5877 | if (mComponent != null) { |
| 5878 | return mComponent; |
| 5879 | } |
| 5880 | |
| 5881 | ResolveInfo info = pm.resolveActivity( |
| 5882 | this, PackageManager.MATCH_DEFAULT_ONLY); |
| 5883 | if (info != null) { |
| 5884 | return new ComponentName( |
| 5885 | info.activityInfo.applicationInfo.packageName, |
| 5886 | info.activityInfo.name); |
| 5887 | } |
| 5888 | |
| 5889 | return null; |
| 5890 | } |
| 5891 | |
| 5892 | /** |
| 5893 | * Resolve the Intent into an {@link ActivityInfo} |
| 5894 | * describing the activity that should execute the intent. Resolution |
| 5895 | * follows the same rules as described for {@link #resolveActivity}, but |
| 5896 | * you get back the completely information about the resolved activity |
| 5897 | * instead of just its class name. |
| 5898 | * |
| 5899 | * @param pm The package manager with which to resolve the Intent. |
| 5900 | * @param flags Addition information to retrieve as per |
| 5901 | * {@link PackageManager#getActivityInfo(ComponentName, int) |
| 5902 | * PackageManager.getActivityInfo()}. |
| 5903 | * |
| 5904 | * @return PackageManager.ActivityInfo |
| 5905 | * |
| 5906 | * @see #resolveActivity |
| 5907 | */ |
| 5908 | public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) { |
| 5909 | ActivityInfo ai = null; |
| 5910 | if (mComponent != null) { |
| 5911 | try { |
| 5912 | ai = pm.getActivityInfo(mComponent, flags); |
| 5913 | } catch (PackageManager.NameNotFoundException e) { |
| 5914 | // ignore |
| 5915 | } |
| 5916 | } else { |
| 5917 | ResolveInfo info = pm.resolveActivity( |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 5918 | this, PackageManager.MATCH_DEFAULT_ONLY | flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5919 | if (info != null) { |
| 5920 | ai = info.activityInfo; |
| 5921 | } |
| 5922 | } |
| 5923 | |
| 5924 | return ai; |
| 5925 | } |
| 5926 | |
| 5927 | /** |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 5928 | * Special function for use by the system to resolve service |
| 5929 | * intents to system apps. Throws an exception if there are |
| 5930 | * multiple potential matches to the Intent. Returns null if |
| 5931 | * there are no matches. |
| 5932 | * @hide |
| 5933 | */ |
| 5934 | public ComponentName resolveSystemService(PackageManager pm, int flags) { |
| 5935 | if (mComponent != null) { |
| 5936 | return mComponent; |
| 5937 | } |
| 5938 | |
| 5939 | List<ResolveInfo> results = pm.queryIntentServices(this, flags); |
| 5940 | if (results == null) { |
| 5941 | return null; |
| 5942 | } |
| 5943 | ComponentName comp = null; |
| 5944 | for (int i=0; i<results.size(); i++) { |
| 5945 | ResolveInfo ri = results.get(i); |
| 5946 | if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { |
| 5947 | continue; |
| 5948 | } |
| 5949 | ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, |
| 5950 | ri.serviceInfo.name); |
| 5951 | if (comp != null) { |
| 5952 | throw new IllegalStateException("Multiple system services handle " + this |
| 5953 | + ": " + comp + ", " + foundComp); |
| 5954 | } |
| 5955 | comp = foundComp; |
| 5956 | } |
| 5957 | return comp; |
| 5958 | } |
| 5959 | |
| 5960 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5961 | * Set the general action to be performed. |
| 5962 | * |
| 5963 | * @param action An action name, such as ACTION_VIEW. Application-specific |
| 5964 | * actions should be prefixed with the vendor's package name. |
| 5965 | * |
| 5966 | * @return Returns the same Intent object, for chaining multiple calls |
| 5967 | * into a single statement. |
| 5968 | * |
| 5969 | * @see #getAction |
| 5970 | */ |
| 5971 | public Intent setAction(String action) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 5972 | mAction = action != null ? action.intern() : null; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5973 | return this; |
| 5974 | } |
| 5975 | |
| 5976 | /** |
| 5977 | * Set the data this intent is operating on. This method automatically |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 5978 | * clears any type that was previously set by {@link #setType} or |
| 5979 | * {@link #setTypeAndNormalize}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5980 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 5981 | * <p><em>Note: scheme matching in the Android framework is |
| 5982 | * case-sensitive, unlike the formal RFC. As a result, |
| 5983 | * you should always write your Uri with a lower case scheme, |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 5984 | * or use {@link Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 5985 | * {@link #setDataAndNormalize} |
| 5986 | * to ensure that the scheme is converted to lower case.</em> |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 5987 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 5988 | * @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] | 5989 | * |
| 5990 | * @return Returns the same Intent object, for chaining multiple calls |
| 5991 | * into a single statement. |
| 5992 | * |
| 5993 | * @see #getData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 5994 | * @see #setDataAndNormalize |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 5995 | * @see android.net.Uri#normalizeScheme() |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5996 | */ |
| 5997 | public Intent setData(Uri data) { |
| 5998 | mData = data; |
| 5999 | mType = null; |
| 6000 | return this; |
| 6001 | } |
| 6002 | |
| 6003 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6004 | * Normalize and set the data this intent is operating on. |
| 6005 | * |
| 6006 | * <p>This method automatically clears any type that was |
| 6007 | * previously set (for example, by {@link #setType}). |
| 6008 | * |
| 6009 | * <p>The data Uri is normalized using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6010 | * {@link android.net.Uri#normalizeScheme} before it is set, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6011 | * so really this is just a convenience method for |
| 6012 | * <pre> |
| 6013 | * setData(data.normalize()) |
| 6014 | * </pre> |
| 6015 | * |
| 6016 | * @param data The Uri of the data this intent is now targeting. |
| 6017 | * |
| 6018 | * @return Returns the same Intent object, for chaining multiple calls |
| 6019 | * into a single statement. |
| 6020 | * |
| 6021 | * @see #getData |
| 6022 | * @see #setType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6023 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6024 | */ |
| 6025 | public Intent setDataAndNormalize(Uri data) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6026 | return setData(data.normalizeScheme()); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6027 | } |
| 6028 | |
| 6029 | /** |
| 6030 | * Set an explicit MIME data type. |
| 6031 | * |
| 6032 | * <p>This is used to create intents that only specify a type and not data, |
| 6033 | * for example to indicate the type of data to return. |
| 6034 | * |
| 6035 | * <p>This method automatically clears any data that was |
| 6036 | * previously set (for example by {@link #setData}). |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 6037 | * |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 6038 | * <p><em>Note: MIME type matching in the Android framework is |
| 6039 | * case-sensitive, unlike formal RFC MIME types. As a result, |
| 6040 | * you should always write your MIME types with lower case letters, |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6041 | * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} |
| 6042 | * 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] | 6043 | * |
| 6044 | * @param type The MIME type of the data being handled by this intent. |
| 6045 | * |
| 6046 | * @return Returns the same Intent object, for chaining multiple calls |
| 6047 | * into a single statement. |
| 6048 | * |
| 6049 | * @see #getType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6050 | * @see #setTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6051 | * @see #setDataAndType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6052 | * @see #normalizeMimeType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6053 | */ |
| 6054 | public Intent setType(String type) { |
| 6055 | mData = null; |
| 6056 | mType = type; |
| 6057 | return this; |
| 6058 | } |
| 6059 | |
| 6060 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6061 | * Normalize and set an explicit MIME data type. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6062 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6063 | * <p>This is used to create intents that only specify a type and not data, |
| 6064 | * for example to indicate the type of data to return. |
Dianne Hackborn | b3cddae | 2009-04-13 16:54:00 -0700 | [diff] [blame] | 6065 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6066 | * <p>This method automatically clears any data that was |
| 6067 | * previously set (for example by {@link #setData}). |
| 6068 | * |
| 6069 | * <p>The MIME type is normalized using |
| 6070 | * {@link #normalizeMimeType} before it is set, |
| 6071 | * so really this is just a convenience method for |
| 6072 | * <pre> |
| 6073 | * setType(Intent.normalizeMimeType(type)) |
| 6074 | * </pre> |
| 6075 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6076 | * @param type The MIME type of the data being handled by this intent. |
| 6077 | * |
| 6078 | * @return Returns the same Intent object, for chaining multiple calls |
| 6079 | * into a single statement. |
| 6080 | * |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6081 | * @see #getType |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6082 | * @see #setData |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6083 | * @see #normalizeMimeType |
| 6084 | */ |
| 6085 | public Intent setTypeAndNormalize(String type) { |
| 6086 | return setType(normalizeMimeType(type)); |
| 6087 | } |
| 6088 | |
| 6089 | /** |
| 6090 | * (Usually optional) Set the data for the intent along with an explicit |
| 6091 | * MIME data type. This method should very rarely be used -- it allows you |
| 6092 | * to override the MIME type that would ordinarily be inferred from the |
| 6093 | * data with your own type given here. |
| 6094 | * |
| 6095 | * <p><em>Note: MIME type and Uri scheme matching in the |
| 6096 | * Android framework is case-sensitive, unlike the formal RFC definitions. |
| 6097 | * 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] | 6098 | * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6099 | * {@link #setDataAndTypeAndNormalize} |
| 6100 | * to ensure that they are converted to lower case.</em> |
| 6101 | * |
| 6102 | * @param data The Uri of the data this intent is now targeting. |
| 6103 | * @param type The MIME type of the data being handled by this intent. |
| 6104 | * |
| 6105 | * @return Returns the same Intent object, for chaining multiple calls |
| 6106 | * into a single statement. |
| 6107 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6108 | * @see #setType |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6109 | * @see #setData |
| 6110 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6111 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6112 | * @see #setDataAndTypeAndNormalize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6113 | */ |
| 6114 | public Intent setDataAndType(Uri data, String type) { |
| 6115 | mData = data; |
| 6116 | mType = type; |
| 6117 | return this; |
| 6118 | } |
| 6119 | |
| 6120 | /** |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6121 | * (Usually optional) Normalize and set both the data Uri and an explicit |
| 6122 | * MIME data type. This method should very rarely be used -- it allows you |
| 6123 | * to override the MIME type that would ordinarily be inferred from the |
| 6124 | * data with your own type given here. |
| 6125 | * |
| 6126 | * <p>The data Uri and the MIME type are normalize using |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6127 | * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6128 | * before they are set, so really this is just a convenience method for |
| 6129 | * <pre> |
| 6130 | * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) |
| 6131 | * </pre> |
| 6132 | * |
| 6133 | * @param data The Uri of the data this intent is now targeting. |
| 6134 | * @param type The MIME type of the data being handled by this intent. |
| 6135 | * |
| 6136 | * @return Returns the same Intent object, for chaining multiple calls |
| 6137 | * into a single statement. |
| 6138 | * |
| 6139 | * @see #setType |
| 6140 | * @see #setData |
| 6141 | * @see #setDataAndType |
| 6142 | * @see #normalizeMimeType |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6143 | * @see android.net.Uri#normalizeScheme |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6144 | */ |
| 6145 | public Intent setDataAndTypeAndNormalize(Uri data, String type) { |
Jesse Wilson | abc43dd | 2012-05-10 14:29:33 -0400 | [diff] [blame] | 6146 | return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 6147 | } |
| 6148 | |
| 6149 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6150 | * Add a new category to the intent. Categories provide additional detail |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 6151 | * 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] | 6152 | * activities that provide <em>all</em> of the requested categories will be |
| 6153 | * used. |
| 6154 | * |
| 6155 | * @param category The desired category. This can be either one of the |
| 6156 | * predefined Intent categories, or a custom category in your own |
| 6157 | * namespace. |
| 6158 | * |
| 6159 | * @return Returns the same Intent object, for chaining multiple calls |
| 6160 | * into a single statement. |
| 6161 | * |
| 6162 | * @see #hasCategory |
| 6163 | * @see #removeCategory |
| 6164 | */ |
| 6165 | public Intent addCategory(String category) { |
| 6166 | if (mCategories == null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 6167 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6168 | } |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 6169 | mCategories.add(category.intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6170 | return this; |
| 6171 | } |
| 6172 | |
| 6173 | /** |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 6174 | * Remove a category from an intent. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6175 | * |
| 6176 | * @param category The category to remove. |
| 6177 | * |
| 6178 | * @see #addCategory |
| 6179 | */ |
| 6180 | public void removeCategory(String category) { |
| 6181 | if (mCategories != null) { |
| 6182 | mCategories.remove(category); |
| 6183 | if (mCategories.size() == 0) { |
| 6184 | mCategories = null; |
| 6185 | } |
| 6186 | } |
| 6187 | } |
| 6188 | |
| 6189 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 6190 | * Set a selector for this Intent. This is a modification to the kinds of |
| 6191 | * things the Intent will match. If the selector is set, it will be used |
| 6192 | * when trying to find entities that can handle the Intent, instead of the |
| 6193 | * main contents of the Intent. This allows you build an Intent containing |
| 6194 | * a generic protocol while targeting it more specifically. |
| 6195 | * |
| 6196 | * <p>An example of where this may be used is with things like |
| 6197 | * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an |
| 6198 | * Intent that will launch the Browser application. However, the correct |
| 6199 | * main entry point of an application is actually {@link #ACTION_MAIN} |
| 6200 | * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} |
| 6201 | * used to specify the actual Activity to launch. If you launch the browser |
| 6202 | * with something different, undesired behavior may happen if the user has |
| 6203 | * previously or later launches it the normal way, since they do not match. |
| 6204 | * Instead, you can build an Intent with the MAIN action (but no ComponentName |
| 6205 | * yet specified) and set a selector with {@link #ACTION_MAIN} and |
| 6206 | * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. |
| 6207 | * |
| 6208 | * <p>Setting a selector does not impact the behavior of |
| 6209 | * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the |
| 6210 | * desired behavior of a selector -- it does not impact the base meaning |
| 6211 | * of the Intent, just what kinds of things will be matched against it |
| 6212 | * when determining who can handle it.</p> |
| 6213 | * |
| 6214 | * <p>You can not use both a selector and {@link #setPackage(String)} on |
| 6215 | * the same base Intent.</p> |
| 6216 | * |
| 6217 | * @param selector The desired selector Intent; set to null to not use |
| 6218 | * a special selector. |
| 6219 | */ |
| 6220 | public void setSelector(Intent selector) { |
| 6221 | if (selector == this) { |
| 6222 | throw new IllegalArgumentException( |
| 6223 | "Intent being set as a selector of itself"); |
| 6224 | } |
| 6225 | if (selector != null && mPackage != null) { |
| 6226 | throw new IllegalArgumentException( |
| 6227 | "Can't set selector when package name is already set"); |
| 6228 | } |
| 6229 | mSelector = selector; |
| 6230 | } |
| 6231 | |
| 6232 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6233 | * Set a {@link ClipData} associated with this Intent. This replaces any |
| 6234 | * previously set ClipData. |
| 6235 | * |
| 6236 | * <p>The ClipData in an intent is not used for Intent matching or other |
| 6237 | * such operations. Semantically it is like extras, used to transmit |
| 6238 | * additional data with the Intent. The main feature of using this over |
| 6239 | * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} |
| 6240 | * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI |
| 6241 | * items included in the clip data. This is useful, in particular, if |
| 6242 | * you want to transmit an Intent containing multiple <code>content:</code> |
| 6243 | * URIs for which the recipient may not have global permission to access the |
| 6244 | * content provider. |
| 6245 | * |
| 6246 | * <p>If the ClipData contains items that are themselves Intents, any |
| 6247 | * grant flags in those Intents will be ignored. Only the top-level flags |
| 6248 | * of the main Intent are respected, and will be applied to all Uri or |
| 6249 | * Intent items in the clip (or sub-items of the clip). |
| 6250 | * |
| 6251 | * <p>The MIME type, label, and icon in the ClipData object are not |
| 6252 | * directly used by Intent. Applications should generally rely on the |
| 6253 | * MIME type of the Intent itself, not what it may find in the ClipData. |
| 6254 | * 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] | 6255 | * with a MIME type of "*/*". |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 6256 | * |
| 6257 | * @param clip The new clip to set. May be null to clear the current clip. |
| 6258 | */ |
| 6259 | public void setClipData(ClipData clip) { |
| 6260 | mClipData = clip; |
| 6261 | } |
| 6262 | |
| 6263 | /** |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 6264 | * This is NOT a secure mechanism to identify the user who sent the intent. |
| 6265 | * When the intent is sent to a different user, it is used to fix uris by adding the userId |
| 6266 | * who sent the intent. |
| 6267 | * @hide |
| 6268 | */ |
Nicolas Prevot | 107f7b7 | 2015-07-01 16:31:48 +0100 | [diff] [blame] | 6269 | public void prepareToLeaveUser(int userId) { |
| 6270 | // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. |
| 6271 | // We want mContentUserHint to refer to the original user, so don't do anything. |
| 6272 | if (mContentUserHint == UserHandle.USER_CURRENT) { |
| 6273 | mContentUserHint = userId; |
| 6274 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 6275 | } |
| 6276 | |
| 6277 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6278 | * Add extended data to the intent. The name must include a package |
| 6279 | * prefix, for example the app com.android.contacts would use names |
| 6280 | * like "com.android.contacts.ShowAll". |
| 6281 | * |
| 6282 | * @param name The name of the extra data, with package prefix. |
| 6283 | * @param value The boolean data value. |
| 6284 | * |
| 6285 | * @return Returns the same Intent object, for chaining multiple calls |
| 6286 | * into a single statement. |
| 6287 | * |
| 6288 | * @see #putExtras |
| 6289 | * @see #removeExtra |
| 6290 | * @see #getBooleanExtra(String, boolean) |
| 6291 | */ |
| 6292 | public Intent putExtra(String name, boolean value) { |
| 6293 | if (mExtras == null) { |
| 6294 | mExtras = new Bundle(); |
| 6295 | } |
| 6296 | mExtras.putBoolean(name, value); |
| 6297 | return this; |
| 6298 | } |
| 6299 | |
| 6300 | /** |
| 6301 | * Add extended data to the intent. The name must include a package |
| 6302 | * prefix, for example the app com.android.contacts would use names |
| 6303 | * like "com.android.contacts.ShowAll". |
| 6304 | * |
| 6305 | * @param name The name of the extra data, with package prefix. |
| 6306 | * @param value The byte data value. |
| 6307 | * |
| 6308 | * @return Returns the same Intent object, for chaining multiple calls |
| 6309 | * into a single statement. |
| 6310 | * |
| 6311 | * @see #putExtras |
| 6312 | * @see #removeExtra |
| 6313 | * @see #getByteExtra(String, byte) |
| 6314 | */ |
| 6315 | public Intent putExtra(String name, byte value) { |
| 6316 | if (mExtras == null) { |
| 6317 | mExtras = new Bundle(); |
| 6318 | } |
| 6319 | mExtras.putByte(name, value); |
| 6320 | return this; |
| 6321 | } |
| 6322 | |
| 6323 | /** |
| 6324 | * Add extended data to the intent. The name must include a package |
| 6325 | * prefix, for example the app com.android.contacts would use names |
| 6326 | * like "com.android.contacts.ShowAll". |
| 6327 | * |
| 6328 | * @param name The name of the extra data, with package prefix. |
| 6329 | * @param value The char data value. |
| 6330 | * |
| 6331 | * @return Returns the same Intent object, for chaining multiple calls |
| 6332 | * into a single statement. |
| 6333 | * |
| 6334 | * @see #putExtras |
| 6335 | * @see #removeExtra |
| 6336 | * @see #getCharExtra(String, char) |
| 6337 | */ |
| 6338 | public Intent putExtra(String name, char value) { |
| 6339 | if (mExtras == null) { |
| 6340 | mExtras = new Bundle(); |
| 6341 | } |
| 6342 | mExtras.putChar(name, value); |
| 6343 | return this; |
| 6344 | } |
| 6345 | |
| 6346 | /** |
| 6347 | * Add extended data to the intent. The name must include a package |
| 6348 | * prefix, for example the app com.android.contacts would use names |
| 6349 | * like "com.android.contacts.ShowAll". |
| 6350 | * |
| 6351 | * @param name The name of the extra data, with package prefix. |
| 6352 | * @param value The short data value. |
| 6353 | * |
| 6354 | * @return Returns the same Intent object, for chaining multiple calls |
| 6355 | * into a single statement. |
| 6356 | * |
| 6357 | * @see #putExtras |
| 6358 | * @see #removeExtra |
| 6359 | * @see #getShortExtra(String, short) |
| 6360 | */ |
| 6361 | public Intent putExtra(String name, short value) { |
| 6362 | if (mExtras == null) { |
| 6363 | mExtras = new Bundle(); |
| 6364 | } |
| 6365 | mExtras.putShort(name, value); |
| 6366 | return this; |
| 6367 | } |
| 6368 | |
| 6369 | /** |
| 6370 | * Add extended data to the intent. The name must include a package |
| 6371 | * prefix, for example the app com.android.contacts would use names |
| 6372 | * like "com.android.contacts.ShowAll". |
| 6373 | * |
| 6374 | * @param name The name of the extra data, with package prefix. |
| 6375 | * @param value The integer data value. |
| 6376 | * |
| 6377 | * @return Returns the same Intent object, for chaining multiple calls |
| 6378 | * into a single statement. |
| 6379 | * |
| 6380 | * @see #putExtras |
| 6381 | * @see #removeExtra |
| 6382 | * @see #getIntExtra(String, int) |
| 6383 | */ |
| 6384 | public Intent putExtra(String name, int value) { |
| 6385 | if (mExtras == null) { |
| 6386 | mExtras = new Bundle(); |
| 6387 | } |
| 6388 | mExtras.putInt(name, value); |
| 6389 | return this; |
| 6390 | } |
| 6391 | |
| 6392 | /** |
| 6393 | * Add extended data to the intent. The name must include a package |
| 6394 | * prefix, for example the app com.android.contacts would use names |
| 6395 | * like "com.android.contacts.ShowAll". |
| 6396 | * |
| 6397 | * @param name The name of the extra data, with package prefix. |
| 6398 | * @param value The long data value. |
| 6399 | * |
| 6400 | * @return Returns the same Intent object, for chaining multiple calls |
| 6401 | * into a single statement. |
| 6402 | * |
| 6403 | * @see #putExtras |
| 6404 | * @see #removeExtra |
| 6405 | * @see #getLongExtra(String, long) |
| 6406 | */ |
| 6407 | public Intent putExtra(String name, long value) { |
| 6408 | if (mExtras == null) { |
| 6409 | mExtras = new Bundle(); |
| 6410 | } |
| 6411 | mExtras.putLong(name, value); |
| 6412 | return this; |
| 6413 | } |
| 6414 | |
| 6415 | /** |
| 6416 | * Add extended data to the intent. The name must include a package |
| 6417 | * prefix, for example the app com.android.contacts would use names |
| 6418 | * like "com.android.contacts.ShowAll". |
| 6419 | * |
| 6420 | * @param name The name of the extra data, with package prefix. |
| 6421 | * @param value The float data value. |
| 6422 | * |
| 6423 | * @return Returns the same Intent object, for chaining multiple calls |
| 6424 | * into a single statement. |
| 6425 | * |
| 6426 | * @see #putExtras |
| 6427 | * @see #removeExtra |
| 6428 | * @see #getFloatExtra(String, float) |
| 6429 | */ |
| 6430 | public Intent putExtra(String name, float value) { |
| 6431 | if (mExtras == null) { |
| 6432 | mExtras = new Bundle(); |
| 6433 | } |
| 6434 | mExtras.putFloat(name, value); |
| 6435 | return this; |
| 6436 | } |
| 6437 | |
| 6438 | /** |
| 6439 | * Add extended data to the intent. The name must include a package |
| 6440 | * prefix, for example the app com.android.contacts would use names |
| 6441 | * like "com.android.contacts.ShowAll". |
| 6442 | * |
| 6443 | * @param name The name of the extra data, with package prefix. |
| 6444 | * @param value The double data value. |
| 6445 | * |
| 6446 | * @return Returns the same Intent object, for chaining multiple calls |
| 6447 | * into a single statement. |
| 6448 | * |
| 6449 | * @see #putExtras |
| 6450 | * @see #removeExtra |
| 6451 | * @see #getDoubleExtra(String, double) |
| 6452 | */ |
| 6453 | public Intent putExtra(String name, double value) { |
| 6454 | if (mExtras == null) { |
| 6455 | mExtras = new Bundle(); |
| 6456 | } |
| 6457 | mExtras.putDouble(name, value); |
| 6458 | return this; |
| 6459 | } |
| 6460 | |
| 6461 | /** |
| 6462 | * Add extended data to the intent. The name must include a package |
| 6463 | * prefix, for example the app com.android.contacts would use names |
| 6464 | * like "com.android.contacts.ShowAll". |
| 6465 | * |
| 6466 | * @param name The name of the extra data, with package prefix. |
| 6467 | * @param value The String data value. |
| 6468 | * |
| 6469 | * @return Returns the same Intent object, for chaining multiple calls |
| 6470 | * into a single statement. |
| 6471 | * |
| 6472 | * @see #putExtras |
| 6473 | * @see #removeExtra |
| 6474 | * @see #getStringExtra(String) |
| 6475 | */ |
| 6476 | public Intent putExtra(String name, String value) { |
| 6477 | if (mExtras == null) { |
| 6478 | mExtras = new Bundle(); |
| 6479 | } |
| 6480 | mExtras.putString(name, value); |
| 6481 | return this; |
| 6482 | } |
| 6483 | |
| 6484 | /** |
| 6485 | * Add extended data to the intent. The name must include a package |
| 6486 | * prefix, for example the app com.android.contacts would use names |
| 6487 | * like "com.android.contacts.ShowAll". |
| 6488 | * |
| 6489 | * @param name The name of the extra data, with package prefix. |
| 6490 | * @param value The CharSequence data value. |
| 6491 | * |
| 6492 | * @return Returns the same Intent object, for chaining multiple calls |
| 6493 | * into a single statement. |
| 6494 | * |
| 6495 | * @see #putExtras |
| 6496 | * @see #removeExtra |
| 6497 | * @see #getCharSequenceExtra(String) |
| 6498 | */ |
| 6499 | public Intent putExtra(String name, CharSequence value) { |
| 6500 | if (mExtras == null) { |
| 6501 | mExtras = new Bundle(); |
| 6502 | } |
| 6503 | mExtras.putCharSequence(name, value); |
| 6504 | return this; |
| 6505 | } |
| 6506 | |
| 6507 | /** |
| 6508 | * Add extended data to the intent. The name must include a package |
| 6509 | * prefix, for example the app com.android.contacts would use names |
| 6510 | * like "com.android.contacts.ShowAll". |
| 6511 | * |
| 6512 | * @param name The name of the extra data, with package prefix. |
| 6513 | * @param value The Parcelable data value. |
| 6514 | * |
| 6515 | * @return Returns the same Intent object, for chaining multiple calls |
| 6516 | * into a single statement. |
| 6517 | * |
| 6518 | * @see #putExtras |
| 6519 | * @see #removeExtra |
| 6520 | * @see #getParcelableExtra(String) |
| 6521 | */ |
| 6522 | public Intent putExtra(String name, Parcelable value) { |
| 6523 | if (mExtras == null) { |
| 6524 | mExtras = new Bundle(); |
| 6525 | } |
| 6526 | mExtras.putParcelable(name, value); |
| 6527 | return this; |
| 6528 | } |
| 6529 | |
| 6530 | /** |
| 6531 | * Add extended data to the intent. The name must include a package |
| 6532 | * prefix, for example the app com.android.contacts would use names |
| 6533 | * like "com.android.contacts.ShowAll". |
| 6534 | * |
| 6535 | * @param name The name of the extra data, with package prefix. |
| 6536 | * @param value The Parcelable[] data value. |
| 6537 | * |
| 6538 | * @return Returns the same Intent object, for chaining multiple calls |
| 6539 | * into a single statement. |
| 6540 | * |
| 6541 | * @see #putExtras |
| 6542 | * @see #removeExtra |
| 6543 | * @see #getParcelableArrayExtra(String) |
| 6544 | */ |
| 6545 | public Intent putExtra(String name, Parcelable[] value) { |
| 6546 | if (mExtras == null) { |
| 6547 | mExtras = new Bundle(); |
| 6548 | } |
| 6549 | mExtras.putParcelableArray(name, value); |
| 6550 | return this; |
| 6551 | } |
| 6552 | |
| 6553 | /** |
| 6554 | * Add extended data to the intent. The name must include a package |
| 6555 | * prefix, for example the app com.android.contacts would use names |
| 6556 | * like "com.android.contacts.ShowAll". |
| 6557 | * |
| 6558 | * @param name The name of the extra data, with package prefix. |
| 6559 | * @param value The ArrayList<Parcelable> data value. |
| 6560 | * |
| 6561 | * @return Returns the same Intent object, for chaining multiple calls |
| 6562 | * into a single statement. |
| 6563 | * |
| 6564 | * @see #putExtras |
| 6565 | * @see #removeExtra |
| 6566 | * @see #getParcelableArrayListExtra(String) |
| 6567 | */ |
| 6568 | public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) { |
| 6569 | if (mExtras == null) { |
| 6570 | mExtras = new Bundle(); |
| 6571 | } |
| 6572 | mExtras.putParcelableArrayList(name, value); |
| 6573 | return this; |
| 6574 | } |
| 6575 | |
| 6576 | /** |
| 6577 | * Add extended data to the intent. The name must include a package |
| 6578 | * prefix, for example the app com.android.contacts would use names |
| 6579 | * like "com.android.contacts.ShowAll". |
| 6580 | * |
| 6581 | * @param name The name of the extra data, with package prefix. |
| 6582 | * @param value The ArrayList<Integer> data value. |
| 6583 | * |
| 6584 | * @return Returns the same Intent object, for chaining multiple calls |
| 6585 | * into a single statement. |
| 6586 | * |
| 6587 | * @see #putExtras |
| 6588 | * @see #removeExtra |
| 6589 | * @see #getIntegerArrayListExtra(String) |
| 6590 | */ |
| 6591 | public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) { |
| 6592 | if (mExtras == null) { |
| 6593 | mExtras = new Bundle(); |
| 6594 | } |
| 6595 | mExtras.putIntegerArrayList(name, value); |
| 6596 | return this; |
| 6597 | } |
| 6598 | |
| 6599 | /** |
| 6600 | * Add extended data to the intent. The name must include a package |
| 6601 | * prefix, for example the app com.android.contacts would use names |
| 6602 | * like "com.android.contacts.ShowAll". |
| 6603 | * |
| 6604 | * @param name The name of the extra data, with package prefix. |
| 6605 | * @param value The ArrayList<String> data value. |
| 6606 | * |
| 6607 | * @return Returns the same Intent object, for chaining multiple calls |
| 6608 | * into a single statement. |
| 6609 | * |
| 6610 | * @see #putExtras |
| 6611 | * @see #removeExtra |
| 6612 | * @see #getStringArrayListExtra(String) |
| 6613 | */ |
| 6614 | public Intent putStringArrayListExtra(String name, ArrayList<String> value) { |
| 6615 | if (mExtras == null) { |
| 6616 | mExtras = new Bundle(); |
| 6617 | } |
| 6618 | mExtras.putStringArrayList(name, value); |
| 6619 | return this; |
| 6620 | } |
| 6621 | |
| 6622 | /** |
| 6623 | * Add extended data to the intent. The name must include a package |
| 6624 | * prefix, for example the app com.android.contacts would use names |
| 6625 | * like "com.android.contacts.ShowAll". |
| 6626 | * |
| 6627 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 6628 | * @param value The ArrayList<CharSequence> data value. |
| 6629 | * |
| 6630 | * @return Returns the same Intent object, for chaining multiple calls |
| 6631 | * into a single statement. |
| 6632 | * |
| 6633 | * @see #putExtras |
| 6634 | * @see #removeExtra |
| 6635 | * @see #getCharSequenceArrayListExtra(String) |
| 6636 | */ |
| 6637 | public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) { |
| 6638 | if (mExtras == null) { |
| 6639 | mExtras = new Bundle(); |
| 6640 | } |
| 6641 | mExtras.putCharSequenceArrayList(name, value); |
| 6642 | return this; |
| 6643 | } |
| 6644 | |
| 6645 | /** |
| 6646 | * Add extended data to the intent. The name must include a package |
| 6647 | * prefix, for example the app com.android.contacts would use names |
| 6648 | * like "com.android.contacts.ShowAll". |
| 6649 | * |
| 6650 | * @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] | 6651 | * @param value The Serializable data value. |
| 6652 | * |
| 6653 | * @return Returns the same Intent object, for chaining multiple calls |
| 6654 | * into a single statement. |
| 6655 | * |
| 6656 | * @see #putExtras |
| 6657 | * @see #removeExtra |
| 6658 | * @see #getSerializableExtra(String) |
| 6659 | */ |
| 6660 | public Intent putExtra(String name, Serializable value) { |
| 6661 | if (mExtras == null) { |
| 6662 | mExtras = new Bundle(); |
| 6663 | } |
| 6664 | mExtras.putSerializable(name, value); |
| 6665 | return this; |
| 6666 | } |
| 6667 | |
| 6668 | /** |
| 6669 | * Add extended data to the intent. The name must include a package |
| 6670 | * prefix, for example the app com.android.contacts would use names |
| 6671 | * like "com.android.contacts.ShowAll". |
| 6672 | * |
| 6673 | * @param name The name of the extra data, with package prefix. |
| 6674 | * @param value The boolean array data value. |
| 6675 | * |
| 6676 | * @return Returns the same Intent object, for chaining multiple calls |
| 6677 | * into a single statement. |
| 6678 | * |
| 6679 | * @see #putExtras |
| 6680 | * @see #removeExtra |
| 6681 | * @see #getBooleanArrayExtra(String) |
| 6682 | */ |
| 6683 | public Intent putExtra(String name, boolean[] value) { |
| 6684 | if (mExtras == null) { |
| 6685 | mExtras = new Bundle(); |
| 6686 | } |
| 6687 | mExtras.putBooleanArray(name, value); |
| 6688 | return this; |
| 6689 | } |
| 6690 | |
| 6691 | /** |
| 6692 | * Add extended data to the intent. The name must include a package |
| 6693 | * prefix, for example the app com.android.contacts would use names |
| 6694 | * like "com.android.contacts.ShowAll". |
| 6695 | * |
| 6696 | * @param name The name of the extra data, with package prefix. |
| 6697 | * @param value The byte array data value. |
| 6698 | * |
| 6699 | * @return Returns the same Intent object, for chaining multiple calls |
| 6700 | * into a single statement. |
| 6701 | * |
| 6702 | * @see #putExtras |
| 6703 | * @see #removeExtra |
| 6704 | * @see #getByteArrayExtra(String) |
| 6705 | */ |
| 6706 | public Intent putExtra(String name, byte[] value) { |
| 6707 | if (mExtras == null) { |
| 6708 | mExtras = new Bundle(); |
| 6709 | } |
| 6710 | mExtras.putByteArray(name, value); |
| 6711 | return this; |
| 6712 | } |
| 6713 | |
| 6714 | /** |
| 6715 | * Add extended data to the intent. The name must include a package |
| 6716 | * prefix, for example the app com.android.contacts would use names |
| 6717 | * like "com.android.contacts.ShowAll". |
| 6718 | * |
| 6719 | * @param name The name of the extra data, with package prefix. |
| 6720 | * @param value The short array data value. |
| 6721 | * |
| 6722 | * @return Returns the same Intent object, for chaining multiple calls |
| 6723 | * into a single statement. |
| 6724 | * |
| 6725 | * @see #putExtras |
| 6726 | * @see #removeExtra |
| 6727 | * @see #getShortArrayExtra(String) |
| 6728 | */ |
| 6729 | public Intent putExtra(String name, short[] value) { |
| 6730 | if (mExtras == null) { |
| 6731 | mExtras = new Bundle(); |
| 6732 | } |
| 6733 | mExtras.putShortArray(name, value); |
| 6734 | return this; |
| 6735 | } |
| 6736 | |
| 6737 | /** |
| 6738 | * Add extended data to the intent. The name must include a package |
| 6739 | * prefix, for example the app com.android.contacts would use names |
| 6740 | * like "com.android.contacts.ShowAll". |
| 6741 | * |
| 6742 | * @param name The name of the extra data, with package prefix. |
| 6743 | * @param value The char array data value. |
| 6744 | * |
| 6745 | * @return Returns the same Intent object, for chaining multiple calls |
| 6746 | * into a single statement. |
| 6747 | * |
| 6748 | * @see #putExtras |
| 6749 | * @see #removeExtra |
| 6750 | * @see #getCharArrayExtra(String) |
| 6751 | */ |
| 6752 | public Intent putExtra(String name, char[] value) { |
| 6753 | if (mExtras == null) { |
| 6754 | mExtras = new Bundle(); |
| 6755 | } |
| 6756 | mExtras.putCharArray(name, value); |
| 6757 | return this; |
| 6758 | } |
| 6759 | |
| 6760 | /** |
| 6761 | * Add extended data to the intent. The name must include a package |
| 6762 | * prefix, for example the app com.android.contacts would use names |
| 6763 | * like "com.android.contacts.ShowAll". |
| 6764 | * |
| 6765 | * @param name The name of the extra data, with package prefix. |
| 6766 | * @param value The int array data value. |
| 6767 | * |
| 6768 | * @return Returns the same Intent object, for chaining multiple calls |
| 6769 | * into a single statement. |
| 6770 | * |
| 6771 | * @see #putExtras |
| 6772 | * @see #removeExtra |
| 6773 | * @see #getIntArrayExtra(String) |
| 6774 | */ |
| 6775 | public Intent putExtra(String name, int[] value) { |
| 6776 | if (mExtras == null) { |
| 6777 | mExtras = new Bundle(); |
| 6778 | } |
| 6779 | mExtras.putIntArray(name, value); |
| 6780 | return this; |
| 6781 | } |
| 6782 | |
| 6783 | /** |
| 6784 | * Add extended data to the intent. The name must include a package |
| 6785 | * prefix, for example the app com.android.contacts would use names |
| 6786 | * like "com.android.contacts.ShowAll". |
| 6787 | * |
| 6788 | * @param name The name of the extra data, with package prefix. |
| 6789 | * @param value The byte array data value. |
| 6790 | * |
| 6791 | * @return Returns the same Intent object, for chaining multiple calls |
| 6792 | * into a single statement. |
| 6793 | * |
| 6794 | * @see #putExtras |
| 6795 | * @see #removeExtra |
| 6796 | * @see #getLongArrayExtra(String) |
| 6797 | */ |
| 6798 | public Intent putExtra(String name, long[] value) { |
| 6799 | if (mExtras == null) { |
| 6800 | mExtras = new Bundle(); |
| 6801 | } |
| 6802 | mExtras.putLongArray(name, value); |
| 6803 | return this; |
| 6804 | } |
| 6805 | |
| 6806 | /** |
| 6807 | * Add extended data to the intent. The name must include a package |
| 6808 | * prefix, for example the app com.android.contacts would use names |
| 6809 | * like "com.android.contacts.ShowAll". |
| 6810 | * |
| 6811 | * @param name The name of the extra data, with package prefix. |
| 6812 | * @param value The float array data value. |
| 6813 | * |
| 6814 | * @return Returns the same Intent object, for chaining multiple calls |
| 6815 | * into a single statement. |
| 6816 | * |
| 6817 | * @see #putExtras |
| 6818 | * @see #removeExtra |
| 6819 | * @see #getFloatArrayExtra(String) |
| 6820 | */ |
| 6821 | public Intent putExtra(String name, float[] value) { |
| 6822 | if (mExtras == null) { |
| 6823 | mExtras = new Bundle(); |
| 6824 | } |
| 6825 | mExtras.putFloatArray(name, value); |
| 6826 | return this; |
| 6827 | } |
| 6828 | |
| 6829 | /** |
| 6830 | * Add extended data to the intent. The name must include a package |
| 6831 | * prefix, for example the app com.android.contacts would use names |
| 6832 | * like "com.android.contacts.ShowAll". |
| 6833 | * |
| 6834 | * @param name The name of the extra data, with package prefix. |
| 6835 | * @param value The double array data value. |
| 6836 | * |
| 6837 | * @return Returns the same Intent object, for chaining multiple calls |
| 6838 | * into a single statement. |
| 6839 | * |
| 6840 | * @see #putExtras |
| 6841 | * @see #removeExtra |
| 6842 | * @see #getDoubleArrayExtra(String) |
| 6843 | */ |
| 6844 | public Intent putExtra(String name, double[] value) { |
| 6845 | if (mExtras == null) { |
| 6846 | mExtras = new Bundle(); |
| 6847 | } |
| 6848 | mExtras.putDoubleArray(name, value); |
| 6849 | return this; |
| 6850 | } |
| 6851 | |
| 6852 | /** |
| 6853 | * Add extended data to the intent. The name must include a package |
| 6854 | * prefix, for example the app com.android.contacts would use names |
| 6855 | * like "com.android.contacts.ShowAll". |
| 6856 | * |
| 6857 | * @param name The name of the extra data, with package prefix. |
| 6858 | * @param value The String array data value. |
| 6859 | * |
| 6860 | * @return Returns the same Intent object, for chaining multiple calls |
| 6861 | * into a single statement. |
| 6862 | * |
| 6863 | * @see #putExtras |
| 6864 | * @see #removeExtra |
| 6865 | * @see #getStringArrayExtra(String) |
| 6866 | */ |
| 6867 | public Intent putExtra(String name, String[] value) { |
| 6868 | if (mExtras == null) { |
| 6869 | mExtras = new Bundle(); |
| 6870 | } |
| 6871 | mExtras.putStringArray(name, value); |
| 6872 | return this; |
| 6873 | } |
| 6874 | |
| 6875 | /** |
| 6876 | * Add extended data to the intent. The name must include a package |
| 6877 | * prefix, for example the app com.android.contacts would use names |
| 6878 | * like "com.android.contacts.ShowAll". |
| 6879 | * |
| 6880 | * @param name The name of the extra data, with package prefix. |
Bjorn Bringert | 08bbffb | 2010-02-25 11:16:22 +0000 | [diff] [blame] | 6881 | * @param value The CharSequence array data value. |
| 6882 | * |
| 6883 | * @return Returns the same Intent object, for chaining multiple calls |
| 6884 | * into a single statement. |
| 6885 | * |
| 6886 | * @see #putExtras |
| 6887 | * @see #removeExtra |
| 6888 | * @see #getCharSequenceArrayExtra(String) |
| 6889 | */ |
| 6890 | public Intent putExtra(String name, CharSequence[] value) { |
| 6891 | if (mExtras == null) { |
| 6892 | mExtras = new Bundle(); |
| 6893 | } |
| 6894 | mExtras.putCharSequenceArray(name, value); |
| 6895 | return this; |
| 6896 | } |
| 6897 | |
| 6898 | /** |
| 6899 | * Add extended data to the intent. The name must include a package |
| 6900 | * prefix, for example the app com.android.contacts would use names |
| 6901 | * like "com.android.contacts.ShowAll". |
| 6902 | * |
| 6903 | * @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] | 6904 | * @param value The Bundle data value. |
| 6905 | * |
| 6906 | * @return Returns the same Intent object, for chaining multiple calls |
| 6907 | * into a single statement. |
| 6908 | * |
| 6909 | * @see #putExtras |
| 6910 | * @see #removeExtra |
| 6911 | * @see #getBundleExtra(String) |
| 6912 | */ |
| 6913 | public Intent putExtra(String name, Bundle value) { |
| 6914 | if (mExtras == null) { |
| 6915 | mExtras = new Bundle(); |
| 6916 | } |
| 6917 | mExtras.putBundle(name, value); |
| 6918 | return this; |
| 6919 | } |
| 6920 | |
| 6921 | /** |
| 6922 | * Add extended data to the intent. The name must include a package |
| 6923 | * prefix, for example the app com.android.contacts would use names |
| 6924 | * like "com.android.contacts.ShowAll". |
| 6925 | * |
| 6926 | * @param name The name of the extra data, with package prefix. |
| 6927 | * @param value The IBinder data value. |
| 6928 | * |
| 6929 | * @return Returns the same Intent object, for chaining multiple calls |
| 6930 | * into a single statement. |
| 6931 | * |
| 6932 | * @see #putExtras |
| 6933 | * @see #removeExtra |
| 6934 | * @see #getIBinderExtra(String) |
| 6935 | * |
| 6936 | * @deprecated |
| 6937 | * @hide |
| 6938 | */ |
| 6939 | @Deprecated |
| 6940 | public Intent putExtra(String name, IBinder value) { |
| 6941 | if (mExtras == null) { |
| 6942 | mExtras = new Bundle(); |
| 6943 | } |
| 6944 | mExtras.putIBinder(name, value); |
| 6945 | return this; |
| 6946 | } |
| 6947 | |
| 6948 | /** |
| 6949 | * Copy all extras in 'src' in to this intent. |
| 6950 | * |
| 6951 | * @param src Contains the extras to copy. |
| 6952 | * |
| 6953 | * @see #putExtra |
| 6954 | */ |
| 6955 | public Intent putExtras(Intent src) { |
| 6956 | if (src.mExtras != null) { |
| 6957 | if (mExtras == null) { |
| 6958 | mExtras = new Bundle(src.mExtras); |
| 6959 | } else { |
| 6960 | mExtras.putAll(src.mExtras); |
| 6961 | } |
| 6962 | } |
| 6963 | return this; |
| 6964 | } |
| 6965 | |
| 6966 | /** |
| 6967 | * Add a set of extended data to the intent. The keys must include a package |
| 6968 | * prefix, for example the app com.android.contacts would use names |
| 6969 | * like "com.android.contacts.ShowAll". |
| 6970 | * |
| 6971 | * @param extras The Bundle of extras to add to this intent. |
| 6972 | * |
| 6973 | * @see #putExtra |
| 6974 | * @see #removeExtra |
| 6975 | */ |
| 6976 | public Intent putExtras(Bundle extras) { |
| 6977 | if (mExtras == null) { |
| 6978 | mExtras = new Bundle(); |
| 6979 | } |
| 6980 | mExtras.putAll(extras); |
| 6981 | return this; |
| 6982 | } |
| 6983 | |
| 6984 | /** |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 6985 | * Completely replace the extras in the Intent with the extras in the |
| 6986 | * given Intent. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6987 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 6988 | * @param src The exact extras contained in this Intent are copied |
| 6989 | * into the target intent, replacing any that were previously there. |
| 6990 | */ |
| 6991 | public Intent replaceExtras(Intent src) { |
| 6992 | mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; |
| 6993 | return this; |
| 6994 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6995 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 6996 | /** |
| 6997 | * Completely replace the extras in the Intent with the given Bundle of |
| 6998 | * extras. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 6999 | * |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7000 | * @param extras The new set of extras in the Intent, or null to erase |
| 7001 | * all extras. |
| 7002 | */ |
| 7003 | public Intent replaceExtras(Bundle extras) { |
| 7004 | mExtras = extras != null ? new Bundle(extras) : null; |
| 7005 | return this; |
| 7006 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 7007 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7008 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7009 | * Remove extended data from the intent. |
| 7010 | * |
| 7011 | * @see #putExtra |
| 7012 | */ |
| 7013 | public void removeExtra(String name) { |
| 7014 | if (mExtras != null) { |
| 7015 | mExtras.remove(name); |
| 7016 | if (mExtras.size() == 0) { |
| 7017 | mExtras = null; |
| 7018 | } |
| 7019 | } |
| 7020 | } |
| 7021 | |
| 7022 | /** |
| 7023 | * Set special flags controlling how this intent is handled. Most values |
| 7024 | * here depend on the type of component being executed by the Intent, |
| 7025 | * specifically the FLAG_ACTIVITY_* flags are all for use with |
| 7026 | * {@link Context#startActivity Context.startActivity()} and the |
| 7027 | * FLAG_RECEIVER_* flags are all for use with |
| 7028 | * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. |
| 7029 | * |
Scott Main | 7aee61f | 2011-02-08 11:25:01 -0800 | [diff] [blame] | 7030 | * <p>See the |
| 7031 | * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back |
| 7032 | * 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] | 7033 | * the behavior of your application. |
| 7034 | * |
| 7035 | * @param flags The desired flags. |
| 7036 | * |
| 7037 | * @return Returns the same Intent object, for chaining multiple calls |
| 7038 | * into a single statement. |
| 7039 | * |
| 7040 | * @see #getFlags |
| 7041 | * @see #addFlags |
| 7042 | * |
| 7043 | * @see #FLAG_GRANT_READ_URI_PERMISSION |
| 7044 | * @see #FLAG_GRANT_WRITE_URI_PERMISSION |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 7045 | * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 7046 | * @see #FLAG_GRANT_PREFIX_URI_PERMISSION |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7047 | * @see #FLAG_DEBUG_LOG_RESOLUTION |
| 7048 | * @see #FLAG_FROM_BACKGROUND |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7049 | * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 7050 | * @see #FLAG_ACTIVITY_CLEAR_TASK |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7051 | * @see #FLAG_ACTIVITY_CLEAR_TOP |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 7052 | * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7053 | * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS |
| 7054 | * @see #FLAG_ACTIVITY_FORWARD_RESULT |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7055 | * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7056 | * @see #FLAG_ACTIVITY_MULTIPLE_TASK |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 7057 | * @see #FLAG_ACTIVITY_NEW_DOCUMENT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7058 | * @see #FLAG_ACTIVITY_NEW_TASK |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 7059 | * @see #FLAG_ACTIVITY_NO_ANIMATION |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7060 | * @see #FLAG_ACTIVITY_NO_HISTORY |
The Android Open Source Project | f1e484a | 2009-01-22 00:13:42 -0800 | [diff] [blame] | 7061 | * @see #FLAG_ACTIVITY_NO_USER_ACTION |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7062 | * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP |
| 7063 | * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 7064 | * @see #FLAG_ACTIVITY_REORDER_TO_FRONT |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7065 | * @see #FLAG_ACTIVITY_SINGLE_TOP |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 7066 | * @see #FLAG_ACTIVITY_TASK_ON_HOME |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7067 | * @see #FLAG_RECEIVER_REGISTERED_ONLY |
| 7068 | */ |
| 7069 | public Intent setFlags(int flags) { |
| 7070 | mFlags = flags; |
| 7071 | return this; |
| 7072 | } |
| 7073 | |
| 7074 | /** |
| 7075 | * Add additional flags to the intent (or with existing flags |
| 7076 | * value). |
| 7077 | * |
| 7078 | * @param flags The new flags to set. |
| 7079 | * |
| 7080 | * @return Returns the same Intent object, for chaining multiple calls |
| 7081 | * into a single statement. |
| 7082 | * |
| 7083 | * @see #setFlags |
| 7084 | */ |
| 7085 | public Intent addFlags(int flags) { |
| 7086 | mFlags |= flags; |
| 7087 | return this; |
| 7088 | } |
| 7089 | |
| 7090 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7091 | * (Usually optional) Set an explicit application package name that limits |
| 7092 | * the components this Intent will resolve to. If left to the default |
| 7093 | * value of null, all components in all applications will considered. |
| 7094 | * If non-null, the Intent can only match the components in the given |
| 7095 | * application package. |
| 7096 | * |
| 7097 | * @param packageName The name of the application package to handle the |
| 7098 | * intent, or null to allow any application package. |
| 7099 | * |
| 7100 | * @return Returns the same Intent object, for chaining multiple calls |
| 7101 | * into a single statement. |
| 7102 | * |
| 7103 | * @see #getPackage |
| 7104 | * @see #resolveActivity |
| 7105 | */ |
| 7106 | public Intent setPackage(String packageName) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7107 | if (packageName != null && mSelector != null) { |
| 7108 | throw new IllegalArgumentException( |
| 7109 | "Can't set package name when selector is already set"); |
| 7110 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7111 | mPackage = packageName; |
| 7112 | return this; |
| 7113 | } |
| 7114 | |
| 7115 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7116 | * (Usually optional) Explicitly set the component to handle the intent. |
| 7117 | * If left with the default value of null, the system will determine the |
| 7118 | * appropriate class to use based on the other fields (action, data, |
| 7119 | * type, categories) in the Intent. If this class is defined, the |
| 7120 | * specified class will always be used regardless of the other fields. You |
| 7121 | * should only set this value when you know you absolutely want a specific |
| 7122 | * class to be used; otherwise it is better to let the system find the |
| 7123 | * appropriate class so that you will respect the installed applications |
| 7124 | * and user preferences. |
| 7125 | * |
| 7126 | * @param component The name of the application component to handle the |
| 7127 | * intent, or null to let the system find one for you. |
| 7128 | * |
| 7129 | * @return Returns the same Intent object, for chaining multiple calls |
| 7130 | * into a single statement. |
| 7131 | * |
| 7132 | * @see #setClass |
| 7133 | * @see #setClassName(Context, String) |
| 7134 | * @see #setClassName(String, String) |
| 7135 | * @see #getComponent |
| 7136 | * @see #resolveActivity |
| 7137 | */ |
| 7138 | public Intent setComponent(ComponentName component) { |
| 7139 | mComponent = component; |
| 7140 | return this; |
| 7141 | } |
| 7142 | |
| 7143 | /** |
| 7144 | * Convenience for calling {@link #setComponent} with an |
| 7145 | * explicit class name. |
| 7146 | * |
| 7147 | * @param packageContext A Context of the application package implementing |
| 7148 | * this class. |
| 7149 | * @param className The name of a class inside of the application package |
| 7150 | * that will be used as the component for this Intent. |
| 7151 | * |
| 7152 | * @return Returns the same Intent object, for chaining multiple calls |
| 7153 | * into a single statement. |
| 7154 | * |
| 7155 | * @see #setComponent |
| 7156 | * @see #setClass |
| 7157 | */ |
| 7158 | public Intent setClassName(Context packageContext, String className) { |
| 7159 | mComponent = new ComponentName(packageContext, className); |
| 7160 | return this; |
| 7161 | } |
| 7162 | |
| 7163 | /** |
| 7164 | * Convenience for calling {@link #setComponent} with an |
| 7165 | * explicit application package name and class name. |
| 7166 | * |
| 7167 | * @param packageName The name of the package implementing the desired |
| 7168 | * component. |
| 7169 | * @param className The name of a class inside of the application package |
| 7170 | * that will be used as the component for this Intent. |
| 7171 | * |
| 7172 | * @return Returns the same Intent object, for chaining multiple calls |
| 7173 | * into a single statement. |
| 7174 | * |
| 7175 | * @see #setComponent |
| 7176 | * @see #setClass |
| 7177 | */ |
| 7178 | public Intent setClassName(String packageName, String className) { |
| 7179 | mComponent = new ComponentName(packageName, className); |
| 7180 | return this; |
| 7181 | } |
| 7182 | |
| 7183 | /** |
| 7184 | * Convenience for calling {@link #setComponent(ComponentName)} with the |
| 7185 | * name returned by a {@link Class} object. |
| 7186 | * |
| 7187 | * @param packageContext A Context of the application package implementing |
| 7188 | * this class. |
| 7189 | * @param cls The class name to set, equivalent to |
| 7190 | * <code>setClassName(context, cls.getName())</code>. |
| 7191 | * |
| 7192 | * @return Returns the same Intent object, for chaining multiple calls |
| 7193 | * into a single statement. |
| 7194 | * |
| 7195 | * @see #setComponent |
| 7196 | */ |
| 7197 | public Intent setClass(Context packageContext, Class<?> cls) { |
| 7198 | mComponent = new ComponentName(packageContext, cls); |
| 7199 | return this; |
| 7200 | } |
| 7201 | |
| 7202 | /** |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7203 | * Set the bounds of the sender of this intent, in screen coordinates. This can be |
| 7204 | * used as a hint to the receiver for animations and the like. Null means that there |
| 7205 | * is no source bounds. |
| 7206 | */ |
| 7207 | public void setSourceBounds(Rect r) { |
| 7208 | if (r != null) { |
| 7209 | mSourceBounds = new Rect(r); |
| 7210 | } else { |
Daniel Lehmann | a5b58df | 2011-10-12 16:24:22 -0700 | [diff] [blame] | 7211 | mSourceBounds = null; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7212 | } |
| 7213 | } |
| 7214 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 7215 | /** @hide */ |
| 7216 | @IntDef(flag = true, |
| 7217 | value = { |
| 7218 | FILL_IN_ACTION, |
| 7219 | FILL_IN_DATA, |
| 7220 | FILL_IN_CATEGORIES, |
| 7221 | FILL_IN_COMPONENT, |
| 7222 | FILL_IN_PACKAGE, |
| 7223 | FILL_IN_SOURCE_BOUNDS, |
| 7224 | FILL_IN_SELECTOR, |
| 7225 | FILL_IN_CLIP_DATA |
| 7226 | }) |
| 7227 | @Retention(RetentionPolicy.SOURCE) |
| 7228 | public @interface FillInFlags {} |
| 7229 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7230 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7231 | * Use with {@link #fillIn} to allow the current action value to be |
| 7232 | * overwritten, even if it is already set. |
| 7233 | */ |
| 7234 | public static final int FILL_IN_ACTION = 1<<0; |
| 7235 | |
| 7236 | /** |
| 7237 | * Use with {@link #fillIn} to allow the current data or type value |
| 7238 | * overwritten, even if it is already set. |
| 7239 | */ |
| 7240 | public static final int FILL_IN_DATA = 1<<1; |
| 7241 | |
| 7242 | /** |
| 7243 | * Use with {@link #fillIn} to allow the current categories to be |
| 7244 | * overwritten, even if they are already set. |
| 7245 | */ |
| 7246 | public static final int FILL_IN_CATEGORIES = 1<<2; |
| 7247 | |
| 7248 | /** |
| 7249 | * Use with {@link #fillIn} to allow the current component value to be |
| 7250 | * overwritten, even if it is already set. |
| 7251 | */ |
| 7252 | public static final int FILL_IN_COMPONENT = 1<<3; |
| 7253 | |
| 7254 | /** |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7255 | * Use with {@link #fillIn} to allow the current package value to be |
| 7256 | * overwritten, even if it is already set. |
| 7257 | */ |
| 7258 | public static final int FILL_IN_PACKAGE = 1<<4; |
| 7259 | |
| 7260 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7261 | * Use with {@link #fillIn} to allow the current bounds rectangle to be |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7262 | * overwritten, even if it is already set. |
| 7263 | */ |
| 7264 | public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; |
| 7265 | |
| 7266 | /** |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7267 | * Use with {@link #fillIn} to allow the current selector to be |
| 7268 | * overwritten, even if it is already set. |
| 7269 | */ |
| 7270 | public static final int FILL_IN_SELECTOR = 1<<6; |
| 7271 | |
| 7272 | /** |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7273 | * Use with {@link #fillIn} to allow the current ClipData to be |
| 7274 | * overwritten, even if it is already set. |
| 7275 | */ |
| 7276 | public static final int FILL_IN_CLIP_DATA = 1<<7; |
| 7277 | |
| 7278 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7279 | * Copy the contents of <var>other</var> in to this object, but only |
| 7280 | * where fields are not defined by this object. For purposes of a field |
| 7281 | * being defined, the following pieces of data in the Intent are |
| 7282 | * considered to be separate fields: |
| 7283 | * |
| 7284 | * <ul> |
| 7285 | * <li> action, as set by {@link #setAction}. |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 7286 | * <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] | 7287 | * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. |
| 7288 | * <li> categories, as set by {@link #addCategory}. |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7289 | * <li> package, as set by {@link #setPackage}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7290 | * <li> component, as set by {@link #setComponent(ComponentName)} or |
| 7291 | * related methods. |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7292 | * <li> source bounds, as set by {@link #setSourceBounds}. |
| 7293 | * <li> selector, as set by {@link #setSelector(Intent)}. |
| 7294 | * <li> clip data, as set by {@link #setClipData(ClipData)}. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7295 | * <li> each top-level name in the associated extras. |
| 7296 | * </ul> |
| 7297 | * |
| 7298 | * <p>In addition, you can use the {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7299 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7300 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
| 7301 | * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override |
| 7302 | * the restriction where the corresponding field will not be replaced if |
| 7303 | * it is already set. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7304 | * |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7305 | * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} |
| 7306 | * is explicitly specified. The selector will only be copied if |
| 7307 | * {@link #FILL_IN_SELECTOR} is explicitly specified. |
Brett Chabot | 3e39175 | 2009-07-21 16:07:23 -0700 | [diff] [blame] | 7308 | * |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7309 | * <p>For example, consider Intent A with {data="foo", categories="bar"} |
| 7310 | * and Intent B with {action="gotit", data-type="some/thing", |
| 7311 | * categories="one","two"}. |
| 7312 | * |
| 7313 | * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now |
| 7314 | * containing: {action="gotit", data-type="some/thing", |
| 7315 | * categories="bar"}. |
| 7316 | * |
| 7317 | * @param other Another Intent whose values are to be used to fill in |
| 7318 | * the current one. |
| 7319 | * @param flags Options to control which fields can be filled in. |
| 7320 | * |
| 7321 | * @return Returns a bit mask of {@link #FILL_IN_ACTION}, |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7322 | * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 7323 | * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, |
| 7324 | * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were |
| 7325 | * changed. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7326 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 7327 | @FillInFlags |
| 7328 | public int fillIn(Intent other, @FillInFlags int flags) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7329 | int changes = 0; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7330 | boolean mayHaveCopiedUris = false; |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7331 | if (other.mAction != null |
| 7332 | && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7333 | mAction = other.mAction; |
| 7334 | changes |= FILL_IN_ACTION; |
| 7335 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7336 | if ((other.mData != null || other.mType != null) |
| 7337 | && ((mData == null && mType == null) |
| 7338 | || (flags&FILL_IN_DATA) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7339 | mData = other.mData; |
| 7340 | mType = other.mType; |
| 7341 | changes |= FILL_IN_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7342 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7343 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7344 | if (other.mCategories != null |
| 7345 | && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7346 | if (other.mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7347 | mCategories = new ArraySet<String>(other.mCategories); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7348 | } |
| 7349 | changes |= FILL_IN_CATEGORIES; |
| 7350 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7351 | if (other.mPackage != null |
| 7352 | && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7353 | // Only do this if mSelector is not set. |
| 7354 | if (mSelector == null) { |
| 7355 | mPackage = other.mPackage; |
| 7356 | changes |= FILL_IN_PACKAGE; |
| 7357 | } |
| 7358 | } |
| 7359 | // Selector is special: it can only be set if explicitly allowed, |
| 7360 | // for the same reason as the component name. |
| 7361 | if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { |
| 7362 | if (mPackage == null) { |
| 7363 | mSelector = new Intent(other.mSelector); |
| 7364 | mPackage = null; |
| 7365 | changes |= FILL_IN_SELECTOR; |
| 7366 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7367 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7368 | if (other.mClipData != null |
| 7369 | && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { |
| 7370 | mClipData = other.mClipData; |
| 7371 | changes |= FILL_IN_CLIP_DATA; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7372 | mayHaveCopiedUris = true; |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7373 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7374 | // Component is special: it can -only- be set if explicitly allowed, |
| 7375 | // since otherwise the sender could force the intent somewhere the |
| 7376 | // originator didn't intend. |
| 7377 | if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7378 | mComponent = other.mComponent; |
| 7379 | changes |= FILL_IN_COMPONENT; |
| 7380 | } |
| 7381 | mFlags |= other.mFlags; |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7382 | if (other.mSourceBounds != null |
| 7383 | && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { |
| 7384 | mSourceBounds = new Rect(other.mSourceBounds); |
| 7385 | changes |= FILL_IN_SOURCE_BOUNDS; |
| 7386 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7387 | if (mExtras == null) { |
| 7388 | if (other.mExtras != null) { |
| 7389 | mExtras = new Bundle(other.mExtras); |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7390 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7391 | } |
| 7392 | } else if (other.mExtras != null) { |
| 7393 | try { |
| 7394 | Bundle newb = new Bundle(other.mExtras); |
| 7395 | newb.putAll(mExtras); |
| 7396 | mExtras = newb; |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7397 | mayHaveCopiedUris = true; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7398 | } catch (RuntimeException e) { |
| 7399 | // Modifying the extras can cause us to unparcel the contents |
| 7400 | // of the bundle, and if we do this in the system process that |
| 7401 | // may fail. We really should handle this (i.e., the Bundle |
| 7402 | // impl shouldn't be on top of a plain map), but for now just |
| 7403 | // ignore it and keep the original contents. :( |
| 7404 | Log.w("Intent", "Failure filling in extras", e); |
| 7405 | } |
| 7406 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7407 | if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT |
| 7408 | && other.mContentUserHint != UserHandle.USER_CURRENT) { |
| 7409 | mContentUserHint = other.mContentUserHint; |
| 7410 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7411 | return changes; |
| 7412 | } |
| 7413 | |
| 7414 | /** |
| 7415 | * Wrapper class holding an Intent and implementing comparisons on it for |
| 7416 | * the purpose of filtering. The class implements its |
| 7417 | * {@link #equals equals()} and {@link #hashCode hashCode()} methods as |
| 7418 | * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and |
| 7419 | * {@link android.content.Intent#filterHashCode()} filterHashCode()} |
| 7420 | * on the wrapped Intent. |
| 7421 | */ |
| 7422 | public static final class FilterComparison { |
| 7423 | private final Intent mIntent; |
| 7424 | private final int mHashCode; |
| 7425 | |
| 7426 | public FilterComparison(Intent intent) { |
| 7427 | mIntent = intent; |
| 7428 | mHashCode = intent.filterHashCode(); |
| 7429 | } |
| 7430 | |
| 7431 | /** |
| 7432 | * Return the Intent that this FilterComparison represents. |
| 7433 | * @return Returns the Intent held by the FilterComparison. Do |
| 7434 | * not modify! |
| 7435 | */ |
| 7436 | public Intent getIntent() { |
| 7437 | return mIntent; |
| 7438 | } |
| 7439 | |
| 7440 | @Override |
| 7441 | public boolean equals(Object obj) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 7442 | if (obj instanceof FilterComparison) { |
| 7443 | Intent other = ((FilterComparison)obj).mIntent; |
| 7444 | return mIntent.filterEquals(other); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7445 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 7446 | return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7447 | } |
| 7448 | |
| 7449 | @Override |
| 7450 | public int hashCode() { |
| 7451 | return mHashCode; |
| 7452 | } |
| 7453 | } |
| 7454 | |
| 7455 | /** |
| 7456 | * Determine if two intents are the same for the purposes of intent |
| 7457 | * resolution (filtering). That is, if their action, data, type, |
| 7458 | * class, and categories are the same. This does <em>not</em> compare |
| 7459 | * any extra data included in the intents. |
| 7460 | * |
| 7461 | * @param other The other Intent to compare against. |
| 7462 | * |
| 7463 | * @return Returns true if action, data, type, class, and categories |
| 7464 | * are the same. |
| 7465 | */ |
| 7466 | public boolean filterEquals(Intent other) { |
| 7467 | if (other == null) { |
| 7468 | return false; |
| 7469 | } |
Christopher Tate | 63d9ae1 | 2014-06-19 19:07:26 -0700 | [diff] [blame] | 7470 | if (!Objects.equals(this.mAction, other.mAction)) return false; |
| 7471 | if (!Objects.equals(this.mData, other.mData)) return false; |
| 7472 | if (!Objects.equals(this.mType, other.mType)) return false; |
| 7473 | if (!Objects.equals(this.mPackage, other.mPackage)) return false; |
| 7474 | if (!Objects.equals(this.mComponent, other.mComponent)) return false; |
| 7475 | if (!Objects.equals(this.mCategories, other.mCategories)) return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7476 | |
| 7477 | return true; |
| 7478 | } |
| 7479 | |
| 7480 | /** |
| 7481 | * Generate hash code that matches semantics of filterEquals(). |
| 7482 | * |
| 7483 | * @return Returns the hash value of the action, data, type, class, and |
| 7484 | * categories. |
| 7485 | * |
| 7486 | * @see #filterEquals |
| 7487 | */ |
| 7488 | public int filterHashCode() { |
| 7489 | int code = 0; |
| 7490 | if (mAction != null) { |
| 7491 | code += mAction.hashCode(); |
| 7492 | } |
| 7493 | if (mData != null) { |
| 7494 | code += mData.hashCode(); |
| 7495 | } |
| 7496 | if (mType != null) { |
| 7497 | code += mType.hashCode(); |
| 7498 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7499 | if (mPackage != null) { |
| 7500 | code += mPackage.hashCode(); |
| 7501 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7502 | if (mComponent != null) { |
| 7503 | code += mComponent.hashCode(); |
| 7504 | } |
| 7505 | if (mCategories != null) { |
| 7506 | code += mCategories.hashCode(); |
| 7507 | } |
| 7508 | return code; |
| 7509 | } |
| 7510 | |
| 7511 | @Override |
| 7512 | public String toString() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 7513 | StringBuilder b = new StringBuilder(128); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7514 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7515 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7516 | toShortString(b, true, true, true, false); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7517 | b.append(" }"); |
| 7518 | |
| 7519 | return b.toString(); |
| 7520 | } |
| 7521 | |
| 7522 | /** @hide */ |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 7523 | public String toInsecureString() { |
| 7524 | StringBuilder b = new StringBuilder(128); |
| 7525 | |
| 7526 | b.append("Intent { "); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7527 | toShortString(b, false, true, true, false); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 7528 | b.append(" }"); |
| 7529 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7530 | return b.toString(); |
| 7531 | } |
Romain Guy | 4969af7 | 2009-06-17 10:53:19 -0700 | [diff] [blame] | 7532 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7533 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7534 | public String toInsecureStringWithClip() { |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 7535 | StringBuilder b = new StringBuilder(128); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7536 | |
| 7537 | b.append("Intent { "); |
| 7538 | toShortString(b, false, true, true, true); |
| 7539 | b.append(" }"); |
| 7540 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 7541 | return b.toString(); |
| 7542 | } |
| 7543 | |
| 7544 | /** @hide */ |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7545 | public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { |
| 7546 | StringBuilder b = new StringBuilder(128); |
| 7547 | toShortString(b, secure, comp, extras, clip); |
| 7548 | return b.toString(); |
| 7549 | } |
| 7550 | |
| 7551 | /** @hide */ |
| 7552 | public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, |
| 7553 | boolean clip) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7554 | boolean first = true; |
| 7555 | if (mAction != null) { |
| 7556 | b.append("act=").append(mAction); |
| 7557 | first = false; |
| 7558 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7559 | if (mCategories != null) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7560 | if (!first) { |
| 7561 | b.append(' '); |
| 7562 | } |
| 7563 | first = false; |
| 7564 | b.append("cat=["); |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7565 | for (int i=0; i<mCategories.size(); i++) { |
| 7566 | if (i > 0) b.append(','); |
| 7567 | b.append(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7568 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7569 | b.append("]"); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7570 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7571 | if (mData != null) { |
| 7572 | if (!first) { |
| 7573 | b.append(' '); |
| 7574 | } |
| 7575 | first = false; |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 7576 | b.append("dat="); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 7577 | if (secure) { |
| 7578 | b.append(mData.toSafeString()); |
Wink Saville | a428807 | 2010-10-12 12:36:38 -0700 | [diff] [blame] | 7579 | } else { |
| 7580 | b.append(mData); |
| 7581 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7582 | } |
| 7583 | if (mType != null) { |
| 7584 | if (!first) { |
| 7585 | b.append(' '); |
| 7586 | } |
| 7587 | first = false; |
| 7588 | b.append("typ=").append(mType); |
| 7589 | } |
| 7590 | if (mFlags != 0) { |
| 7591 | if (!first) { |
| 7592 | b.append(' '); |
| 7593 | } |
| 7594 | first = false; |
| 7595 | b.append("flg=0x").append(Integer.toHexString(mFlags)); |
| 7596 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7597 | if (mPackage != null) { |
| 7598 | if (!first) { |
| 7599 | b.append(' '); |
| 7600 | } |
| 7601 | first = false; |
| 7602 | b.append("pkg=").append(mPackage); |
| 7603 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7604 | if (comp && mComponent != null) { |
| 7605 | if (!first) { |
| 7606 | b.append(' '); |
| 7607 | } |
| 7608 | first = false; |
| 7609 | b.append("cmp=").append(mComponent.flattenToShortString()); |
| 7610 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7611 | if (mSourceBounds != null) { |
| 7612 | if (!first) { |
| 7613 | b.append(' '); |
| 7614 | } |
| 7615 | first = false; |
| 7616 | b.append("bnds=").append(mSourceBounds.toShortString()); |
| 7617 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7618 | if (mClipData != null) { |
| 7619 | if (!first) { |
| 7620 | b.append(' '); |
| 7621 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 7622 | b.append("clip={"); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7623 | if (clip) { |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7624 | mClipData.toShortString(b); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7625 | } else { |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 7626 | if (mClipData.getDescription() != null) { |
| 7627 | first = !mClipData.getDescription().toShortStringTypesOnly(b); |
| 7628 | } else { |
| 7629 | first = true; |
| 7630 | } |
| 7631 | mClipData.toShortStringShortItems(b, first); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7632 | } |
Dianne Hackborn | ae49872 | 2015-08-14 13:29:47 -0700 | [diff] [blame] | 7633 | first = false; |
| 7634 | b.append('}'); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7635 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7636 | if (extras && mExtras != null) { |
| 7637 | if (!first) { |
| 7638 | b.append(' '); |
| 7639 | } |
| 7640 | first = false; |
| 7641 | b.append("(has extras)"); |
| 7642 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7643 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
| 7644 | if (!first) { |
| 7645 | b.append(' '); |
| 7646 | } |
| 7647 | first = false; |
| 7648 | b.append("u=").append(mContentUserHint); |
| 7649 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7650 | if (mSelector != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7651 | b.append(" sel="); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7652 | mSelector.toShortString(b, secure, comp, extras, clip); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7653 | b.append("}"); |
| 7654 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7655 | } |
| 7656 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7657 | /** |
| 7658 | * Call {@link #toUri} with 0 flags. |
| 7659 | * @deprecated Use {@link #toUri} instead. |
| 7660 | */ |
| 7661 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7662 | public String toURI() { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7663 | return toUri(0); |
| 7664 | } |
| 7665 | |
| 7666 | /** |
| 7667 | * Convert this Intent into a String holding a URI representation of it. |
| 7668 | * The returned URI string has been properly URI encoded, so it can be |
| 7669 | * used with {@link Uri#parse Uri.parse(String)}. The URI contains the |
| 7670 | * Intent's data as the base URI, with an additional fragment describing |
| 7671 | * the action, categories, type, flags, package, component, and extras. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 7672 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7673 | * <p>You can convert the returned string back to an Intent with |
| 7674 | * {@link #getIntent}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 7675 | * |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7676 | * @param flags Additional operating flags. Either 0, |
| 7677 | * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}. |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 7678 | * |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7679 | * @return Returns a URI encoding URI string describing the entire contents |
| 7680 | * of the Intent. |
| 7681 | */ |
| 7682 | public String toUri(int flags) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 7683 | StringBuilder uri = new StringBuilder(128); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7684 | if ((flags&URI_ANDROID_APP_SCHEME) != 0) { |
| 7685 | if (mPackage == null) { |
| 7686 | throw new IllegalArgumentException( |
| 7687 | "Intent must include an explicit package name to build an android-app: " |
| 7688 | + this); |
| 7689 | } |
| 7690 | uri.append("android-app://"); |
| 7691 | uri.append(mPackage); |
| 7692 | String scheme = null; |
| 7693 | if (mData != null) { |
| 7694 | scheme = mData.getScheme(); |
| 7695 | if (scheme != null) { |
| 7696 | uri.append('/'); |
| 7697 | uri.append(scheme); |
| 7698 | String authority = mData.getEncodedAuthority(); |
| 7699 | if (authority != null) { |
| 7700 | uri.append('/'); |
| 7701 | uri.append(authority); |
| 7702 | String path = mData.getEncodedPath(); |
| 7703 | if (path != null) { |
| 7704 | uri.append(path); |
| 7705 | } |
| 7706 | String queryParams = mData.getEncodedQuery(); |
| 7707 | if (queryParams != null) { |
| 7708 | uri.append('?'); |
| 7709 | uri.append(queryParams); |
| 7710 | } |
| 7711 | String fragment = mData.getEncodedFragment(); |
| 7712 | if (fragment != null) { |
| 7713 | uri.append('#'); |
| 7714 | uri.append(fragment); |
| 7715 | } |
| 7716 | } |
| 7717 | } |
| 7718 | } |
| 7719 | toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, |
| 7720 | mPackage, flags); |
| 7721 | return uri.toString(); |
| 7722 | } |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7723 | String scheme = null; |
| 7724 | if (mData != null) { |
| 7725 | String data = mData.toString(); |
| 7726 | if ((flags&URI_INTENT_SCHEME) != 0) { |
| 7727 | final int N = data.length(); |
| 7728 | for (int i=0; i<N; i++) { |
| 7729 | char c = data.charAt(i); |
| 7730 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') |
| 7731 | || c == '.' || c == '-') { |
| 7732 | continue; |
| 7733 | } |
| 7734 | if (c == ':' && i > 0) { |
| 7735 | // Valid scheme. |
| 7736 | scheme = data.substring(0, i); |
| 7737 | uri.append("intent:"); |
| 7738 | data = data.substring(i+1); |
| 7739 | break; |
| 7740 | } |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 7741 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7742 | // No scheme. |
| 7743 | break; |
| 7744 | } |
| 7745 | } |
| 7746 | uri.append(data); |
Tom Taylor | d4a4729 | 2009-12-21 13:59:18 -0800 | [diff] [blame] | 7747 | |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7748 | } else if ((flags&URI_INTENT_SCHEME) != 0) { |
| 7749 | uri.append("intent:"); |
| 7750 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7751 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7752 | toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7753 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7754 | return uri.toString(); |
| 7755 | } |
| 7756 | |
| 7757 | private void toUriFragment(StringBuilder uri, String scheme, String defAction, |
| 7758 | String defPackage, int flags) { |
| 7759 | StringBuilder frag = new StringBuilder(128); |
| 7760 | |
| 7761 | toUriInner(frag, scheme, defAction, defPackage, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7762 | if (mSelector != null) { |
Dianne Hackborn | 80b1c56 | 2014-12-09 20:22:08 -0800 | [diff] [blame] | 7763 | frag.append("SEL;"); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7764 | // Note that for now we are not going to try to handle the |
| 7765 | // data part; not clear how to represent this as a URI, and |
| 7766 | // not much utility in it. |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7767 | mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, |
| 7768 | null, null, flags); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7769 | } |
| 7770 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7771 | if (frag.length() > 0) { |
| 7772 | uri.append("#Intent;"); |
| 7773 | uri.append(frag); |
| 7774 | uri.append("end"); |
| 7775 | } |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7776 | } |
| 7777 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7778 | private void toUriInner(StringBuilder uri, String scheme, String defAction, |
| 7779 | String defPackage, int flags) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7780 | if (scheme != null) { |
| 7781 | uri.append("scheme=").append(scheme).append(';'); |
| 7782 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7783 | if (mAction != null && !mAction.equals(defAction)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7784 | uri.append("action=").append(Uri.encode(mAction)).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7785 | } |
| 7786 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7787 | for (int i=0; i<mCategories.size(); i++) { |
| 7788 | 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] | 7789 | } |
| 7790 | } |
| 7791 | if (mType != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7792 | uri.append("type=").append(Uri.encode(mType, "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7793 | } |
| 7794 | if (mFlags != 0) { |
| 7795 | uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); |
| 7796 | } |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 7797 | if (mPackage != null && !mPackage.equals(defPackage)) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7798 | uri.append("package=").append(Uri.encode(mPackage)).append(';'); |
| 7799 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7800 | if (mComponent != null) { |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7801 | uri.append("component=").append(Uri.encode( |
| 7802 | mComponent.flattenToShortString(), "/")).append(';'); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7803 | } |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7804 | if (mSourceBounds != null) { |
| 7805 | uri.append("sourceBounds=") |
| 7806 | .append(Uri.encode(mSourceBounds.flattenToString())) |
| 7807 | .append(';'); |
| 7808 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7809 | if (mExtras != null) { |
| 7810 | for (String key : mExtras.keySet()) { |
| 7811 | final Object value = mExtras.get(key); |
| 7812 | char entryType = |
| 7813 | value instanceof String ? 'S' : |
| 7814 | value instanceof Boolean ? 'B' : |
| 7815 | value instanceof Byte ? 'b' : |
| 7816 | value instanceof Character ? 'c' : |
| 7817 | value instanceof Double ? 'd' : |
| 7818 | value instanceof Float ? 'f' : |
| 7819 | value instanceof Integer ? 'i' : |
| 7820 | value instanceof Long ? 'l' : |
| 7821 | value instanceof Short ? 's' : |
| 7822 | '\0'; |
| 7823 | |
| 7824 | if (entryType != '\0') { |
| 7825 | uri.append(entryType); |
| 7826 | uri.append('.'); |
| 7827 | uri.append(Uri.encode(key)); |
| 7828 | uri.append('='); |
| 7829 | uri.append(Uri.encode(value.toString())); |
| 7830 | uri.append(';'); |
| 7831 | } |
| 7832 | } |
| 7833 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7834 | } |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 7835 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7836 | public int describeContents() { |
| 7837 | return (mExtras != null) ? mExtras.describeContents() : 0; |
| 7838 | } |
| 7839 | |
| 7840 | public void writeToParcel(Parcel out, int flags) { |
| 7841 | out.writeString(mAction); |
| 7842 | Uri.writeToParcel(out, mData); |
| 7843 | out.writeString(mType); |
| 7844 | out.writeInt(mFlags); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7845 | out.writeString(mPackage); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7846 | ComponentName.writeToParcel(mComponent, out); |
| 7847 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7848 | if (mSourceBounds != null) { |
| 7849 | out.writeInt(1); |
| 7850 | mSourceBounds.writeToParcel(out, flags); |
| 7851 | } else { |
| 7852 | out.writeInt(0); |
| 7853 | } |
| 7854 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7855 | if (mCategories != null) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7856 | final int N = mCategories.size(); |
| 7857 | out.writeInt(N); |
| 7858 | for (int i=0; i<N; i++) { |
| 7859 | out.writeString(mCategories.valueAt(i)); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7860 | } |
| 7861 | } else { |
| 7862 | out.writeInt(0); |
| 7863 | } |
| 7864 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7865 | if (mSelector != null) { |
| 7866 | out.writeInt(1); |
| 7867 | mSelector.writeToParcel(out, flags); |
| 7868 | } else { |
| 7869 | out.writeInt(0); |
| 7870 | } |
| 7871 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7872 | if (mClipData != null) { |
| 7873 | out.writeInt(1); |
| 7874 | mClipData.writeToParcel(out, flags); |
| 7875 | } else { |
| 7876 | out.writeInt(0); |
| 7877 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7878 | out.writeInt(mContentUserHint); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7879 | out.writeBundle(mExtras); |
| 7880 | } |
| 7881 | |
| 7882 | public static final Parcelable.Creator<Intent> CREATOR |
| 7883 | = new Parcelable.Creator<Intent>() { |
| 7884 | public Intent createFromParcel(Parcel in) { |
| 7885 | return new Intent(in); |
| 7886 | } |
| 7887 | public Intent[] newArray(int size) { |
| 7888 | return new Intent[size]; |
| 7889 | } |
| 7890 | }; |
| 7891 | |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 7892 | /** @hide */ |
| 7893 | protected Intent(Parcel in) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7894 | readFromParcel(in); |
| 7895 | } |
| 7896 | |
| 7897 | public void readFromParcel(Parcel in) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 7898 | setAction(in.readString()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7899 | mData = Uri.CREATOR.createFromParcel(in); |
| 7900 | mType = in.readString(); |
| 7901 | mFlags = in.readInt(); |
Dianne Hackborn | c14b9cc | 2009-06-17 18:02:12 -0700 | [diff] [blame] | 7902 | mPackage = in.readString(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7903 | mComponent = ComponentName.readFromParcel(in); |
| 7904 | |
Joe Onorato | c7a63ee | 2009-12-02 21:13:17 -0800 | [diff] [blame] | 7905 | if (in.readInt() != 0) { |
| 7906 | mSourceBounds = Rect.CREATOR.createFromParcel(in); |
| 7907 | } |
| 7908 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7909 | int N = in.readInt(); |
| 7910 | if (N > 0) { |
Dianne Hackborn | add005c | 2013-07-17 18:43:12 -0700 | [diff] [blame] | 7911 | mCategories = new ArraySet<String>(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7912 | int i; |
| 7913 | for (i=0; i<N; i++) { |
Jeff Brown | 2c376fc | 2011-01-28 17:34:01 -0800 | [diff] [blame] | 7914 | mCategories.add(in.readString().intern()); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7915 | } |
| 7916 | } else { |
| 7917 | mCategories = null; |
| 7918 | } |
| 7919 | |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 7920 | if (in.readInt() != 0) { |
| 7921 | mSelector = new Intent(in); |
| 7922 | } |
| 7923 | |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 7924 | if (in.readInt() != 0) { |
| 7925 | mClipData = new ClipData(in); |
| 7926 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 7927 | mContentUserHint = in.readInt(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7928 | mExtras = in.readBundle(); |
| 7929 | } |
| 7930 | |
| 7931 | /** |
| 7932 | * Parses the "intent" element (and its children) from XML and instantiates |
| 7933 | * an Intent object. The given XML parser should be located at the tag |
| 7934 | * where parsing should start (often named "intent"), from which the |
| 7935 | * basic action, data, type, and package and class name will be |
| 7936 | * retrieved. The function will then parse in to any child elements, |
| 7937 | * looking for <category android:name="xxx"> tags to add categories and |
| 7938 | * <extra android:name="xxx" android:value="yyy"> to attach extra data |
| 7939 | * to the intent. |
| 7940 | * |
| 7941 | * @param resources The Resources to use when inflating resources. |
| 7942 | * @param parser The XML parser pointing at an "intent" tag. |
| 7943 | * @param attrs The AttributeSet interface for retrieving extended |
| 7944 | * attribute data at the current <var>parser</var> location. |
| 7945 | * @return An Intent object matching the XML data. |
| 7946 | * @throws XmlPullParserException If there was an XML parsing error. |
| 7947 | * @throws IOException If there was an I/O error. |
| 7948 | */ |
| 7949 | public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs) |
| 7950 | throws XmlPullParserException, IOException { |
| 7951 | Intent intent = new Intent(); |
| 7952 | |
| 7953 | TypedArray sa = resources.obtainAttributes(attrs, |
| 7954 | com.android.internal.R.styleable.Intent); |
| 7955 | |
| 7956 | intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); |
| 7957 | |
| 7958 | String data = sa.getString(com.android.internal.R.styleable.Intent_data); |
| 7959 | String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); |
| 7960 | intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); |
| 7961 | |
| 7962 | String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); |
| 7963 | String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); |
| 7964 | if (packageName != null && className != null) { |
| 7965 | intent.setComponent(new ComponentName(packageName, className)); |
| 7966 | } |
| 7967 | |
| 7968 | sa.recycle(); |
| 7969 | |
| 7970 | int outerDepth = parser.getDepth(); |
| 7971 | int type; |
| 7972 | while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 7973 | && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { |
| 7974 | if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { |
| 7975 | continue; |
| 7976 | } |
| 7977 | |
| 7978 | String nodeName = parser.getName(); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 7979 | if (nodeName.equals(TAG_CATEGORIES)) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7980 | sa = resources.obtainAttributes(attrs, |
| 7981 | com.android.internal.R.styleable.IntentCategory); |
| 7982 | String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); |
| 7983 | sa.recycle(); |
| 7984 | |
| 7985 | if (cat != null) { |
| 7986 | intent.addCategory(cat); |
| 7987 | } |
| 7988 | XmlUtils.skipCurrentTag(parser); |
| 7989 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 7990 | } else if (nodeName.equals(TAG_EXTRA)) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7991 | if (intent.mExtras == null) { |
| 7992 | intent.mExtras = new Bundle(); |
| 7993 | } |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 7994 | resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 7995 | XmlUtils.skipCurrentTag(parser); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 7996 | |
| 7997 | } else { |
| 7998 | XmlUtils.skipCurrentTag(parser); |
| 7999 | } |
| 8000 | } |
| 8001 | |
| 8002 | return intent; |
| 8003 | } |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 8004 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 8005 | /** @hide */ |
| 8006 | public void saveToXml(XmlSerializer out) throws IOException { |
| 8007 | if (mAction != null) { |
| 8008 | out.attribute(null, ATTR_ACTION, mAction); |
| 8009 | } |
| 8010 | if (mData != null) { |
| 8011 | out.attribute(null, ATTR_DATA, mData.toString()); |
| 8012 | } |
| 8013 | if (mType != null) { |
| 8014 | out.attribute(null, ATTR_TYPE, mType); |
| 8015 | } |
| 8016 | if (mComponent != null) { |
| 8017 | out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); |
| 8018 | } |
| 8019 | out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); |
| 8020 | |
| 8021 | if (mCategories != null) { |
| 8022 | out.startTag(null, TAG_CATEGORIES); |
| 8023 | for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { |
| 8024 | out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); |
| 8025 | } |
Craig Mautner | 43e52ed | 2014-06-16 17:18:52 -0700 | [diff] [blame] | 8026 | out.endTag(null, TAG_CATEGORIES); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 8027 | } |
| 8028 | } |
| 8029 | |
| 8030 | /** @hide */ |
| 8031 | public static Intent restoreFromXml(XmlPullParser in) throws IOException, |
| 8032 | XmlPullParserException { |
| 8033 | Intent intent = new Intent(); |
| 8034 | final int outerDepth = in.getDepth(); |
| 8035 | |
| 8036 | int attrCount = in.getAttributeCount(); |
| 8037 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 8038 | final String attrName = in.getAttributeName(attrNdx); |
| 8039 | final String attrValue = in.getAttributeValue(attrNdx); |
| 8040 | if (ATTR_ACTION.equals(attrName)) { |
| 8041 | intent.setAction(attrValue); |
| 8042 | } else if (ATTR_DATA.equals(attrName)) { |
| 8043 | intent.setData(Uri.parse(attrValue)); |
| 8044 | } else if (ATTR_TYPE.equals(attrName)) { |
| 8045 | intent.setType(attrValue); |
| 8046 | } else if (ATTR_COMPONENT.equals(attrName)) { |
| 8047 | intent.setComponent(ComponentName.unflattenFromString(attrValue)); |
| 8048 | } else if (ATTR_FLAGS.equals(attrName)) { |
| 8049 | intent.setFlags(Integer.valueOf(attrValue, 16)); |
| 8050 | } else { |
| 8051 | Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName); |
| 8052 | } |
| 8053 | } |
| 8054 | |
| 8055 | int event; |
| 8056 | String name; |
| 8057 | while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && |
| 8058 | (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { |
| 8059 | if (event == XmlPullParser.START_TAG) { |
| 8060 | name = in.getName(); |
| 8061 | if (TAG_CATEGORIES.equals(name)) { |
| 8062 | attrCount = in.getAttributeCount(); |
| 8063 | for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { |
| 8064 | intent.addCategory(in.getAttributeValue(attrNdx)); |
| 8065 | } |
| 8066 | } else { |
| 8067 | Log.w("Intent", "restoreFromXml: unknown name=" + name); |
| 8068 | XmlUtils.skipCurrentTag(in); |
| 8069 | } |
| 8070 | } |
| 8071 | } |
| 8072 | |
| 8073 | return intent; |
| 8074 | } |
| 8075 | |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 8076 | /** |
| 8077 | * Normalize a MIME data type. |
| 8078 | * |
| 8079 | * <p>A normalized MIME type has white-space trimmed, |
| 8080 | * content-type parameters removed, and is lower-case. |
| 8081 | * This aligns the type with Android best practices for |
| 8082 | * intent filtering. |
| 8083 | * |
| 8084 | * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". |
| 8085 | * "text/x-vCard" becomes "text/x-vcard". |
| 8086 | * |
| 8087 | * <p>All MIME types received from outside Android (such as user input, |
| 8088 | * or external sources like Bluetooth, NFC, or the Internet) should |
| 8089 | * be normalized before they are used to create an Intent. |
| 8090 | * |
| 8091 | * @param type MIME data type to normalize |
| 8092 | * @return normalized MIME data type, or null if the input was null |
John Spurlock | 125d133 | 2013-11-25 11:58:37 -0500 | [diff] [blame] | 8093 | * @see #setType |
| 8094 | * @see #setTypeAndNormalize |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 8095 | */ |
| 8096 | public static String normalizeMimeType(String type) { |
| 8097 | if (type == null) { |
| 8098 | return null; |
| 8099 | } |
| 8100 | |
Elliott Hughes | cb64d43 | 2013-08-02 10:00:44 -0700 | [diff] [blame] | 8101 | type = type.trim().toLowerCase(Locale.ROOT); |
Nick Pelly | ccae412 | 2012-01-09 14:12:58 -0800 | [diff] [blame] | 8102 | |
| 8103 | final int semicolonIndex = type.indexOf(';'); |
| 8104 | if (semicolonIndex != -1) { |
| 8105 | type = type.substring(0, semicolonIndex); |
| 8106 | } |
| 8107 | return type; |
| 8108 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8109 | |
| 8110 | /** |
Jeff Sharkey | a14acd2 | 2013-04-02 18:27:45 -0700 | [diff] [blame] | 8111 | * Prepare this {@link Intent} to leave an app process. |
| 8112 | * |
| 8113 | * @hide |
| 8114 | */ |
| 8115 | public void prepareToLeaveProcess() { |
| 8116 | setAllowFds(false); |
| 8117 | |
| 8118 | if (mSelector != null) { |
| 8119 | mSelector.prepareToLeaveProcess(); |
| 8120 | } |
| 8121 | if (mClipData != null) { |
| 8122 | mClipData.prepareToLeaveProcess(); |
| 8123 | } |
| 8124 | |
| 8125 | if (mData != null && StrictMode.vmFileUriExposureEnabled()) { |
| 8126 | // There are several ACTION_MEDIA_* broadcasts that send file:// |
| 8127 | // Uris, so only check common actions. |
| 8128 | if (ACTION_VIEW.equals(mAction) || |
| 8129 | ACTION_EDIT.equals(mAction) || |
| 8130 | ACTION_ATTACH_DATA.equals(mAction)) { |
| 8131 | mData.checkFileUriExposed("Intent.getData()"); |
| 8132 | } |
| 8133 | } |
| 8134 | } |
| 8135 | |
| 8136 | /** |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8137 | * @hide |
| 8138 | */ |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8139 | public void prepareToEnterProcess() { |
| 8140 | if (mContentUserHint != UserHandle.USER_CURRENT) { |
Nicolas Prevot | c4fc00a | 2014-10-31 12:01:32 +0000 | [diff] [blame] | 8141 | if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { |
| 8142 | fixUris(mContentUserHint); |
| 8143 | mContentUserHint = UserHandle.USER_CURRENT; |
| 8144 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8145 | } |
| 8146 | } |
| 8147 | |
| 8148 | /** |
| 8149 | * @hide |
| 8150 | */ |
| 8151 | public void fixUris(int contentUserHint) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8152 | Uri data = getData(); |
| 8153 | if (data != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8154 | mData = maybeAddUserId(data, contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8155 | } |
| 8156 | if (mClipData != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8157 | mClipData.fixUris(contentUserHint); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8158 | } |
| 8159 | String action = getAction(); |
| 8160 | if (ACTION_SEND.equals(action)) { |
| 8161 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 8162 | if (stream != null) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8163 | putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8164 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8165 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8166 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 8167 | if (streams != null) { |
| 8168 | ArrayList<Uri> newStreams = new ArrayList<Uri>(); |
| 8169 | for (int i = 0; i < streams.size(); i++) { |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8170 | newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8171 | } |
| 8172 | putParcelableArrayListExtra(EXTRA_STREAM, newStreams); |
| 8173 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8174 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 8175 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 8176 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 8177 | final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 8178 | if (output != null) { |
| 8179 | putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); |
| 8180 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8181 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8182 | } |
Nicolas Prevot | d85fc72 | 2014-04-16 19:52:08 +0100 | [diff] [blame] | 8183 | |
| 8184 | /** |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8185 | * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8186 | * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested |
| 8187 | * intents in {@link #ACTION_CHOOSER}. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8188 | * |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8189 | * @return Whether any contents were migrated. |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8190 | * @hide |
| 8191 | */ |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8192 | public boolean migrateExtraStreamToClipData() { |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8193 | // Refuse to touch if extras already parcelled |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8194 | if (mExtras != null && mExtras.isParcelled()) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8195 | |
| 8196 | // Bail when someone already gave us ClipData |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8197 | if (getClipData() != null) return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8198 | |
| 8199 | final String action = getAction(); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8200 | if (ACTION_CHOOSER.equals(action)) { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 8201 | // Inspect contained intents to see if we need to migrate extras. We |
| 8202 | // don't promote ClipData to the parent, since ChooserActivity will |
| 8203 | // already start the picked item as the caller, and we can't combine |
| 8204 | // the flags in a safe way. |
| 8205 | |
| 8206 | boolean migrated = false; |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 8207 | try { |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 8208 | final Intent intent = getParcelableExtra(EXTRA_INTENT); |
| 8209 | if (intent != null) { |
| 8210 | migrated |= intent.migrateExtraStreamToClipData(); |
Jeff Sharkey | 1c29700 | 2012-05-18 13:55:47 -0700 | [diff] [blame] | 8211 | } |
| 8212 | } catch (ClassCastException e) { |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8213 | } |
Jeff Sharkey | c004eef | 2014-09-23 16:40:50 -0700 | [diff] [blame] | 8214 | try { |
| 8215 | final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); |
| 8216 | if (intents != null) { |
| 8217 | for (int i = 0; i < intents.length; i++) { |
| 8218 | final Intent intent = (Intent) intents[i]; |
| 8219 | if (intent != null) { |
| 8220 | migrated |= intent.migrateExtraStreamToClipData(); |
| 8221 | } |
| 8222 | } |
| 8223 | } |
| 8224 | } catch (ClassCastException e) { |
| 8225 | } |
| 8226 | return migrated; |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8227 | |
| 8228 | } else if (ACTION_SEND.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 8229 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 8230 | final Uri stream = getParcelableExtra(EXTRA_STREAM); |
| 8231 | final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); |
| 8232 | final String htmlText = getStringExtra(EXTRA_HTML_TEXT); |
| 8233 | if (stream != null || text != null || htmlText != null) { |
| 8234 | final ClipData clipData = new ClipData( |
| 8235 | null, new String[] { getType() }, |
| 8236 | new ClipData.Item(text, htmlText, null, stream)); |
| 8237 | setClipData(clipData); |
| 8238 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8239 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 8240 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 8241 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 8242 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8243 | |
| 8244 | } else if (ACTION_SEND_MULTIPLE.equals(action)) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 8245 | try { |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 8246 | final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); |
| 8247 | final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); |
| 8248 | final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); |
| 8249 | int num = -1; |
| 8250 | if (streams != null) { |
| 8251 | num = streams.size(); |
| 8252 | } |
| 8253 | if (texts != null) { |
| 8254 | if (num >= 0 && num != texts.size()) { |
| 8255 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8256 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 8257 | } |
| 8258 | num = texts.size(); |
| 8259 | } |
| 8260 | if (htmlTexts != null) { |
| 8261 | if (num >= 0 && num != htmlTexts.size()) { |
| 8262 | // Wha...! F- you. |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8263 | return false; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 8264 | } |
| 8265 | num = htmlTexts.size(); |
| 8266 | } |
| 8267 | if (num > 0) { |
| 8268 | final ClipData clipData = new ClipData( |
| 8269 | null, new String[] { getType() }, |
| 8270 | makeClipItem(streams, texts, htmlTexts, 0)); |
| 8271 | |
| 8272 | for (int i = 1; i < num; i++) { |
| 8273 | clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); |
| 8274 | } |
| 8275 | |
| 8276 | setClipData(clipData); |
| 8277 | addFlags(FLAG_GRANT_READ_URI_PERMISSION); |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8278 | return true; |
Jeff Sharkey | dd471e6 | 2012-05-01 13:07:01 -0700 | [diff] [blame] | 8279 | } |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 8280 | } catch (ClassCastException e) { |
Jeff Sharkey | f27ea66 | 2012-03-27 10:34:24 -0700 | [diff] [blame] | 8281 | } |
Nicolas Prevot | d1c99b1 | 2014-07-04 16:56:17 +0100 | [diff] [blame] | 8282 | } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) |
| 8283 | || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action) |
| 8284 | || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) { |
| 8285 | final Uri output; |
| 8286 | try { |
| 8287 | output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); |
| 8288 | } catch (ClassCastException e) { |
| 8289 | return false; |
| 8290 | } |
| 8291 | if (output != null) { |
| 8292 | setClipData(ClipData.newRawUri("", output)); |
| 8293 | addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); |
| 8294 | return true; |
| 8295 | } |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8296 | } |
Jeff Sharkey | 3b7d1ef | 2012-05-14 17:21:10 -0700 | [diff] [blame] | 8297 | |
| 8298 | return false; |
Jeff Sharkey | 678d04f | 2012-03-23 15:41:58 -0700 | [diff] [blame] | 8299 | } |
Dianne Hackborn | ac4243f | 2012-04-13 17:32:18 -0700 | [diff] [blame] | 8300 | |
| 8301 | private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, |
| 8302 | ArrayList<String> htmlTexts, int which) { |
| 8303 | Uri uri = streams != null ? streams.get(which) : null; |
| 8304 | CharSequence text = texts != null ? texts.get(which) : null; |
| 8305 | String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; |
| 8306 | return new ClipData.Item(text, htmlText, null, uri); |
| 8307 | } |
Craig Mautner | d00f474 | 2014-03-12 14:17:26 -0700 | [diff] [blame] | 8308 | |
| 8309 | /** @hide */ |
| 8310 | public boolean isDocument() { |
| 8311 | return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; |
| 8312 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8313 | } |