blob: 09aad3b664280f385dfff929ecb29e842d3daadb [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070020import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070021import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050023import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050025import android.content.pm.ApplicationInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070026import android.content.pm.PackageManager;
27import android.content.pm.ResolveInfo;
28import android.content.res.Resources;
29import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080030import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.net.Uri;
32import android.os.Bundle;
33import android.os.IBinder;
34import android.os.Parcel;
35import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000036import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050037import android.os.ResultReceiver;
38import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070039import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010040import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070041import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070042import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050043import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070044import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050045import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070046import android.util.AttributeSet;
47import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080048import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050049import org.xmlpull.v1.XmlPullParser;
50import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070051import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070052
53import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080054import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070055import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070056import java.lang.annotation.Retention;
57import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058import java.net.URISyntaxException;
59import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080060import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070061import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080062import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070063import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070064import java.util.Set;
65
Jason Monk2f68e8a2016-02-23 17:57:28 -050066import static android.content.ContentProvider.maybeAddUserId;
67
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068/**
69 * An intent is an abstract description of an operation to be performed. It
70 * can be used with {@link Context#startActivity(Intent) startActivity} to
71 * launch an {@link android.app.Activity},
72 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
73 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
74 * and {@link android.content.Context#startService} or
75 * {@link android.content.Context#bindService} to communicate with a
76 * background {@link android.app.Service}.
77 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070078 * <p>An Intent provides a facility for performing late runtime binding between the code in
79 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070080 * can be thought of as the glue between activities. It is basically a passive data structure
81 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070082 *
83 * <div class="special reference">
84 * <h3>Developer Guides</h3>
85 * <p>For information about how to create and resolve intents, read the
86 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
87 * developer guide.</p>
88 * </div>
89 *
90 * <a name="IntentStructure"></a>
91 * <h3>Intent Structure</h3>
92 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070093 *
94 * <ul>
95 * <li> <p><b>action</b> -- The general action to be performed, such as
96 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
97 * etc.</p>
98 * </li>
99 * <li> <p><b>data</b> -- The data to operate on, such as a person record
100 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
101 * </li>
102 * </ul>
103 *
104 *
105 * <p>Some examples of action/data pairs are:</p>
106 *
107 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700108 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700109 * information about the person whose identifier is "1".</p>
110 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700111 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700112 * the phone dialer with the person filled in.</p>
113 * </li>
114 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
115 * the phone dialer with the given number filled in. Note how the
116 * VIEW action does what what is considered the most reasonable thing for
117 * a particular URI.</p>
118 * </li>
119 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
120 * the phone dialer with the given number filled in.</p>
121 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700122 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700123 * information about the person whose identifier is "1".</p>
124 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700125 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700126 * a list of people, which the user can browse through. This example is a
127 * typical top-level entry into the Contacts application, showing you the
128 * list of people. Selecting a particular person to view would result in a
129 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
130 * being used to start an activity to display that person.</p>
131 * </li>
132 * </ul>
133 *
134 * <p>In addition to these primary attributes, there are a number of secondary
135 * attributes that you can also include with an intent:</p>
136 *
137 * <ul>
138 * <li> <p><b>category</b> -- Gives additional information about the action
139 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
140 * appear in the Launcher as a top-level application, while
141 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
142 * of alternative actions the user can perform on a piece of data.</p>
143 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
144 * intent data. Normally the type is inferred from the data itself.
145 * By setting this attribute, you disable that evaluation and force
146 * an explicit type.</p>
147 * <li> <p><b>component</b> -- Specifies an explicit name of a component
148 * class to use for the intent. Normally this is determined by looking
149 * at the other information in the intent (the action, data/type, and
150 * categories) and matching that with a component that can handle it.
151 * If this attribute is set then none of the evaluation is performed,
152 * and this component is used exactly as is. By specifying this attribute,
153 * all of the other Intent attributes become optional.</p>
154 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
155 * This can be used to provide extended information to the component.
156 * For example, if we have a action to send an e-mail message, we could
157 * also include extra pieces of data here to supply a subject, body,
158 * etc.</p>
159 * </ul>
160 *
161 * <p>Here are some examples of other operations you can specify as intents
162 * using these additional parameters:</p>
163 *
164 * <ul>
165 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
166 * Launch the home screen.</p>
167 * </li>
168 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
169 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
170 * vnd.android.cursor.item/phone}</i></b>
171 * -- Display the list of people's phone numbers, allowing the user to
172 * browse through them and pick one and return it to the parent activity.</p>
173 * </li>
174 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
175 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
176 * -- Display all pickers for data that can be opened with
177 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
178 * allowing the user to pick one of them and then some data inside of it
179 * and returning the resulting URI to the caller. This can be used,
180 * for example, in an e-mail application to allow the user to pick some
181 * data to include as an attachment.</p>
182 * </li>
183 * </ul>
184 *
185 * <p>There are a variety of standard Intent action and category constants
186 * defined in the Intent class, but applications can also define their own.
187 * These strings use java style scoping, to ensure they are unique -- for
188 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700189 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700190 *
191 * <p>Put together, the set of actions, data types, categories, and extra data
192 * defines a language for the system allowing for the expression of phrases
193 * such as "call john smith's cell". As applications are added to the system,
194 * they can extend this language by adding new actions, types, and categories, or
195 * they can modify the behavior of existing phrases by supplying their own
196 * activities that handle them.</p>
197 *
198 * <a name="IntentResolution"></a>
199 * <h3>Intent Resolution</h3>
200 *
201 * <p>There are two primary forms of intents you will use.
202 *
203 * <ul>
204 * <li> <p><b>Explicit Intents</b> have specified a component (via
205 * {@link #setComponent} or {@link #setClass}), which provides the exact
206 * class to be run. Often these will not include any other information,
207 * simply being a way for an application to launch various internal
208 * activities it has as the user interacts with the application.
209 *
210 * <li> <p><b>Implicit Intents</b> have not specified a component;
211 * instead, they must include enough information for the system to
212 * determine which of the available components is best to run for that
213 * intent.
214 * </ul>
215 *
216 * <p>When using implicit intents, given such an arbitrary intent we need to
217 * know what to do with it. This is handled by the process of <em>Intent
218 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
219 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
220 * more activities/receivers) that can handle it.</p>
221 *
222 * <p>The intent resolution mechanism basically revolves around matching an
223 * Intent against all of the &lt;intent-filter&gt; descriptions in the
224 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
225 * objects explicitly registered with {@link Context#registerReceiver}.) More
226 * details on this can be found in the documentation on the {@link
227 * IntentFilter} class.</p>
228 *
229 * <p>There are three pieces of information in the Intent that are used for
230 * resolution: the action, type, and category. Using this information, a query
231 * is done on the {@link PackageManager} for a component that can handle the
232 * intent. The appropriate component is determined based on the intent
233 * information supplied in the <code>AndroidManifest.xml</code> file as
234 * follows:</p>
235 *
236 * <ul>
237 * <li> <p>The <b>action</b>, if given, must be listed by the component as
238 * one it handles.</p>
239 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
240 * already supplied in the Intent. Like the action, if a type is
241 * included in the intent (either explicitly or implicitly in its
242 * data), then this must be listed by the component as one it handles.</p>
243 * <li> For data that is not a <code>content:</code> URI and where no explicit
244 * type is included in the Intent, instead the <b>scheme</b> of the
245 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
246 * considered. Again like the action, if we are matching a scheme it
247 * must be listed by the component as one it can handle.
248 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
249 * by the activity as categories it handles. That is, if you include
250 * the categories {@link #CATEGORY_LAUNCHER} and
251 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
252 * with an intent that lists <em>both</em> of those categories.
253 * Activities will very often need to support the
254 * {@link #CATEGORY_DEFAULT} so that they can be found by
255 * {@link Context#startActivity Context.startActivity()}.</p>
256 * </ul>
257 *
258 * <p>For example, consider the Note Pad sample application that
259 * allows user to browse through a list of notes data and view details about
260 * individual items. Text in italics indicate places were you would replace a
261 * name with one specific to your own package.</p>
262 *
263 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
264 * package="<i>com.android.notepad</i>"&gt;
265 * &lt;application android:icon="@drawable/app_notes"
266 * android:label="@string/app_name"&gt;
267 *
268 * &lt;provider class=".NotePadProvider"
269 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
270 *
271 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
272 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700273 * &lt;action android:name="android.intent.action.MAIN" /&gt;
274 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700275 * &lt;/intent-filter&gt;
276 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700277 * &lt;action android:name="android.intent.action.VIEW" /&gt;
278 * &lt;action android:name="android.intent.action.EDIT" /&gt;
279 * &lt;action android:name="android.intent.action.PICK" /&gt;
280 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
281 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700282 * &lt;/intent-filter&gt;
283 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700284 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
285 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
286 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;/activity&gt;
289 *
290 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
291 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700292 * &lt;action android:name="android.intent.action.VIEW" /&gt;
293 * &lt;action android:name="android.intent.action.EDIT" /&gt;
294 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
295 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700296 * &lt;/intent-filter&gt;
297 *
298 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700299 * &lt;action android:name="android.intent.action.INSERT" /&gt;
300 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
301 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700302 * &lt;/intent-filter&gt;
303 *
304 * &lt;/activity&gt;
305 *
306 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
307 * android:theme="@android:style/Theme.Dialog"&gt;
308 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700309 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
310 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
311 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
312 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
313 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700314 * &lt;/intent-filter&gt;
315 * &lt;/activity&gt;
316 *
317 * &lt;/application&gt;
318 * &lt;/manifest&gt;</pre>
319 *
320 * <p>The first activity,
321 * <code>com.android.notepad.NotesList</code>, serves as our main
322 * entry into the app. It can do three things as described by its three intent
323 * templates:
324 * <ol>
325 * <li><pre>
326 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700327 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
328 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700329 * &lt;/intent-filter&gt;</pre>
330 * <p>This provides a top-level entry into the NotePad application: the standard
331 * MAIN action is a main entry point (not requiring any other information in
332 * the Intent), and the LAUNCHER category says that this entry point should be
333 * listed in the application launcher.</p>
334 * <li><pre>
335 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700336 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
337 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
338 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
339 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
340 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700341 * &lt;/intent-filter&gt;</pre>
342 * <p>This declares the things that the activity can do on a directory of
343 * notes. The type being supported is given with the &lt;type&gt; tag, where
344 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
345 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
346 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
347 * The activity allows the user to view or edit the directory of data (via
348 * the VIEW and EDIT actions), or to pick a particular note and return it
349 * to the caller (via the PICK action). Note also the DEFAULT category
350 * supplied here: this is <em>required</em> for the
351 * {@link Context#startActivity Context.startActivity} method to resolve your
352 * activity when its component name is not explicitly specified.</p>
353 * <li><pre>
354 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700355 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
356 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
357 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700358 * &lt;/intent-filter&gt;</pre>
359 * <p>This filter describes the ability return to the caller a note selected by
360 * the user without needing to know where it came from. The data type
361 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
362 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
363 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
364 * The GET_CONTENT action is similar to the PICK action, where the activity
365 * will return to its caller a piece of data selected by the user. Here,
366 * however, the caller specifies the type of data they desire instead of
367 * the type of data the user will be picking from.</p>
368 * </ol>
369 *
370 * <p>Given these capabilities, the following intents will resolve to the
371 * NotesList activity:</p>
372 *
373 * <ul>
374 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
375 * activities that can be used as top-level entry points into an
376 * application.</p>
377 * <li> <p><b>{ action=android.app.action.MAIN,
378 * category=android.app.category.LAUNCHER }</b> is the actual intent
379 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700380 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700381 * data=content://com.google.provider.NotePad/notes }</b>
382 * displays a list of all the notes under
383 * "content://com.google.provider.NotePad/notes", which
384 * the user can browse through and see the details on.</p>
385 * <li> <p><b>{ action=android.app.action.PICK
386 * data=content://com.google.provider.NotePad/notes }</b>
387 * provides a list of the notes under
388 * "content://com.google.provider.NotePad/notes", from which
389 * the user can pick a note whose data URL is returned back to the caller.</p>
390 * <li> <p><b>{ action=android.app.action.GET_CONTENT
391 * type=vnd.android.cursor.item/vnd.google.note }</b>
392 * is similar to the pick action, but allows the caller to specify the
393 * kind of data they want back so that the system can find the appropriate
394 * activity to pick something of that data type.</p>
395 * </ul>
396 *
397 * <p>The second activity,
398 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
399 * note entry and allows them to edit it. It can do two things as described
400 * by its two intent templates:
401 * <ol>
402 * <li><pre>
403 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700404 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
405 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
406 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
407 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700408 * &lt;/intent-filter&gt;</pre>
409 * <p>The first, primary, purpose of this activity is to let the user interact
410 * with a single note, as decribed by the MIME type
411 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
412 * either VIEW a note or allow the user to EDIT it. Again we support the
413 * DEFAULT category to allow the activity to be launched without explicitly
414 * specifying its component.</p>
415 * <li><pre>
416 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700417 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
418 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
419 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700420 * &lt;/intent-filter&gt;</pre>
421 * <p>The secondary use of this activity is to insert a new note entry into
422 * an existing directory of notes. This is used when the user creates a new
423 * note: the INSERT action is executed on the directory of notes, causing
424 * this activity to run and have the user create the new note data which
425 * it then adds to the content provider.</p>
426 * </ol>
427 *
428 * <p>Given these capabilities, the following intents will resolve to the
429 * NoteEditor activity:</p>
430 *
431 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700432 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700433 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
434 * shows the user the content of note <var>{ID}</var>.</p>
435 * <li> <p><b>{ action=android.app.action.EDIT
436 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
437 * allows the user to edit the content of note <var>{ID}</var>.</p>
438 * <li> <p><b>{ action=android.app.action.INSERT
439 * data=content://com.google.provider.NotePad/notes }</b>
440 * creates a new, empty note in the notes list at
441 * "content://com.google.provider.NotePad/notes"
442 * and allows the user to edit it. If they keep their changes, the URI
443 * of the newly created note is returned to the caller.</p>
444 * </ul>
445 *
446 * <p>The last activity,
447 * <code>com.android.notepad.TitleEditor</code>, allows the user to
448 * edit the title of a note. This could be implemented as a class that the
449 * application directly invokes (by explicitly setting its component in
450 * the Intent), but here we show a way you can publish alternative
451 * operations on existing data:</p>
452 *
453 * <pre>
454 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700455 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
456 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
457 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
458 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
459 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700460 * &lt;/intent-filter&gt;</pre>
461 *
462 * <p>In the single intent template here, we
463 * have created our own private action called
464 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
465 * edit the title of a note. It must be invoked on a specific note
466 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
467 * view and edit actions, but here displays and edits the title contained
468 * in the note data.
469 *
470 * <p>In addition to supporting the default category as usual, our title editor
471 * also supports two other standard categories: ALTERNATIVE and
472 * SELECTED_ALTERNATIVE. Implementing
473 * these categories allows others to find the special action it provides
474 * without directly knowing about it, through the
475 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
476 * more often to build dynamic menu items with
477 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
478 * template here was also supply an explicit name for the template
479 * (via <code>android:label="@string/resolve_title"</code>) to better control
480 * what the user sees when presented with this activity as an alternative
481 * action to the data they are viewing.
482 *
483 * <p>Given these capabilities, the following intent will resolve to the
484 * TitleEditor activity:</p>
485 *
486 * <ul>
487 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
488 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
489 * displays and allows the user to edit the title associated
490 * with note <var>{ID}</var>.</p>
491 * </ul>
492 *
493 * <h3>Standard Activity Actions</h3>
494 *
495 * <p>These are the current standard actions that Intent defines for launching
496 * activities (usually through {@link Context#startActivity}. The most
497 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
498 * {@link #ACTION_EDIT}.
499 *
500 * <ul>
501 * <li> {@link #ACTION_MAIN}
502 * <li> {@link #ACTION_VIEW}
503 * <li> {@link #ACTION_ATTACH_DATA}
504 * <li> {@link #ACTION_EDIT}
505 * <li> {@link #ACTION_PICK}
506 * <li> {@link #ACTION_CHOOSER}
507 * <li> {@link #ACTION_GET_CONTENT}
508 * <li> {@link #ACTION_DIAL}
509 * <li> {@link #ACTION_CALL}
510 * <li> {@link #ACTION_SEND}
511 * <li> {@link #ACTION_SENDTO}
512 * <li> {@link #ACTION_ANSWER}
513 * <li> {@link #ACTION_INSERT}
514 * <li> {@link #ACTION_DELETE}
515 * <li> {@link #ACTION_RUN}
516 * <li> {@link #ACTION_SYNC}
517 * <li> {@link #ACTION_PICK_ACTIVITY}
518 * <li> {@link #ACTION_SEARCH}
519 * <li> {@link #ACTION_WEB_SEARCH}
520 * <li> {@link #ACTION_FACTORY_TEST}
521 * </ul>
522 *
523 * <h3>Standard Broadcast Actions</h3>
524 *
525 * <p>These are the current standard actions that Intent defines for receiving
526 * broadcasts (usually through {@link Context#registerReceiver} or a
527 * &lt;receiver&gt; tag in a manifest).
528 *
529 * <ul>
530 * <li> {@link #ACTION_TIME_TICK}
531 * <li> {@link #ACTION_TIME_CHANGED}
532 * <li> {@link #ACTION_TIMEZONE_CHANGED}
533 * <li> {@link #ACTION_BOOT_COMPLETED}
534 * <li> {@link #ACTION_PACKAGE_ADDED}
535 * <li> {@link #ACTION_PACKAGE_CHANGED}
536 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800537 * <li> {@link #ACTION_PACKAGE_RESTARTED}
538 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000539 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
540 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700541 * <li> {@link #ACTION_UID_REMOVED}
542 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700543 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700544 * <li> {@link #ACTION_POWER_DISCONNECTED}
545 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * </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 Project9066cfe2009-03-03 19:31:44 -0800560 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700561 * <li> {@link #CATEGORY_HOME}
562 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400564 * <li> {@link #CATEGORY_CAR_DOCK}
565 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500566 * <li> {@link #CATEGORY_LE_DESK_DOCK}
567 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200568 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700569 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * </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 Johnsd59fb6e2009-11-20 12:54:57 -0800578 * <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 Bharathi21e941b2010-10-06 15:23:14 -0500584 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
585 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800586 * <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 Project54b6cfa2008-10-21 07:00:00 -0700592 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800593 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700594 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800595 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700596 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <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 Project54b6cfa2008-10-21 07:00:00 -0700602 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_SHORTCUT_NAME}
604 * <li> {@link #EXTRA_SUBJECT}
605 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_TITLE}
608 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * </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 Projectf013e1a2008-12-17 18:05:43 -0800614 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
615 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800617public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700618 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 Project54b6cfa2008-10-21 07:00:00 -0700627 // ---------------------------------------------------------------------
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 Projectf013e1a2008-12-17 18:05:43 -0800639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700640 /**
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 Projectf013e1a2008-12-17 18:05:43 -0800653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 /**
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 Projectf013e1a2008-12-17 18:05:43 -0800659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900661 * Activity Action: Quick view the data. Launches a quick viewer for
662 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900663 * <p>Activities handling this intent action should handle the vast majority of
664 * MIME types rather than only specific ones.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900665 * <p>Input: {@link #getData} is a mandatory content URI of the item to
666 * preview. {@link #getClipData} contains an optional list of content URIs
667 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
668 * optional index of the URI in the clip data to show first.
Steve McKayc78bcb82015-07-31 14:35:22 -0700669 * <p>Output: nothing.
Steve McKayc78bcb82015-07-31 14:35:22 -0700670 */
671 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
672 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
673
674 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700675 * Used to indicate that some piece of data should be attached to some other
676 * place. For example, image data could be attached to a contact. It is up
677 * to the recipient to decide where the data should be attached; the intent
678 * does not specify the ultimate destination.
679 * <p>Input: {@link #getData} is URI of data to be attached.
680 * <p>Output: nothing.
681 */
682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
683 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800684
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700685 /**
686 * Activity Action: Provide explicit editable access to the given data.
687 * <p>Input: {@link #getData} is URI of data to be edited.
688 * <p>Output: nothing.
689 */
690 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
691 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800692
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700693 /**
694 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
695 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
696 * The extras can contain type specific data to pass through to the editing/creating
697 * activity.
698 * <p>Output: The URI of the item that was picked. This must be a content:
699 * URI so that any receiver can access it.
700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 /**
705 * Activity Action: Pick an item from the data, returning what was selected.
706 * <p>Input: {@link #getData} is URI containing a directory of data
707 * (vnd.android.cursor.dir/*) from which to pick an item.
708 * <p>Output: The URI of the item that was picked.
709 */
710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
711 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800712
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700713 /**
714 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 * <p>Output: An Intent representing the shortcut. The intent must contain three
717 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
718 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800719 * (value: ShortcutIconResource).</p>
720 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700721 * @see #EXTRA_SHORTCUT_INTENT
722 * @see #EXTRA_SHORTCUT_NAME
723 * @see #EXTRA_SHORTCUT_ICON
724 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
725 * @see android.content.Intent.ShortcutIconResource
726 */
727 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
728 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
729
730 /**
731 * The name of the extra used to define the Intent of a shortcut.
732 *
733 * @see #ACTION_CREATE_SHORTCUT
734 */
735 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
736 /**
737 * The name of the extra used to define the name of a shortcut.
738 *
739 * @see #ACTION_CREATE_SHORTCUT
740 */
741 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
742 /**
743 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
744 *
745 * @see #ACTION_CREATE_SHORTCUT
746 */
747 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
748 /**
749 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
750 *
751 * @see #ACTION_CREATE_SHORTCUT
752 * @see android.content.Intent.ShortcutIconResource
753 */
754 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
755 "android.intent.extra.shortcut.ICON_RESOURCE";
756
757 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500758 * An activity that provides a user interface for adjusting application preferences.
759 * Optional but recommended settings for all applications which have settings.
760 */
761 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
762 public static final String ACTION_APPLICATION_PREFERENCES
763 = "android.intent.action.APPLICATION_PREFERENCES";
764
765 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800766 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 *
768 * @see Intent#ACTION_CREATE_SHORTCUT
769 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800770 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
771 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700772 */
773 public static class ShortcutIconResource implements Parcelable {
774 /**
775 * The package name of the application containing the icon.
776 */
777 public String packageName;
778
779 /**
780 * The resource name of the icon, including package, name and type.
781 */
782 public String resourceName;
783
784 /**
785 * Creates a new ShortcutIconResource for the specified context and resource
786 * identifier.
787 *
788 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700789 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700790 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700791 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700792 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700793 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700794 ShortcutIconResource icon = new ShortcutIconResource();
795 icon.packageName = context.getPackageName();
796 icon.resourceName = context.getResources().getResourceName(resourceId);
797 return icon;
798 }
799
800 /**
801 * Used to read a ShortcutIconResource from a Parcel.
802 */
803 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
804 new Parcelable.Creator<ShortcutIconResource>() {
805
806 public ShortcutIconResource createFromParcel(Parcel source) {
807 ShortcutIconResource icon = new ShortcutIconResource();
808 icon.packageName = source.readString();
809 icon.resourceName = source.readString();
810 return icon;
811 }
812
813 public ShortcutIconResource[] newArray(int size) {
814 return new ShortcutIconResource[size];
815 }
816 };
817
818 /**
819 * No special parcel contents.
820 */
821 public int describeContents() {
822 return 0;
823 }
824
825 public void writeToParcel(Parcel dest, int flags) {
826 dest.writeString(packageName);
827 dest.writeString(resourceName);
828 }
829
830 @Override
831 public String toString() {
832 return resourceName;
833 }
834 }
835
836 /**
837 * Activity Action: Display an activity chooser, allowing the user to pick
838 * what they want to before proceeding. This can be used as an alternative
839 * to the standard activity picker that is displayed by the system when
840 * you try to start an activity with multiple possible matches, with these
841 * differences in behavior:
842 * <ul>
843 * <li>You can specify the title that will appear in the activity chooser.
844 * <li>The user does not have the option to make one of the matching
845 * activities a preferred activity, and all possible activities will
846 * always be shown even if one of them is currently marked as the
847 * preferred activity.
848 * </ul>
849 * <p>
850 * This action should be used when the user will naturally expect to
851 * select an activity in order to proceed. An example if when not to use
852 * it is when the user clicks on a "mailto:" link. They would naturally
853 * expect to go directly to their mail app, so startActivity() should be
854 * called directly: it will
855 * either launch the current preferred app, or put up a dialog allowing the
856 * user to pick an app to use and optionally marking that as preferred.
857 * <p>
858 * In contrast, if the user is selecting a menu item to send a picture
859 * they are viewing to someone else, there are many different things they
860 * may want to do at this point: send it through e-mail, upload it to a
861 * web service, etc. In this case the CHOOSER action should be used, to
862 * always present to the user a list of the things they can do, with a
863 * nice title given by the caller such as "Send this photo with:".
864 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700865 * If you need to grant URI permissions through a chooser, you must specify
866 * the permissions to be granted on the ACTION_CHOOSER Intent
867 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
868 * {@link #setClipData} to specify the URIs to be granted as well as
869 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
870 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
871 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700872 * As a convenience, an Intent of this form can be created with the
873 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700874 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700875 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700876 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
877 * and can optionally have a {@link #EXTRA_TITLE} field containing the
878 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700879 * <p>
880 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700881 */
882 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
883 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
884
885 /**
886 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
887 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700888 * <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,
John Spurlock33900182014-01-02 11:04:18 -0500894 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700895 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700896 * @param target The Intent that the user will be selecting an activity
897 * to perform.
898 * @param title Optional title that will be displayed in the chooser.
899 * @return Return a new Intent object that you can hand to
900 * {@link Context#startActivity(Intent) Context.startActivity()} and
901 * related methods.
902 */
903 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700904 return createChooser(target, title, null);
905 }
906
907 /**
908 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
909 *
910 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
911 * target intent, also optionally supplying a title. If the target
912 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
913 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
914 * set in the returned chooser intent, with its ClipData set appropriately:
915 * either a direct reflection of {@link #getClipData()} if that is non-null,
916 * or a new ClipData built from {@link #getData()}.</p>
917 *
918 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
919 * when the user makes a choice. This can be useful if the calling application wants
920 * to remember the last chosen target and surface it as a more prominent or one-touch
921 * affordance elsewhere in the UI for next time.</p>
922 *
923 * @param target The Intent that the user will be selecting an activity
924 * to perform.
925 * @param title Optional title that will be displayed in the chooser.
926 * @param sender Optional IntentSender to be called when a choice is made.
927 * @return Return a new Intent object that you can hand to
928 * {@link Context#startActivity(Intent) Context.startActivity()} and
929 * related methods.
930 */
931 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700932 Intent intent = new Intent(ACTION_CHOOSER);
933 intent.putExtra(EXTRA_INTENT, target);
934 if (title != null) {
935 intent.putExtra(EXTRA_TITLE, title);
936 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700937
Adam Powell0b3c1122014-10-09 12:50:14 -0700938 if (sender != null) {
939 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
940 }
941
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700942 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700943 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
944 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
945 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700946 if (permFlags != 0) {
947 ClipData targetClipData = target.getClipData();
948 if (targetClipData == null && target.getData() != null) {
949 ClipData.Item item = new ClipData.Item(target.getData());
950 String[] mimeTypes;
951 if (target.getType() != null) {
952 mimeTypes = new String[] { target.getType() };
953 } else {
954 mimeTypes = new String[] { };
955 }
956 targetClipData = new ClipData(null, mimeTypes, item);
957 }
958 if (targetClipData != null) {
959 intent.setClipData(targetClipData);
960 intent.addFlags(permFlags);
961 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700962 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700963
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700964 return intent;
965 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700966
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700967 /**
968 * Activity Action: Allow the user to select a particular kind of data and
969 * return it. This is different than {@link #ACTION_PICK} in that here we
970 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800971 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700972 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900973 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700974 * etc.
975 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900976 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700977 * of data, such as a person contact, you set the MIME type to the kind of
978 * data you want and launch it with {@link Context#startActivity(Intent)}.
979 * The system will then launch the best application to select that kind
980 * of data for you.
981 * <p>
982 * You may also be interested in any of a set of types of content the user
983 * can pick. For example, an e-mail application that wants to allow the
984 * user to add an attachment to an e-mail message can use this action to
985 * bring up a list of all of the types of content the user can attach.
986 * <p>
987 * In this case, you should wrap the GET_CONTENT intent with a chooser
988 * (through {@link #createChooser}), which will give the proper interface
989 * for the user to pick how to send your data and allow you to specify
990 * a prompt indicating what they are doing. You will usually specify a
991 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
992 * broad range of content types the user can select from.
993 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900994 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700995 * only pick from data that can be represented as a stream. This is
996 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
997 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800998 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900999 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001000 * is locally available on the device. For example, if this extra is set
1001 * to true then an image picker should not show any pictures that are available
1002 * from a remote server but not already on the local device (thus requiring
1003 * they be downloaded when opened).
1004 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001005 * If the caller can handle multiple returned items (the user performing
1006 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1007 * to indicate this.
1008 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001009 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1010 * that no URI is supplied in the intent, as there are no constraints on
1011 * where the returned data originally comes from. You may also include the
1012 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001013 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001014 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1015 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001016 * <p>
1017 * Output: The URI of the item that was picked. This must be a content:
1018 * URI so that any receiver can access it.
1019 */
1020 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1021 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1022 /**
1023 * Activity Action: Dial a number as specified by the data. This shows a
1024 * UI with the number being dialed, allowing the user to explicitly
1025 * initiate the call.
1026 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1027 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1028 * number.
1029 * <p>Output: nothing.
1030 */
1031 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1032 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1033 /**
1034 * Activity Action: Perform a call to someone specified by the data.
1035 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1036 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1037 * number.
1038 * <p>Output: nothing.
1039 *
1040 * <p>Note: there will be restrictions on which applications can initiate a
1041 * call; most applications should use the {@link #ACTION_DIAL}.
1042 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1043 * numbers. Applications can <strong>dial</strong> emergency numbers using
1044 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001045 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001046 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001047 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001048 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001049 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001050 */
1051 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1052 public static final String ACTION_CALL = "android.intent.action.CALL";
1053 /**
1054 * Activity Action: Perform a call to an emergency number specified by the
1055 * data.
1056 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1057 * tel: URI of an explicit phone number.
1058 * <p>Output: nothing.
1059 * @hide
1060 */
1061 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1062 /**
1063 * Activity action: Perform a call to any number (emergency or not)
1064 * specified by the data.
1065 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1066 * tel: URI of an explicit phone number.
1067 * <p>Output: nothing.
1068 * @hide
1069 */
1070 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1071 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001072 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1073 * sending this intent is a no-op.
1074 * <p>Input: No data should be specified. get*Extra may have an optional
1075 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1076 * send the activation result.
1077 * <p>Output: nothing.
1078 * @hide
1079 */
1080 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1081 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1082 "android.intent.action.SIM_ACTIVATION_REQUEST";
1083 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001084 * Activity Action: Send a message to someone specified by the data.
1085 * <p>Input: {@link #getData} is URI describing the target.
1086 * <p>Output: nothing.
1087 */
1088 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1089 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1090 /**
1091 * Activity Action: Deliver some data to someone else. Who the data is
1092 * being delivered to is not specified; it is up to the receiver of this
1093 * action to ask the user where the data should be sent.
1094 * <p>
1095 * When launching a SEND intent, you should usually wrap it in a chooser
1096 * (through {@link #createChooser}), which will give the proper interface
1097 * for the user to pick how to send your data and allow you to specify
1098 * a prompt indicating what they are doing.
1099 * <p>
1100 * Input: {@link #getType} is the MIME type of the data being sent.
1101 * get*Extra can have either a {@link #EXTRA_TEXT}
1102 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1103 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1104 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1105 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001106 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1107 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1108 * your text with HTML formatting.
1109 * <p>
1110 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1111 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1112 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1113 * content: URIs and other advanced features of {@link ClipData}. If
1114 * using this approach, you still must supply the same data through the
1115 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1116 * for compatibility with old applications. If you don't set a ClipData,
1117 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001118 * <p>
1119 * Optional standard extras, which may be interpreted by some recipients as
1120 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1121 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1122 * <p>
1123 * Output: nothing.
1124 */
1125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1126 public static final String ACTION_SEND = "android.intent.action.SEND";
1127 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001128 * Activity Action: Deliver multiple data to someone else.
1129 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001130 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001131 * <p>
1132 * Input: {@link #getType} is the MIME type of the data being sent.
1133 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001134 * #EXTRA_STREAM} field, containing the data to be sent. If using
1135 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1136 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001137 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001138 * Multiple types are supported, and receivers should handle mixed types
1139 * whenever possible. The right way for the receiver to check them is to
1140 * use the content resolver on each URI. The intent sender should try to
1141 * put the most concrete mime type in the intent type, but it can fall
1142 * back to {@literal <type>/*} or {@literal *}/* as needed.
1143 * <p>
1144 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1145 * be image/jpg, but if you are sending image/jpg and image/png, then the
1146 * intent's type should be image/*.
1147 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001148 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1149 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1150 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1151 * content: URIs and other advanced features of {@link ClipData}. If
1152 * using this approach, you still must supply the same data through the
1153 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1154 * for compatibility with old applications. If you don't set a ClipData,
1155 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1156 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001157 * Optional standard extras, which may be interpreted by some recipients as
1158 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1159 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1160 * <p>
1161 * Output: nothing.
1162 */
1163 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1164 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1165 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001166 * Activity Action: Handle an incoming phone call.
1167 * <p>Input: nothing.
1168 * <p>Output: nothing.
1169 */
1170 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1171 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1172 /**
1173 * Activity Action: Insert an empty item into the given container.
1174 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1175 * in which to place the data.
1176 * <p>Output: URI of the new data that was created.
1177 */
1178 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1179 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1180 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001181 * Activity Action: Create a new item in the given container, initializing it
1182 * from the current contents of the clipboard.
1183 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1184 * in which to place the data.
1185 * <p>Output: URI of the new data that was created.
1186 */
1187 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1188 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1189 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001190 * Activity Action: Delete the given data from its container.
1191 * <p>Input: {@link #getData} is URI of data to be deleted.
1192 * <p>Output: nothing.
1193 */
1194 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1195 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1196 /**
1197 * Activity Action: Run the data, whatever that means.
1198 * <p>Input: ? (Note: this is currently specific to the test harness.)
1199 * <p>Output: nothing.
1200 */
1201 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1202 public static final String ACTION_RUN = "android.intent.action.RUN";
1203 /**
1204 * Activity Action: Perform a data synchronization.
1205 * <p>Input: ?
1206 * <p>Output: ?
1207 */
1208 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1209 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1210 /**
1211 * Activity Action: Pick an activity given an intent, returning the class
1212 * selected.
1213 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1214 * used with {@link PackageManager#queryIntentActivities} to determine the
1215 * set of activities from which to pick.
1216 * <p>Output: Class name of the activity that was selected.
1217 */
1218 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1219 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1220 /**
1221 * Activity Action: Perform a search.
1222 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1223 * is the text to search for. If empty, simply
1224 * enter your search results Activity with the search UI activated.
1225 * <p>Output: nothing.
1226 */
1227 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1228 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1229 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001230 * Activity Action: Start the platform-defined tutorial
1231 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1232 * is the text to search for. If empty, simply
1233 * enter your search results Activity with the search UI activated.
1234 * <p>Output: nothing.
1235 */
1236 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1238 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001239 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001240 * <p>
1241 * Input: {@link android.app.SearchManager#QUERY
1242 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1243 * a url starts with http or https, the site will be opened. If it is plain
1244 * text, Google search will be applied.
1245 * <p>
1246 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001247 */
1248 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1249 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001250
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001251 /**
Jim Miller07994402012-05-02 14:22:27 -07001252 * Activity Action: Perform assist action.
1253 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001254 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1255 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001256 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1257 * information.
Jim Miller07994402012-05-02 14:22:27 -07001258 * Output: nothing.
1259 */
1260 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1261 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001262
1263 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001264 * Activity Action: Perform voice assist action.
1265 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001266 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1267 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001268 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001269 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001270 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001271 */
1272 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1273 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1274
1275 /**
Adam Skory7140a252013-09-11 12:04:58 +01001276 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1277 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001278 */
1279 public static final String EXTRA_ASSIST_PACKAGE
1280 = "android.intent.extra.ASSIST_PACKAGE";
1281
1282 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001283 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1284 * application package at the time the assist was invoked.
1285 */
1286 public static final String EXTRA_ASSIST_UID
1287 = "android.intent.extra.ASSIST_UID";
1288
1289 /**
Adam Skory7140a252013-09-11 12:04:58 +01001290 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1291 * information supplied by the current foreground app at the time of the assist request.
1292 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001293 */
1294 public static final String EXTRA_ASSIST_CONTEXT
1295 = "android.intent.extra.ASSIST_CONTEXT";
1296
Jim Miller07994402012-05-02 14:22:27 -07001297 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001298 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1299 * keyboard as the primary input device for assistance.
1300 */
1301 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1302 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1303
1304 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001305 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1306 * that was used to invoke the assist.
1307 */
1308 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1309 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1310
1311 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001312 * Activity Action: List all available applications
1313 * <p>Input: Nothing.
1314 * <p>Output: nothing.
1315 */
1316 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1317 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1318 /**
1319 * Activity Action: Show settings for choosing wallpaper
1320 * <p>Input: Nothing.
1321 * <p>Output: Nothing.
1322 */
1323 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1324 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1325
1326 /**
1327 * Activity Action: Show activity for reporting a bug.
1328 * <p>Input: Nothing.
1329 * <p>Output: Nothing.
1330 */
1331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1332 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1333
1334 /**
1335 * Activity Action: Main entry point for factory tests. Only used when
1336 * the device is booting in factory test node. The implementing package
1337 * must be installed in the system image.
1338 * <p>Input: nothing
1339 * <p>Output: nothing
1340 */
1341 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1342
1343 /**
1344 * Activity Action: The user pressed the "call" button to go to the dialer
1345 * or other appropriate UI for placing a call.
1346 * <p>Input: Nothing.
1347 * <p>Output: Nothing.
1348 */
1349 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1350 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1351
1352 /**
1353 * Activity Action: Start Voice Command.
1354 * <p>Input: Nothing.
1355 * <p>Output: Nothing.
1356 */
1357 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1358 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001359
1360 /**
1361 * Activity Action: Start action associated with long pressing on the
1362 * search key.
1363 * <p>Input: Nothing.
1364 * <p>Output: Nothing.
1365 */
1366 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1367 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001368
Jacek Surazski86b6c532009-05-13 14:38:28 +02001369 /**
1370 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1371 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001372 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001373 * <p>Input: No data is specified. The bug report is passed in using
1374 * an {@link #EXTRA_BUG_REPORT} field.
1375 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001376 *
1377 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001381
1382 /**
1383 * Activity Action: Show power usage information to the user.
1384 * <p>Input: Nothing.
1385 * <p>Output: Nothing.
1386 */
1387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1388 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001389
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001390 /**
1391 * Activity Action: Setup wizard to launch after a platform update. This
1392 * activity should have a string meta-data field associated with it,
1393 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1394 * the platform for setup. The activity will be launched only if
1395 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1396 * same value.
1397 * <p>Input: Nothing.
1398 * <p>Output: Nothing.
1399 * @hide
1400 */
1401 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1402 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001403
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001404 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001405 * Activity Action: Show settings for managing network data usage of a
1406 * specific application. Applications should define an activity that offers
1407 * options to control data usage.
1408 */
1409 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1410 public static final String ACTION_MANAGE_NETWORK_USAGE =
1411 "android.intent.action.MANAGE_NETWORK_USAGE";
1412
1413 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001414 * Activity Action: Launch application installer.
1415 * <p>
1416 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001417 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1418 * you can also use "package:<package-name>" to install an application for the
1419 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001420 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1421 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1422 * <p>
1423 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1424 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001425 * <p>
1426 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1427 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1428 * in order to launch the application installer.
1429 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001430 *
1431 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1432 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1433 * @see #EXTRA_RETURN_RESULT
1434 */
1435 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1436 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1437
1438 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001439 * Activity Action: Launch ephemeral installer.
1440 * <p>
1441 * Input: The data must be a http: URI that the ephemeral application is registered
1442 * to handle.
1443 * <p class="note">
1444 * This is a protected intent that can only be sent by the system.
1445 * </p>
1446 *
1447 * @hide
1448 */
1449 @SystemApi
1450 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1451 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1452 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1453
1454 /**
1455 * Service Action: Resolve ephemeral application.
1456 * <p>
1457 * The system will have a persistent connection to this service.
1458 * This is a protected intent that can only be sent by the system.
1459 * </p>
1460 *
1461 * @hide
1462 */
1463 @SystemApi
1464 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1465 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1466 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1467
1468 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001469 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1470 * package. Specifies the installer package name; this package will receive the
1471 * {@link #ACTION_APP_ERROR} intent.
1472 */
1473 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1474 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1475
1476 /**
1477 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1478 * package. Specifies that the application being installed should not be
1479 * treated as coming from an unknown source, but as coming from the app
1480 * invoking the Intent. For this to work you must start the installer with
1481 * startActivityForResult().
1482 */
1483 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1484 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1485
1486 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001487 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1488 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001489 * data field originated from.
1490 */
rich cannings706e8ba2012-08-20 13:20:14 -07001491 public static final String EXTRA_ORIGINATING_URI
1492 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001493
1494 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001495 * This extra can be used with any Intent used to launch an activity, supplying information
1496 * about who is launching that activity. This field contains a {@link android.net.Uri}
1497 * object, typically an http: or https: URI of the web site that the referral came from;
1498 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1499 * a native application that it came from.
1500 *
1501 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1502 * instead of directly retrieving the extra. It is also valid for applications to
1503 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1504 * a string, not a Uri; the field here, if supplied, will always take precedence,
1505 * however.</p>
1506 *
1507 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001508 */
1509 public static final String EXTRA_REFERRER
1510 = "android.intent.extra.REFERRER";
1511
1512 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001513 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1514 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1515 * not be created, in particular when Intent extras are supplied through the
1516 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1517 * schemes.
1518 *
1519 * @see #EXTRA_REFERRER
1520 */
1521 public static final String EXTRA_REFERRER_NAME
1522 = "android.intent.extra.REFERRER_NAME";
1523
1524 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001525 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1526 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1527 * @hide
1528 */
1529 public static final String EXTRA_ORIGINATING_UID
1530 = "android.intent.extra.ORIGINATING_UID";
1531
1532 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001533 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1534 * package. Tells the installer UI to skip the confirmation with the user
1535 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001536 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1537 * will no longer show an interstitial message about updating existing
1538 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001539 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001540 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001541 public static final String EXTRA_ALLOW_REPLACE
1542 = "android.intent.extra.ALLOW_REPLACE";
1543
1544 /**
1545 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1546 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1547 * return to the application the result code of the install/uninstall. The returned result
1548 * code will be {@link android.app.Activity#RESULT_OK} on success or
1549 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1550 */
1551 public static final String EXTRA_RETURN_RESULT
1552 = "android.intent.extra.RETURN_RESULT";
1553
1554 /**
1555 * Package manager install result code. @hide because result codes are not
1556 * yet ready to be exposed.
1557 */
1558 public static final String EXTRA_INSTALL_RESULT
1559 = "android.intent.extra.INSTALL_RESULT";
1560
1561 /**
1562 * Activity Action: Launch application uninstaller.
1563 * <p>
1564 * Input: The data must be a package: URI whose scheme specific part is
1565 * the package name of the current installed package to be uninstalled.
1566 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1567 * <p>
1568 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1569 * succeeded.
1570 */
1571 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1572 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1573
1574 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001575 * Specify whether the package should be uninstalled for all users.
1576 * @hide because these should not be part of normal application flow.
1577 */
1578 public static final String EXTRA_UNINSTALL_ALL_USERS
1579 = "android.intent.extra.UNINSTALL_ALL_USERS";
1580
1581 /**
Suprabh Shukla74a2fe42016-01-27 12:57:24 -08001582 * Specified when the uninstall confirmation dialog is not required to be shown.
1583 * Use with {@link #ACTION_UNINSTALL_PACKAGE}
1584 * @hide
1585 */
1586 public static final String EXTRA_SKIP_UNINSTALL_CONFIRMATION =
1587 "android.intent.extra.SKIP_UNINSTALL_CONFIRMATION";
1588
1589 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001590 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1591 * describing the last run version of the platform that was setup.
1592 * @hide
1593 */
1594 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1595
Svet Ganov3695b8a2015-03-24 16:30:25 -07001596 /**
1597 * Activity action: Launch UI to manage the permissions of an app.
1598 * <p>
1599 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1600 * will be managed by the launched UI.
1601 * </p>
1602 * <p>
1603 * Output: Nothing.
1604 * </p>
1605 *
1606 * @see #EXTRA_PACKAGE_NAME
1607 *
1608 * @hide
1609 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001610 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1611 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1612 "android.intent.action.MANAGE_APP_PERMISSIONS";
1613
1614 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001615 * Activity action: Launch UI to manage permissions.
1616 * <p>
1617 * Input: Nothing.
1618 * </p>
1619 * <p>
1620 * Output: Nothing.
1621 * </p>
1622 *
1623 * @hide
1624 */
Svet Ganov321f0152015-05-16 22:51:50 -07001625 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1626 public static final String ACTION_MANAGE_PERMISSIONS =
1627 "android.intent.action.MANAGE_PERMISSIONS";
1628
1629 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001630 * Activity action: Launch UI to review permissions for an app.
1631 * The system uses this intent if permission review for apps not
1632 * supporting the new runtime permissions model is enabled. In
1633 * this mode a permission review is required before any of the
1634 * app components can run.
1635 * <p>
1636 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1637 * permissions will be reviewed (mandatory).
1638 * </p>
1639 * <p>
1640 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1641 * be fired after the permission review (optional).
1642 * </p>
1643 * <p>
1644 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1645 * be invoked after the permission review (optional).
1646 * </p>
1647 * <p>
1648 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1649 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1650 * </p>
1651 * <p>
1652 * Output: Nothing.
1653 * </p>
1654 *
1655 * @see #EXTRA_PACKAGE_NAME
1656 * @see #EXTRA_INTENT
1657 * @see #EXTRA_REMOTE_CALLBACK
1658 * @see #EXTRA_RESULT_NEEDED
1659 *
1660 * @hide
1661 */
1662 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1663 public static final String ACTION_REVIEW_PERMISSIONS =
1664 "android.intent.action.REVIEW_PERMISSIONS";
1665
1666 /**
1667 * Intent extra: A callback for reporting remote result as a bundle.
1668 * <p>
1669 * Type: IRemoteCallback
1670 * </p>
1671 *
1672 * @hide
1673 */
1674 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1675
1676 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001677 * Intent extra: An app package name.
1678 * <p>
1679 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001680 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001681 *
1682 * @hide
1683 */
1684 @SystemApi
1685 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1686
1687 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001688 * Intent extra: An extra for specifying whether a result is needed.
1689 * <p>
1690 * Type: boolean
1691 * </p>
1692 *
1693 * @hide
1694 */
1695 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1696
1697 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001698 * Broadcast action that requests current permission granted information. It will respond
1699 * to the request by sending a broadcast with action defined by
1700 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001701 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1702 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1703 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001704 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001705 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1706 * number of permissions requested and the number of granted additional permissions
1707 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001708 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001709 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1710 * of localized permission group names that are granted in
1711 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001712 *
1713 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1714 * permissions and the total number of apps requesting runtime permissions will be the first
1715 * and second elements respectively of an int[] in the response as
1716 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1717 *
1718 * @hide
1719 */
1720 public static final String ACTION_GET_PERMISSIONS_COUNT
1721 = "android.intent.action.GET_PERMISSIONS_COUNT";
1722
1723 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001724 * Broadcast action that requests list of all apps that have runtime permissions. It will
1725 * respond to the request by sending a broadcast with action defined by
1726 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1727 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1728 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1729 * a null upon failure.
1730 *
1731 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1732 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1733 * will contain the list of app labels corresponding ot the apps in the first list.
1734 *
1735 * @hide
1736 */
1737 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1738 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1739
1740 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001741 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1742 * @hide
1743 */
1744 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1745 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1746
1747 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001748 * List of CharSequence of localized permission group labels.
1749 * @hide
1750 */
1751 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1752 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1753
1754 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001755 * String list of apps that have one or more runtime permissions.
1756 * @hide
1757 */
1758 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1759 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1760
1761 /**
1762 * String list of app labels for apps that have one or more runtime permissions.
1763 * @hide
1764 */
1765 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1766 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1767
1768 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001769 * Boolean list describing if the app is a system app for apps that have one or more runtime
1770 * permissions.
1771 * @hide
1772 */
1773 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1774 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1775
1776 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001777 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001778 * @hide
1779 */
1780 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1781 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1782
1783 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001784 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1785 * @hide
1786 */
1787 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1788 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1789
1790 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001791 * Activity action: Launch UI to manage which apps have a given permission.
1792 * <p>
1793 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1794 * to which will be managed by the launched UI.
1795 * </p>
1796 * <p>
1797 * Output: Nothing.
1798 * </p>
1799 *
1800 * @see #EXTRA_PERMISSION_NAME
1801 *
1802 * @hide
1803 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001804 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1805 public static final String ACTION_MANAGE_PERMISSION_APPS =
1806 "android.intent.action.MANAGE_PERMISSION_APPS";
1807
1808 /**
1809 * Intent extra: The name of a permission.
1810 * <p>
1811 * Type: String
1812 * </p>
1813 *
1814 * @hide
1815 */
1816 @SystemApi
1817 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1818
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001819 // ---------------------------------------------------------------------
1820 // ---------------------------------------------------------------------
1821 // Standard intent broadcast actions (see action variable).
1822
1823 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001824 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1825 * <p>
1826 * For historical reasons, the name of this broadcast action refers to the power
1827 * state of the screen but it is actually sent in response to changes in the
1828 * overall interactive state of the device.
1829 * </p><p>
1830 * This broadcast is sent when the device becomes non-interactive which may have
1831 * nothing to do with the screen turning off. To determine the
1832 * actual state of the screen, use {@link android.view.Display#getState}.
1833 * </p><p>
1834 * See {@link android.os.PowerManager#isInteractive} for details.
1835 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001836 * You <em>cannot</em> receive this through components declared in
1837 * manifests, only by explicitly registering for it with
1838 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1839 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001840 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001841 * <p class="note">This is a protected intent that can only be sent
1842 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001843 */
1844 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1845 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001846
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001847 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001848 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1849 * <p>
1850 * For historical reasons, the name of this broadcast action refers to the power
1851 * state of the screen but it is actually sent in response to changes in the
1852 * overall interactive state of the device.
1853 * </p><p>
1854 * This broadcast is sent when the device becomes interactive which may have
1855 * nothing to do with the screen turning on. To determine the
1856 * actual state of the screen, use {@link android.view.Display#getState}.
1857 * </p><p>
1858 * See {@link android.os.PowerManager#isInteractive} for details.
1859 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001860 * You <em>cannot</em> receive this through components declared in
1861 * manifests, only by explicitly registering for it with
1862 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1863 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001864 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001865 * <p class="note">This is a protected intent that can only be sent
1866 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001867 */
1868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1869 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001870
1871 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001872 * Broadcast Action: Sent after the system stops dreaming.
1873 *
1874 * <p class="note">This is a protected intent that can only be sent by the system.
1875 * It is only sent to registered receivers.</p>
1876 */
1877 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1878 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1879
1880 /**
1881 * Broadcast Action: Sent after the system starts dreaming.
1882 *
1883 * <p class="note">This is a protected intent that can only be sent by the system.
1884 * It is only sent to registered receivers.</p>
1885 */
1886 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1887 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1888
1889 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001890 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001891 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001892 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001893 * <p class="note">This is a protected intent that can only be sent
1894 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001895 */
1896 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001897 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001898
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001899 /**
1900 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001901 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001902 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001903 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1904 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001905 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001906 * <p class="note">This is a protected intent that can only be sent
1907 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001908 */
1909 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1910 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1911 /**
1912 * Broadcast Action: The time was set.
1913 */
1914 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1915 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1916 /**
1917 * Broadcast Action: The date has changed.
1918 */
1919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1920 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1921 /**
1922 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1923 * <ul>
1924 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1925 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001926 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001927 * <p class="note">This is a protected intent that can only be sent
1928 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001929 */
1930 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1931 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1932 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001933 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1934 * DNS entries should be tossed.
1935 * @hide
1936 */
1937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1938 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1939 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001940 * Alarm Changed Action: This is broadcast when the AlarmClock
1941 * application's alarm is set or unset. It is used by the
1942 * AlarmClock application and the StatusBar service.
1943 * @hide
1944 */
1945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1946 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001947
1948 /**
1949 * Broadcast Action: This is broadcast once, after the system has finished
1950 * booting and the user is in a "locked" state. A user is locked when their
1951 * credential-encrypted private app data storage is unavailable. Once the
1952 * user has entered their credentials (such as a lock pattern or PIN) for
1953 * the first time, the {@link #ACTION_BOOT_COMPLETED} broadcast will be
1954 * sent.
1955 * <p>
1956 * You must hold the
1957 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1958 * order to receive this broadcast.
1959 * <p class="note">
1960 * This is a protected intent that can only be sent by the system.
1961 */
1962 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1963 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1964
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001965 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001966 * Broadcast Action: This is broadcast once, after the system has finished
1967 * booting. It can be used to perform application-specific initialization,
1968 * such as installing alarms. You must hold the
1969 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1970 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001971 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001972 * <p class="note">This is a protected intent that can only be sent
1973 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001974 */
1975 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1976 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001977
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001978 /**
1979 * Broadcast Action: This is broadcast when a user action should request a
1980 * temporary system dialog to dismiss. Some examples of temporary system
1981 * dialogs are the notification window-shade and the recent tasks dialog.
1982 */
1983 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1984 /**
1985 * Broadcast Action: Trigger the download and eventual installation
1986 * of a package.
1987 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001988 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001989 * <p class="note">This is a protected intent that can only be sent
1990 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001991 *
1992 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001993 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001994 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1996 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1997 /**
1998 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001999 * device. The data contains the name of the package. Note that the
2000 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002001 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002002 * <ul>
2003 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2004 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2005 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2006 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002007 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002008 * <p class="note">This is a protected intent that can only be sent
2009 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002010 */
2011 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2012 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2013 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002014 * Broadcast Action: A new version of an application package has been
2015 * installed, replacing an existing version that was previously installed.
2016 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002017 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002018 * <ul>
2019 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2020 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002021 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002022 * <p class="note">This is a protected intent that can only be sent
2023 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002024 */
2025 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2026 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2027 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002028 * Broadcast Action: A new version of your application has been installed
2029 * over an existing one. This is only sent to the application that was
2030 * replaced. It does not contain any additional data; to receive it, just
2031 * use an intent filter for this action.
2032 *
2033 * <p class="note">This is a protected intent that can only be sent
2034 * by the system.
2035 */
2036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2037 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2038 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002039 * Broadcast Action: An existing application package has been removed from
2040 * the device. The data contains the name of the package. The package
2041 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002042 * <ul>
2043 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2044 * to the package.
2045 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2046 * application -- data and code -- is being removed.
2047 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2048 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2049 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002050 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002051 * <p class="note">This is a protected intent that can only be sent
2052 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002053 */
2054 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2055 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2056 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002057 * Broadcast Action: An existing application package has been completely
2058 * removed from the device. The data contains the name of the package.
2059 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2060 * {@link #EXTRA_DATA_REMOVED} is true and
2061 * {@link #EXTRA_REPLACING} is false of that broadcast.
2062 *
2063 * <ul>
2064 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2065 * to the package.
2066 * </ul>
2067 *
2068 * <p class="note">This is a protected intent that can only be sent
2069 * by the system.
2070 */
2071 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2072 public static final String ACTION_PACKAGE_FULLY_REMOVED
2073 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2074 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002075 * Broadcast Action: An existing application package has been changed (e.g.
2076 * a component has been enabled or disabled). The data contains the name of
2077 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002078 * <ul>
2079 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002080 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002081 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002082 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2083 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002084 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002085 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002086 * <p class="note">This is a protected intent that can only be sent
2087 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002088 */
2089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2090 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2091 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002092 * @hide
2093 * Broadcast Action: Ask system services if there is any reason to
2094 * restart the given package. The data contains the name of the
2095 * package.
2096 * <ul>
2097 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2098 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2099 * </ul>
2100 *
2101 * <p class="note">This is a protected intent that can only be sent
2102 * by the system.
2103 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002104 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2106 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2107 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002108 * Broadcast Action: The user has restarted a package, and all of its
2109 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002110 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002111 * be removed. Note that the restarted package does <em>not</em>
2112 * receive this broadcast.
2113 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002114 * <ul>
2115 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2116 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002117 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002118 * <p class="note">This is a protected intent that can only be sent
2119 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002120 */
2121 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2122 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2123 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002124 * Broadcast Action: The user has cleared the data of a package. This should
2125 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002126 * its persistent data is erased and this broadcast sent.
2127 * Note that the cleared package does <em>not</em>
2128 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002129 * <ul>
2130 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2131 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002132 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002133 * <p class="note">This is a protected intent that can only be sent
2134 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002135 */
2136 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2137 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2138 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002139 * Broadcast Action: Packages have been suspended.
2140 * <p>Includes the following extras:
2141 * <ul>
2142 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2143 * </ul>
2144 *
2145 * <p class="note">This is a protected intent that can only be sent
2146 * by the system. It is only sent to registered receivers.
2147 */
2148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2149 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2150 /**
2151 * Broadcast Action: Packages have been unsuspended.
2152 * <p>Includes the following extras:
2153 * <ul>
2154 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2155 * </ul>
2156 *
2157 * <p class="note">This is a protected intent that can only be sent
2158 * by the system. It is only sent to registered receivers.
2159 */
2160 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2161 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2162 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002163 * Broadcast Action: A user ID has been removed from the system. The user
2164 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002165 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002166 * <p class="note">This is a protected intent that can only be sent
2167 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002168 */
2169 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2170 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002171
2172 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002173 * Broadcast Action: Sent to the installer package of an application
2174 * when that application is first launched (that is the first time it
2175 * is moved out of the stopped state). The data contains the name of the package.
2176 *
2177 * <p class="note">This is a protected intent that can only be sent
2178 * by the system.
2179 */
2180 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2181 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2182
2183 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002184 * Broadcast Action: Sent to the system package verifier when a package
2185 * needs to be verified. The data contains the package URI.
2186 * <p class="note">
2187 * This is a protected intent that can only be sent by the system.
2188 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002189 */
2190 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2191 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2192
2193 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002194 * Broadcast Action: Sent to the system package verifier when a package is
2195 * verified. The data contains the package URI.
2196 * <p class="note">
2197 * This is a protected intent that can only be sent by the system.
2198 */
2199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2200 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2201
2202 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002203 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2204 * needs to be verified. The data contains the filter data hosts to be verified against.
2205 * <p class="note">
2206 * This is a protected intent that can only be sent by the system.
2207 * </p>
2208 *
2209 * @hide
2210 */
2211 @SystemApi
2212 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2213 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2214
2215 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002216 * Broadcast Action: Resources for a set of packages (which were
2217 * previously unavailable) are currently
2218 * available since the media on which they exist is available.
2219 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2220 * list of packages whose availability changed.
2221 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2222 * list of uids of packages whose availability changed.
2223 * Note that the
2224 * packages in this list do <em>not</em> receive this broadcast.
2225 * The specified set of packages are now available on the system.
2226 * <p>Includes the following extras:
2227 * <ul>
2228 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2229 * whose resources(were previously unavailable) are currently available.
2230 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2231 * packages whose resources(were previously unavailable)
2232 * are currently available.
2233 * </ul>
2234 *
2235 * <p class="note">This is a protected intent that can only be sent
2236 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002237 */
2238 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002239 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2240 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002241
2242 /**
2243 * Broadcast Action: Resources for a set of packages are currently
2244 * unavailable since the media on which they exist is unavailable.
2245 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2246 * list of packages whose availability changed.
2247 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2248 * list of uids of packages whose availability changed.
2249 * The specified set of packages can no longer be
2250 * launched and are practically unavailable on the system.
2251 * <p>Inclues the following extras:
2252 * <ul>
2253 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2254 * whose resources are no longer available.
2255 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2256 * whose resources are no longer available.
2257 * </ul>
2258 *
2259 * <p class="note">This is a protected intent that can only be sent
2260 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002261 */
2262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002263 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002264 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002265
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002266 /**
2267 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002268 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002269 * This should <em>only</em> be used to determine when the wallpaper
2270 * has changed to show the new wallpaper to the user. You should certainly
2271 * never, in response to this, change the wallpaper or other attributes of
2272 * it such as the suggested size. That would be crazy, right? You'd cause
2273 * all kinds of loops, especially if other apps are doing similar things,
2274 * right? Of course. So please don't do this.
2275 *
2276 * @deprecated Modern applications should use
2277 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2278 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2279 * shown behind their UI, rather than watching for this broadcast and
2280 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002281 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002282 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002283 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2284 /**
2285 * Broadcast Action: The current device {@link android.content.res.Configuration}
2286 * (orientation, locale, etc) has changed. When such a change happens, the
2287 * UIs (view hierarchy) will need to be rebuilt based on this new
2288 * information; for the most part, applications don't need to worry about
2289 * this, because the system will take care of stopping and restarting the
2290 * application to make sure it sees the new changes. Some system code that
2291 * can not be restarted will need to watch for this action and handle it
2292 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002293 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002294 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002295 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002296 * in manifests, only by explicitly registering for it with
2297 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2298 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002299 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002300 * <p class="note">This is a protected intent that can only be sent
2301 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002302 *
2303 * @see android.content.res.Configuration
2304 */
2305 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2306 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2307 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002308 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002309 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002310 * <p class="note">This is a protected intent that can only be sent
2311 * by the system.
2312 */
2313 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2314 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2315 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002316 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2317 * charging state, level, and other information about the battery.
2318 * See {@link android.os.BatteryManager} for documentation on the
2319 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002320 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002321 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002322 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002323 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002324 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002325 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2326 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2327 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2328 * broadcasts that are sent and can be received through manifest
2329 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002330 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002331 * <p class="note">This is a protected intent that can only be sent
2332 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002333 */
2334 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2335 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2336 /**
2337 * Broadcast Action: Indicates low battery condition on the device.
2338 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002339 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002340 * <p class="note">This is a protected intent that can only be sent
2341 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002342 */
2343 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2344 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2345 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002346 * Broadcast Action: Indicates the battery is now okay after being low.
2347 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2348 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002349 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002350 * <p class="note">This is a protected intent that can only be sent
2351 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002352 */
2353 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2354 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2355 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002356 * Broadcast Action: External power has been connected to the device.
2357 * This is intended for applications that wish to register specifically to this notification.
2358 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2359 * stay active to receive this notification. This action can be used to implement actions
2360 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002361 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002362 * <p class="note">This is a protected intent that can only be sent
2363 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002364 */
2365 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002366 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002367 /**
2368 * Broadcast Action: External power has been removed from the device.
2369 * This is intended for applications that wish to register specifically to this notification.
2370 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2371 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002372 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002373 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002374 * <p class="note">This is a protected intent that can only be sent
2375 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002376 */
2377 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002378 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002379 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002380 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002381 * Broadcast Action: Device is shutting down.
2382 * This is broadcast when the device is being shut down (completely turned
2383 * off, not sleeping). Once the broadcast is complete, the final shutdown
2384 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002385 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002386 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002387 * <p class="note">This is a protected intent that can only be sent
2388 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002389 * <p>May include the following extras:
2390 * <ul>
2391 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2392 * shutdown is only for userspace processes. If not set, assumed to be false.
2393 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002394 */
2395 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002396 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002397 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002398 * Activity Action: Start this activity to request system shutdown.
2399 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002400 * to request confirmation from the user before shutting down. The optional boolean
2401 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2402 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002403 *
2404 * <p class="note">This is a protected intent that can only be sent
2405 * by the system.
2406 *
2407 * {@hide}
2408 */
2409 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2410 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002411 * Broadcast Action: A sticky broadcast that indicates low memory
2412 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002413 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002414 * <p class="note">This is a protected intent that can only be sent
2415 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002416 */
2417 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2418 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2419 /**
2420 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002421 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002422 * <p class="note">This is a protected intent that can only be sent
2423 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002424 */
2425 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2426 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2427 /**
Jake Hambybb371632010-08-23 18:16:48 -07002428 * Broadcast Action: A sticky broadcast that indicates a memory full
2429 * condition on the device. This is intended for activities that want
2430 * to be able to fill the data partition completely, leaving only
2431 * enough free space to prevent system-wide SQLite failures.
2432 *
2433 * <p class="note">This is a protected intent that can only be sent
2434 * by the system.
2435 *
2436 * {@hide}
2437 */
2438 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2439 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2440 /**
2441 * Broadcast Action: Indicates memory full condition on the device
2442 * no longer exists.
2443 *
2444 * <p class="note">This is a protected intent that can only be sent
2445 * by the system.
2446 *
2447 * {@hide}
2448 */
2449 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2450 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2451 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002452 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2453 * and package management should be started.
2454 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2455 * notification.
2456 */
2457 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2458 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2459 /**
2460 * Broadcast Action: The device has entered USB Mass Storage mode.
2461 * This is used mainly for the USB Settings panel.
2462 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2463 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002464 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002465 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002466 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002467 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2468
2469 /**
2470 * Broadcast Action: The device has exited USB Mass Storage mode.
2471 * This is used mainly for the USB Settings panel.
2472 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2473 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002474 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002475 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002476 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002477 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2478
2479 /**
2480 * Broadcast Action: External media has been removed.
2481 * The path to the mount point for the removed media is contained in the Intent.mData field.
2482 */
2483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2484 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2485
2486 /**
2487 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002488 * The path to the mount point for the unmounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002489 */
2490 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2491 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2492
2493 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002494 * Broadcast Action: External media is present, and being disk-checked
2495 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2498 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2499
2500 /**
2501 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2502 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002503 */
2504 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2505 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2506
2507 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002508 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002509 * The path to the mount point for the mounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002510 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2511 * media was mounted read only.
2512 */
2513 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2514 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2515
2516 /**
2517 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002518 * The path to the mount point for the shared media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002519 */
2520 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2521 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2522
2523 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002524 * Broadcast Action: External media is no longer being shared via USB mass storage.
2525 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2526 *
2527 * @hide
2528 */
2529 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2530
2531 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002532 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2533 * The path to the mount point for the removed media is contained in the Intent.mData field.
2534 */
2535 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2536 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2537
2538 /**
2539 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002540 * The path to the mount point for the unmountable media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002541 */
2542 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2543 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2544
2545 /**
2546 * Broadcast Action: User has expressed the desire to remove the external storage media.
2547 * Applications should close all files they have open within the mount point when they receive this intent.
2548 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2549 */
2550 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2551 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2552
2553 /**
2554 * Broadcast Action: The media scanner has started scanning a directory.
2555 * The path to the directory being scanned is contained in the Intent.mData field.
2556 */
2557 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2558 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2559
2560 /**
2561 * Broadcast Action: The media scanner has finished scanning a directory.
2562 * The path to the scanned directory is contained in the Intent.mData field.
2563 */
2564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2565 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2566
2567 /**
2568 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2569 * The path to the file is contained in the Intent.mData field.
2570 */
2571 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2572 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2573
2574 /**
2575 * Broadcast Action: The "Media Button" was pressed. Includes a single
2576 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2577 * caused the broadcast.
2578 */
2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2580 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2581
2582 /**
2583 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2584 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2585 * caused the broadcast.
2586 */
2587 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2588 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2589
2590 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2591 // location; they are not general-purpose actions.
2592
2593 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002594 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002595 */
2596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2597 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2598 "android.intent.action.GTALK_CONNECTED";
2599
2600 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002601 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002602 */
2603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2604 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2605 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002606
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002607 /**
2608 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002609 */
2610 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2611 public static final String ACTION_INPUT_METHOD_CHANGED =
2612 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002613
2614 /**
2615 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2616 * more radios have been turned off or on. The intent will have the following extra value:</p>
2617 * <ul>
2618 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2619 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2620 * turned off</li>
2621 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002622 *
Peng Xua35b5532016-01-20 00:05:45 -08002623 * <p class="note">This is a protected intent that can only be sent by the system.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002624 */
2625 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2626 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2627
2628 /**
2629 * Broadcast Action: Some content providers have parts of their namespace
2630 * where they publish new events or items that the user may be especially
2631 * interested in. For these things, they may broadcast this action when the
2632 * set of interesting items change.
2633 *
2634 * For example, GmailProvider sends this notification when the set of unread
2635 * mail in the inbox changes.
2636 *
2637 * <p>The data of the intent identifies which part of which provider
2638 * changed. When queried through the content resolver, the data URI will
2639 * return the data set in question.
2640 *
2641 * <p>The intent will have the following extra values:
2642 * <ul>
2643 * <li><em>count</em> - The number of items in the data set. This is the
2644 * same as the number of items in the cursor returned by querying the
2645 * data URI. </li>
2646 * </ul>
2647 *
2648 * This intent will be sent at boot (if the count is non-zero) and when the
2649 * data set changes. It is possible for the data set to change without the
2650 * count changing (for example, if a new unread message arrives in the same
2651 * sync operation in which a message is archived). The phone should still
2652 * ring/vibrate/etc as normal in this case.
2653 */
2654 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2655 public static final String ACTION_PROVIDER_CHANGED =
2656 "android.intent.action.PROVIDER_CHANGED";
2657
2658 /**
2659 * Broadcast Action: Wired Headset plugged in or unplugged.
2660 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002661 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2662 * and documentation.
2663 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002664 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002665 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002666 */
2667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002668 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002669
2670 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002671 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2672 * <ul>
2673 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2674 * </ul>
2675 *
2676 * <p class="note">This is a protected intent that can only be sent
2677 * by the system.
2678 *
2679 * @hide
2680 */
2681 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2682 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2683 = "android.intent.action.ADVANCED_SETTINGS";
2684
2685 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002686 * Broadcast Action: Sent after application restrictions are changed.
2687 *
2688 * <p class="note">This is a protected intent that can only be sent
2689 * by the system.</p>
2690 */
2691 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2692 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2693 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2694
2695 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002696 * Broadcast Action: An outgoing call is about to be placed.
2697 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002698 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002699 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002700 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002701 * the phone number originally intended to be dialed.</li>
2702 * </ul>
2703 * <p>Once the broadcast is finished, the resultData is used as the actual
2704 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002705 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002706 * outgoing call in turn: for example, a parental control application
2707 * might verify that the user is authorized to place the call at that
2708 * time, then a number-rewriting application might add an area code if
2709 * one was not specified.</p>
2710 * <p>For consistency, any receiver whose purpose is to prohibit phone
2711 * calls should have a priority of 0, to ensure it will see the final
2712 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002713 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002714 * should have a positive priority.
2715 * Negative priorities are reserved for the system for this broadcast;
2716 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002717 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2718 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002719 * <p>Emergency calls cannot be intercepted using this mechanism, and
2720 * other calls cannot be modified to call emergency numbers using this
2721 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002722 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2723 * call to use their own service instead. Those apps should first prevent
2724 * the call from being placed by setting resultData to <code>null</code>
2725 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002726 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002727 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2728 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002729 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002730 * <p class="note">This is a protected intent that can only be sent
2731 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002732 */
2733 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2734 public static final String ACTION_NEW_OUTGOING_CALL =
2735 "android.intent.action.NEW_OUTGOING_CALL";
2736
2737 /**
2738 * Broadcast Action: Have the device reboot. This is only for use by
2739 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002740 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002741 * <p class="note">This is a protected intent that can only be sent
2742 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002743 */
2744 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2745 public static final String ACTION_REBOOT =
2746 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002747
Wei Huang97ecc9c2009-05-11 17:44:20 -07002748 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002749 * Broadcast Action: A sticky broadcast for changes in the physical
2750 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002751 *
2752 * <p>The intent will have the following extra values:
2753 * <ul>
2754 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002755 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002756 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002757 * <p>This is intended for monitoring the current physical dock state.
2758 * See {@link android.app.UiModeManager} for the normal API dealing with
2759 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002760 */
2761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2762 public static final String ACTION_DOCK_EVENT =
2763 "android.intent.action.DOCK_EVENT";
2764
2765 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002766 * Broadcast Action: A broadcast when idle maintenance can be started.
2767 * This means that the user is not interacting with the device and is
2768 * not expected to do so soon. Typical use of the idle maintenance is
2769 * to perform somehow expensive tasks that can be postponed at a moment
2770 * when they will not degrade user experience.
2771 * <p>
2772 * <p class="note">In order to keep the device responsive in case of an
2773 * unexpected user interaction, implementations of a maintenance task
2774 * should be interruptible. In such a scenario a broadcast with action
2775 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2776 * should not do the maintenance work in
2777 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2778 * maintenance service by {@link Context#startService(Intent)}. Also
2779 * you should hold a wake lock while your maintenance service is running
2780 * to prevent the device going to sleep.
2781 * </p>
2782 * <p>
2783 * <p class="note">This is a protected intent that can only be sent by
2784 * the system.
2785 * </p>
2786 *
2787 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002788 *
2789 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002790 */
2791 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2792 public static final String ACTION_IDLE_MAINTENANCE_START =
2793 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2794
2795 /**
2796 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2797 * This means that the user was not interacting with the device as a result
2798 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2799 * was sent and now the user started interacting with the device. Typical
2800 * use of the idle maintenance is to perform somehow expensive tasks that
2801 * can be postponed at a moment when they will not degrade user experience.
2802 * <p>
2803 * <p class="note">In order to keep the device responsive in case of an
2804 * unexpected user interaction, implementations of a maintenance task
2805 * should be interruptible. Hence, on receiving a broadcast with this
2806 * action, the maintenance task should be interrupted as soon as possible.
2807 * In other words, you should not do the maintenance work in
2808 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2809 * maintenance service that was started on receiving of
2810 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2811 * lock you acquired when your maintenance service started.
2812 * </p>
2813 * <p class="note">This is a protected intent that can only be sent
2814 * by the system.
2815 *
2816 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002817 *
2818 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002819 */
2820 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2821 public static final String ACTION_IDLE_MAINTENANCE_END =
2822 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2823
2824 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002825 * Broadcast Action: a remote intent is to be broadcasted.
2826 *
2827 * A remote intent is used for remote RPC between devices. The remote intent
2828 * is serialized and sent from one device to another device. The receiving
2829 * device parses the remote intent and broadcasts it. Note that anyone can
2830 * broadcast a remote intent. However, if the intent receiver of the remote intent
2831 * does not trust intent broadcasts from arbitrary intent senders, it should require
2832 * the sender to hold certain permissions so only trusted sender's broadcast will be
2833 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002834 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002835 */
2836 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002837 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002838
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002839 /**
2840 * Broadcast Action: hook for permforming cleanup after a system update.
2841 *
2842 * The broadcast is sent when the system is booting, before the
2843 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2844 * image. A receiver for this should do its work and then disable itself
2845 * so that it does not get run again at the next boot.
2846 * @hide
2847 */
2848 public static final String ACTION_PRE_BOOT_COMPLETED =
2849 "android.intent.action.PRE_BOOT_COMPLETED";
2850
Amith Yamasani13593602012-03-22 16:16:17 -07002851 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002852 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002853 * on restricted users. The broadcast intent contains an extra
2854 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2855 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2856 * String[] depending on the restriction type.<p/>
2857 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002858 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2859 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2860 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002861 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2862 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002863 * @see RestrictionEntry
2864 */
2865 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2866 "android.intent.action.GET_RESTRICTION_ENTRIES";
2867
2868 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002869 * Sent the first time a user is starting, to allow system apps to
2870 * perform one time initialization. (This will not be seen by third
2871 * party applications because a newly initialized user does not have any
2872 * third party applications installed for it.) This is sent early in
2873 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002874 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2875 * broadcast, since it is part of a visible user interaction; be as quick
2876 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002877 */
2878 public static final String ACTION_USER_INITIALIZE =
2879 "android.intent.action.USER_INITIALIZE";
2880
2881 /**
2882 * Sent when a user switch is happening, causing the process's user to be
2883 * brought to the foreground. This is only sent to receivers registered
2884 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2885 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002886 * foreground. This is sent as a foreground
2887 * broadcast, since it is part of a visible user interaction; be as quick
2888 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002889 */
2890 public static final String ACTION_USER_FOREGROUND =
2891 "android.intent.action.USER_FOREGROUND";
2892
2893 /**
2894 * Sent when a user switch is happening, causing the process's user to be
2895 * sent to the background. This is only sent to receivers registered
2896 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2897 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002898 * background. This is sent as a foreground
2899 * broadcast, since it is part of a visible user interaction; be as quick
2900 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002901 */
2902 public static final String ACTION_USER_BACKGROUND =
2903 "android.intent.action.USER_BACKGROUND";
2904
2905 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002906 * Broadcast sent to the system when a user is added. Carries an extra
2907 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2908 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002909 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002910 * @hide
2911 */
2912 public static final String ACTION_USER_ADDED =
2913 "android.intent.action.USER_ADDED";
2914
2915 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002916 * Broadcast sent by the system when a user is started. Carries an extra
2917 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002918 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002919 * that has been started. This is sent as a foreground
2920 * broadcast, since it is part of a visible user interaction; be as quick
2921 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002922 * @hide
2923 */
2924 public static final String ACTION_USER_STARTED =
2925 "android.intent.action.USER_STARTED";
2926
2927 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002928 * Broadcast sent when a user is in the process of starting. Carries an extra
2929 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2930 * sent to registered receivers, not manifest receivers. It is sent to all
2931 * users (including the one that is being started). You must hold
2932 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2933 * this broadcast. This is sent as a background broadcast, since
2934 * its result is not part of the primary UX flow; to safely keep track of
2935 * started/stopped state of a user you can use this in conjunction with
2936 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2937 * other user state broadcasts since those are foreground broadcasts so can
2938 * execute in a different order.
2939 * @hide
2940 */
2941 public static final String ACTION_USER_STARTING =
2942 "android.intent.action.USER_STARTING";
2943
2944 /**
2945 * Broadcast sent when a user is going to be stopped. Carries an extra
2946 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2947 * sent to registered receivers, not manifest receivers. It is sent to all
2948 * users (including the one that is being stopped). You must hold
2949 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2950 * this broadcast. The user will not stop until all receivers have
2951 * handled the broadcast. This is sent as a background broadcast, since
2952 * its result is not part of the primary UX flow; to safely keep track of
2953 * started/stopped state of a user you can use this in conjunction with
2954 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2955 * other user state broadcasts since those are foreground broadcasts so can
2956 * execute in a different order.
2957 * @hide
2958 */
2959 public static final String ACTION_USER_STOPPING =
2960 "android.intent.action.USER_STOPPING";
2961
2962 /**
2963 * Broadcast sent to the system when a user is stopped. Carries an extra
2964 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2965 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2966 * specific package. This is only sent to registered receivers, not manifest
2967 * receivers. It is sent to all running users <em>except</em> the one that
2968 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002969 * @hide
2970 */
2971 public static final String ACTION_USER_STOPPED =
2972 "android.intent.action.USER_STOPPED";
2973
2974 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002975 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002976 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002977 * one that has been removed. The user will not be completely removed until all receivers have
2978 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002979 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002980 * @hide
2981 */
2982 public static final String ACTION_USER_REMOVED =
2983 "android.intent.action.USER_REMOVED";
2984
2985 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002986 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002987 * the userHandle of the user to become the current one. This is only sent to
2988 * registered receivers, not manifest receivers. It is sent to all running users.
2989 * You must hold
2990 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002991 * @hide
2992 */
2993 public static final String ACTION_USER_SWITCHED =
2994 "android.intent.action.USER_SWITCHED";
2995
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002996 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002997 * Broadcast Action: Sent when the credential-encrypted private storage has
2998 * become unlocked for the target user. This is only sent to registered
2999 * receivers, not manifest receivers.
3000 */
3001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3002 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3003
3004 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003005 * Broadcast sent to the system when a user's information changes. Carries an extra
3006 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003007 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003008 * @hide
3009 */
3010 public static final String ACTION_USER_INFO_CHANGED =
3011 "android.intent.action.USER_INFO_CHANGED";
3012
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003013 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003014 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3015 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003016 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3017 * that need to display merged content across both primary and managed profiles need to
3018 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003019 * not manifest receivers.
3020 */
3021 public static final String ACTION_MANAGED_PROFILE_ADDED =
3022 "android.intent.action.MANAGED_PROFILE_ADDED";
3023
3024 /**
3025 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003026 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3027 * Only applications (for example Launchers) that need to display merged content across both
3028 * primary and managed profiles need to worry about this broadcast. This is only sent to
3029 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003030 */
3031 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3032 "android.intent.action.MANAGED_PROFILE_REMOVED";
3033
3034 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003035 * Broadcast sent to the primary user when the credential-encrypted private storage for
3036 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3037 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3038 * Launchers) that need to display merged content across both primary and managed profiles
3039 * need to worry about this broadcast. This is only sent to registered receivers,
3040 * not manifest receivers.
3041 */
3042 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3043 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3044
3045 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003046 * Broadcast sent to the primary user when an associated managed profile's availability has
Rubin Xuf13c9802016-01-21 18:06:00 +00003047 * changed. This includes when the user toggles the profile's quiet mode. Carries an extra
3048 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3049 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3050 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003051 */
3052 public static final String ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED =
3053 "android.intent.action.MANAGED_PROFILE_AVAILABILITY_CHANGED";
3054
3055 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003056 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3057 */
3058 public static final String ACTION_QUICK_CLOCK =
3059 "android.intent.action.QUICK_CLOCK";
3060
Michael Wright0087a142013-02-05 16:29:39 -08003061 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003062 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003063 * @hide
3064 */
3065 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3066 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3067
Justin Kohd378ad72013-04-01 12:18:26 -07003068 /**
3069 * Broadcast Action: A global button was pressed. Includes a single
3070 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3071 * caused the broadcast.
3072 * @hide
3073 */
3074 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3075
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003076 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003077 * Broadcast Action: Sent when media resource is granted.
3078 * <p>
3079 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3080 * granted.
3081 * </p>
3082 * <p class="note">
3083 * This is a protected intent that can only be sent by the system.
3084 * </p>
3085 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003086 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003087 * </p>
3088 *
3089 * @hide
3090 */
3091 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3092 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3093
3094 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003095 * Activity Action: Allow the user to select and return one or more existing
3096 * documents. When invoked, the system will display the various
3097 * {@link DocumentsProvider} instances installed on the device, letting the
3098 * user interactively navigate through them. These documents include local
3099 * media, such as photos and video, and documents provided by installed
3100 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003101 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003102 * Each document is represented as a {@code content://} URI backed by a
3103 * {@link DocumentsProvider}, which can be opened as a stream with
3104 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3105 * {@link android.provider.DocumentsContract.Document} metadata.
3106 * <p>
3107 * All selected documents are returned to the calling application with
3108 * persistable read and write permission grants. If you want to maintain
3109 * access to the documents across device reboots, you need to explicitly
3110 * take the persistable permissions using
3111 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3112 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003113 * Callers must indicate the acceptable document MIME types through
3114 * {@link #setType(String)}. For example, to select photos, use
3115 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3116 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3117 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003118 * <p>
3119 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003120 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3121 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003122 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003123 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3124 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003125 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003126 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003127 * Output: The URI of the item that was picked, returned in
3128 * {@link #getData()}. This must be a {@code content://} URI so that any
3129 * receiver can access it. If multiple documents were selected, they are
3130 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003131 *
3132 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003133 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003134 * @see #ACTION_CREATE_DOCUMENT
3135 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003136 */
3137 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3138 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3139
3140 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003141 * Activity Action: Allow the user to create a new document. When invoked,
3142 * the system will display the various {@link DocumentsProvider} instances
3143 * installed on the device, letting the user navigate through them. The
3144 * returned document may be a newly created document with no content, or it
3145 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003146 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003147 * Each document is represented as a {@code content://} URI backed by a
3148 * {@link DocumentsProvider}, which can be opened as a stream with
3149 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3150 * {@link android.provider.DocumentsContract.Document} metadata.
3151 * <p>
3152 * Callers must indicate the concrete MIME type of the document being
3153 * created by setting {@link #setType(String)}. This MIME type cannot be
3154 * changed after the document is created.
3155 * <p>
3156 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3157 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003158 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003159 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3160 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003161 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003162 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003163 * Output: The URI of the item that was created. This must be a
3164 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003165 *
3166 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003167 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003168 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003169 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003170 */
3171 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3172 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3173
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003174 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003175 * Activity Action: Allow the user to pick a directory subtree. When
3176 * invoked, the system will display the various {@link DocumentsProvider}
3177 * instances installed on the device, letting the user navigate through
3178 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003179 * <p>
3180 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003181 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3182 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3183 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003184 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003185 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003186 *
3187 * @see DocumentsContract
3188 */
3189 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003190 public static final String
3191 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003192
Felipe Lemec7b1f892016-01-15 15:02:31 -08003193 /**
Peng Xua35b5532016-01-20 00:05:45 -08003194 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3195 * exisiting sensor being disconnected.
3196 *
3197 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3198 *
3199 * {@hide}
3200 */
3201 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3202 public static final String
3203 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3204
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003205 /** {@hide} */
3206 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3207
Christopher Tate6597e342015-02-17 12:15:25 -08003208 /**
3209 * Broadcast action: report that a settings element is being restored from backup. The intent
3210 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3211 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3212 * is the value of that settings entry prior to the restore operation. All of these values are
3213 * represented as strings.
3214 *
3215 * <p>This broadcast is sent only for settings provider entries known to require special handling
3216 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3217 * the provider's backup agent implementation.
3218 *
3219 * @see #EXTRA_SETTING_NAME
3220 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3221 * @see #EXTRA_SETTING_NEW_VALUE
3222 * {@hide}
3223 */
3224 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3225
3226 /** {@hide} */
3227 public static final String EXTRA_SETTING_NAME = "setting_name";
3228 /** {@hide} */
3229 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3230 /** {@hide} */
3231 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3232
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003233 /**
3234 * Activity Action: Process a piece of text.
3235 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3236 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3237 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3238 */
3239 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3240 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3241 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003242 * The name of the extra used to define the text to be processed, as a
3243 * CharSequence. Note that this may be a styled CharSequence, so you must use
3244 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003245 */
3246 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3247 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003248 * The name of the boolean extra used to define if the processed text will be used as read-only.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003249 */
3250 public static final String EXTRA_PROCESS_TEXT_READONLY =
3251 "android.intent.extra.PROCESS_TEXT_READONLY";
3252
Bryce Leebc58f592015-09-25 16:43:01 -07003253 /**
3254 * Broadcast action: reports when a new thermal event has been reached. When the device
3255 * is reaching its maximum temperatue, the thermal level reported
3256 * {@hide}
3257 */
3258 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3259 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3260
3261 /** {@hide} */
3262 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3263
3264 /**
3265 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003266 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003267 * {@hide}
3268 */
3269 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3270
3271 /**
3272 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003273 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003274 * {@hide}
3275 */
3276 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3277
3278 /**
3279 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003280 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003281 * {@hide}
3282 */
3283 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3284
3285
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003286 // ---------------------------------------------------------------------
3287 // ---------------------------------------------------------------------
3288 // Standard intent categories (see addCategory()).
3289
3290 /**
3291 * Set if the activity should be an option for the default action
3292 * (center press) to perform on a piece of data. Setting this will
3293 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003294 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003295 * Intent when initiating an action -- it is for use in intent filters
3296 * specified in packages.
3297 */
3298 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3299 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3300 /**
3301 * Activities that can be safely invoked from a browser must support this
3302 * category. For example, if the user is viewing a web page or an e-mail
3303 * and clicks on a link in the text, the Intent generated execute that
3304 * link will require the BROWSABLE category, so that only activities
3305 * supporting this category will be considered as possible actions. By
3306 * supporting this category, you are promising that there is nothing
3307 * damaging (without user intervention) that can happen by invoking any
3308 * matching Intent.
3309 */
3310 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3311 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3312 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003313 * Categories for activities that can participate in voice interaction.
3314 * An activity that supports this category must be prepared to run with
3315 * no UI shown at all (though in some case it may have a UI shown), and
3316 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3317 */
3318 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3319 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3320 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003321 * Set if the activity should be considered as an alternative action to
3322 * the data the user is currently viewing. See also
3323 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3324 * applies to the selection in a list of items.
3325 *
3326 * <p>Supporting this category means that you would like your activity to be
3327 * displayed in the set of alternative things the user can do, usually as
3328 * part of the current activity's options menu. You will usually want to
3329 * include a specific label in the &lt;intent-filter&gt; of this action
3330 * describing to the user what it does.
3331 *
3332 * <p>The action of IntentFilter with this category is important in that it
3333 * describes the specific action the target will perform. This generally
3334 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3335 * a specific name such as "com.android.camera.action.CROP. Only one
3336 * alternative of any particular action will be shown to the user, so using
3337 * a specific action like this makes sure that your alternative will be
3338 * displayed while also allowing other applications to provide their own
3339 * overrides of that particular action.
3340 */
3341 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3342 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3343 /**
3344 * Set if the activity should be considered as an alternative selection
3345 * action to the data the user has currently selected. This is like
3346 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3347 * of items from which the user can select, giving them alternatives to the
3348 * default action that will be performed on it.
3349 */
3350 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3351 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3352 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003353 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003354 */
3355 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3356 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3357 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003358 * Should be displayed in the top-level launcher.
3359 */
3360 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3361 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3362 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003363 * Indicates an activity optimized for Leanback mode, and that should
3364 * be displayed in the Leanback launcher.
3365 */
3366 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3367 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3368 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003369 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3370 * @hide
3371 */
3372 @SystemApi
3373 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3374 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003375 * Provides information about the package it is in; typically used if
3376 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3377 * a front-door to the user without having to be shown in the all apps list.
3378 */
3379 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3380 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3381 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003382 * This is the home activity, that is the first activity that is displayed
3383 * when the device boots.
3384 */
3385 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3386 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3387 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003388 * This is the home activity that is displayed when the device is finished setting up and ready
3389 * for use.
3390 * @hide
3391 */
3392 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3393 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3394 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003395 * This is the setup wizard activity, that is the first activity that is displayed
3396 * when the user sets up the device for the first time.
3397 * @hide
3398 */
3399 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3400 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3401 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003402 * This activity is a preference panel.
3403 */
3404 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3405 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3406 /**
3407 * This activity is a development preference panel.
3408 */
3409 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3410 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3411 /**
3412 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003413 */
3414 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3415 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3416 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003417 * This activity allows the user to browse and download new applications.
3418 */
3419 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3420 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3421 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003422 * This activity may be exercised by the monkey or other automated test tools.
3423 */
3424 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3425 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3426 /**
3427 * To be used as a test (not part of the normal user experience).
3428 */
3429 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3430 /**
3431 * To be used as a unit test (run through the Test Harness).
3432 */
3433 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3434 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003435 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003436 * experience).
3437 */
3438 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003439
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003440 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003441 * Used to indicate that an intent only wants URIs that can be opened with
3442 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3443 * must support at least the columns defined in {@link OpenableColumns} when
3444 * queried.
3445 *
3446 * @see #ACTION_GET_CONTENT
3447 * @see #ACTION_OPEN_DOCUMENT
3448 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003449 */
3450 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3451 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3452
3453 /**
3454 * To be used as code under test for framework instrumentation tests.
3455 */
3456 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3457 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003458 /**
3459 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003460 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3461 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003462 */
3463 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3464 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3465 /**
3466 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003467 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3468 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003469 */
3470 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3471 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003472 /**
3473 * An activity to run when device is inserted into a analog (low end) dock.
3474 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3475 * information, see {@link android.app.UiModeManager}.
3476 */
3477 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3478 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3479
3480 /**
3481 * An activity to run when device is inserted into a digital (high end) dock.
3482 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3483 * information, see {@link android.app.UiModeManager}.
3484 */
3485 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3486 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003487
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003488 /**
3489 * Used to indicate that the activity can be used in a car environment.
3490 */
3491 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3492 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3493
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003494 // ---------------------------------------------------------------------
3495 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003496 // Application launch intent categories (see addCategory()).
3497
3498 /**
3499 * Used with {@link #ACTION_MAIN} to launch the browser application.
3500 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003501 * <p>NOTE: This should not be used as the primary key of an Intent,
3502 * since it will not result in the app launching with the correct
3503 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003504 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003505 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003506 */
3507 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3508 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3509
3510 /**
3511 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3512 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003513 * <p>NOTE: This should not be used as the primary key of an Intent,
3514 * since it will not result in the app launching with the correct
3515 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003516 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003517 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003518 */
3519 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3520 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3521
3522 /**
3523 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3524 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003525 * <p>NOTE: This should not be used as the primary key of an Intent,
3526 * since it will not result in the app launching with the correct
3527 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003528 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003529 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003530 */
3531 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3532 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3533
3534 /**
3535 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3536 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003537 * <p>NOTE: This should not be used as the primary key of an Intent,
3538 * since it will not result in the app launching with the correct
3539 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003540 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003541 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003542 */
3543 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3544 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3545
3546 /**
3547 * Used with {@link #ACTION_MAIN} to launch the email application.
3548 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003549 * <p>NOTE: This should not be used as the primary key of an Intent,
3550 * since it will not result in the app launching with the correct
3551 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003552 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003553 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003554 */
3555 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3556 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3557
3558 /**
3559 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3560 * The activity should be able to view and manipulate image and video files
3561 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003562 * <p>NOTE: This should not be used as the primary key of an Intent,
3563 * since it will not result in the app launching with the correct
3564 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003565 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003566 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003567 */
3568 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3569 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3570
3571 /**
3572 * Used with {@link #ACTION_MAIN} to launch the maps application.
3573 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003574 * <p>NOTE: This should not be used as the primary key of an Intent,
3575 * since it will not result in the app launching with the correct
3576 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003577 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003578 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003579 */
3580 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3581 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3582
3583 /**
3584 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3585 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003586 * <p>NOTE: This should not be used as the primary key of an Intent,
3587 * since it will not result in the app launching with the correct
3588 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003589 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003590 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003591 */
3592 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3593 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3594
3595 /**
3596 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003597 * The activity should be able to play, browse, or manipulate music files
3598 * stored on the device.
3599 * <p>NOTE: This should not be used as the primary key of an Intent,
3600 * since it will not result in the app launching with the correct
3601 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003602 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003603 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003604 */
3605 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3606 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3607
3608 // ---------------------------------------------------------------------
3609 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003610 // Standard extra data keys.
3611
3612 /**
3613 * The initial data to place in a newly created record. Use with
3614 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3615 * fields as would be given to the underlying ContentProvider.insert()
3616 * call.
3617 */
3618 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3619
3620 /**
3621 * A constant CharSequence that is associated with the Intent, used with
3622 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3623 * this may be a styled CharSequence, so you must use
3624 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3625 * retrieve it.
3626 */
3627 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3628
3629 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003630 * A constant String that is associated with the Intent, used with
3631 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3632 * as HTML formatted text. Note that you <em>must</em> also supply
3633 * {@link #EXTRA_TEXT}.
3634 */
3635 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3636
3637 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003638 * A content: URI holding a stream of data associated with the Intent,
3639 * used with {@link #ACTION_SEND} to supply the data being sent.
3640 */
3641 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3642
3643 /**
3644 * A String[] holding e-mail addresses that should be delivered to.
3645 */
3646 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3647
3648 /**
3649 * A String[] holding e-mail addresses that should be carbon copied.
3650 */
3651 public static final String EXTRA_CC = "android.intent.extra.CC";
3652
3653 /**
3654 * A String[] holding e-mail addresses that should be blind carbon copied.
3655 */
3656 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3657
3658 /**
3659 * A constant string holding the desired subject line of a message.
3660 */
3661 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3662
3663 /**
3664 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003665 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003666 */
3667 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3668
3669 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003670 * An int representing the user id to be used.
3671 *
3672 * @hide
3673 */
3674 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3675
3676 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003677 * An int representing the task id to be retrieved. This is used when a launch from recents is
3678 * intercepted by another action such as credentials confirmation to remember which task should
3679 * be resumed when complete.
3680 *
3681 * @hide
3682 */
3683 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3684
3685 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003686 * An Intent[] describing additional, alternate choices you would like shown with
3687 * {@link #ACTION_CHOOSER}.
3688 *
3689 * <p>An app may be capable of providing several different payload types to complete a
3690 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3691 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3692 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3693 * photo data or a hosted link where the photos can be viewed.</p>
3694 *
3695 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3696 * first/primary/preferred intent in the set. Additional intents specified in
3697 * this extra are ordered; by default intents that appear earlier in the array will be
3698 * preferred over intents that appear later in the array as matches for the same
3699 * target component. To alter this preference, a calling app may also supply
3700 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3701 */
3702 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3703
3704 /**
3705 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3706 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3707 *
3708 * <p>An app preparing an action for another app to complete may wish to allow the user to
3709 * disambiguate between several options for completing the action based on the chosen target
3710 * or otherwise refine the action before it is invoked.
3711 * </p>
3712 *
3713 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3714 * <ul>
3715 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3716 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3717 * chosen target beyond the first</li>
3718 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3719 * should fill in and send once the disambiguation is complete</li>
3720 * </ul>
3721 */
3722 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3723 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3724
3725 /**
3726 * A {@link ResultReceiver} used to return data back to the sender.
3727 *
3728 * <p>Used to complete an app-specific
3729 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3730 *
3731 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3732 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3733 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3734 * when the user selects a target component from the chooser. It is up to the recipient
3735 * to send a result to this ResultReceiver to signal that disambiguation is complete
3736 * and that the chooser should invoke the user's choice.</p>
3737 *
3738 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3739 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3740 * to match and fill in the final Intent or ChooserTarget before starting it.
3741 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3742 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3743 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3744 *
3745 * <p>The result code passed to the ResultReceiver should be
3746 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3747 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3748 * the chooser should finish without starting a target.</p>
3749 */
3750 public static final String EXTRA_RESULT_RECEIVER
3751 = "android.intent.extra.RESULT_RECEIVER";
3752
3753 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003754 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003755 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003756 */
3757 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3758
3759 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003760 * A Parcelable[] of {@link Intent} or
3761 * {@link android.content.pm.LabeledIntent} objects as set with
3762 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3763 * a the front of the list of choices, when shown to the user with a
3764 * {@link #ACTION_CHOOSER}.
3765 */
3766 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3767
3768 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003769 * A {@link IntentSender} to start after ephemeral installation success.
3770 * @hide
3771 */
3772 @SystemApi
3773 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3774
3775 /**
3776 * A {@link IntentSender} to start after ephemeral installation failure.
3777 * @hide
3778 */
3779 @SystemApi
3780 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3781
3782 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003783 * A Bundle forming a mapping of potential target package names to different extras Bundles
3784 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3785 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3786 * be currently installed on the device.
3787 *
3788 * <p>An application may choose to provide alternate extras for the case where a user
3789 * selects an activity from a predetermined set of target packages. If the activity
3790 * the user selects from the chooser belongs to a package with its package name as
3791 * a key in this bundle, the corresponding extras for that package will be merged with
3792 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3793 * extra has the same key as an extra already present in the intent it will overwrite
3794 * the extra from the intent.</p>
3795 *
3796 * <p><em>Examples:</em>
3797 * <ul>
3798 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3799 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3800 * parameters for that target.</li>
3801 * <li>An application may offer additional metadata for known targets of a given intent
3802 * to pass along information only relevant to that target such as account or content
3803 * identifiers already known to that application.</li>
3804 * </ul></p>
3805 */
3806 public static final String EXTRA_REPLACEMENT_EXTRAS =
3807 "android.intent.extra.REPLACEMENT_EXTRAS";
3808
3809 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003810 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3811 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3812 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3813 * {@link ComponentName} of the chosen component.
3814 *
3815 * <p>In some situations this callback may never come, for example if the user abandons
3816 * the chooser, switches to another task or any number of other reasons. Apps should not
3817 * be written assuming that this callback will always occur.</p>
3818 */
3819 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3820 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3821
3822 /**
3823 * The {@link ComponentName} chosen by the user to complete an action.
3824 *
3825 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3826 */
3827 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3828
3829 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003830 * A {@link android.view.KeyEvent} object containing the event that
3831 * triggered the creation of the Intent it is in.
3832 */
3833 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3834
3835 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003836 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3837 * before shutting down.
3838 *
3839 * {@hide}
3840 */
3841 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3842
3843 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003844 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3845 * requested by the user.
3846 *
3847 * {@hide}
3848 */
3849 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3850 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3851
3852 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003853 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003854 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3855 * of restarting the application.
3856 */
3857 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3858
3859 /**
3860 * A String holding the phone number originally entered in
3861 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3862 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3863 */
3864 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003865
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003866 /**
3867 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3868 * intents to supply the uid the package had been assigned. Also an optional
3869 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3870 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3871 * purpose.
3872 */
3873 public static final String EXTRA_UID = "android.intent.extra.UID";
3874
3875 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003876 * @hide String array of package names.
3877 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003878 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003879 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3880
3881 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003882 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3883 * intents to indicate whether this represents a full uninstall (removing
3884 * both the code and its data) or a partial uninstall (leaving its data,
3885 * implying that this is an update).
3886 */
3887 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003889 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003890 * @hide
3891 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3892 * intents to indicate that at this point the package has been removed for
3893 * all users on the device.
3894 */
3895 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3896 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3897
3898 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003899 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3900 * intents to indicate that this is a replacement of the package, so this
3901 * broadcast will immediately be followed by an add broadcast for a
3902 * different version of the same package.
3903 */
3904 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003905
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003906 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003907 * Used as an int extra field in {@link android.app.AlarmManager} intents
3908 * to tell the application being invoked how many pending alarms are being
3909 * delievered with the intent. For one-shot alarms this will always be 1.
3910 * For recurring alarms, this might be greater than 1 if the device was
3911 * asleep or powered off at the time an earlier alarm would have been
3912 * delivered.
3913 */
3914 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003915
Jacek Surazski86b6c532009-05-13 14:38:28 +02003916 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003917 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3918 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003919 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3920 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003921 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3922 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3923 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003924 */
3925 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3926
3927 /**
3928 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3929 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003930 */
3931 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3932
3933 /**
3934 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3935 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003936 */
3937 public static final int EXTRA_DOCK_STATE_DESK = 1;
3938
3939 /**
3940 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3941 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003942 */
3943 public static final int EXTRA_DOCK_STATE_CAR = 2;
3944
3945 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003946 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3947 * to represent that the phone is in a analog (low end) dock.
3948 */
3949 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3950
3951 /**
3952 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3953 * to represent that the phone is in a digital (high end) dock.
3954 */
3955 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3956
3957 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003958 * Boolean that can be supplied as meta-data with a dock activity, to
3959 * indicate that the dock should take over the home key when it is active.
3960 */
3961 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003962
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003963 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003964 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3965 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003966 */
3967 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3968
3969 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003970 * Used in the extra field in the remote intent. It's astring token passed with the
3971 * remote intent.
3972 */
3973 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3974 "android.intent.extra.remote_intent_token";
3975
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003976 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003977 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003978 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003979 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003980 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003981 "android.intent.extra.changed_component_name";
3982
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003983 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003984 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003985 * and contains a string array of all of the components that have changed. If
3986 * the state of the overall package has changed, then it will contain an entry
3987 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003988 */
3989 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3990 "android.intent.extra.changed_component_name_list";
3991
3992 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003993 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003994 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00003995 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
3996 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
3997 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003998 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003999 */
4000 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4001 "android.intent.extra.changed_package_list";
4002
4003 /**
4004 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004005 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4006 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004007 * and contains an integer array of uids of all of the components
4008 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004009 */
4010 public static final String EXTRA_CHANGED_UID_LIST =
4011 "android.intent.extra.changed_uid_list";
4012
4013 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004014 * @hide
4015 * Magic extra system code can use when binding, to give a label for
4016 * who it is that has bound to a service. This is an integer giving
4017 * a framework string resource that can be displayed to the user.
4018 */
4019 public static final String EXTRA_CLIENT_LABEL =
4020 "android.intent.extra.client_label";
4021
4022 /**
4023 * @hide
4024 * Magic extra system code can use when binding, to give a PendingIntent object
4025 * that can be launched for the user to disable the system's use of this
4026 * service.
4027 */
4028 public static final String EXTRA_CLIENT_INTENT =
4029 "android.intent.extra.client_intent";
4030
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004031 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004032 * Extra used to indicate that an intent should only return data that is on
4033 * the local device. This is a boolean extra; the default is false. If true,
4034 * an implementation should only allow the user to select data that is
4035 * already on the device, not requiring it be downloaded from a remote
4036 * service when opened.
4037 *
4038 * @see #ACTION_GET_CONTENT
4039 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004040 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004041 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004042 */
4043 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004044 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004045
Amith Yamasani13593602012-03-22 16:16:17 -07004046 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004047 * Extra used to indicate that an intent can allow the user to select and
4048 * return multiple items. This is a boolean extra; the default is false. If
4049 * true, an implementation is allowed to present the user with a UI where
4050 * they can pick multiple items that are all returned to the caller. When
4051 * this happens, they should be returned as the {@link #getClipData()} part
4052 * of the result Intent.
4053 *
4054 * @see #ACTION_GET_CONTENT
4055 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004056 */
4057 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004058 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004059
4060 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004061 * The integer userHandle carried with broadcast intents related to addition, removal and
4062 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4063 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4064 *
Amith Yamasani13593602012-03-22 16:16:17 -07004065 * @hide
4066 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004067 public static final String EXTRA_USER_HANDLE =
4068 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004069
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004070 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004071 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4072 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4073 */
4074 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004075 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004076
4077 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004078 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004079 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4080 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004081 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004082 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4083
4084 /**
4085 * Extra sent in the intent to the BroadcastReceiver that handles
4086 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4087 * the restrictions as key/value pairs.
4088 */
4089 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4090 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004091
Amith Yamasani86118ba2013-03-28 14:33:16 -07004092 /**
4093 * Extra used in the response from a BroadcastReceiver that handles
4094 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4095 */
4096 public static final String EXTRA_RESTRICTIONS_INTENT =
4097 "android.intent.extra.restrictions_intent";
4098
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004099 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004100 * Extra used to communicate a set of acceptable MIME types. The type of the
4101 * extra is {@code String[]}. Values may be a combination of concrete MIME
4102 * types (such as "image/png") and/or partial MIME types (such as
4103 * "audio/*").
4104 *
4105 * @see #ACTION_GET_CONTENT
4106 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004107 */
4108 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4109
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004110 /**
4111 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4112 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004113 * When this is true, hardware devices can use this information to determine that
4114 * they shouldn't do a complete shutdown of their device since this is not a
4115 * complete shutdown down to the kernel, but only user space restarting.
4116 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004117 */
4118 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4119 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4120
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004121 /**
4122 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4123 * user has set their time format preferences to the 24 hour format.
4124 *
4125 * @hide for internal use only.
4126 */
4127 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4128 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4129
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004130 /** {@hide} */
4131 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4132
Rubin Xue8490f12015-06-25 12:17:48 +01004133 /** {@hide} */
4134 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4135
Santos Cordon15a13782015-03-31 18:32:31 -07004136 /**
4137 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4138 * activation request.
4139 * TODO: Add information about the structure and response data used with the pending intent.
4140 * @hide
4141 */
4142 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4143 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4144
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004145 /**
4146 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004147 *
4148 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004149 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004150 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4151
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004152 /**
4153 * Optional boolean extra indicating whether quiet mode has been switched on or off.
4154 */
4155 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004156
4157 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004158 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004159 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004160 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4161 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004162 *
4163 * @hide
4164 */
4165 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4166 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4167
4168 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004169 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004170 * to represent that a video codec is allowed to use.
4171 *
4172 * @hide
4173 */
4174 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4175
4176 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004177 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004178 * to represent that a audio codec is allowed to use.
4179 *
4180 * @hide
4181 */
4182 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4183
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004184 // ---------------------------------------------------------------------
4185 // ---------------------------------------------------------------------
4186 // Intent flags (see mFlags variable).
4187
Tor Norbyed9273d62013-05-30 15:59:53 -07004188 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004189 @IntDef(flag = true, value = {
4190 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4191 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004192 @Retention(RetentionPolicy.SOURCE)
4193 public @interface GrantUriMode {}
4194
Jeff Sharkey846318a2014-04-04 12:12:41 -07004195 /** @hide */
4196 @IntDef(flag = true, value = {
4197 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4198 @Retention(RetentionPolicy.SOURCE)
4199 public @interface AccessUriMode {}
4200
4201 /**
4202 * Test if given mode flags specify an access mode, which must be at least
4203 * read and/or write.
4204 *
4205 * @hide
4206 */
4207 public static boolean isAccessUriMode(int modeFlags) {
4208 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4209 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4210 }
4211
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004212 /**
4213 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004214 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004215 * specified in its ClipData. When applying to an Intent's ClipData,
4216 * all URIs as well as recursive traversals through data or other ClipData
4217 * in Intent items will be granted; only the grant flags of the top-level
4218 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004219 */
4220 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4221 /**
4222 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004223 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004224 * specified in its ClipData. When applying to an Intent's ClipData,
4225 * all URIs as well as recursive traversals through data or other ClipData
4226 * in Intent items will be granted; only the grant flags of the top-level
4227 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004228 */
4229 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4230 /**
4231 * Can be set by the caller to indicate that this Intent is coming from
4232 * a background operation, not from direct user interaction.
4233 */
4234 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4235 /**
4236 * A flag you can enable for debugging: when set, log messages will be
4237 * printed during the resolution of this intent to show you what has
4238 * been found to create the final resolved list.
4239 */
4240 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004241 /**
4242 * If set, this intent will not match any components in packages that
4243 * are currently stopped. If this is not set, then the default behavior
4244 * is to include such applications in the result.
4245 */
4246 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4247 /**
4248 * If set, this intent will always match any components in packages that
4249 * are currently stopped. This is the default behavior when
4250 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4251 * flags are set, this one wins (it allows overriding of exclude for
4252 * places where the framework may automatically set the exclude flag).
4253 */
4254 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004255
4256 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004257 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004258 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004259 * persisted across device reboots until explicitly revoked with
4260 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4261 * grant for possible persisting; the receiving application must call
4262 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4263 * actually persist.
4264 *
4265 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4266 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4267 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004268 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004269 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004270 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004271
4272 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004273 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4274 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4275 * applies to any URI that is a prefix match against the original granted
4276 * URI. (Without this flag, the URI must match exactly for access to be
4277 * granted.) Another URI is considered a prefix match only when scheme,
4278 * authority, and all path segments defined by the prefix are an exact
4279 * match.
4280 */
4281 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4282
4283 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004284 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004285 * homework and verified that they correctly handle packages and components
4286 * that come and go over time. In particular:
4287 * <ul>
4288 * <li>Apps installed on external storage, which will appear to be
4289 * uninstalled while the the device is ejected.
4290 * <li>Apps with encryption unaware components, which will appear to not
4291 * exist while the device is locked.
4292 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004293 *
4294 * @hide
4295 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004296 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004297
4298 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004299 * If set, the new activity is not kept in the history stack. As soon as
4300 * the user navigates away from it, the activity is finished. This may also
4301 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4302 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004303 *
4304 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4305 * is never invoked when the current activity starts a new activity which
4306 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004307 */
4308 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4309 /**
4310 * If set, the activity will not be launched if it is already running
4311 * at the top of the history stack.
4312 */
4313 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4314 /**
4315 * If set, this activity will become the start of a new task on this
4316 * history stack. A task (from the activity that started it to the
4317 * next task activity) defines an atomic group of activities that the
4318 * user can move to. Tasks can be moved to the foreground and background;
4319 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004320 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004321 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4322 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004323 *
4324 * <p>This flag is generally used by activities that want
4325 * to present a "launcher" style behavior: they give the user a list of
4326 * separate things that can be done, which otherwise run completely
4327 * independently of the activity launching them.
4328 *
4329 * <p>When using this flag, if a task is already running for the activity
4330 * you are now starting, then a new activity will not be started; instead,
4331 * the current task will simply be brought to the front of the screen with
4332 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4333 * to disable this behavior.
4334 *
4335 * <p>This flag can not be used when the caller is requesting a result from
4336 * the activity being launched.
4337 */
4338 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4339 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004340 * This flag is used to create a new task and launch an activity into it.
4341 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4342 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4343 * search through existing tasks for ones matching this Intent. Only if no such
4344 * task is found would a new task be created. When paired with
4345 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4346 * the search for a matching task and unconditionally start a new task.
4347 *
4348 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4349 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004350 * top-level application launcher.</strong> Used in conjunction with
4351 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4352 * behavior of bringing an existing task to the foreground. When set,
4353 * a new task is <em>always</em> started to host the Activity for the
4354 * Intent, regardless of whether there is already an existing task running
4355 * the same thing.
4356 *
4357 * <p><strong>Because the default system does not include graphical task management,
4358 * you should not use this flag unless you provide some way for a user to
4359 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004360 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004361 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4362 * creating new document tasks.
4363 *
4364 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004365 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004366 *
Scott Main7aee61f2011-02-08 11:25:01 -08004367 * <p>See
4368 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4369 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004370 *
4371 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4372 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004373 */
4374 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4375 /**
4376 * If set, and the activity being launched is already running in the
4377 * current task, then instead of launching a new instance of that activity,
4378 * all of the other activities on top of it will be closed and this Intent
4379 * will be delivered to the (now on top) old activity as a new Intent.
4380 *
4381 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4382 * If D calls startActivity() with an Intent that resolves to the component
4383 * of activity B, then C and D will be finished and B receive the given
4384 * Intent, resulting in the stack now being: A, B.
4385 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004386 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004387 * either receive the new intent you are starting here in its
4388 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004389 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004390 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4391 * the same intent, then it will be finished and re-created; for all other
4392 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4393 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004394 *
4395 * <p>This launch mode can also be used to good effect in conjunction with
4396 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4397 * of a task, it will bring any currently running instance of that task
4398 * to the foreground, and then clear it to its root state. This is
4399 * especially useful, for example, when launching an activity from the
4400 * notification manager.
4401 *
Scott Main7aee61f2011-02-08 11:25:01 -08004402 * <p>See
4403 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4404 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004405 */
4406 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4407 /**
4408 * If set and this intent is being used to launch a new activity from an
4409 * existing one, then the reply target of the existing activity will be
4410 * transfered to the new activity. This way the new activity can call
4411 * {@link android.app.Activity#setResult} and have that result sent back to
4412 * the reply target of the original activity.
4413 */
4414 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4415 /**
4416 * If set and this intent is being used to launch a new activity from an
4417 * existing one, the current activity will not be counted as the top
4418 * activity for deciding whether the new intent should be delivered to
4419 * the top instead of starting a new one. The previous activity will
4420 * be used as the top, with the assumption being that the current activity
4421 * will finish itself immediately.
4422 */
4423 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4424 /**
4425 * If set, the new activity is not kept in the list of recently launched
4426 * activities.
4427 */
4428 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4429 /**
4430 * This flag is not normally set by application code, but set for you by
4431 * the system as described in the
4432 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4433 * launchMode} documentation for the singleTask mode.
4434 */
4435 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4436 /**
4437 * If set, and this activity is either being started in a new task or
4438 * bringing to the top an existing task, then it will be launched as
4439 * the front door of the task. This will result in the application of
4440 * any affinities needed to have that task in the proper state (either
4441 * moving activities to or from it), or simply resetting that task to
4442 * its initial state if needed.
4443 */
4444 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4445 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004446 * This flag is not normally set by application code, but set for you by
4447 * the system if this activity is being launched from history
4448 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004449 */
4450 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004451 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004452 * @deprecated As of API 21 this performs identically to
4453 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004454 */
4455 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004456 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004457 * This flag is used to open a document into a new task rooted at the activity launched
4458 * by this Intent. Through the use of this flag, or its equivalent attribute,
4459 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004460 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004461 *
Craig Mautner026596b2014-05-21 15:35:44 -07004462 * <p>The use of the activity attribute form of this,
4463 * {@link android.R.attr#documentLaunchMode}, is
4464 * preferred over the Intent flag described here. The attribute form allows the
4465 * Activity to specify multiple document behavior for all launchers of the Activity
4466 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004467 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004468 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4469 * it is kept after the activity is finished is different than the use of
4470 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4471 * this flag is being used to create a new recents entry, then by default that entry
4472 * will be removed once the activity is finished. You can modify this behavior with
4473 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4474 *
Craig Mautner026596b2014-05-21 15:35:44 -07004475 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4476 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4477 * equivalent of the Activity manifest specifying {@link
4478 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4479 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4480 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004481 *
Craig Mautner026596b2014-05-21 15:35:44 -07004482 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004483 *
Craig Mautner026596b2014-05-21 15:35:44 -07004484 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004485 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4486 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004487 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004488 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004489 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004490 * callback from occurring on the current frontmost activity before it is
4491 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004492 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004493 * <p>Typically, an activity can rely on that callback to indicate that an
4494 * explicit user action has caused their activity to be moved out of the
4495 * foreground. The callback marks an appropriate point in the activity's
4496 * lifecycle for it to dismiss any notifications that it intends to display
4497 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004498 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004499 * <p>If an activity is ever started via any non-user-driven events such as
4500 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4501 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004502 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004503 */
4504 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004505 /**
4506 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4507 * this flag will cause the launched activity to be brought to the front of its
4508 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004509 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004510 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4511 * If D calls startActivity() with an Intent that resolves to the component
4512 * of activity B, then B will be brought to the front of the history stack,
4513 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004514 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004515 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004516 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004517 */
4518 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004519 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004520 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4521 * this flag will prevent the system from applying an activity transition
4522 * animation to go to the next activity state. This doesn't mean an
4523 * animation will never run -- if another activity change happens that doesn't
4524 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004525 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004526 * when you are going to do a series of activity operations but the
4527 * animation seen by the user shouldn't be driven by the first activity
4528 * change but rather a later one.
4529 */
4530 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4531 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004532 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4533 * this flag will cause any existing task that would be associated with the
4534 * activity to be cleared before the activity is started. That is, the activity
4535 * becomes the new root of an otherwise empty task, and any old activities
4536 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4537 */
4538 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4539 /**
4540 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4541 * this flag will cause a newly launching task to be placed on top of the current
4542 * home activity task (if there is one). That is, pressing back from the task
4543 * will always return the user to home even if that was not the last activity they
4544 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4545 */
4546 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4547 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004548 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4549 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004550 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004551 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004552 * this flag. When set and the task's activity is finished, the recents
4553 * entry will remain in the interface for the user to re-launch it, like a
4554 * recents entry for a top-level application.
4555 * <p>
4556 * The receiving activity can override this request with
4557 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4558 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004559 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004560 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004561 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004562
4563 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004564 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4565 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004566 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4567 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004568 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004569 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004570
4571 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004572 * If set, when sending a broadcast only registered receivers will be
4573 * called -- no BroadcastReceiver components will be launched.
4574 */
4575 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004576 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004577 * If set, when sending a broadcast the new broadcast will replace
4578 * any existing pending broadcast that matches it. Matching is defined
4579 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4580 * true for the intents of the two broadcasts. When a match is found,
4581 * the new broadcast (and receivers associated with it) will replace the
4582 * existing one in the pending broadcast list, remaining at the same
4583 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004584 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004585 * <p>This flag is most typically used with sticky broadcasts, which
4586 * only care about delivering the most recent values of the broadcast
4587 * to their receivers.
4588 */
4589 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4590 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004591 * If set, when sending a broadcast the recipient is allowed to run at
4592 * foreground priority, with a shorter timeout interval. During normal
4593 * broadcasts the receivers are not automatically hoisted out of the
4594 * background priority class.
4595 */
4596 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4597 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004598 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4599 * They can still propagate results through to later receivers, but they can not prevent
4600 * later receivers from seeing the broadcast.
4601 */
4602 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4603 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004604 * If set, when sending a broadcast <i>before boot has completed</i> only
4605 * registered receivers will be called -- no BroadcastReceiver components
4606 * will be launched. Sticky intent state will be recorded properly even
4607 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4608 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004609 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004610 * <p>This flag is only for use by system sevices as a convenience to
4611 * avoid having to implement a more complex mechanism around detection
4612 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004613 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004614 * @hide
4615 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004616 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004617 /**
4618 * Set when this broadcast is for a boot upgrade, a special mode that
4619 * allows the broadcast to be sent before the system is ready and launches
4620 * the app process with no providers running in it.
4621 * @hide
4622 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004623 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004624 /**
4625 * If set, the broadcast will always go to manifest receivers in background (cached
4626 * or not running) apps, regardless of whether that would be done by default. By
4627 * default they will only receive broadcasts if the broadcast has specified an
4628 * explicit component or package name.
4629 * @hide
4630 */
4631 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4632 /**
4633 * If set, the broadcast will never go to manifest receivers in background (cached
4634 * or not running) apps, regardless of whether that would be done by default. By
4635 * default they will receive broadcasts if the broadcast has specified an
4636 * explicit component or package name.
4637 * @hide
4638 */
4639 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004640
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004641 /**
4642 * @hide Flags that can't be changed with PendingIntent.
4643 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004644 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4645 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4646 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004647
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004648 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004649 // ---------------------------------------------------------------------
4650 // toUri() and parseUri() options.
4651
4652 /**
4653 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4654 * always has the "intent:" scheme. This syntax can be used when you want
4655 * to later disambiguate between URIs that are intended to describe an
4656 * Intent vs. all others that should be treated as raw URIs. When used
4657 * with {@link #parseUri}, any other scheme will result in a generic
4658 * VIEW action for that raw URI.
4659 */
4660 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004661
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004662 /**
4663 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4664 * always has the "android-app:" scheme. This is a variation of
4665 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4666 * http/https URI being delivered to a specific package name. The format
4667 * is:
4668 *
4669 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004670 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004671 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004672 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4673 * you must also include a scheme; including a path also requires both a host and a scheme.
4674 * The final #Intent; fragment can be used without a scheme, host, or path.
4675 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004676 * used with intents that have a {@link #setSelector}, since the base intent
4677 * will always have an explicit package name.</p>
4678 *
4679 * <p>Some examples of how this scheme maps to Intent objects:</p>
4680 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4681 * <colgroup align="left" />
4682 * <colgroup align="left" />
4683 * <thead>
4684 * <tr><th>URI</th> <th>Intent</th></tr>
4685 * </thead>
4686 *
4687 * <tbody>
4688 * <tr><td><code>android-app://com.example.app</code></td>
4689 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4690 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4691 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4692 * </table></td>
4693 * </tr>
4694 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4695 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4696 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4697 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4698 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4699 * </table></td>
4700 * </tr>
4701 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4702 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4703 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4704 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4705 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4706 * </table></td>
4707 * </tr>
4708 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4709 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4710 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4711 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4712 * </table></td>
4713 * </tr>
4714 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4715 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4716 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4717 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4718 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4719 * </table></td>
4720 * </tr>
4721 * <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>
4722 * <td><table border="" style="margin:0" >
4723 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4724 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4725 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4726 * </table></td>
4727 * </tr>
4728 * </tbody>
4729 * </table>
4730 */
4731 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4732
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004733 /**
4734 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4735 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4736 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4737 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4738 * generated Intent can not cause unexpected data access to happen.
4739 *
4740 * <p>If you do not trust the source of the URI being parsed, you should still do further
4741 * processing to protect yourself from it. In particular, when using it to start an
4742 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4743 * that can handle it.</p>
4744 */
4745 public static final int URI_ALLOW_UNSAFE = 1<<2;
4746
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004747 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004748
4749 private String mAction;
4750 private Uri mData;
4751 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004752 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004753 private ComponentName mComponent;
4754 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004755 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004756 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004757 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004758 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004759 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004760 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004761
4762 // ---------------------------------------------------------------------
4763
4764 /**
4765 * Create an empty intent.
4766 */
4767 public Intent() {
4768 }
4769
4770 /**
4771 * Copy constructor.
4772 */
4773 public Intent(Intent o) {
4774 this.mAction = o.mAction;
4775 this.mData = o.mData;
4776 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004777 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004778 this.mComponent = o.mComponent;
4779 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004780 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004781 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004782 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004783 }
4784 if (o.mExtras != null) {
4785 this.mExtras = new Bundle(o.mExtras);
4786 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004787 if (o.mSourceBounds != null) {
4788 this.mSourceBounds = new Rect(o.mSourceBounds);
4789 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004790 if (o.mSelector != null) {
4791 this.mSelector = new Intent(o.mSelector);
4792 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004793 if (o.mClipData != null) {
4794 this.mClipData = new ClipData(o.mClipData);
4795 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004796 }
4797
4798 @Override
4799 public Object clone() {
4800 return new Intent(this);
4801 }
4802
4803 private Intent(Intent o, boolean all) {
4804 this.mAction = o.mAction;
4805 this.mData = o.mData;
4806 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004807 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004808 this.mComponent = o.mComponent;
4809 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004810 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004811 }
4812 }
4813
4814 /**
4815 * Make a clone of only the parts of the Intent that are relevant for
4816 * filter matching: the action, data, type, component, and categories.
4817 */
4818 public Intent cloneFilter() {
4819 return new Intent(this, false);
4820 }
4821
4822 /**
4823 * Create an intent with a given action. All other fields (data, type,
4824 * class) are null. Note that the action <em>must</em> be in a
4825 * namespace because Intents are used globally in the system -- for
4826 * example the system VIEW action is android.intent.action.VIEW; an
4827 * application's custom action would be something like
4828 * com.google.app.myapp.CUSTOM_ACTION.
4829 *
4830 * @param action The Intent action, such as ACTION_VIEW.
4831 */
4832 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004833 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004834 }
4835
4836 /**
4837 * Create an intent with a given action and for a given data url. Note
4838 * that the action <em>must</em> be in a namespace because Intents are
4839 * used globally in the system -- for example the system VIEW action is
4840 * android.intent.action.VIEW; an application's custom action would be
4841 * something like com.google.app.myapp.CUSTOM_ACTION.
4842 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004843 * <p><em>Note: scheme and host name matching in the Android framework is
4844 * case-sensitive, unlike the formal RFC. As a result,
4845 * you should always ensure that you write your Uri with these elements
4846 * using lower case letters, and normalize any Uris you receive from
4847 * outside of Android to ensure the scheme and host is lower case.</em></p>
4848 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004849 * @param action The Intent action, such as ACTION_VIEW.
4850 * @param uri The Intent data URI.
4851 */
4852 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004853 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004854 mData = uri;
4855 }
4856
4857 /**
4858 * Create an intent for a specific component. All other fields (action, data,
4859 * type, class) are null, though they can be modified later with explicit
4860 * calls. This provides a convenient way to create an intent that is
4861 * intended to execute a hard-coded class name, rather than relying on the
4862 * system to find an appropriate class for you; see {@link #setComponent}
4863 * for more information on the repercussions of this.
4864 *
4865 * @param packageContext A Context of the application package implementing
4866 * this class.
4867 * @param cls The component class that is to be used for the intent.
4868 *
4869 * @see #setClass
4870 * @see #setComponent
4871 * @see #Intent(String, android.net.Uri , Context, Class)
4872 */
4873 public Intent(Context packageContext, Class<?> cls) {
4874 mComponent = new ComponentName(packageContext, cls);
4875 }
4876
4877 /**
4878 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004879 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004880 * construct the Intent and then calling {@link #setClass} to set its
4881 * class.
4882 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004883 * <p><em>Note: scheme and host name matching in the Android framework is
4884 * case-sensitive, unlike the formal RFC. As a result,
4885 * you should always ensure that you write your Uri with these elements
4886 * using lower case letters, and normalize any Uris you receive from
4887 * outside of Android to ensure the scheme and host is lower case.</em></p>
4888 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004889 * @param action The Intent action, such as ACTION_VIEW.
4890 * @param uri The Intent data URI.
4891 * @param packageContext A Context of the application package implementing
4892 * this class.
4893 * @param cls The component class that is to be used for the intent.
4894 *
4895 * @see #Intent(String, android.net.Uri)
4896 * @see #Intent(Context, Class)
4897 * @see #setClass
4898 * @see #setComponent
4899 */
4900 public Intent(String action, Uri uri,
4901 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004902 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004903 mData = uri;
4904 mComponent = new ComponentName(packageContext, cls);
4905 }
4906
4907 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004908 * Create an intent to launch the main (root) activity of a task. This
4909 * is the Intent that is started when the application's is launched from
4910 * Home. For anything else that wants to launch an application in the
4911 * same way, it is important that they use an Intent structured the same
4912 * way, and can use this function to ensure this is the case.
4913 *
4914 * <p>The returned Intent has the given Activity component as its explicit
4915 * component, {@link #ACTION_MAIN} as its action, and includes the
4916 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4917 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4918 * to do that through {@link #addFlags(int)} on the returned Intent.
4919 *
4920 * @param mainActivity The main activity component that this Intent will
4921 * launch.
4922 * @return Returns a newly created Intent that can be used to launch the
4923 * activity as a main application entry.
4924 *
4925 * @see #setClass
4926 * @see #setComponent
4927 */
4928 public static Intent makeMainActivity(ComponentName mainActivity) {
4929 Intent intent = new Intent(ACTION_MAIN);
4930 intent.setComponent(mainActivity);
4931 intent.addCategory(CATEGORY_LAUNCHER);
4932 return intent;
4933 }
4934
4935 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004936 * Make an Intent for the main activity of an application, without
4937 * specifying a specific activity to run but giving a selector to find
4938 * the activity. This results in a final Intent that is structured
4939 * the same as when the application is launched from
4940 * Home. For anything else that wants to launch an application in the
4941 * same way, it is important that they use an Intent structured the same
4942 * way, and can use this function to ensure this is the case.
4943 *
4944 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4945 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4946 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4947 * to do that through {@link #addFlags(int)} on the returned Intent.
4948 *
4949 * @param selectorAction The action name of the Intent's selector.
4950 * @param selectorCategory The name of a category to add to the Intent's
4951 * selector.
4952 * @return Returns a newly created Intent that can be used to launch the
4953 * activity as a main application entry.
4954 *
4955 * @see #setSelector(Intent)
4956 */
4957 public static Intent makeMainSelectorActivity(String selectorAction,
4958 String selectorCategory) {
4959 Intent intent = new Intent(ACTION_MAIN);
4960 intent.addCategory(CATEGORY_LAUNCHER);
4961 Intent selector = new Intent();
4962 selector.setAction(selectorAction);
4963 selector.addCategory(selectorCategory);
4964 intent.setSelector(selector);
4965 return intent;
4966 }
4967
4968 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004969 * Make an Intent that can be used to re-launch an application's task
4970 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4971 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4972 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4973 *
4974 * @param mainActivity The activity component that is the root of the
4975 * task; this is the activity that has been published in the application's
4976 * manifest as the main launcher icon.
4977 *
4978 * @return Returns a newly created Intent that can be used to relaunch the
4979 * activity's task in its root state.
4980 */
4981 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4982 Intent intent = makeMainActivity(mainActivity);
4983 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4984 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4985 return intent;
4986 }
4987
4988 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004989 * Call {@link #parseUri} with 0 flags.
4990 * @deprecated Use {@link #parseUri} instead.
4991 */
4992 @Deprecated
4993 public static Intent getIntent(String uri) throws URISyntaxException {
4994 return parseUri(uri, 0);
4995 }
Tom Taylord4a47292009-12-21 13:59:18 -08004996
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004997 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004998 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004999 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005000 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005001 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005002 *
5003 * <p>The URI given here must not be relative -- that is, it must include
5004 * the scheme and full path.
5005 *
5006 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005007 * @param flags Additional processing flags. Either 0,
5008 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005009 *
5010 * @return Intent The newly created Intent object.
5011 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005012 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5013 * it bad (as parsed by the Uri class) or the Intent data within the
5014 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005015 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005016 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005017 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005018 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005019 int i = 0;
5020 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005021 final boolean androidApp = uri.startsWith("android-app:");
5022
5023 // Validate intent scheme if requested.
5024 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5025 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005026 Intent intent = new Intent(ACTION_VIEW);
5027 try {
5028 intent.setData(Uri.parse(uri));
5029 } catch (IllegalArgumentException e) {
5030 throw new URISyntaxException(uri, e.getMessage());
5031 }
5032 return intent;
5033 }
5034 }
Tom Taylord4a47292009-12-21 13:59:18 -08005035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005036 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005037 // simple case
5038 if (i == -1) {
5039 if (!androidApp) {
5040 return new Intent(ACTION_VIEW, Uri.parse(uri));
5041 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005042
5043 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005044 } else if (!uri.startsWith("#Intent;", i)) {
5045 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005046 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005047 } else {
5048 i = -1;
5049 }
5050 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005051
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005052 // new format
5053 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005054 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005055 boolean explicitAction = false;
5056 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005057
5058 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005059 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005060 String data;
5061 if (i >= 0) {
5062 data = uri.substring(0, i);
5063 i += 8; // length of "#Intent;"
5064 } else {
5065 data = uri;
5066 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005067
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005068 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005069 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005070 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005071 if (eq < 0) eq = i-1;
5072 int semi = uri.indexOf(';', i);
5073 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005074
5075 // action
5076 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005077 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005078 if (!inSelector) {
5079 explicitAction = true;
5080 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005081 }
5082
5083 // categories
5084 else if (uri.startsWith("category=", i)) {
5085 intent.addCategory(value);
5086 }
5087
5088 // type
5089 else if (uri.startsWith("type=", i)) {
5090 intent.mType = value;
5091 }
5092
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005093 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005094 else if (uri.startsWith("launchFlags=", i)) {
5095 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005096 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5097 intent.mFlags &= ~IMMUTABLE_FLAGS;
5098 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005099 }
5100
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005101 // package
5102 else if (uri.startsWith("package=", i)) {
5103 intent.mPackage = value;
5104 }
5105
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005106 // component
5107 else if (uri.startsWith("component=", i)) {
5108 intent.mComponent = ComponentName.unflattenFromString(value);
5109 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005110
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005111 // scheme
5112 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005113 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005114 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005115 } else {
5116 scheme = value;
5117 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005118 }
5119
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005120 // source bounds
5121 else if (uri.startsWith("sourceBounds=", i)) {
5122 intent.mSourceBounds = Rect.unflattenFromString(value);
5123 }
5124
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005125 // selector
5126 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5127 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005128 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005129 }
5130
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005131 // extra
5132 else {
5133 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005134 // create Bundle if it doesn't already exist
5135 if (intent.mExtras == null) intent.mExtras = new Bundle();
5136 Bundle b = intent.mExtras;
5137 // add EXTRA
5138 if (uri.startsWith("S.", i)) b.putString(key, value);
5139 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5140 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5141 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5142 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5143 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5144 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5145 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5146 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5147 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5148 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005149
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005150 // move to the next item
5151 i = semi + 1;
5152 }
5153
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005154 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005155 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005156 if (baseIntent.mPackage == null) {
5157 baseIntent.setSelector(intent);
5158 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005159 intent = baseIntent;
5160 }
5161
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005162 if (data != null) {
5163 if (data.startsWith("intent:")) {
5164 data = data.substring(7);
5165 if (scheme != null) {
5166 data = scheme + ':' + data;
5167 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005168 } else if (data.startsWith("android-app:")) {
5169 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5170 // Correctly formed android-app, first part is package name.
5171 int end = data.indexOf('/', 14);
5172 if (end < 0) {
5173 // All we have is a package name.
5174 intent.mPackage = data.substring(14);
5175 if (!explicitAction) {
5176 intent.setAction(ACTION_MAIN);
5177 }
5178 data = "";
5179 } else {
5180 // Target the Intent at the given package name always.
5181 String authority = null;
5182 intent.mPackage = data.substring(14, end);
5183 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005184 if ((end+1) < data.length()) {
5185 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5186 // Found a scheme, remember it.
5187 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005188 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005189 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5190 // Found a authority, remember it.
5191 authority = data.substring(end+1, newEnd);
5192 end = newEnd;
5193 }
5194 } else {
5195 // All we have is a scheme.
5196 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005197 }
5198 }
5199 if (scheme == null) {
5200 // If there was no scheme, then this just targets the package.
5201 if (!explicitAction) {
5202 intent.setAction(ACTION_MAIN);
5203 }
5204 data = "";
5205 } else if (authority == null) {
5206 data = scheme + ":";
5207 } else {
5208 data = scheme + "://" + authority + data.substring(end);
5209 }
5210 }
5211 } else {
5212 data = "";
5213 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005214 }
Tom Taylord4a47292009-12-21 13:59:18 -08005215
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005216 if (data.length() > 0) {
5217 try {
5218 intent.mData = Uri.parse(data);
5219 } catch (IllegalArgumentException e) {
5220 throw new URISyntaxException(uri, e.getMessage());
5221 }
5222 }
5223 }
Tom Taylord4a47292009-12-21 13:59:18 -08005224
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005225 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005226
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005227 } catch (IndexOutOfBoundsException e) {
5228 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5229 }
5230 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005231
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005232 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005233 return getIntentOld(uri, 0);
5234 }
5235
5236 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005237 Intent intent;
5238
5239 int i = uri.lastIndexOf('#');
5240 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005241 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005242 final int intentFragmentStart = i;
5243 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005244
5245 i++;
5246
5247 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005248 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005249 i += 7;
5250 int j = uri.indexOf(')', i);
5251 action = uri.substring(i, j);
5252 i = j + 1;
5253 }
5254
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005255 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005256
5257 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005258 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005259 i += 11;
5260 int j = uri.indexOf(')', i);
5261 while (i < j) {
5262 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005263 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005264 if (i < sep) {
5265 intent.addCategory(uri.substring(i, sep));
5266 }
5267 i = sep + 1;
5268 }
5269 i = j + 1;
5270 }
5271
5272 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005273 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005274 i += 5;
5275 int j = uri.indexOf(')', i);
5276 intent.mType = uri.substring(i, j);
5277 i = j + 1;
5278 }
5279
5280 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005281 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005282 i += 12;
5283 int j = uri.indexOf(')', i);
5284 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005285 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5286 intent.mFlags &= ~IMMUTABLE_FLAGS;
5287 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005288 i = j + 1;
5289 }
5290
5291 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005292 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005293 i += 10;
5294 int j = uri.indexOf(')', i);
5295 int sep = uri.indexOf('!', i);
5296 if (sep >= 0 && sep < j) {
5297 String pkg = uri.substring(i, sep);
5298 String cls = uri.substring(sep + 1, j);
5299 intent.mComponent = new ComponentName(pkg, cls);
5300 }
5301 i = j + 1;
5302 }
5303
5304 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005305 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005306 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005307
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005308 final int closeParen = uri.indexOf(')', i);
5309 if (closeParen == -1) throw new URISyntaxException(uri,
5310 "EXTRA missing trailing ')'", i);
5311
5312 while (i < closeParen) {
5313 // fetch the key value
5314 int j = uri.indexOf('=', i);
5315 if (j <= i + 1 || i >= closeParen) {
5316 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5317 }
5318 char type = uri.charAt(i);
5319 i++;
5320 String key = uri.substring(i, j);
5321 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005322
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005323 // get type-value
5324 j = uri.indexOf('!', i);
5325 if (j == -1 || j >= closeParen) j = closeParen;
5326 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5327 String value = uri.substring(i, j);
5328 i = j;
5329
5330 // create Bundle if it doesn't already exist
5331 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005332
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005333 // add item to bundle
5334 try {
5335 switch (type) {
5336 case 'S':
5337 intent.mExtras.putString(key, Uri.decode(value));
5338 break;
5339 case 'B':
5340 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5341 break;
5342 case 'b':
5343 intent.mExtras.putByte(key, Byte.parseByte(value));
5344 break;
5345 case 'c':
5346 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5347 break;
5348 case 'd':
5349 intent.mExtras.putDouble(key, Double.parseDouble(value));
5350 break;
5351 case 'f':
5352 intent.mExtras.putFloat(key, Float.parseFloat(value));
5353 break;
5354 case 'i':
5355 intent.mExtras.putInt(key, Integer.parseInt(value));
5356 break;
5357 case 'l':
5358 intent.mExtras.putLong(key, Long.parseLong(value));
5359 break;
5360 case 's':
5361 intent.mExtras.putShort(key, Short.parseShort(value));
5362 break;
5363 default:
5364 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5365 }
5366 } catch (NumberFormatException e) {
5367 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5368 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005369
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005370 char ch = uri.charAt(i);
5371 if (ch == ')') break;
5372 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5373 i++;
5374 }
5375 }
5376
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005377 if (isIntentFragment) {
5378 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5379 } else {
5380 intent.mData = Uri.parse(uri);
5381 }
Tom Taylord4a47292009-12-21 13:59:18 -08005382
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005383 if (intent.mAction == null) {
5384 // By default, if no action is specified, then use VIEW.
5385 intent.mAction = ACTION_VIEW;
5386 }
5387
5388 } else {
5389 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5390 }
5391
5392 return intent;
5393 }
5394
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005395 /** @hide */
5396 public interface CommandOptionHandler {
5397 boolean handleOption(String opt, ShellCommand cmd);
5398 }
5399
5400 /** @hide */
5401 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5402 throws URISyntaxException {
5403 Intent intent = new Intent();
5404 Intent baseIntent = intent;
5405 boolean hasIntentInfo = false;
5406
5407 Uri data = null;
5408 String type = null;
5409
5410 String opt;
5411 while ((opt=cmd.getNextOption()) != null) {
5412 switch (opt) {
5413 case "-a":
5414 intent.setAction(cmd.getNextArgRequired());
5415 if (intent == baseIntent) {
5416 hasIntentInfo = true;
5417 }
5418 break;
5419 case "-d":
5420 data = Uri.parse(cmd.getNextArgRequired());
5421 if (intent == baseIntent) {
5422 hasIntentInfo = true;
5423 }
5424 break;
5425 case "-t":
5426 type = cmd.getNextArgRequired();
5427 if (intent == baseIntent) {
5428 hasIntentInfo = true;
5429 }
5430 break;
5431 case "-c":
5432 intent.addCategory(cmd.getNextArgRequired());
5433 if (intent == baseIntent) {
5434 hasIntentInfo = true;
5435 }
5436 break;
5437 case "-e":
5438 case "--es": {
5439 String key = cmd.getNextArgRequired();
5440 String value = cmd.getNextArgRequired();
5441 intent.putExtra(key, value);
5442 }
5443 break;
5444 case "--esn": {
5445 String key = cmd.getNextArgRequired();
5446 intent.putExtra(key, (String) null);
5447 }
5448 break;
5449 case "--ei": {
5450 String key = cmd.getNextArgRequired();
5451 String value = cmd.getNextArgRequired();
5452 intent.putExtra(key, Integer.decode(value));
5453 }
5454 break;
5455 case "--eu": {
5456 String key = cmd.getNextArgRequired();
5457 String value = cmd.getNextArgRequired();
5458 intent.putExtra(key, Uri.parse(value));
5459 }
5460 break;
5461 case "--ecn": {
5462 String key = cmd.getNextArgRequired();
5463 String value = cmd.getNextArgRequired();
5464 ComponentName cn = ComponentName.unflattenFromString(value);
5465 if (cn == null)
5466 throw new IllegalArgumentException("Bad component name: " + value);
5467 intent.putExtra(key, cn);
5468 }
5469 break;
5470 case "--eia": {
5471 String key = cmd.getNextArgRequired();
5472 String value = cmd.getNextArgRequired();
5473 String[] strings = value.split(",");
5474 int[] list = new int[strings.length];
5475 for (int i = 0; i < strings.length; i++) {
5476 list[i] = Integer.decode(strings[i]);
5477 }
5478 intent.putExtra(key, list);
5479 }
5480 break;
5481 case "--eial": {
5482 String key = cmd.getNextArgRequired();
5483 String value = cmd.getNextArgRequired();
5484 String[] strings = value.split(",");
5485 ArrayList<Integer> list = new ArrayList<>(strings.length);
5486 for (int i = 0; i < strings.length; i++) {
5487 list.add(Integer.decode(strings[i]));
5488 }
5489 intent.putExtra(key, list);
5490 }
5491 break;
5492 case "--el": {
5493 String key = cmd.getNextArgRequired();
5494 String value = cmd.getNextArgRequired();
5495 intent.putExtra(key, Long.valueOf(value));
5496 }
5497 break;
5498 case "--ela": {
5499 String key = cmd.getNextArgRequired();
5500 String value = cmd.getNextArgRequired();
5501 String[] strings = value.split(",");
5502 long[] list = new long[strings.length];
5503 for (int i = 0; i < strings.length; i++) {
5504 list[i] = Long.valueOf(strings[i]);
5505 }
5506 intent.putExtra(key, list);
5507 hasIntentInfo = true;
5508 }
5509 break;
5510 case "--elal": {
5511 String key = cmd.getNextArgRequired();
5512 String value = cmd.getNextArgRequired();
5513 String[] strings = value.split(",");
5514 ArrayList<Long> list = new ArrayList<>(strings.length);
5515 for (int i = 0; i < strings.length; i++) {
5516 list.add(Long.valueOf(strings[i]));
5517 }
5518 intent.putExtra(key, list);
5519 hasIntentInfo = true;
5520 }
5521 break;
5522 case "--ef": {
5523 String key = cmd.getNextArgRequired();
5524 String value = cmd.getNextArgRequired();
5525 intent.putExtra(key, Float.valueOf(value));
5526 hasIntentInfo = true;
5527 }
5528 break;
5529 case "--efa": {
5530 String key = cmd.getNextArgRequired();
5531 String value = cmd.getNextArgRequired();
5532 String[] strings = value.split(",");
5533 float[] list = new float[strings.length];
5534 for (int i = 0; i < strings.length; i++) {
5535 list[i] = Float.valueOf(strings[i]);
5536 }
5537 intent.putExtra(key, list);
5538 hasIntentInfo = true;
5539 }
5540 break;
5541 case "--efal": {
5542 String key = cmd.getNextArgRequired();
5543 String value = cmd.getNextArgRequired();
5544 String[] strings = value.split(",");
5545 ArrayList<Float> list = new ArrayList<>(strings.length);
5546 for (int i = 0; i < strings.length; i++) {
5547 list.add(Float.valueOf(strings[i]));
5548 }
5549 intent.putExtra(key, list);
5550 hasIntentInfo = true;
5551 }
5552 break;
5553 case "--esa": {
5554 String key = cmd.getNextArgRequired();
5555 String value = cmd.getNextArgRequired();
5556 // Split on commas unless they are preceeded by an escape.
5557 // The escape character must be escaped for the string and
5558 // again for the regex, thus four escape characters become one.
5559 String[] strings = value.split("(?<!\\\\),");
5560 intent.putExtra(key, strings);
5561 hasIntentInfo = true;
5562 }
5563 break;
5564 case "--esal": {
5565 String key = cmd.getNextArgRequired();
5566 String value = cmd.getNextArgRequired();
5567 // Split on commas unless they are preceeded by an escape.
5568 // The escape character must be escaped for the string and
5569 // again for the regex, thus four escape characters become one.
5570 String[] strings = value.split("(?<!\\\\),");
5571 ArrayList<String> list = new ArrayList<>(strings.length);
5572 for (int i = 0; i < strings.length; i++) {
5573 list.add(strings[i]);
5574 }
5575 intent.putExtra(key, list);
5576 hasIntentInfo = true;
5577 }
5578 break;
5579 case "--ez": {
5580 String key = cmd.getNextArgRequired();
5581 String value = cmd.getNextArgRequired().toLowerCase();
5582 // Boolean.valueOf() results in false for anything that is not "true", which is
5583 // error-prone in shell commands
5584 boolean arg;
5585 if ("true".equals(value) || "t".equals(value)) {
5586 arg = true;
5587 } else if ("false".equals(value) || "f".equals(value)) {
5588 arg = false;
5589 } else {
5590 try {
5591 arg = Integer.decode(value) != 0;
5592 } catch (NumberFormatException ex) {
5593 throw new IllegalArgumentException("Invalid boolean value: " + value);
5594 }
5595 }
5596
5597 intent.putExtra(key, arg);
5598 }
5599 break;
5600 case "-n": {
5601 String str = cmd.getNextArgRequired();
5602 ComponentName cn = ComponentName.unflattenFromString(str);
5603 if (cn == null)
5604 throw new IllegalArgumentException("Bad component name: " + str);
5605 intent.setComponent(cn);
5606 if (intent == baseIntent) {
5607 hasIntentInfo = true;
5608 }
5609 }
5610 break;
5611 case "-p": {
5612 String str = cmd.getNextArgRequired();
5613 intent.setPackage(str);
5614 if (intent == baseIntent) {
5615 hasIntentInfo = true;
5616 }
5617 }
5618 break;
5619 case "-f":
5620 String str = cmd.getNextArgRequired();
5621 intent.setFlags(Integer.decode(str).intValue());
5622 break;
5623 case "--grant-read-uri-permission":
5624 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5625 break;
5626 case "--grant-write-uri-permission":
5627 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5628 break;
5629 case "--grant-persistable-uri-permission":
5630 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5631 break;
5632 case "--grant-prefix-uri-permission":
5633 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5634 break;
5635 case "--exclude-stopped-packages":
5636 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5637 break;
5638 case "--include-stopped-packages":
5639 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5640 break;
5641 case "--debug-log-resolution":
5642 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5643 break;
5644 case "--activity-brought-to-front":
5645 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5646 break;
5647 case "--activity-clear-top":
5648 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5649 break;
5650 case "--activity-clear-when-task-reset":
5651 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5652 break;
5653 case "--activity-exclude-from-recents":
5654 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5655 break;
5656 case "--activity-launched-from-history":
5657 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5658 break;
5659 case "--activity-multiple-task":
5660 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5661 break;
5662 case "--activity-no-animation":
5663 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5664 break;
5665 case "--activity-no-history":
5666 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5667 break;
5668 case "--activity-no-user-action":
5669 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5670 break;
5671 case "--activity-previous-is-top":
5672 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5673 break;
5674 case "--activity-reorder-to-front":
5675 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5676 break;
5677 case "--activity-reset-task-if-needed":
5678 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5679 break;
5680 case "--activity-single-top":
5681 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5682 break;
5683 case "--activity-clear-task":
5684 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5685 break;
5686 case "--activity-task-on-home":
5687 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5688 break;
5689 case "--receiver-registered-only":
5690 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5691 break;
5692 case "--receiver-replace-pending":
5693 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5694 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005695 case "--receiver-foreground":
5696 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
5697 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005698 case "--selector":
5699 intent.setDataAndType(data, type);
5700 intent = new Intent();
5701 break;
5702 default:
5703 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5704 // Okay, caller handled this option.
5705 } else {
5706 throw new IllegalArgumentException("Unknown option: " + opt);
5707 }
5708 break;
5709 }
5710 }
5711 intent.setDataAndType(data, type);
5712
5713 final boolean hasSelector = intent != baseIntent;
5714 if (hasSelector) {
5715 // A selector was specified; fix up.
5716 baseIntent.setSelector(intent);
5717 intent = baseIntent;
5718 }
5719
5720 String arg = cmd.getNextArg();
5721 baseIntent = null;
5722 if (arg == null) {
5723 if (hasSelector) {
5724 // If a selector has been specified, and no arguments
5725 // have been supplied for the main Intent, then we can
5726 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5727 // need to have a component name specified yet, the
5728 // selector will take care of that.
5729 baseIntent = new Intent(Intent.ACTION_MAIN);
5730 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5731 }
5732 } else if (arg.indexOf(':') >= 0) {
5733 // The argument is a URI. Fully parse it, and use that result
5734 // to fill in any data not specified so far.
5735 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5736 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5737 } else if (arg.indexOf('/') >= 0) {
5738 // The argument is a component name. Build an Intent to launch
5739 // it.
5740 baseIntent = new Intent(Intent.ACTION_MAIN);
5741 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5742 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5743 } else {
5744 // Assume the argument is a package name.
5745 baseIntent = new Intent(Intent.ACTION_MAIN);
5746 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5747 baseIntent.setPackage(arg);
5748 }
5749 if (baseIntent != null) {
5750 Bundle extras = intent.getExtras();
5751 intent.replaceExtras((Bundle)null);
5752 Bundle uriExtras = baseIntent.getExtras();
5753 baseIntent.replaceExtras((Bundle)null);
5754 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5755 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5756 for (String c : cats) {
5757 baseIntent.removeCategory(c);
5758 }
5759 }
5760 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5761 if (extras == null) {
5762 extras = uriExtras;
5763 } else if (uriExtras != null) {
5764 uriExtras.putAll(extras);
5765 extras = uriExtras;
5766 }
5767 intent.replaceExtras(extras);
5768 hasIntentInfo = true;
5769 }
5770
5771 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5772 return intent;
5773 }
5774
5775 /** @hide */
5776 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5777 final String[] lines = new String[] {
5778 "<INTENT> specifications include these flags and arguments:",
5779 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5780 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5781 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5782 " [--esn <EXTRA_KEY> ...]",
5783 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5784 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5785 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5786 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5787 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5788 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5789 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5790 " (mutiple extras passed as Integer[])",
5791 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5792 " (mutiple extras passed as List<Integer>)",
5793 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5794 " (mutiple extras passed as Long[])",
5795 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5796 " (mutiple extras passed as List<Long>)",
5797 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5798 " (mutiple extras passed as Float[])",
5799 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5800 " (mutiple extras passed as List<Float>)",
5801 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5802 " (mutiple extras passed as String[]; to embed a comma into a string,",
5803 " escape it using \"\\,\")",
5804 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5805 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5806 " escape it using \"\\,\")",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005807 " [--f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005808 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5809 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5810 " [--debug-log-resolution] [--exclude-stopped-packages]",
5811 " [--include-stopped-packages]",
5812 " [--activity-brought-to-front] [--activity-clear-top]",
5813 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5814 " [--activity-launched-from-history] [--activity-multiple-task]",
5815 " [--activity-no-animation] [--activity-no-history]",
5816 " [--activity-no-user-action] [--activity-previous-is-top]",
5817 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5818 " [--activity-single-top] [--activity-clear-task]",
5819 " [--activity-task-on-home]",
5820 " [--receiver-registered-only] [--receiver-replace-pending]",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005821 " [--receiver-foreground]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005822 " [--selector]",
5823 " [<URI> | <PACKAGE> | <COMPONENT>]"
5824 };
5825 for (String line : lines) {
5826 pw.print(prefix);
5827 pw.println(line);
5828 }
5829 }
5830
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005831 /**
5832 * Retrieve the general action to be performed, such as
5833 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5834 * the information in the intent should be interpreted -- most importantly,
5835 * what to do with the data returned by {@link #getData}.
5836 *
5837 * @return The action of this intent or null if none is specified.
5838 *
5839 * @see #setAction
5840 */
5841 public String getAction() {
5842 return mAction;
5843 }
5844
5845 /**
5846 * Retrieve data this intent is operating on. This URI specifies the name
5847 * of the data; often it uses the content: scheme, specifying data in a
5848 * content provider. Other schemes may be handled by specific activities,
5849 * such as http: by the web browser.
5850 *
5851 * @return The URI of the data this intent is targeting or null.
5852 *
5853 * @see #getScheme
5854 * @see #setData
5855 */
5856 public Uri getData() {
5857 return mData;
5858 }
5859
5860 /**
5861 * The same as {@link #getData()}, but returns the URI as an encoded
5862 * String.
5863 */
5864 public String getDataString() {
5865 return mData != null ? mData.toString() : null;
5866 }
5867
5868 /**
5869 * Return the scheme portion of the intent's data. If the data is null or
5870 * does not include a scheme, null is returned. Otherwise, the scheme
5871 * prefix without the final ':' is returned, i.e. "http".
5872 *
5873 * <p>This is the same as calling getData().getScheme() (and checking for
5874 * null data).
5875 *
5876 * @return The scheme of this intent.
5877 *
5878 * @see #getData
5879 */
5880 public String getScheme() {
5881 return mData != null ? mData.getScheme() : null;
5882 }
5883
5884 /**
5885 * Retrieve any explicit MIME type included in the intent. This is usually
5886 * null, as the type is determined by the intent data.
5887 *
5888 * @return If a type was manually set, it is returned; else null is
5889 * returned.
5890 *
5891 * @see #resolveType(ContentResolver)
5892 * @see #setType
5893 */
5894 public String getType() {
5895 return mType;
5896 }
5897
5898 /**
5899 * Return the MIME data type of this intent. If the type field is
5900 * explicitly set, that is simply returned. Otherwise, if the data is set,
5901 * the type of that data is returned. If neither fields are set, a null is
5902 * returned.
5903 *
5904 * @return The MIME type of this intent.
5905 *
5906 * @see #getType
5907 * @see #resolveType(ContentResolver)
5908 */
5909 public String resolveType(Context context) {
5910 return resolveType(context.getContentResolver());
5911 }
5912
5913 /**
5914 * Return the MIME data type of this intent. If the type field is
5915 * explicitly set, that is simply returned. Otherwise, if the data is set,
5916 * the type of that data is returned. If neither fields are set, a null is
5917 * returned.
5918 *
5919 * @param resolver A ContentResolver that can be used to determine the MIME
5920 * type of the intent's data.
5921 *
5922 * @return The MIME type of this intent.
5923 *
5924 * @see #getType
5925 * @see #resolveType(Context)
5926 */
5927 public String resolveType(ContentResolver resolver) {
5928 if (mType != null) {
5929 return mType;
5930 }
5931 if (mData != null) {
5932 if ("content".equals(mData.getScheme())) {
5933 return resolver.getType(mData);
5934 }
5935 }
5936 return null;
5937 }
5938
5939 /**
5940 * Return the MIME data type of this intent, only if it will be needed for
5941 * intent resolution. This is not generally useful for application code;
5942 * it is used by the frameworks for communicating with back-end system
5943 * services.
5944 *
5945 * @param resolver A ContentResolver that can be used to determine the MIME
5946 * type of the intent's data.
5947 *
5948 * @return The MIME type of this intent, or null if it is unknown or not
5949 * needed.
5950 */
5951 public String resolveTypeIfNeeded(ContentResolver resolver) {
5952 if (mComponent != null) {
5953 return mType;
5954 }
5955 return resolveType(resolver);
5956 }
5957
5958 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005959 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005960 *
5961 * @param category The category to check.
5962 *
5963 * @return boolean True if the intent contains the category, else false.
5964 *
5965 * @see #getCategories
5966 * @see #addCategory
5967 */
5968 public boolean hasCategory(String category) {
5969 return mCategories != null && mCategories.contains(category);
5970 }
5971
5972 /**
5973 * Return the set of all categories in the intent. If there are no categories,
5974 * returns NULL.
5975 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005976 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005977 *
5978 * @see #hasCategory
5979 * @see #addCategory
5980 */
5981 public Set<String> getCategories() {
5982 return mCategories;
5983 }
5984
5985 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005986 * Return the specific selector associated with this Intent. If there is
5987 * none, returns null. See {@link #setSelector} for more information.
5988 *
5989 * @see #setSelector
5990 */
5991 public Intent getSelector() {
5992 return mSelector;
5993 }
5994
5995 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005996 * Return the {@link ClipData} associated with this Intent. If there is
5997 * none, returns null. See {@link #setClipData} for more information.
5998 *
John Spurlock125d1332013-11-25 11:58:37 -05005999 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006000 */
6001 public ClipData getClipData() {
6002 return mClipData;
6003 }
6004
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006005 /** @hide */
6006 public int getContentUserHint() {
6007 return mContentUserHint;
6008 }
6009
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006010 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006011 * Sets the ClassLoader that will be used when unmarshalling
6012 * any Parcelable values from the extras of this Intent.
6013 *
6014 * @param loader a ClassLoader, or null to use the default loader
6015 * at the time of unmarshalling.
6016 */
6017 public void setExtrasClassLoader(ClassLoader loader) {
6018 if (mExtras != null) {
6019 mExtras.setClassLoader(loader);
6020 }
6021 }
6022
6023 /**
6024 * Returns true if an extra value is associated with the given name.
6025 * @param name the extra's name
6026 * @return true if the given extra is present.
6027 */
6028 public boolean hasExtra(String name) {
6029 return mExtras != null && mExtras.containsKey(name);
6030 }
6031
6032 /**
6033 * Returns true if the Intent's extras contain a parcelled file descriptor.
6034 * @return true if the Intent contains a parcelled file descriptor.
6035 */
6036 public boolean hasFileDescriptors() {
6037 return mExtras != null && mExtras.hasFileDescriptors();
6038 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006039
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006040 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006041 public void setAllowFds(boolean allowFds) {
6042 if (mExtras != null) {
6043 mExtras.setAllowFds(allowFds);
6044 }
6045 }
6046
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006047 /** {@hide} */
6048 public void setDefusable(boolean defusable) {
6049 if (mExtras != null) {
6050 mExtras.setDefusable(defusable);
6051 }
6052 }
6053
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006054 /**
6055 * Retrieve extended data from the intent.
6056 *
6057 * @param name The name of the desired item.
6058 *
6059 * @return the value of an item that previously added with putExtra()
6060 * or null if none was found.
6061 *
6062 * @deprecated
6063 * @hide
6064 */
6065 @Deprecated
6066 public Object getExtra(String name) {
6067 return getExtra(name, null);
6068 }
6069
6070 /**
6071 * Retrieve extended data from the intent.
6072 *
6073 * @param name The name of the desired item.
6074 * @param defaultValue the value to be returned if no value of the desired
6075 * type is stored with the given name.
6076 *
6077 * @return the value of an item that previously added with putExtra()
6078 * or the default value if none was found.
6079 *
6080 * @see #putExtra(String, boolean)
6081 */
6082 public boolean getBooleanExtra(String name, boolean defaultValue) {
6083 return mExtras == null ? defaultValue :
6084 mExtras.getBoolean(name, defaultValue);
6085 }
6086
6087 /**
6088 * Retrieve extended data from the intent.
6089 *
6090 * @param name The name of the desired item.
6091 * @param defaultValue the value to be returned if no value of the desired
6092 * type is stored with the given name.
6093 *
6094 * @return the value of an item that previously added with putExtra()
6095 * or the default value if none was found.
6096 *
6097 * @see #putExtra(String, byte)
6098 */
6099 public byte getByteExtra(String name, byte defaultValue) {
6100 return mExtras == null ? defaultValue :
6101 mExtras.getByte(name, defaultValue);
6102 }
6103
6104 /**
6105 * Retrieve extended data from the intent.
6106 *
6107 * @param name The name of the desired item.
6108 * @param defaultValue the value to be returned if no value of the desired
6109 * type is stored with the given name.
6110 *
6111 * @return the value of an item that previously added with putExtra()
6112 * or the default value if none was found.
6113 *
6114 * @see #putExtra(String, short)
6115 */
6116 public short getShortExtra(String name, short defaultValue) {
6117 return mExtras == null ? defaultValue :
6118 mExtras.getShort(name, defaultValue);
6119 }
6120
6121 /**
6122 * Retrieve extended data from the intent.
6123 *
6124 * @param name The name of the desired item.
6125 * @param defaultValue the value to be returned if no value of the desired
6126 * type is stored with the given name.
6127 *
6128 * @return the value of an item that previously added with putExtra()
6129 * or the default value if none was found.
6130 *
6131 * @see #putExtra(String, char)
6132 */
6133 public char getCharExtra(String name, char defaultValue) {
6134 return mExtras == null ? defaultValue :
6135 mExtras.getChar(name, defaultValue);
6136 }
6137
6138 /**
6139 * Retrieve extended data from the intent.
6140 *
6141 * @param name The name of the desired item.
6142 * @param defaultValue the value to be returned if no value of the desired
6143 * type is stored with the given name.
6144 *
6145 * @return the value of an item that previously added with putExtra()
6146 * or the default value if none was found.
6147 *
6148 * @see #putExtra(String, int)
6149 */
6150 public int getIntExtra(String name, int defaultValue) {
6151 return mExtras == null ? defaultValue :
6152 mExtras.getInt(name, defaultValue);
6153 }
6154
6155 /**
6156 * Retrieve extended data from the intent.
6157 *
6158 * @param name The name of the desired item.
6159 * @param defaultValue the value to be returned if no value of the desired
6160 * type is stored with the given name.
6161 *
6162 * @return the value of an item that previously added with putExtra()
6163 * or the default value if none was found.
6164 *
6165 * @see #putExtra(String, long)
6166 */
6167 public long getLongExtra(String name, long defaultValue) {
6168 return mExtras == null ? defaultValue :
6169 mExtras.getLong(name, defaultValue);
6170 }
6171
6172 /**
6173 * Retrieve extended data from the intent.
6174 *
6175 * @param name The name of the desired item.
6176 * @param defaultValue the value to be returned if no value of the desired
6177 * type is stored with the given name.
6178 *
6179 * @return the value of an item that previously added with putExtra(),
6180 * or the default value if no such item is present
6181 *
6182 * @see #putExtra(String, float)
6183 */
6184 public float getFloatExtra(String name, float defaultValue) {
6185 return mExtras == null ? defaultValue :
6186 mExtras.getFloat(name, defaultValue);
6187 }
6188
6189 /**
6190 * Retrieve extended data from the intent.
6191 *
6192 * @param name The name of the desired item.
6193 * @param defaultValue the value to be returned if no value of the desired
6194 * type is stored with the given name.
6195 *
6196 * @return the value of an item that previously added with putExtra()
6197 * or the default value if none was found.
6198 *
6199 * @see #putExtra(String, double)
6200 */
6201 public double getDoubleExtra(String name, double defaultValue) {
6202 return mExtras == null ? defaultValue :
6203 mExtras.getDouble(name, defaultValue);
6204 }
6205
6206 /**
6207 * Retrieve extended data from the intent.
6208 *
6209 * @param name The name of the desired item.
6210 *
6211 * @return the value of an item that previously added with putExtra()
6212 * or null if no String value was found.
6213 *
6214 * @see #putExtra(String, String)
6215 */
6216 public String getStringExtra(String name) {
6217 return mExtras == null ? null : mExtras.getString(name);
6218 }
6219
6220 /**
6221 * Retrieve extended data from the intent.
6222 *
6223 * @param name The name of the desired item.
6224 *
6225 * @return the value of an item that previously added with putExtra()
6226 * or null if no CharSequence value was found.
6227 *
6228 * @see #putExtra(String, CharSequence)
6229 */
6230 public CharSequence getCharSequenceExtra(String name) {
6231 return mExtras == null ? null : mExtras.getCharSequence(name);
6232 }
6233
6234 /**
6235 * Retrieve extended data from the intent.
6236 *
6237 * @param name The name of the desired item.
6238 *
6239 * @return the value of an item that previously added with putExtra()
6240 * or null if no Parcelable value was found.
6241 *
6242 * @see #putExtra(String, Parcelable)
6243 */
6244 public <T extends Parcelable> T getParcelableExtra(String name) {
6245 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6246 }
6247
6248 /**
6249 * Retrieve extended data from the intent.
6250 *
6251 * @param name The name of the desired item.
6252 *
6253 * @return the value of an item that previously added with putExtra()
6254 * or null if no Parcelable[] value was found.
6255 *
6256 * @see #putExtra(String, Parcelable[])
6257 */
6258 public Parcelable[] getParcelableArrayExtra(String name) {
6259 return mExtras == null ? null : mExtras.getParcelableArray(name);
6260 }
6261
6262 /**
6263 * Retrieve extended data from the intent.
6264 *
6265 * @param name The name of the desired item.
6266 *
6267 * @return the value of an item that previously added with putExtra()
6268 * or null if no ArrayList<Parcelable> value was found.
6269 *
6270 * @see #putParcelableArrayListExtra(String, ArrayList)
6271 */
6272 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6273 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6274 }
6275
6276 /**
6277 * Retrieve extended data from the intent.
6278 *
6279 * @param name The name of the desired item.
6280 *
6281 * @return the value of an item that previously added with putExtra()
6282 * or null if no Serializable value was found.
6283 *
6284 * @see #putExtra(String, Serializable)
6285 */
6286 public Serializable getSerializableExtra(String name) {
6287 return mExtras == null ? null : mExtras.getSerializable(name);
6288 }
6289
6290 /**
6291 * Retrieve extended data from the intent.
6292 *
6293 * @param name The name of the desired item.
6294 *
6295 * @return the value of an item that previously added with putExtra()
6296 * or null if no ArrayList<Integer> value was found.
6297 *
6298 * @see #putIntegerArrayListExtra(String, ArrayList)
6299 */
6300 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6301 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6302 }
6303
6304 /**
6305 * Retrieve extended data from the intent.
6306 *
6307 * @param name The name of the desired item.
6308 *
6309 * @return the value of an item that previously added with putExtra()
6310 * or null if no ArrayList<String> value was found.
6311 *
6312 * @see #putStringArrayListExtra(String, ArrayList)
6313 */
6314 public ArrayList<String> getStringArrayListExtra(String name) {
6315 return mExtras == null ? null : mExtras.getStringArrayList(name);
6316 }
6317
6318 /**
6319 * Retrieve extended data from the intent.
6320 *
6321 * @param name The name of the desired item.
6322 *
6323 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006324 * or null if no ArrayList<CharSequence> value was found.
6325 *
6326 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6327 */
6328 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6329 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6330 }
6331
6332 /**
6333 * Retrieve extended data from the intent.
6334 *
6335 * @param name The name of the desired item.
6336 *
6337 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006338 * or null if no boolean array value was found.
6339 *
6340 * @see #putExtra(String, boolean[])
6341 */
6342 public boolean[] getBooleanArrayExtra(String name) {
6343 return mExtras == null ? null : mExtras.getBooleanArray(name);
6344 }
6345
6346 /**
6347 * Retrieve extended data from the intent.
6348 *
6349 * @param name The name of the desired item.
6350 *
6351 * @return the value of an item that previously added with putExtra()
6352 * or null if no byte array value was found.
6353 *
6354 * @see #putExtra(String, byte[])
6355 */
6356 public byte[] getByteArrayExtra(String name) {
6357 return mExtras == null ? null : mExtras.getByteArray(name);
6358 }
6359
6360 /**
6361 * Retrieve extended data from the intent.
6362 *
6363 * @param name The name of the desired item.
6364 *
6365 * @return the value of an item that previously added with putExtra()
6366 * or null if no short array value was found.
6367 *
6368 * @see #putExtra(String, short[])
6369 */
6370 public short[] getShortArrayExtra(String name) {
6371 return mExtras == null ? null : mExtras.getShortArray(name);
6372 }
6373
6374 /**
6375 * Retrieve extended data from the intent.
6376 *
6377 * @param name The name of the desired item.
6378 *
6379 * @return the value of an item that previously added with putExtra()
6380 * or null if no char array value was found.
6381 *
6382 * @see #putExtra(String, char[])
6383 */
6384 public char[] getCharArrayExtra(String name) {
6385 return mExtras == null ? null : mExtras.getCharArray(name);
6386 }
6387
6388 /**
6389 * Retrieve extended data from the intent.
6390 *
6391 * @param name The name of the desired item.
6392 *
6393 * @return the value of an item that previously added with putExtra()
6394 * or null if no int array value was found.
6395 *
6396 * @see #putExtra(String, int[])
6397 */
6398 public int[] getIntArrayExtra(String name) {
6399 return mExtras == null ? null : mExtras.getIntArray(name);
6400 }
6401
6402 /**
6403 * Retrieve extended data from the intent.
6404 *
6405 * @param name The name of the desired item.
6406 *
6407 * @return the value of an item that previously added with putExtra()
6408 * or null if no long array value was found.
6409 *
6410 * @see #putExtra(String, long[])
6411 */
6412 public long[] getLongArrayExtra(String name) {
6413 return mExtras == null ? null : mExtras.getLongArray(name);
6414 }
6415
6416 /**
6417 * Retrieve extended data from the intent.
6418 *
6419 * @param name The name of the desired item.
6420 *
6421 * @return the value of an item that previously added with putExtra()
6422 * or null if no float array value was found.
6423 *
6424 * @see #putExtra(String, float[])
6425 */
6426 public float[] getFloatArrayExtra(String name) {
6427 return mExtras == null ? null : mExtras.getFloatArray(name);
6428 }
6429
6430 /**
6431 * Retrieve extended data from the intent.
6432 *
6433 * @param name The name of the desired item.
6434 *
6435 * @return the value of an item that previously added with putExtra()
6436 * or null if no double array value was found.
6437 *
6438 * @see #putExtra(String, double[])
6439 */
6440 public double[] getDoubleArrayExtra(String name) {
6441 return mExtras == null ? null : mExtras.getDoubleArray(name);
6442 }
6443
6444 /**
6445 * Retrieve extended data from the intent.
6446 *
6447 * @param name The name of the desired item.
6448 *
6449 * @return the value of an item that previously added with putExtra()
6450 * or null if no String array value was found.
6451 *
6452 * @see #putExtra(String, String[])
6453 */
6454 public String[] getStringArrayExtra(String name) {
6455 return mExtras == null ? null : mExtras.getStringArray(name);
6456 }
6457
6458 /**
6459 * Retrieve extended data from the intent.
6460 *
6461 * @param name The name of the desired item.
6462 *
6463 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006464 * or null if no CharSequence array value was found.
6465 *
6466 * @see #putExtra(String, CharSequence[])
6467 */
6468 public CharSequence[] getCharSequenceArrayExtra(String name) {
6469 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6470 }
6471
6472 /**
6473 * Retrieve extended data from the intent.
6474 *
6475 * @param name The name of the desired item.
6476 *
6477 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006478 * or null if no Bundle value was found.
6479 *
6480 * @see #putExtra(String, Bundle)
6481 */
6482 public Bundle getBundleExtra(String name) {
6483 return mExtras == null ? null : mExtras.getBundle(name);
6484 }
6485
6486 /**
6487 * Retrieve extended data from the intent.
6488 *
6489 * @param name The name of the desired item.
6490 *
6491 * @return the value of an item that previously added with putExtra()
6492 * or null if no IBinder value was found.
6493 *
6494 * @see #putExtra(String, IBinder)
6495 *
6496 * @deprecated
6497 * @hide
6498 */
6499 @Deprecated
6500 public IBinder getIBinderExtra(String name) {
6501 return mExtras == null ? null : mExtras.getIBinder(name);
6502 }
6503
6504 /**
6505 * Retrieve extended data from the intent.
6506 *
6507 * @param name The name of the desired item.
6508 * @param defaultValue The default value to return in case no item is
6509 * associated with the key 'name'
6510 *
6511 * @return the value of an item that previously added with putExtra()
6512 * or defaultValue if none was found.
6513 *
6514 * @see #putExtra
6515 *
6516 * @deprecated
6517 * @hide
6518 */
6519 @Deprecated
6520 public Object getExtra(String name, Object defaultValue) {
6521 Object result = defaultValue;
6522 if (mExtras != null) {
6523 Object result2 = mExtras.get(name);
6524 if (result2 != null) {
6525 result = result2;
6526 }
6527 }
6528
6529 return result;
6530 }
6531
6532 /**
6533 * Retrieves a map of extended data from the intent.
6534 *
6535 * @return the map of all extras previously added with putExtra(),
6536 * or null if none have been added.
6537 */
6538 public Bundle getExtras() {
6539 return (mExtras != null)
6540 ? new Bundle(mExtras)
6541 : null;
6542 }
6543
6544 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006545 * Filter extras to only basic types.
6546 * @hide
6547 */
6548 public void removeUnsafeExtras() {
6549 if (mExtras != null) {
6550 mExtras.filterValues();
6551 }
6552 }
6553
6554 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006555 * Retrieve any special flags associated with this intent. You will
6556 * normally just set them with {@link #setFlags} and let the system
6557 * take the appropriate action with them.
6558 *
6559 * @return int The currently set flags.
6560 *
6561 * @see #setFlags
6562 */
6563 public int getFlags() {
6564 return mFlags;
6565 }
6566
Dianne Hackborne7f97212011-02-24 14:40:20 -08006567 /** @hide */
6568 public boolean isExcludingStopped() {
6569 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6570 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6571 }
6572
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006573 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006574 * Retrieve the application package name this Intent is limited to. When
6575 * resolving an Intent, if non-null this limits the resolution to only
6576 * components in the given application package.
6577 *
6578 * @return The name of the application package for the Intent.
6579 *
6580 * @see #resolveActivity
6581 * @see #setPackage
6582 */
6583 public String getPackage() {
6584 return mPackage;
6585 }
6586
6587 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006588 * Retrieve the concrete component associated with the intent. When receiving
6589 * an intent, this is the component that was found to best handle it (that is,
6590 * yourself) and will always be non-null; in all other cases it will be
6591 * null unless explicitly set.
6592 *
6593 * @return The name of the application component to handle the intent.
6594 *
6595 * @see #resolveActivity
6596 * @see #setComponent
6597 */
6598 public ComponentName getComponent() {
6599 return mComponent;
6600 }
6601
6602 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006603 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6604 * used as a hint to the receiver for animations and the like. Null means that there
6605 * is no source bounds.
6606 */
6607 public Rect getSourceBounds() {
6608 return mSourceBounds;
6609 }
6610
6611 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006612 * Return the Activity component that should be used to handle this intent.
6613 * The appropriate component is determined based on the information in the
6614 * intent, evaluated as follows:
6615 *
6616 * <p>If {@link #getComponent} returns an explicit class, that is returned
6617 * without any further consideration.
6618 *
6619 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6620 * category to be considered.
6621 *
6622 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6623 * action.
6624 *
6625 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6626 * this type.
6627 *
6628 * <p>If {@link #addCategory} has added any categories, the activity must
6629 * handle ALL of the categories specified.
6630 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006631 * <p>If {@link #getPackage} is non-NULL, only activity components in
6632 * that application package will be considered.
6633 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006634 * <p>If there are no activities that satisfy all of these conditions, a
6635 * null string is returned.
6636 *
6637 * <p>If multiple activities are found to satisfy the intent, the one with
6638 * the highest priority will be used. If there are multiple activities
6639 * with the same priority, the system will either pick the best activity
6640 * based on user preference, or resolve to a system class that will allow
6641 * the user to pick an activity and forward from there.
6642 *
6643 * <p>This method is implemented simply by calling
6644 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6645 * true.</p>
6646 * <p> This API is called for you as part of starting an activity from an
6647 * intent. You do not normally need to call it yourself.</p>
6648 *
6649 * @param pm The package manager with which to resolve the Intent.
6650 *
6651 * @return Name of the component implementing an activity that can
6652 * display the intent.
6653 *
6654 * @see #setComponent
6655 * @see #getComponent
6656 * @see #resolveActivityInfo
6657 */
6658 public ComponentName resolveActivity(PackageManager pm) {
6659 if (mComponent != null) {
6660 return mComponent;
6661 }
6662
6663 ResolveInfo info = pm.resolveActivity(
6664 this, PackageManager.MATCH_DEFAULT_ONLY);
6665 if (info != null) {
6666 return new ComponentName(
6667 info.activityInfo.applicationInfo.packageName,
6668 info.activityInfo.name);
6669 }
6670
6671 return null;
6672 }
6673
6674 /**
6675 * Resolve the Intent into an {@link ActivityInfo}
6676 * describing the activity that should execute the intent. Resolution
6677 * follows the same rules as described for {@link #resolveActivity}, but
6678 * you get back the completely information about the resolved activity
6679 * instead of just its class name.
6680 *
6681 * @param pm The package manager with which to resolve the Intent.
6682 * @param flags Addition information to retrieve as per
6683 * {@link PackageManager#getActivityInfo(ComponentName, int)
6684 * PackageManager.getActivityInfo()}.
6685 *
6686 * @return PackageManager.ActivityInfo
6687 *
6688 * @see #resolveActivity
6689 */
6690 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6691 ActivityInfo ai = null;
6692 if (mComponent != null) {
6693 try {
6694 ai = pm.getActivityInfo(mComponent, flags);
6695 } catch (PackageManager.NameNotFoundException e) {
6696 // ignore
6697 }
6698 } else {
6699 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006700 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006701 if (info != null) {
6702 ai = info.activityInfo;
6703 }
6704 }
6705
6706 return ai;
6707 }
6708
6709 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006710 * Special function for use by the system to resolve service
6711 * intents to system apps. Throws an exception if there are
6712 * multiple potential matches to the Intent. Returns null if
6713 * there are no matches.
6714 * @hide
6715 */
6716 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6717 if (mComponent != null) {
6718 return mComponent;
6719 }
6720
6721 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6722 if (results == null) {
6723 return null;
6724 }
6725 ComponentName comp = null;
6726 for (int i=0; i<results.size(); i++) {
6727 ResolveInfo ri = results.get(i);
6728 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6729 continue;
6730 }
6731 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6732 ri.serviceInfo.name);
6733 if (comp != null) {
6734 throw new IllegalStateException("Multiple system services handle " + this
6735 + ": " + comp + ", " + foundComp);
6736 }
6737 comp = foundComp;
6738 }
6739 return comp;
6740 }
6741
6742 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006743 * Set the general action to be performed.
6744 *
6745 * @param action An action name, such as ACTION_VIEW. Application-specific
6746 * actions should be prefixed with the vendor's package name.
6747 *
6748 * @return Returns the same Intent object, for chaining multiple calls
6749 * into a single statement.
6750 *
6751 * @see #getAction
6752 */
6753 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006754 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006755 return this;
6756 }
6757
6758 /**
6759 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006760 * clears any type that was previously set by {@link #setType} or
6761 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006762 *
Nick Pellyccae4122012-01-09 14:12:58 -08006763 * <p><em>Note: scheme matching in the Android framework is
6764 * case-sensitive, unlike the formal RFC. As a result,
6765 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006766 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006767 * {@link #setDataAndNormalize}
6768 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006769 *
Nick Pellyccae4122012-01-09 14:12:58 -08006770 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006771 *
6772 * @return Returns the same Intent object, for chaining multiple calls
6773 * into a single statement.
6774 *
6775 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006776 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006777 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006778 */
6779 public Intent setData(Uri data) {
6780 mData = data;
6781 mType = null;
6782 return this;
6783 }
6784
6785 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006786 * Normalize and set the data this intent is operating on.
6787 *
6788 * <p>This method automatically clears any type that was
6789 * previously set (for example, by {@link #setType}).
6790 *
6791 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006792 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006793 * so really this is just a convenience method for
6794 * <pre>
6795 * setData(data.normalize())
6796 * </pre>
6797 *
6798 * @param data The Uri of the data this intent is now targeting.
6799 *
6800 * @return Returns the same Intent object, for chaining multiple calls
6801 * into a single statement.
6802 *
6803 * @see #getData
6804 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006805 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006806 */
6807 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006808 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006809 }
6810
6811 /**
6812 * Set an explicit MIME data type.
6813 *
6814 * <p>This is used to create intents that only specify a type and not data,
6815 * for example to indicate the type of data to return.
6816 *
6817 * <p>This method automatically clears any data that was
6818 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006819 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006820 * <p><em>Note: MIME type matching in the Android framework is
6821 * case-sensitive, unlike formal RFC MIME types. As a result,
6822 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006823 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6824 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006825 *
6826 * @param type The MIME type of the data being handled by this intent.
6827 *
6828 * @return Returns the same Intent object, for chaining multiple calls
6829 * into a single statement.
6830 *
6831 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006832 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006833 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006834 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006835 */
6836 public Intent setType(String type) {
6837 mData = null;
6838 mType = type;
6839 return this;
6840 }
6841
6842 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006843 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006844 *
Nick Pellyccae4122012-01-09 14:12:58 -08006845 * <p>This is used to create intents that only specify a type and not data,
6846 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006847 *
Nick Pellyccae4122012-01-09 14:12:58 -08006848 * <p>This method automatically clears any data that was
6849 * previously set (for example by {@link #setData}).
6850 *
6851 * <p>The MIME type is normalized using
6852 * {@link #normalizeMimeType} before it is set,
6853 * so really this is just a convenience method for
6854 * <pre>
6855 * setType(Intent.normalizeMimeType(type))
6856 * </pre>
6857 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006858 * @param type The MIME type of the data being handled by this intent.
6859 *
6860 * @return Returns the same Intent object, for chaining multiple calls
6861 * into a single statement.
6862 *
Nick Pellyccae4122012-01-09 14:12:58 -08006863 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006864 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006865 * @see #normalizeMimeType
6866 */
6867 public Intent setTypeAndNormalize(String type) {
6868 return setType(normalizeMimeType(type));
6869 }
6870
6871 /**
6872 * (Usually optional) Set the data for the intent along with an explicit
6873 * MIME data type. This method should very rarely be used -- it allows you
6874 * to override the MIME type that would ordinarily be inferred from the
6875 * data with your own type given here.
6876 *
6877 * <p><em>Note: MIME type and Uri scheme matching in the
6878 * Android framework is case-sensitive, unlike the formal RFC definitions.
6879 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006880 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006881 * {@link #setDataAndTypeAndNormalize}
6882 * to ensure that they are converted to lower case.</em>
6883 *
6884 * @param data The Uri of the data this intent is now targeting.
6885 * @param type The MIME type of the data being handled by this intent.
6886 *
6887 * @return Returns the same Intent object, for chaining multiple calls
6888 * into a single statement.
6889 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006890 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006891 * @see #setData
6892 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006893 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006894 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006895 */
6896 public Intent setDataAndType(Uri data, String type) {
6897 mData = data;
6898 mType = type;
6899 return this;
6900 }
6901
6902 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006903 * (Usually optional) Normalize and set both the data Uri and an explicit
6904 * MIME data type. This method should very rarely be used -- it allows you
6905 * to override the MIME type that would ordinarily be inferred from the
6906 * data with your own type given here.
6907 *
6908 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006909 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006910 * before they are set, so really this is just a convenience method for
6911 * <pre>
6912 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6913 * </pre>
6914 *
6915 * @param data The Uri of the data this intent is now targeting.
6916 * @param type The MIME type of the data being handled by this intent.
6917 *
6918 * @return Returns the same Intent object, for chaining multiple calls
6919 * into a single statement.
6920 *
6921 * @see #setType
6922 * @see #setData
6923 * @see #setDataAndType
6924 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006925 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006926 */
6927 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006928 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006929 }
6930
6931 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006932 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006933 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006934 * activities that provide <em>all</em> of the requested categories will be
6935 * used.
6936 *
6937 * @param category The desired category. This can be either one of the
6938 * predefined Intent categories, or a custom category in your own
6939 * namespace.
6940 *
6941 * @return Returns the same Intent object, for chaining multiple calls
6942 * into a single statement.
6943 *
6944 * @see #hasCategory
6945 * @see #removeCategory
6946 */
6947 public Intent addCategory(String category) {
6948 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006949 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006950 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006951 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006952 return this;
6953 }
6954
6955 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006956 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006957 *
6958 * @param category The category to remove.
6959 *
6960 * @see #addCategory
6961 */
6962 public void removeCategory(String category) {
6963 if (mCategories != null) {
6964 mCategories.remove(category);
6965 if (mCategories.size() == 0) {
6966 mCategories = null;
6967 }
6968 }
6969 }
6970
6971 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006972 * Set a selector for this Intent. This is a modification to the kinds of
6973 * things the Intent will match. If the selector is set, it will be used
6974 * when trying to find entities that can handle the Intent, instead of the
6975 * main contents of the Intent. This allows you build an Intent containing
6976 * a generic protocol while targeting it more specifically.
6977 *
6978 * <p>An example of where this may be used is with things like
6979 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6980 * Intent that will launch the Browser application. However, the correct
6981 * main entry point of an application is actually {@link #ACTION_MAIN}
6982 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6983 * used to specify the actual Activity to launch. If you launch the browser
6984 * with something different, undesired behavior may happen if the user has
6985 * previously or later launches it the normal way, since they do not match.
6986 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6987 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6988 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6989 *
6990 * <p>Setting a selector does not impact the behavior of
6991 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6992 * desired behavior of a selector -- it does not impact the base meaning
6993 * of the Intent, just what kinds of things will be matched against it
6994 * when determining who can handle it.</p>
6995 *
6996 * <p>You can not use both a selector and {@link #setPackage(String)} on
6997 * the same base Intent.</p>
6998 *
6999 * @param selector The desired selector Intent; set to null to not use
7000 * a special selector.
7001 */
7002 public void setSelector(Intent selector) {
7003 if (selector == this) {
7004 throw new IllegalArgumentException(
7005 "Intent being set as a selector of itself");
7006 }
7007 if (selector != null && mPackage != null) {
7008 throw new IllegalArgumentException(
7009 "Can't set selector when package name is already set");
7010 }
7011 mSelector = selector;
7012 }
7013
7014 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007015 * Set a {@link ClipData} associated with this Intent. This replaces any
7016 * previously set ClipData.
7017 *
7018 * <p>The ClipData in an intent is not used for Intent matching or other
7019 * such operations. Semantically it is like extras, used to transmit
7020 * additional data with the Intent. The main feature of using this over
7021 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7022 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7023 * items included in the clip data. This is useful, in particular, if
7024 * you want to transmit an Intent containing multiple <code>content:</code>
7025 * URIs for which the recipient may not have global permission to access the
7026 * content provider.
7027 *
7028 * <p>If the ClipData contains items that are themselves Intents, any
7029 * grant flags in those Intents will be ignored. Only the top-level flags
7030 * of the main Intent are respected, and will be applied to all Uri or
7031 * Intent items in the clip (or sub-items of the clip).
7032 *
7033 * <p>The MIME type, label, and icon in the ClipData object are not
7034 * directly used by Intent. Applications should generally rely on the
7035 * MIME type of the Intent itself, not what it may find in the ClipData.
7036 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007037 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007038 *
7039 * @param clip The new clip to set. May be null to clear the current clip.
7040 */
7041 public void setClipData(ClipData clip) {
7042 mClipData = clip;
7043 }
7044
7045 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007046 * This is NOT a secure mechanism to identify the user who sent the intent.
7047 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7048 * who sent the intent.
7049 * @hide
7050 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007051 public void prepareToLeaveUser(int userId) {
7052 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7053 // We want mContentUserHint to refer to the original user, so don't do anything.
7054 if (mContentUserHint == UserHandle.USER_CURRENT) {
7055 mContentUserHint = userId;
7056 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007057 }
7058
7059 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007060 * Add extended data to the intent. The name must include a package
7061 * prefix, for example the app com.android.contacts would use names
7062 * like "com.android.contacts.ShowAll".
7063 *
7064 * @param name The name of the extra data, with package prefix.
7065 * @param value The boolean data value.
7066 *
7067 * @return Returns the same Intent object, for chaining multiple calls
7068 * into a single statement.
7069 *
7070 * @see #putExtras
7071 * @see #removeExtra
7072 * @see #getBooleanExtra(String, boolean)
7073 */
7074 public Intent putExtra(String name, boolean value) {
7075 if (mExtras == null) {
7076 mExtras = new Bundle();
7077 }
7078 mExtras.putBoolean(name, value);
7079 return this;
7080 }
7081
7082 /**
7083 * Add extended data to the intent. The name must include a package
7084 * prefix, for example the app com.android.contacts would use names
7085 * like "com.android.contacts.ShowAll".
7086 *
7087 * @param name The name of the extra data, with package prefix.
7088 * @param value The byte data value.
7089 *
7090 * @return Returns the same Intent object, for chaining multiple calls
7091 * into a single statement.
7092 *
7093 * @see #putExtras
7094 * @see #removeExtra
7095 * @see #getByteExtra(String, byte)
7096 */
7097 public Intent putExtra(String name, byte value) {
7098 if (mExtras == null) {
7099 mExtras = new Bundle();
7100 }
7101 mExtras.putByte(name, value);
7102 return this;
7103 }
7104
7105 /**
7106 * Add extended data to the intent. The name must include a package
7107 * prefix, for example the app com.android.contacts would use names
7108 * like "com.android.contacts.ShowAll".
7109 *
7110 * @param name The name of the extra data, with package prefix.
7111 * @param value The char data value.
7112 *
7113 * @return Returns the same Intent object, for chaining multiple calls
7114 * into a single statement.
7115 *
7116 * @see #putExtras
7117 * @see #removeExtra
7118 * @see #getCharExtra(String, char)
7119 */
7120 public Intent putExtra(String name, char value) {
7121 if (mExtras == null) {
7122 mExtras = new Bundle();
7123 }
7124 mExtras.putChar(name, value);
7125 return this;
7126 }
7127
7128 /**
7129 * Add extended data to the intent. The name must include a package
7130 * prefix, for example the app com.android.contacts would use names
7131 * like "com.android.contacts.ShowAll".
7132 *
7133 * @param name The name of the extra data, with package prefix.
7134 * @param value The short data value.
7135 *
7136 * @return Returns the same Intent object, for chaining multiple calls
7137 * into a single statement.
7138 *
7139 * @see #putExtras
7140 * @see #removeExtra
7141 * @see #getShortExtra(String, short)
7142 */
7143 public Intent putExtra(String name, short value) {
7144 if (mExtras == null) {
7145 mExtras = new Bundle();
7146 }
7147 mExtras.putShort(name, value);
7148 return this;
7149 }
7150
7151 /**
7152 * Add extended data to the intent. The name must include a package
7153 * prefix, for example the app com.android.contacts would use names
7154 * like "com.android.contacts.ShowAll".
7155 *
7156 * @param name The name of the extra data, with package prefix.
7157 * @param value The integer data value.
7158 *
7159 * @return Returns the same Intent object, for chaining multiple calls
7160 * into a single statement.
7161 *
7162 * @see #putExtras
7163 * @see #removeExtra
7164 * @see #getIntExtra(String, int)
7165 */
7166 public Intent putExtra(String name, int value) {
7167 if (mExtras == null) {
7168 mExtras = new Bundle();
7169 }
7170 mExtras.putInt(name, value);
7171 return this;
7172 }
7173
7174 /**
7175 * Add extended data to the intent. The name must include a package
7176 * prefix, for example the app com.android.contacts would use names
7177 * like "com.android.contacts.ShowAll".
7178 *
7179 * @param name The name of the extra data, with package prefix.
7180 * @param value The long data value.
7181 *
7182 * @return Returns the same Intent object, for chaining multiple calls
7183 * into a single statement.
7184 *
7185 * @see #putExtras
7186 * @see #removeExtra
7187 * @see #getLongExtra(String, long)
7188 */
7189 public Intent putExtra(String name, long value) {
7190 if (mExtras == null) {
7191 mExtras = new Bundle();
7192 }
7193 mExtras.putLong(name, value);
7194 return this;
7195 }
7196
7197 /**
7198 * Add extended data to the intent. The name must include a package
7199 * prefix, for example the app com.android.contacts would use names
7200 * like "com.android.contacts.ShowAll".
7201 *
7202 * @param name The name of the extra data, with package prefix.
7203 * @param value The float data value.
7204 *
7205 * @return Returns the same Intent object, for chaining multiple calls
7206 * into a single statement.
7207 *
7208 * @see #putExtras
7209 * @see #removeExtra
7210 * @see #getFloatExtra(String, float)
7211 */
7212 public Intent putExtra(String name, float value) {
7213 if (mExtras == null) {
7214 mExtras = new Bundle();
7215 }
7216 mExtras.putFloat(name, value);
7217 return this;
7218 }
7219
7220 /**
7221 * Add extended data to the intent. The name must include a package
7222 * prefix, for example the app com.android.contacts would use names
7223 * like "com.android.contacts.ShowAll".
7224 *
7225 * @param name The name of the extra data, with package prefix.
7226 * @param value The double data value.
7227 *
7228 * @return Returns the same Intent object, for chaining multiple calls
7229 * into a single statement.
7230 *
7231 * @see #putExtras
7232 * @see #removeExtra
7233 * @see #getDoubleExtra(String, double)
7234 */
7235 public Intent putExtra(String name, double value) {
7236 if (mExtras == null) {
7237 mExtras = new Bundle();
7238 }
7239 mExtras.putDouble(name, value);
7240 return this;
7241 }
7242
7243 /**
7244 * Add extended data to the intent. The name must include a package
7245 * prefix, for example the app com.android.contacts would use names
7246 * like "com.android.contacts.ShowAll".
7247 *
7248 * @param name The name of the extra data, with package prefix.
7249 * @param value The String data value.
7250 *
7251 * @return Returns the same Intent object, for chaining multiple calls
7252 * into a single statement.
7253 *
7254 * @see #putExtras
7255 * @see #removeExtra
7256 * @see #getStringExtra(String)
7257 */
7258 public Intent putExtra(String name, String value) {
7259 if (mExtras == null) {
7260 mExtras = new Bundle();
7261 }
7262 mExtras.putString(name, value);
7263 return this;
7264 }
7265
7266 /**
7267 * Add extended data to the intent. The name must include a package
7268 * prefix, for example the app com.android.contacts would use names
7269 * like "com.android.contacts.ShowAll".
7270 *
7271 * @param name The name of the extra data, with package prefix.
7272 * @param value The CharSequence data value.
7273 *
7274 * @return Returns the same Intent object, for chaining multiple calls
7275 * into a single statement.
7276 *
7277 * @see #putExtras
7278 * @see #removeExtra
7279 * @see #getCharSequenceExtra(String)
7280 */
7281 public Intent putExtra(String name, CharSequence value) {
7282 if (mExtras == null) {
7283 mExtras = new Bundle();
7284 }
7285 mExtras.putCharSequence(name, value);
7286 return this;
7287 }
7288
7289 /**
7290 * Add extended data to the intent. The name must include a package
7291 * prefix, for example the app com.android.contacts would use names
7292 * like "com.android.contacts.ShowAll".
7293 *
7294 * @param name The name of the extra data, with package prefix.
7295 * @param value The Parcelable data value.
7296 *
7297 * @return Returns the same Intent object, for chaining multiple calls
7298 * into a single statement.
7299 *
7300 * @see #putExtras
7301 * @see #removeExtra
7302 * @see #getParcelableExtra(String)
7303 */
7304 public Intent putExtra(String name, Parcelable value) {
7305 if (mExtras == null) {
7306 mExtras = new Bundle();
7307 }
7308 mExtras.putParcelable(name, value);
7309 return this;
7310 }
7311
7312 /**
7313 * Add extended data to the intent. The name must include a package
7314 * prefix, for example the app com.android.contacts would use names
7315 * like "com.android.contacts.ShowAll".
7316 *
7317 * @param name The name of the extra data, with package prefix.
7318 * @param value The Parcelable[] data value.
7319 *
7320 * @return Returns the same Intent object, for chaining multiple calls
7321 * into a single statement.
7322 *
7323 * @see #putExtras
7324 * @see #removeExtra
7325 * @see #getParcelableArrayExtra(String)
7326 */
7327 public Intent putExtra(String name, Parcelable[] value) {
7328 if (mExtras == null) {
7329 mExtras = new Bundle();
7330 }
7331 mExtras.putParcelableArray(name, value);
7332 return this;
7333 }
7334
7335 /**
7336 * Add extended data to the intent. The name must include a package
7337 * prefix, for example the app com.android.contacts would use names
7338 * like "com.android.contacts.ShowAll".
7339 *
7340 * @param name The name of the extra data, with package prefix.
7341 * @param value The ArrayList<Parcelable> data value.
7342 *
7343 * @return Returns the same Intent object, for chaining multiple calls
7344 * into a single statement.
7345 *
7346 * @see #putExtras
7347 * @see #removeExtra
7348 * @see #getParcelableArrayListExtra(String)
7349 */
7350 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7351 if (mExtras == null) {
7352 mExtras = new Bundle();
7353 }
7354 mExtras.putParcelableArrayList(name, value);
7355 return this;
7356 }
7357
7358 /**
7359 * Add extended data to the intent. The name must include a package
7360 * prefix, for example the app com.android.contacts would use names
7361 * like "com.android.contacts.ShowAll".
7362 *
7363 * @param name The name of the extra data, with package prefix.
7364 * @param value The ArrayList<Integer> data value.
7365 *
7366 * @return Returns the same Intent object, for chaining multiple calls
7367 * into a single statement.
7368 *
7369 * @see #putExtras
7370 * @see #removeExtra
7371 * @see #getIntegerArrayListExtra(String)
7372 */
7373 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7374 if (mExtras == null) {
7375 mExtras = new Bundle();
7376 }
7377 mExtras.putIntegerArrayList(name, value);
7378 return this;
7379 }
7380
7381 /**
7382 * Add extended data to the intent. The name must include a package
7383 * prefix, for example the app com.android.contacts would use names
7384 * like "com.android.contacts.ShowAll".
7385 *
7386 * @param name The name of the extra data, with package prefix.
7387 * @param value The ArrayList<String> data value.
7388 *
7389 * @return Returns the same Intent object, for chaining multiple calls
7390 * into a single statement.
7391 *
7392 * @see #putExtras
7393 * @see #removeExtra
7394 * @see #getStringArrayListExtra(String)
7395 */
7396 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7397 if (mExtras == null) {
7398 mExtras = new Bundle();
7399 }
7400 mExtras.putStringArrayList(name, value);
7401 return this;
7402 }
7403
7404 /**
7405 * Add extended data to the intent. The name must include a package
7406 * prefix, for example the app com.android.contacts would use names
7407 * like "com.android.contacts.ShowAll".
7408 *
7409 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007410 * @param value The ArrayList<CharSequence> data value.
7411 *
7412 * @return Returns the same Intent object, for chaining multiple calls
7413 * into a single statement.
7414 *
7415 * @see #putExtras
7416 * @see #removeExtra
7417 * @see #getCharSequenceArrayListExtra(String)
7418 */
7419 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7420 if (mExtras == null) {
7421 mExtras = new Bundle();
7422 }
7423 mExtras.putCharSequenceArrayList(name, value);
7424 return this;
7425 }
7426
7427 /**
7428 * Add extended data to the intent. The name must include a package
7429 * prefix, for example the app com.android.contacts would use names
7430 * like "com.android.contacts.ShowAll".
7431 *
7432 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007433 * @param value The Serializable data value.
7434 *
7435 * @return Returns the same Intent object, for chaining multiple calls
7436 * into a single statement.
7437 *
7438 * @see #putExtras
7439 * @see #removeExtra
7440 * @see #getSerializableExtra(String)
7441 */
7442 public Intent putExtra(String name, Serializable value) {
7443 if (mExtras == null) {
7444 mExtras = new Bundle();
7445 }
7446 mExtras.putSerializable(name, value);
7447 return this;
7448 }
7449
7450 /**
7451 * Add extended data to the intent. The name must include a package
7452 * prefix, for example the app com.android.contacts would use names
7453 * like "com.android.contacts.ShowAll".
7454 *
7455 * @param name The name of the extra data, with package prefix.
7456 * @param value The boolean array data value.
7457 *
7458 * @return Returns the same Intent object, for chaining multiple calls
7459 * into a single statement.
7460 *
7461 * @see #putExtras
7462 * @see #removeExtra
7463 * @see #getBooleanArrayExtra(String)
7464 */
7465 public Intent putExtra(String name, boolean[] value) {
7466 if (mExtras == null) {
7467 mExtras = new Bundle();
7468 }
7469 mExtras.putBooleanArray(name, value);
7470 return this;
7471 }
7472
7473 /**
7474 * Add extended data to the intent. The name must include a package
7475 * prefix, for example the app com.android.contacts would use names
7476 * like "com.android.contacts.ShowAll".
7477 *
7478 * @param name The name of the extra data, with package prefix.
7479 * @param value The byte array data value.
7480 *
7481 * @return Returns the same Intent object, for chaining multiple calls
7482 * into a single statement.
7483 *
7484 * @see #putExtras
7485 * @see #removeExtra
7486 * @see #getByteArrayExtra(String)
7487 */
7488 public Intent putExtra(String name, byte[] value) {
7489 if (mExtras == null) {
7490 mExtras = new Bundle();
7491 }
7492 mExtras.putByteArray(name, value);
7493 return this;
7494 }
7495
7496 /**
7497 * Add extended data to the intent. The name must include a package
7498 * prefix, for example the app com.android.contacts would use names
7499 * like "com.android.contacts.ShowAll".
7500 *
7501 * @param name The name of the extra data, with package prefix.
7502 * @param value The short array data value.
7503 *
7504 * @return Returns the same Intent object, for chaining multiple calls
7505 * into a single statement.
7506 *
7507 * @see #putExtras
7508 * @see #removeExtra
7509 * @see #getShortArrayExtra(String)
7510 */
7511 public Intent putExtra(String name, short[] value) {
7512 if (mExtras == null) {
7513 mExtras = new Bundle();
7514 }
7515 mExtras.putShortArray(name, value);
7516 return this;
7517 }
7518
7519 /**
7520 * Add extended data to the intent. The name must include a package
7521 * prefix, for example the app com.android.contacts would use names
7522 * like "com.android.contacts.ShowAll".
7523 *
7524 * @param name The name of the extra data, with package prefix.
7525 * @param value The char array data value.
7526 *
7527 * @return Returns the same Intent object, for chaining multiple calls
7528 * into a single statement.
7529 *
7530 * @see #putExtras
7531 * @see #removeExtra
7532 * @see #getCharArrayExtra(String)
7533 */
7534 public Intent putExtra(String name, char[] value) {
7535 if (mExtras == null) {
7536 mExtras = new Bundle();
7537 }
7538 mExtras.putCharArray(name, value);
7539 return this;
7540 }
7541
7542 /**
7543 * Add extended data to the intent. The name must include a package
7544 * prefix, for example the app com.android.contacts would use names
7545 * like "com.android.contacts.ShowAll".
7546 *
7547 * @param name The name of the extra data, with package prefix.
7548 * @param value The int array data value.
7549 *
7550 * @return Returns the same Intent object, for chaining multiple calls
7551 * into a single statement.
7552 *
7553 * @see #putExtras
7554 * @see #removeExtra
7555 * @see #getIntArrayExtra(String)
7556 */
7557 public Intent putExtra(String name, int[] value) {
7558 if (mExtras == null) {
7559 mExtras = new Bundle();
7560 }
7561 mExtras.putIntArray(name, value);
7562 return this;
7563 }
7564
7565 /**
7566 * Add extended data to the intent. The name must include a package
7567 * prefix, for example the app com.android.contacts would use names
7568 * like "com.android.contacts.ShowAll".
7569 *
7570 * @param name The name of the extra data, with package prefix.
7571 * @param value The byte array data value.
7572 *
7573 * @return Returns the same Intent object, for chaining multiple calls
7574 * into a single statement.
7575 *
7576 * @see #putExtras
7577 * @see #removeExtra
7578 * @see #getLongArrayExtra(String)
7579 */
7580 public Intent putExtra(String name, long[] value) {
7581 if (mExtras == null) {
7582 mExtras = new Bundle();
7583 }
7584 mExtras.putLongArray(name, value);
7585 return this;
7586 }
7587
7588 /**
7589 * Add extended data to the intent. The name must include a package
7590 * prefix, for example the app com.android.contacts would use names
7591 * like "com.android.contacts.ShowAll".
7592 *
7593 * @param name The name of the extra data, with package prefix.
7594 * @param value The float array data value.
7595 *
7596 * @return Returns the same Intent object, for chaining multiple calls
7597 * into a single statement.
7598 *
7599 * @see #putExtras
7600 * @see #removeExtra
7601 * @see #getFloatArrayExtra(String)
7602 */
7603 public Intent putExtra(String name, float[] value) {
7604 if (mExtras == null) {
7605 mExtras = new Bundle();
7606 }
7607 mExtras.putFloatArray(name, value);
7608 return this;
7609 }
7610
7611 /**
7612 * Add extended data to the intent. The name must include a package
7613 * prefix, for example the app com.android.contacts would use names
7614 * like "com.android.contacts.ShowAll".
7615 *
7616 * @param name The name of the extra data, with package prefix.
7617 * @param value The double array data value.
7618 *
7619 * @return Returns the same Intent object, for chaining multiple calls
7620 * into a single statement.
7621 *
7622 * @see #putExtras
7623 * @see #removeExtra
7624 * @see #getDoubleArrayExtra(String)
7625 */
7626 public Intent putExtra(String name, double[] value) {
7627 if (mExtras == null) {
7628 mExtras = new Bundle();
7629 }
7630 mExtras.putDoubleArray(name, value);
7631 return this;
7632 }
7633
7634 /**
7635 * Add extended data to the intent. The name must include a package
7636 * prefix, for example the app com.android.contacts would use names
7637 * like "com.android.contacts.ShowAll".
7638 *
7639 * @param name The name of the extra data, with package prefix.
7640 * @param value The String array data value.
7641 *
7642 * @return Returns the same Intent object, for chaining multiple calls
7643 * into a single statement.
7644 *
7645 * @see #putExtras
7646 * @see #removeExtra
7647 * @see #getStringArrayExtra(String)
7648 */
7649 public Intent putExtra(String name, String[] value) {
7650 if (mExtras == null) {
7651 mExtras = new Bundle();
7652 }
7653 mExtras.putStringArray(name, value);
7654 return this;
7655 }
7656
7657 /**
7658 * Add extended data to the intent. The name must include a package
7659 * prefix, for example the app com.android.contacts would use names
7660 * like "com.android.contacts.ShowAll".
7661 *
7662 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007663 * @param value The CharSequence array data value.
7664 *
7665 * @return Returns the same Intent object, for chaining multiple calls
7666 * into a single statement.
7667 *
7668 * @see #putExtras
7669 * @see #removeExtra
7670 * @see #getCharSequenceArrayExtra(String)
7671 */
7672 public Intent putExtra(String name, CharSequence[] value) {
7673 if (mExtras == null) {
7674 mExtras = new Bundle();
7675 }
7676 mExtras.putCharSequenceArray(name, value);
7677 return this;
7678 }
7679
7680 /**
7681 * Add extended data to the intent. The name must include a package
7682 * prefix, for example the app com.android.contacts would use names
7683 * like "com.android.contacts.ShowAll".
7684 *
7685 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007686 * @param value The Bundle data value.
7687 *
7688 * @return Returns the same Intent object, for chaining multiple calls
7689 * into a single statement.
7690 *
7691 * @see #putExtras
7692 * @see #removeExtra
7693 * @see #getBundleExtra(String)
7694 */
7695 public Intent putExtra(String name, Bundle value) {
7696 if (mExtras == null) {
7697 mExtras = new Bundle();
7698 }
7699 mExtras.putBundle(name, value);
7700 return this;
7701 }
7702
7703 /**
7704 * Add extended data to the intent. The name must include a package
7705 * prefix, for example the app com.android.contacts would use names
7706 * like "com.android.contacts.ShowAll".
7707 *
7708 * @param name The name of the extra data, with package prefix.
7709 * @param value The IBinder data value.
7710 *
7711 * @return Returns the same Intent object, for chaining multiple calls
7712 * into a single statement.
7713 *
7714 * @see #putExtras
7715 * @see #removeExtra
7716 * @see #getIBinderExtra(String)
7717 *
7718 * @deprecated
7719 * @hide
7720 */
7721 @Deprecated
7722 public Intent putExtra(String name, IBinder value) {
7723 if (mExtras == null) {
7724 mExtras = new Bundle();
7725 }
7726 mExtras.putIBinder(name, value);
7727 return this;
7728 }
7729
7730 /**
7731 * Copy all extras in 'src' in to this intent.
7732 *
7733 * @param src Contains the extras to copy.
7734 *
7735 * @see #putExtra
7736 */
7737 public Intent putExtras(Intent src) {
7738 if (src.mExtras != null) {
7739 if (mExtras == null) {
7740 mExtras = new Bundle(src.mExtras);
7741 } else {
7742 mExtras.putAll(src.mExtras);
7743 }
7744 }
7745 return this;
7746 }
7747
7748 /**
7749 * Add a set of extended data to the intent. The keys must include a package
7750 * prefix, for example the app com.android.contacts would use names
7751 * like "com.android.contacts.ShowAll".
7752 *
7753 * @param extras The Bundle of extras to add to this intent.
7754 *
7755 * @see #putExtra
7756 * @see #removeExtra
7757 */
7758 public Intent putExtras(Bundle extras) {
7759 if (mExtras == null) {
7760 mExtras = new Bundle();
7761 }
7762 mExtras.putAll(extras);
7763 return this;
7764 }
7765
7766 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007767 * Completely replace the extras in the Intent with the extras in the
7768 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007769 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007770 * @param src The exact extras contained in this Intent are copied
7771 * into the target intent, replacing any that were previously there.
7772 */
7773 public Intent replaceExtras(Intent src) {
7774 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7775 return this;
7776 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007777
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007778 /**
7779 * Completely replace the extras in the Intent with the given Bundle of
7780 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007781 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007782 * @param extras The new set of extras in the Intent, or null to erase
7783 * all extras.
7784 */
7785 public Intent replaceExtras(Bundle extras) {
7786 mExtras = extras != null ? new Bundle(extras) : null;
7787 return this;
7788 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007789
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007790 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007791 * Remove extended data from the intent.
7792 *
7793 * @see #putExtra
7794 */
7795 public void removeExtra(String name) {
7796 if (mExtras != null) {
7797 mExtras.remove(name);
7798 if (mExtras.size() == 0) {
7799 mExtras = null;
7800 }
7801 }
7802 }
7803
7804 /**
7805 * Set special flags controlling how this intent is handled. Most values
7806 * here depend on the type of component being executed by the Intent,
7807 * specifically the FLAG_ACTIVITY_* flags are all for use with
7808 * {@link Context#startActivity Context.startActivity()} and the
7809 * FLAG_RECEIVER_* flags are all for use with
7810 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7811 *
Scott Main7aee61f2011-02-08 11:25:01 -08007812 * <p>See the
7813 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7814 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007815 * the behavior of your application.
7816 *
7817 * @param flags The desired flags.
7818 *
7819 * @return Returns the same Intent object, for chaining multiple calls
7820 * into a single statement.
7821 *
7822 * @see #getFlags
7823 * @see #addFlags
7824 *
7825 * @see #FLAG_GRANT_READ_URI_PERMISSION
7826 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007827 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7828 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007829 * @see #FLAG_DEBUG_LOG_RESOLUTION
7830 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007831 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007832 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007833 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007834 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007835 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7836 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007837 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007839 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007840 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007841 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007842 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007843 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007844 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7845 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007846 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007847 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007848 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007849 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7850 */
7851 public Intent setFlags(int flags) {
7852 mFlags = flags;
7853 return this;
7854 }
7855
7856 /**
7857 * Add additional flags to the intent (or with existing flags
7858 * value).
7859 *
7860 * @param flags The new flags to set.
7861 *
7862 * @return Returns the same Intent object, for chaining multiple calls
7863 * into a single statement.
7864 *
7865 * @see #setFlags
7866 */
7867 public Intent addFlags(int flags) {
7868 mFlags |= flags;
7869 return this;
7870 }
7871
7872 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007873 * (Usually optional) Set an explicit application package name that limits
7874 * the components this Intent will resolve to. If left to the default
7875 * value of null, all components in all applications will considered.
7876 * If non-null, the Intent can only match the components in the given
7877 * application package.
7878 *
7879 * @param packageName The name of the application package to handle the
7880 * intent, or null to allow any application package.
7881 *
7882 * @return Returns the same Intent object, for chaining multiple calls
7883 * into a single statement.
7884 *
7885 * @see #getPackage
7886 * @see #resolveActivity
7887 */
7888 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007889 if (packageName != null && mSelector != null) {
7890 throw new IllegalArgumentException(
7891 "Can't set package name when selector is already set");
7892 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007893 mPackage = packageName;
7894 return this;
7895 }
7896
7897 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007898 * (Usually optional) Explicitly set the component to handle the intent.
7899 * If left with the default value of null, the system will determine the
7900 * appropriate class to use based on the other fields (action, data,
7901 * type, categories) in the Intent. If this class is defined, the
7902 * specified class will always be used regardless of the other fields. You
7903 * should only set this value when you know you absolutely want a specific
7904 * class to be used; otherwise it is better to let the system find the
7905 * appropriate class so that you will respect the installed applications
7906 * and user preferences.
7907 *
7908 * @param component The name of the application component to handle the
7909 * intent, or null to let the system find one for you.
7910 *
7911 * @return Returns the same Intent object, for chaining multiple calls
7912 * into a single statement.
7913 *
7914 * @see #setClass
7915 * @see #setClassName(Context, String)
7916 * @see #setClassName(String, String)
7917 * @see #getComponent
7918 * @see #resolveActivity
7919 */
7920 public Intent setComponent(ComponentName component) {
7921 mComponent = component;
7922 return this;
7923 }
7924
7925 /**
7926 * Convenience for calling {@link #setComponent} with an
7927 * explicit class name.
7928 *
7929 * @param packageContext A Context of the application package implementing
7930 * this class.
7931 * @param className The name of a class inside of the application package
7932 * that will be used as the component for this Intent.
7933 *
7934 * @return Returns the same Intent object, for chaining multiple calls
7935 * into a single statement.
7936 *
7937 * @see #setComponent
7938 * @see #setClass
7939 */
7940 public Intent setClassName(Context packageContext, String className) {
7941 mComponent = new ComponentName(packageContext, className);
7942 return this;
7943 }
7944
7945 /**
7946 * Convenience for calling {@link #setComponent} with an
7947 * explicit application package name and class name.
7948 *
7949 * @param packageName The name of the package implementing the desired
7950 * component.
7951 * @param className The name of a class inside of the application package
7952 * that will be used as the component for this Intent.
7953 *
7954 * @return Returns the same Intent object, for chaining multiple calls
7955 * into a single statement.
7956 *
7957 * @see #setComponent
7958 * @see #setClass
7959 */
7960 public Intent setClassName(String packageName, String className) {
7961 mComponent = new ComponentName(packageName, className);
7962 return this;
7963 }
7964
7965 /**
7966 * Convenience for calling {@link #setComponent(ComponentName)} with the
7967 * name returned by a {@link Class} object.
7968 *
7969 * @param packageContext A Context of the application package implementing
7970 * this class.
7971 * @param cls The class name to set, equivalent to
7972 * <code>setClassName(context, cls.getName())</code>.
7973 *
7974 * @return Returns the same Intent object, for chaining multiple calls
7975 * into a single statement.
7976 *
7977 * @see #setComponent
7978 */
7979 public Intent setClass(Context packageContext, Class<?> cls) {
7980 mComponent = new ComponentName(packageContext, cls);
7981 return this;
7982 }
7983
7984 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007985 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7986 * used as a hint to the receiver for animations and the like. Null means that there
7987 * is no source bounds.
7988 */
7989 public void setSourceBounds(Rect r) {
7990 if (r != null) {
7991 mSourceBounds = new Rect(r);
7992 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007993 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007994 }
7995 }
7996
Tor Norbyed9273d62013-05-30 15:59:53 -07007997 /** @hide */
7998 @IntDef(flag = true,
7999 value = {
8000 FILL_IN_ACTION,
8001 FILL_IN_DATA,
8002 FILL_IN_CATEGORIES,
8003 FILL_IN_COMPONENT,
8004 FILL_IN_PACKAGE,
8005 FILL_IN_SOURCE_BOUNDS,
8006 FILL_IN_SELECTOR,
8007 FILL_IN_CLIP_DATA
8008 })
8009 @Retention(RetentionPolicy.SOURCE)
8010 public @interface FillInFlags {}
8011
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008012 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008013 * Use with {@link #fillIn} to allow the current action value to be
8014 * overwritten, even if it is already set.
8015 */
8016 public static final int FILL_IN_ACTION = 1<<0;
8017
8018 /**
8019 * Use with {@link #fillIn} to allow the current data or type value
8020 * overwritten, even if it is already set.
8021 */
8022 public static final int FILL_IN_DATA = 1<<1;
8023
8024 /**
8025 * Use with {@link #fillIn} to allow the current categories to be
8026 * overwritten, even if they are already set.
8027 */
8028 public static final int FILL_IN_CATEGORIES = 1<<2;
8029
8030 /**
8031 * Use with {@link #fillIn} to allow the current component value to be
8032 * overwritten, even if it is already set.
8033 */
8034 public static final int FILL_IN_COMPONENT = 1<<3;
8035
8036 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008037 * Use with {@link #fillIn} to allow the current package value to be
8038 * overwritten, even if it is already set.
8039 */
8040 public static final int FILL_IN_PACKAGE = 1<<4;
8041
8042 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008043 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008044 * overwritten, even if it is already set.
8045 */
8046 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8047
8048 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008049 * Use with {@link #fillIn} to allow the current selector to be
8050 * overwritten, even if it is already set.
8051 */
8052 public static final int FILL_IN_SELECTOR = 1<<6;
8053
8054 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008055 * Use with {@link #fillIn} to allow the current ClipData to be
8056 * overwritten, even if it is already set.
8057 */
8058 public static final int FILL_IN_CLIP_DATA = 1<<7;
8059
8060 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008061 * Copy the contents of <var>other</var> in to this object, but only
8062 * where fields are not defined by this object. For purposes of a field
8063 * being defined, the following pieces of data in the Intent are
8064 * considered to be separate fields:
8065 *
8066 * <ul>
8067 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008068 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008069 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8070 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008071 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008072 * <li> component, as set by {@link #setComponent(ComponentName)} or
8073 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008074 * <li> source bounds, as set by {@link #setSourceBounds}.
8075 * <li> selector, as set by {@link #setSelector(Intent)}.
8076 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008077 * <li> each top-level name in the associated extras.
8078 * </ul>
8079 *
8080 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008081 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008082 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8083 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8084 * the restriction where the corresponding field will not be replaced if
8085 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008086 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008087 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8088 * is explicitly specified. The selector will only be copied if
8089 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008090 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008091 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8092 * and Intent B with {action="gotit", data-type="some/thing",
8093 * categories="one","two"}.
8094 *
8095 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8096 * containing: {action="gotit", data-type="some/thing",
8097 * categories="bar"}.
8098 *
8099 * @param other Another Intent whose values are to be used to fill in
8100 * the current one.
8101 * @param flags Options to control which fields can be filled in.
8102 *
8103 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008104 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008105 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8106 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8107 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008108 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008109 @FillInFlags
8110 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008111 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008112 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008113 if (other.mAction != null
8114 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008115 mAction = other.mAction;
8116 changes |= FILL_IN_ACTION;
8117 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008118 if ((other.mData != null || other.mType != null)
8119 && ((mData == null && mType == null)
8120 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008121 mData = other.mData;
8122 mType = other.mType;
8123 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008124 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008125 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008126 if (other.mCategories != null
8127 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008128 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008129 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008130 }
8131 changes |= FILL_IN_CATEGORIES;
8132 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008133 if (other.mPackage != null
8134 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008135 // Only do this if mSelector is not set.
8136 if (mSelector == null) {
8137 mPackage = other.mPackage;
8138 changes |= FILL_IN_PACKAGE;
8139 }
8140 }
8141 // Selector is special: it can only be set if explicitly allowed,
8142 // for the same reason as the component name.
8143 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8144 if (mPackage == null) {
8145 mSelector = new Intent(other.mSelector);
8146 mPackage = null;
8147 changes |= FILL_IN_SELECTOR;
8148 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008149 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008150 if (other.mClipData != null
8151 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8152 mClipData = other.mClipData;
8153 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008154 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008155 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008156 // Component is special: it can -only- be set if explicitly allowed,
8157 // since otherwise the sender could force the intent somewhere the
8158 // originator didn't intend.
8159 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008160 mComponent = other.mComponent;
8161 changes |= FILL_IN_COMPONENT;
8162 }
8163 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008164 if (other.mSourceBounds != null
8165 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8166 mSourceBounds = new Rect(other.mSourceBounds);
8167 changes |= FILL_IN_SOURCE_BOUNDS;
8168 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008169 if (mExtras == null) {
8170 if (other.mExtras != null) {
8171 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008172 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008173 }
8174 } else if (other.mExtras != null) {
8175 try {
8176 Bundle newb = new Bundle(other.mExtras);
8177 newb.putAll(mExtras);
8178 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008179 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008180 } catch (RuntimeException e) {
8181 // Modifying the extras can cause us to unparcel the contents
8182 // of the bundle, and if we do this in the system process that
8183 // may fail. We really should handle this (i.e., the Bundle
8184 // impl shouldn't be on top of a plain map), but for now just
8185 // ignore it and keep the original contents. :(
8186 Log.w("Intent", "Failure filling in extras", e);
8187 }
8188 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008189 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8190 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8191 mContentUserHint = other.mContentUserHint;
8192 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008193 return changes;
8194 }
8195
8196 /**
8197 * Wrapper class holding an Intent and implementing comparisons on it for
8198 * the purpose of filtering. The class implements its
8199 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8200 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8201 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8202 * on the wrapped Intent.
8203 */
8204 public static final class FilterComparison {
8205 private final Intent mIntent;
8206 private final int mHashCode;
8207
8208 public FilterComparison(Intent intent) {
8209 mIntent = intent;
8210 mHashCode = intent.filterHashCode();
8211 }
8212
8213 /**
8214 * Return the Intent that this FilterComparison represents.
8215 * @return Returns the Intent held by the FilterComparison. Do
8216 * not modify!
8217 */
8218 public Intent getIntent() {
8219 return mIntent;
8220 }
8221
8222 @Override
8223 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008224 if (obj instanceof FilterComparison) {
8225 Intent other = ((FilterComparison)obj).mIntent;
8226 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008227 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008228 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008229 }
8230
8231 @Override
8232 public int hashCode() {
8233 return mHashCode;
8234 }
8235 }
8236
8237 /**
8238 * Determine if two intents are the same for the purposes of intent
8239 * resolution (filtering). That is, if their action, data, type,
8240 * class, and categories are the same. This does <em>not</em> compare
8241 * any extra data included in the intents.
8242 *
8243 * @param other The other Intent to compare against.
8244 *
8245 * @return Returns true if action, data, type, class, and categories
8246 * are the same.
8247 */
8248 public boolean filterEquals(Intent other) {
8249 if (other == null) {
8250 return false;
8251 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008252 if (!Objects.equals(this.mAction, other.mAction)) return false;
8253 if (!Objects.equals(this.mData, other.mData)) return false;
8254 if (!Objects.equals(this.mType, other.mType)) return false;
8255 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8256 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8257 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008258
8259 return true;
8260 }
8261
8262 /**
8263 * Generate hash code that matches semantics of filterEquals().
8264 *
8265 * @return Returns the hash value of the action, data, type, class, and
8266 * categories.
8267 *
8268 * @see #filterEquals
8269 */
8270 public int filterHashCode() {
8271 int code = 0;
8272 if (mAction != null) {
8273 code += mAction.hashCode();
8274 }
8275 if (mData != null) {
8276 code += mData.hashCode();
8277 }
8278 if (mType != null) {
8279 code += mType.hashCode();
8280 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008281 if (mPackage != null) {
8282 code += mPackage.hashCode();
8283 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008284 if (mComponent != null) {
8285 code += mComponent.hashCode();
8286 }
8287 if (mCategories != null) {
8288 code += mCategories.hashCode();
8289 }
8290 return code;
8291 }
8292
8293 @Override
8294 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008295 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008296
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008297 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008298 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008299 b.append(" }");
8300
8301 return b.toString();
8302 }
8303
8304 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008305 public String toInsecureString() {
8306 StringBuilder b = new StringBuilder(128);
8307
8308 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008309 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008310 b.append(" }");
8311
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008312 return b.toString();
8313 }
Romain Guy4969af72009-06-17 10:53:19 -07008314
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008315 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008316 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008317 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008318
8319 b.append("Intent { ");
8320 toShortString(b, false, true, true, true);
8321 b.append(" }");
8322
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008323 return b.toString();
8324 }
8325
8326 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008327 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8328 StringBuilder b = new StringBuilder(128);
8329 toShortString(b, secure, comp, extras, clip);
8330 return b.toString();
8331 }
8332
8333 /** @hide */
8334 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8335 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008336 boolean first = true;
8337 if (mAction != null) {
8338 b.append("act=").append(mAction);
8339 first = false;
8340 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008341 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008342 if (!first) {
8343 b.append(' ');
8344 }
8345 first = false;
8346 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008347 for (int i=0; i<mCategories.size(); i++) {
8348 if (i > 0) b.append(',');
8349 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008350 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008351 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008352 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008353 if (mData != null) {
8354 if (!first) {
8355 b.append(' ');
8356 }
8357 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008358 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008359 if (secure) {
8360 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008361 } else {
8362 b.append(mData);
8363 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008364 }
8365 if (mType != null) {
8366 if (!first) {
8367 b.append(' ');
8368 }
8369 first = false;
8370 b.append("typ=").append(mType);
8371 }
8372 if (mFlags != 0) {
8373 if (!first) {
8374 b.append(' ');
8375 }
8376 first = false;
8377 b.append("flg=0x").append(Integer.toHexString(mFlags));
8378 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008379 if (mPackage != null) {
8380 if (!first) {
8381 b.append(' ');
8382 }
8383 first = false;
8384 b.append("pkg=").append(mPackage);
8385 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008386 if (comp && mComponent != null) {
8387 if (!first) {
8388 b.append(' ');
8389 }
8390 first = false;
8391 b.append("cmp=").append(mComponent.flattenToShortString());
8392 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008393 if (mSourceBounds != null) {
8394 if (!first) {
8395 b.append(' ');
8396 }
8397 first = false;
8398 b.append("bnds=").append(mSourceBounds.toShortString());
8399 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008400 if (mClipData != null) {
8401 if (!first) {
8402 b.append(' ');
8403 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008404 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008405 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008406 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008407 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008408 if (mClipData.getDescription() != null) {
8409 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8410 } else {
8411 first = true;
8412 }
8413 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008414 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008415 first = false;
8416 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008417 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008418 if (extras && mExtras != null) {
8419 if (!first) {
8420 b.append(' ');
8421 }
8422 first = false;
8423 b.append("(has extras)");
8424 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008425 if (mContentUserHint != UserHandle.USER_CURRENT) {
8426 if (!first) {
8427 b.append(' ');
8428 }
8429 first = false;
8430 b.append("u=").append(mContentUserHint);
8431 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008432 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008433 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008434 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008435 b.append("}");
8436 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008437 }
8438
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008439 /**
8440 * Call {@link #toUri} with 0 flags.
8441 * @deprecated Use {@link #toUri} instead.
8442 */
8443 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008444 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008445 return toUri(0);
8446 }
8447
8448 /**
8449 * Convert this Intent into a String holding a URI representation of it.
8450 * The returned URI string has been properly URI encoded, so it can be
8451 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8452 * Intent's data as the base URI, with an additional fragment describing
8453 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008454 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008455 * <p>You can convert the returned string back to an Intent with
8456 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008457 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008458 * @param flags Additional operating flags. Either 0,
8459 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008460 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008461 * @return Returns a URI encoding URI string describing the entire contents
8462 * of the Intent.
8463 */
8464 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008465 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008466 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8467 if (mPackage == null) {
8468 throw new IllegalArgumentException(
8469 "Intent must include an explicit package name to build an android-app: "
8470 + this);
8471 }
8472 uri.append("android-app://");
8473 uri.append(mPackage);
8474 String scheme = null;
8475 if (mData != null) {
8476 scheme = mData.getScheme();
8477 if (scheme != null) {
8478 uri.append('/');
8479 uri.append(scheme);
8480 String authority = mData.getEncodedAuthority();
8481 if (authority != null) {
8482 uri.append('/');
8483 uri.append(authority);
8484 String path = mData.getEncodedPath();
8485 if (path != null) {
8486 uri.append(path);
8487 }
8488 String queryParams = mData.getEncodedQuery();
8489 if (queryParams != null) {
8490 uri.append('?');
8491 uri.append(queryParams);
8492 }
8493 String fragment = mData.getEncodedFragment();
8494 if (fragment != null) {
8495 uri.append('#');
8496 uri.append(fragment);
8497 }
8498 }
8499 }
8500 }
8501 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8502 mPackage, flags);
8503 return uri.toString();
8504 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008505 String scheme = null;
8506 if (mData != null) {
8507 String data = mData.toString();
8508 if ((flags&URI_INTENT_SCHEME) != 0) {
8509 final int N = data.length();
8510 for (int i=0; i<N; i++) {
8511 char c = data.charAt(i);
8512 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8513 || c == '.' || c == '-') {
8514 continue;
8515 }
8516 if (c == ':' && i > 0) {
8517 // Valid scheme.
8518 scheme = data.substring(0, i);
8519 uri.append("intent:");
8520 data = data.substring(i+1);
8521 break;
8522 }
Tom Taylord4a47292009-12-21 13:59:18 -08008523
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008524 // No scheme.
8525 break;
8526 }
8527 }
8528 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008529
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008530 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8531 uri.append("intent:");
8532 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008533
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008534 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008535
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008536 return uri.toString();
8537 }
8538
8539 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8540 String defPackage, int flags) {
8541 StringBuilder frag = new StringBuilder(128);
8542
8543 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008544 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008545 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008546 // Note that for now we are not going to try to handle the
8547 // data part; not clear how to represent this as a URI, and
8548 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008549 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8550 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008551 }
8552
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008553 if (frag.length() > 0) {
8554 uri.append("#Intent;");
8555 uri.append(frag);
8556 uri.append("end");
8557 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008558 }
8559
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008560 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8561 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008562 if (scheme != null) {
8563 uri.append("scheme=").append(scheme).append(';');
8564 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008565 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008566 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008567 }
8568 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008569 for (int i=0; i<mCategories.size(); i++) {
8570 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008571 }
8572 }
8573 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008574 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 }
8576 if (mFlags != 0) {
8577 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8578 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008579 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008580 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8581 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008582 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008583 uri.append("component=").append(Uri.encode(
8584 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008585 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008586 if (mSourceBounds != null) {
8587 uri.append("sourceBounds=")
8588 .append(Uri.encode(mSourceBounds.flattenToString()))
8589 .append(';');
8590 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008591 if (mExtras != null) {
8592 for (String key : mExtras.keySet()) {
8593 final Object value = mExtras.get(key);
8594 char entryType =
8595 value instanceof String ? 'S' :
8596 value instanceof Boolean ? 'B' :
8597 value instanceof Byte ? 'b' :
8598 value instanceof Character ? 'c' :
8599 value instanceof Double ? 'd' :
8600 value instanceof Float ? 'f' :
8601 value instanceof Integer ? 'i' :
8602 value instanceof Long ? 'l' :
8603 value instanceof Short ? 's' :
8604 '\0';
8605
8606 if (entryType != '\0') {
8607 uri.append(entryType);
8608 uri.append('.');
8609 uri.append(Uri.encode(key));
8610 uri.append('=');
8611 uri.append(Uri.encode(value.toString()));
8612 uri.append(';');
8613 }
8614 }
8615 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008616 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008617
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008618 public int describeContents() {
8619 return (mExtras != null) ? mExtras.describeContents() : 0;
8620 }
8621
8622 public void writeToParcel(Parcel out, int flags) {
8623 out.writeString(mAction);
8624 Uri.writeToParcel(out, mData);
8625 out.writeString(mType);
8626 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008627 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008628 ComponentName.writeToParcel(mComponent, out);
8629
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008630 if (mSourceBounds != null) {
8631 out.writeInt(1);
8632 mSourceBounds.writeToParcel(out, flags);
8633 } else {
8634 out.writeInt(0);
8635 }
8636
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008637 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008638 final int N = mCategories.size();
8639 out.writeInt(N);
8640 for (int i=0; i<N; i++) {
8641 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008642 }
8643 } else {
8644 out.writeInt(0);
8645 }
8646
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008647 if (mSelector != null) {
8648 out.writeInt(1);
8649 mSelector.writeToParcel(out, flags);
8650 } else {
8651 out.writeInt(0);
8652 }
8653
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008654 if (mClipData != null) {
8655 out.writeInt(1);
8656 mClipData.writeToParcel(out, flags);
8657 } else {
8658 out.writeInt(0);
8659 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008660 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008661 out.writeBundle(mExtras);
8662 }
8663
8664 public static final Parcelable.Creator<Intent> CREATOR
8665 = new Parcelable.Creator<Intent>() {
8666 public Intent createFromParcel(Parcel in) {
8667 return new Intent(in);
8668 }
8669 public Intent[] newArray(int size) {
8670 return new Intent[size];
8671 }
8672 };
8673
Dianne Hackborneb034652009-09-07 00:49:58 -07008674 /** @hide */
8675 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008676 readFromParcel(in);
8677 }
8678
8679 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008680 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008681 mData = Uri.CREATOR.createFromParcel(in);
8682 mType = in.readString();
8683 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008684 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008685 mComponent = ComponentName.readFromParcel(in);
8686
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008687 if (in.readInt() != 0) {
8688 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8689 }
8690
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008691 int N = in.readInt();
8692 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008693 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008694 int i;
8695 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008696 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008697 }
8698 } else {
8699 mCategories = null;
8700 }
8701
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008702 if (in.readInt() != 0) {
8703 mSelector = new Intent(in);
8704 }
8705
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008706 if (in.readInt() != 0) {
8707 mClipData = new ClipData(in);
8708 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008709 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008710 mExtras = in.readBundle();
8711 }
8712
8713 /**
8714 * Parses the "intent" element (and its children) from XML and instantiates
8715 * an Intent object. The given XML parser should be located at the tag
8716 * where parsing should start (often named "intent"), from which the
8717 * basic action, data, type, and package and class name will be
8718 * retrieved. The function will then parse in to any child elements,
8719 * looking for <category android:name="xxx"> tags to add categories and
8720 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8721 * to the intent.
8722 *
8723 * @param resources The Resources to use when inflating resources.
8724 * @param parser The XML parser pointing at an "intent" tag.
8725 * @param attrs The AttributeSet interface for retrieving extended
8726 * attribute data at the current <var>parser</var> location.
8727 * @return An Intent object matching the XML data.
8728 * @throws XmlPullParserException If there was an XML parsing error.
8729 * @throws IOException If there was an I/O error.
8730 */
8731 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8732 throws XmlPullParserException, IOException {
8733 Intent intent = new Intent();
8734
8735 TypedArray sa = resources.obtainAttributes(attrs,
8736 com.android.internal.R.styleable.Intent);
8737
8738 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8739
8740 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8741 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8742 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8743
8744 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8745 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8746 if (packageName != null && className != null) {
8747 intent.setComponent(new ComponentName(packageName, className));
8748 }
8749
8750 sa.recycle();
8751
8752 int outerDepth = parser.getDepth();
8753 int type;
8754 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8755 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8756 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8757 continue;
8758 }
8759
8760 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008761 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008762 sa = resources.obtainAttributes(attrs,
8763 com.android.internal.R.styleable.IntentCategory);
8764 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8765 sa.recycle();
8766
8767 if (cat != null) {
8768 intent.addCategory(cat);
8769 }
8770 XmlUtils.skipCurrentTag(parser);
8771
Craig Mautner21d24a22014-04-23 11:45:37 -07008772 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008773 if (intent.mExtras == null) {
8774 intent.mExtras = new Bundle();
8775 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008776 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008777 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008778
8779 } else {
8780 XmlUtils.skipCurrentTag(parser);
8781 }
8782 }
8783
8784 return intent;
8785 }
Nick Pellyccae4122012-01-09 14:12:58 -08008786
Craig Mautner21d24a22014-04-23 11:45:37 -07008787 /** @hide */
8788 public void saveToXml(XmlSerializer out) throws IOException {
8789 if (mAction != null) {
8790 out.attribute(null, ATTR_ACTION, mAction);
8791 }
8792 if (mData != null) {
8793 out.attribute(null, ATTR_DATA, mData.toString());
8794 }
8795 if (mType != null) {
8796 out.attribute(null, ATTR_TYPE, mType);
8797 }
8798 if (mComponent != null) {
8799 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8800 }
8801 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8802
8803 if (mCategories != null) {
8804 out.startTag(null, TAG_CATEGORIES);
8805 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8806 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8807 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008808 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008809 }
8810 }
8811
8812 /** @hide */
8813 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8814 XmlPullParserException {
8815 Intent intent = new Intent();
8816 final int outerDepth = in.getDepth();
8817
8818 int attrCount = in.getAttributeCount();
8819 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8820 final String attrName = in.getAttributeName(attrNdx);
8821 final String attrValue = in.getAttributeValue(attrNdx);
8822 if (ATTR_ACTION.equals(attrName)) {
8823 intent.setAction(attrValue);
8824 } else if (ATTR_DATA.equals(attrName)) {
8825 intent.setData(Uri.parse(attrValue));
8826 } else if (ATTR_TYPE.equals(attrName)) {
8827 intent.setType(attrValue);
8828 } else if (ATTR_COMPONENT.equals(attrName)) {
8829 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8830 } else if (ATTR_FLAGS.equals(attrName)) {
8831 intent.setFlags(Integer.valueOf(attrValue, 16));
8832 } else {
8833 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8834 }
8835 }
8836
8837 int event;
8838 String name;
8839 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8840 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8841 if (event == XmlPullParser.START_TAG) {
8842 name = in.getName();
8843 if (TAG_CATEGORIES.equals(name)) {
8844 attrCount = in.getAttributeCount();
8845 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8846 intent.addCategory(in.getAttributeValue(attrNdx));
8847 }
8848 } else {
8849 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8850 XmlUtils.skipCurrentTag(in);
8851 }
8852 }
8853 }
8854
8855 return intent;
8856 }
8857
Nick Pellyccae4122012-01-09 14:12:58 -08008858 /**
8859 * Normalize a MIME data type.
8860 *
8861 * <p>A normalized MIME type has white-space trimmed,
8862 * content-type parameters removed, and is lower-case.
8863 * This aligns the type with Android best practices for
8864 * intent filtering.
8865 *
8866 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8867 * "text/x-vCard" becomes "text/x-vcard".
8868 *
8869 * <p>All MIME types received from outside Android (such as user input,
8870 * or external sources like Bluetooth, NFC, or the Internet) should
8871 * be normalized before they are used to create an Intent.
8872 *
8873 * @param type MIME data type to normalize
8874 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008875 * @see #setType
8876 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008877 */
8878 public static String normalizeMimeType(String type) {
8879 if (type == null) {
8880 return null;
8881 }
8882
Elliott Hughescb64d432013-08-02 10:00:44 -07008883 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008884
8885 final int semicolonIndex = type.indexOf(';');
8886 if (semicolonIndex != -1) {
8887 type = type.substring(0, semicolonIndex);
8888 }
8889 return type;
8890 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008891
8892 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008893 * Prepare this {@link Intent} to leave an app process.
8894 *
8895 * @hide
8896 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07008897 public void prepareToLeaveProcess(Context context) {
8898 final boolean leavingPackage = (mComponent == null)
8899 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
8900 prepareToLeaveProcess(leavingPackage);
8901 }
8902
8903 /**
8904 * Prepare this {@link Intent} to leave an app process.
8905 *
8906 * @hide
8907 */
8908 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008909 setAllowFds(false);
8910
8911 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008912 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008913 }
8914 if (mClipData != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008915 mClipData.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008916 }
8917
Jeff Sharkeya8b42782016-01-30 17:58:09 -07008918 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
8919 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008920 switch (mAction) {
8921 case ACTION_MEDIA_REMOVED:
8922 case ACTION_MEDIA_UNMOUNTED:
8923 case ACTION_MEDIA_CHECKING:
8924 case ACTION_MEDIA_NOFS:
8925 case ACTION_MEDIA_MOUNTED:
8926 case ACTION_MEDIA_SHARED:
8927 case ACTION_MEDIA_UNSHARED:
8928 case ACTION_MEDIA_BAD_REMOVAL:
8929 case ACTION_MEDIA_UNMOUNTABLE:
8930 case ACTION_MEDIA_EJECT:
8931 case ACTION_MEDIA_SCANNER_STARTED:
8932 case ACTION_MEDIA_SCANNER_FINISHED:
8933 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07008934 case ACTION_PACKAGE_NEEDS_VERIFICATION:
8935 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07008936 // Ignore legacy actions
8937 break;
8938 default:
8939 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008940 }
8941 }
8942 }
8943
8944 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008945 * @hide
8946 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008947 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07008948 // We just entered destination process, so we should be able to read all
8949 // parcelables inside.
8950 setDefusable(true);
8951
8952 if (mSelector != null) {
8953 mSelector.prepareToEnterProcess();
8954 }
8955 if (mClipData != null) {
8956 mClipData.prepareToEnterProcess();
8957 }
8958
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008959 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008960 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8961 fixUris(mContentUserHint);
8962 mContentUserHint = UserHandle.USER_CURRENT;
8963 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008964 }
8965 }
8966
8967 /**
8968 * @hide
8969 */
8970 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008971 Uri data = getData();
8972 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008973 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008974 }
8975 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008976 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008977 }
8978 String action = getAction();
8979 if (ACTION_SEND.equals(action)) {
8980 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8981 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008982 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008983 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008984 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008985 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8986 if (streams != null) {
8987 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8988 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008989 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008990 }
8991 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8992 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008993 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8994 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8995 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8996 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8997 if (output != null) {
8998 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8999 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009000 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009001 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009002
9003 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009004 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009005 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9006 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009007 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009008 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009009 * @hide
9010 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009011 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009012 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009013 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009014
9015 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009016 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009017
9018 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009019 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009020 // Inspect contained intents to see if we need to migrate extras. We
9021 // don't promote ClipData to the parent, since ChooserActivity will
9022 // already start the picked item as the caller, and we can't combine
9023 // the flags in a safe way.
9024
9025 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009026 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009027 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9028 if (intent != null) {
9029 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009030 }
9031 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009032 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009033 try {
9034 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9035 if (intents != null) {
9036 for (int i = 0; i < intents.length; i++) {
9037 final Intent intent = (Intent) intents[i];
9038 if (intent != null) {
9039 migrated |= intent.migrateExtraStreamToClipData();
9040 }
9041 }
9042 }
9043 } catch (ClassCastException e) {
9044 }
9045 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009046
9047 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009048 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009049 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9050 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9051 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9052 if (stream != null || text != null || htmlText != null) {
9053 final ClipData clipData = new ClipData(
9054 null, new String[] { getType() },
9055 new ClipData.Item(text, htmlText, null, stream));
9056 setClipData(clipData);
9057 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009058 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009059 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009060 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009061 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009062
9063 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009064 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009065 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9066 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9067 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9068 int num = -1;
9069 if (streams != null) {
9070 num = streams.size();
9071 }
9072 if (texts != null) {
9073 if (num >= 0 && num != texts.size()) {
9074 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009075 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009076 }
9077 num = texts.size();
9078 }
9079 if (htmlTexts != null) {
9080 if (num >= 0 && num != htmlTexts.size()) {
9081 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009082 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009083 }
9084 num = htmlTexts.size();
9085 }
9086 if (num > 0) {
9087 final ClipData clipData = new ClipData(
9088 null, new String[] { getType() },
9089 makeClipItem(streams, texts, htmlTexts, 0));
9090
9091 for (int i = 1; i < num; i++) {
9092 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9093 }
9094
9095 setClipData(clipData);
9096 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009097 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009098 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009099 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009100 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009101 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9102 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9103 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9104 final Uri output;
9105 try {
9106 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9107 } catch (ClassCastException e) {
9108 return false;
9109 }
9110 if (output != null) {
9111 setClipData(ClipData.newRawUri("", output));
9112 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9113 return true;
9114 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009115 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009116
9117 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009118 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009119
9120 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9121 ArrayList<String> htmlTexts, int which) {
9122 Uri uri = streams != null ? streams.get(which) : null;
9123 CharSequence text = texts != null ? texts.get(which) : null;
9124 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9125 return new ClipData.Item(text, htmlText, null, uri);
9126 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009127
9128 /** @hide */
9129 public boolean isDocument() {
9130 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9131 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009132}