blob: 4bde37809ee709106390f76ce4a81d8c2fa58fec [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
Dianne Hackborn221ea892013-08-04 16:50:16 -070019import android.content.pm.ApplicationInfo;
Adam Powell2ed547e2015-04-29 18:45:04 -070020import android.os.ResultReceiver;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080021import android.os.ShellCommand;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010022import android.provider.MediaStore;
Dianne Hackbornadd005c2013-07-17 18:43:12 -070023import android.util.ArraySet;
Jeff Sharkey846318a2014-04-04 12:12:41 -070024
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070025import org.xmlpull.v1.XmlPullParser;
26import org.xmlpull.v1.XmlPullParserException;
27
Tor Norbye7b9c9122013-05-30 16:48:33 -070028import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070029import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.annotation.SdkConstant;
Jose Lima73915cf2014-07-29 17:16:31 -070031import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.annotation.SdkConstant.SdkConstantType;
33import android.content.pm.ActivityInfo;
Jose Lima73915cf2014-07-29 17:16:31 -070034
Nicolas Prevotd85fc722014-04-16 19:52:08 +010035import static android.content.ContentProvider.maybeAddUserId;
Jose Lima73915cf2014-07-29 17:16:31 -070036
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.content.pm.PackageManager;
38import android.content.pm.ResolveInfo;
39import android.content.res.Resources;
40import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080041import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070042import android.net.Uri;
43import android.os.Bundle;
44import android.os.IBinder;
45import android.os.Parcel;
46import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000047import android.os.Process;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070048import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010049import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070050import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070051import android.provider.DocumentsProvider;
52import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070053import android.util.AttributeSet;
54import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080055
56import com.android.internal.util.XmlUtils;
Jose Lima73915cf2014-07-29 17:16:31 -070057
Craig Mautner21d24a22014-04-23 11:45:37 -070058import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059
60import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080061import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070063import java.lang.annotation.Retention;
64import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065import java.net.URISyntaxException;
66import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080067import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070068import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080069import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070070import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070071import java.util.Set;
72
73/**
74 * An intent is an abstract description of an operation to be performed. It
75 * can be used with {@link Context#startActivity(Intent) startActivity} to
76 * launch an {@link android.app.Activity},
77 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
78 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
79 * and {@link android.content.Context#startService} or
80 * {@link android.content.Context#bindService} to communicate with a
81 * background {@link android.app.Service}.
82 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070083 * <p>An Intent provides a facility for performing late runtime binding between the code in
84 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070085 * can be thought of as the glue between activities. It is basically a passive data structure
86 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070087 *
88 * <div class="special reference">
89 * <h3>Developer Guides</h3>
90 * <p>For information about how to create and resolve intents, read the
91 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
92 * developer guide.</p>
93 * </div>
94 *
95 * <a name="IntentStructure"></a>
96 * <h3>Intent Structure</h3>
97 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 *
99 * <ul>
100 * <li> <p><b>action</b> -- The general action to be performed, such as
101 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
102 * etc.</p>
103 * </li>
104 * <li> <p><b>data</b> -- The data to operate on, such as a person record
105 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
106 * </li>
107 * </ul>
108 *
109 *
110 * <p>Some examples of action/data pairs are:</p>
111 *
112 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * information about the person whose identifier is "1".</p>
115 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700116 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700117 * the phone dialer with the person filled in.</p>
118 * </li>
119 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
120 * the phone dialer with the given number filled in. Note how the
121 * VIEW action does what what is considered the most reasonable thing for
122 * a particular URI.</p>
123 * </li>
124 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
125 * the phone dialer with the given number filled in.</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * information about the person whose identifier is "1".</p>
129 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700130 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700131 * a list of people, which the user can browse through. This example is a
132 * typical top-level entry into the Contacts application, showing you the
133 * list of people. Selecting a particular person to view would result in a
134 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
135 * being used to start an activity to display that person.</p>
136 * </li>
137 * </ul>
138 *
139 * <p>In addition to these primary attributes, there are a number of secondary
140 * attributes that you can also include with an intent:</p>
141 *
142 * <ul>
143 * <li> <p><b>category</b> -- Gives additional information about the action
144 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
145 * appear in the Launcher as a top-level application, while
146 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
147 * of alternative actions the user can perform on a piece of data.</p>
148 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
149 * intent data. Normally the type is inferred from the data itself.
150 * By setting this attribute, you disable that evaluation and force
151 * an explicit type.</p>
152 * <li> <p><b>component</b> -- Specifies an explicit name of a component
153 * class to use for the intent. Normally this is determined by looking
154 * at the other information in the intent (the action, data/type, and
155 * categories) and matching that with a component that can handle it.
156 * If this attribute is set then none of the evaluation is performed,
157 * and this component is used exactly as is. By specifying this attribute,
158 * all of the other Intent attributes become optional.</p>
159 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
160 * This can be used to provide extended information to the component.
161 * For example, if we have a action to send an e-mail message, we could
162 * also include extra pieces of data here to supply a subject, body,
163 * etc.</p>
164 * </ul>
165 *
166 * <p>Here are some examples of other operations you can specify as intents
167 * using these additional parameters:</p>
168 *
169 * <ul>
170 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
171 * Launch the home screen.</p>
172 * </li>
173 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
174 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
175 * vnd.android.cursor.item/phone}</i></b>
176 * -- Display the list of people's phone numbers, allowing the user to
177 * browse through them and pick one and return it to the parent activity.</p>
178 * </li>
179 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
180 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
181 * -- Display all pickers for data that can be opened with
182 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
183 * allowing the user to pick one of them and then some data inside of it
184 * and returning the resulting URI to the caller. This can be used,
185 * for example, in an e-mail application to allow the user to pick some
186 * data to include as an attachment.</p>
187 * </li>
188 * </ul>
189 *
190 * <p>There are a variety of standard Intent action and category constants
191 * defined in the Intent class, but applications can also define their own.
192 * These strings use java style scoping, to ensure they are unique -- for
193 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700194 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700195 *
196 * <p>Put together, the set of actions, data types, categories, and extra data
197 * defines a language for the system allowing for the expression of phrases
198 * such as "call john smith's cell". As applications are added to the system,
199 * they can extend this language by adding new actions, types, and categories, or
200 * they can modify the behavior of existing phrases by supplying their own
201 * activities that handle them.</p>
202 *
203 * <a name="IntentResolution"></a>
204 * <h3>Intent Resolution</h3>
205 *
206 * <p>There are two primary forms of intents you will use.
207 *
208 * <ul>
209 * <li> <p><b>Explicit Intents</b> have specified a component (via
210 * {@link #setComponent} or {@link #setClass}), which provides the exact
211 * class to be run. Often these will not include any other information,
212 * simply being a way for an application to launch various internal
213 * activities it has as the user interacts with the application.
214 *
215 * <li> <p><b>Implicit Intents</b> have not specified a component;
216 * instead, they must include enough information for the system to
217 * determine which of the available components is best to run for that
218 * intent.
219 * </ul>
220 *
221 * <p>When using implicit intents, given such an arbitrary intent we need to
222 * know what to do with it. This is handled by the process of <em>Intent
223 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
224 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
225 * more activities/receivers) that can handle it.</p>
226 *
227 * <p>The intent resolution mechanism basically revolves around matching an
228 * Intent against all of the &lt;intent-filter&gt; descriptions in the
229 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
230 * objects explicitly registered with {@link Context#registerReceiver}.) More
231 * details on this can be found in the documentation on the {@link
232 * IntentFilter} class.</p>
233 *
234 * <p>There are three pieces of information in the Intent that are used for
235 * resolution: the action, type, and category. Using this information, a query
236 * is done on the {@link PackageManager} for a component that can handle the
237 * intent. The appropriate component is determined based on the intent
238 * information supplied in the <code>AndroidManifest.xml</code> file as
239 * follows:</p>
240 *
241 * <ul>
242 * <li> <p>The <b>action</b>, if given, must be listed by the component as
243 * one it handles.</p>
244 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
245 * already supplied in the Intent. Like the action, if a type is
246 * included in the intent (either explicitly or implicitly in its
247 * data), then this must be listed by the component as one it handles.</p>
248 * <li> For data that is not a <code>content:</code> URI and where no explicit
249 * type is included in the Intent, instead the <b>scheme</b> of the
250 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
251 * considered. Again like the action, if we are matching a scheme it
252 * must be listed by the component as one it can handle.
253 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
254 * by the activity as categories it handles. That is, if you include
255 * the categories {@link #CATEGORY_LAUNCHER} and
256 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
257 * with an intent that lists <em>both</em> of those categories.
258 * Activities will very often need to support the
259 * {@link #CATEGORY_DEFAULT} so that they can be found by
260 * {@link Context#startActivity Context.startActivity()}.</p>
261 * </ul>
262 *
263 * <p>For example, consider the Note Pad sample application that
264 * allows user to browse through a list of notes data and view details about
265 * individual items. Text in italics indicate places were you would replace a
266 * name with one specific to your own package.</p>
267 *
268 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
269 * package="<i>com.android.notepad</i>"&gt;
270 * &lt;application android:icon="@drawable/app_notes"
271 * android:label="@string/app_name"&gt;
272 *
273 * &lt;provider class=".NotePadProvider"
274 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
275 *
276 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
277 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700278 * &lt;action android:name="android.intent.action.MAIN" /&gt;
279 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700280 * &lt;/intent-filter&gt;
281 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700282 * &lt;action android:name="android.intent.action.VIEW" /&gt;
283 * &lt;action android:name="android.intent.action.EDIT" /&gt;
284 * &lt;action android:name="android.intent.action.PICK" /&gt;
285 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
286 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700289 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
290 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
291 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700292 * &lt;/intent-filter&gt;
293 * &lt;/activity&gt;
294 *
295 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
296 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700297 * &lt;action android:name="android.intent.action.VIEW" /&gt;
298 * &lt;action android:name="android.intent.action.EDIT" /&gt;
299 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
300 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;
302 *
303 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700304 * &lt;action android:name="android.intent.action.INSERT" /&gt;
305 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
306 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700307 * &lt;/intent-filter&gt;
308 *
309 * &lt;/activity&gt;
310 *
311 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
312 * android:theme="@android:style/Theme.Dialog"&gt;
313 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700314 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
315 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
317 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
318 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700319 * &lt;/intent-filter&gt;
320 * &lt;/activity&gt;
321 *
322 * &lt;/application&gt;
323 * &lt;/manifest&gt;</pre>
324 *
325 * <p>The first activity,
326 * <code>com.android.notepad.NotesList</code>, serves as our main
327 * entry into the app. It can do three things as described by its three intent
328 * templates:
329 * <ol>
330 * <li><pre>
331 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700332 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
333 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700334 * &lt;/intent-filter&gt;</pre>
335 * <p>This provides a top-level entry into the NotePad application: the standard
336 * MAIN action is a main entry point (not requiring any other information in
337 * the Intent), and the LAUNCHER category says that this entry point should be
338 * listed in the application launcher.</p>
339 * <li><pre>
340 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700341 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
342 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
343 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
344 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
345 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700346 * &lt;/intent-filter&gt;</pre>
347 * <p>This declares the things that the activity can do on a directory of
348 * notes. The type being supported is given with the &lt;type&gt; tag, where
349 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
350 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
351 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
352 * The activity allows the user to view or edit the directory of data (via
353 * the VIEW and EDIT actions), or to pick a particular note and return it
354 * to the caller (via the PICK action). Note also the DEFAULT category
355 * supplied here: this is <em>required</em> for the
356 * {@link Context#startActivity Context.startActivity} method to resolve your
357 * activity when its component name is not explicitly specified.</p>
358 * <li><pre>
359 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700360 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
361 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
362 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700363 * &lt;/intent-filter&gt;</pre>
364 * <p>This filter describes the ability return to the caller a note selected by
365 * the user without needing to know where it came from. The data type
366 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
367 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
368 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
369 * The GET_CONTENT action is similar to the PICK action, where the activity
370 * will return to its caller a piece of data selected by the user. Here,
371 * however, the caller specifies the type of data they desire instead of
372 * the type of data the user will be picking from.</p>
373 * </ol>
374 *
375 * <p>Given these capabilities, the following intents will resolve to the
376 * NotesList activity:</p>
377 *
378 * <ul>
379 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
380 * activities that can be used as top-level entry points into an
381 * application.</p>
382 * <li> <p><b>{ action=android.app.action.MAIN,
383 * category=android.app.category.LAUNCHER }</b> is the actual intent
384 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700385 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700386 * data=content://com.google.provider.NotePad/notes }</b>
387 * displays a list of all the notes under
388 * "content://com.google.provider.NotePad/notes", which
389 * the user can browse through and see the details on.</p>
390 * <li> <p><b>{ action=android.app.action.PICK
391 * data=content://com.google.provider.NotePad/notes }</b>
392 * provides a list of the notes under
393 * "content://com.google.provider.NotePad/notes", from which
394 * the user can pick a note whose data URL is returned back to the caller.</p>
395 * <li> <p><b>{ action=android.app.action.GET_CONTENT
396 * type=vnd.android.cursor.item/vnd.google.note }</b>
397 * is similar to the pick action, but allows the caller to specify the
398 * kind of data they want back so that the system can find the appropriate
399 * activity to pick something of that data type.</p>
400 * </ul>
401 *
402 * <p>The second activity,
403 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
404 * note entry and allows them to edit it. It can do two things as described
405 * by its two intent templates:
406 * <ol>
407 * <li><pre>
408 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700409 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
410 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
411 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
412 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700413 * &lt;/intent-filter&gt;</pre>
414 * <p>The first, primary, purpose of this activity is to let the user interact
415 * with a single note, as decribed by the MIME type
416 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
417 * either VIEW a note or allow the user to EDIT it. Again we support the
418 * DEFAULT category to allow the activity to be launched without explicitly
419 * specifying its component.</p>
420 * <li><pre>
421 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700422 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
423 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
424 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700425 * &lt;/intent-filter&gt;</pre>
426 * <p>The secondary use of this activity is to insert a new note entry into
427 * an existing directory of notes. This is used when the user creates a new
428 * note: the INSERT action is executed on the directory of notes, causing
429 * this activity to run and have the user create the new note data which
430 * it then adds to the content provider.</p>
431 * </ol>
432 *
433 * <p>Given these capabilities, the following intents will resolve to the
434 * NoteEditor activity:</p>
435 *
436 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700437 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * shows the user the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.EDIT
441 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
442 * allows the user to edit the content of note <var>{ID}</var>.</p>
443 * <li> <p><b>{ action=android.app.action.INSERT
444 * data=content://com.google.provider.NotePad/notes }</b>
445 * creates a new, empty note in the notes list at
446 * "content://com.google.provider.NotePad/notes"
447 * and allows the user to edit it. If they keep their changes, the URI
448 * of the newly created note is returned to the caller.</p>
449 * </ul>
450 *
451 * <p>The last activity,
452 * <code>com.android.notepad.TitleEditor</code>, allows the user to
453 * edit the title of a note. This could be implemented as a class that the
454 * application directly invokes (by explicitly setting its component in
455 * the Intent), but here we show a way you can publish alternative
456 * operations on existing data:</p>
457 *
458 * <pre>
459 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700460 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
463 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
464 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700465 * &lt;/intent-filter&gt;</pre>
466 *
467 * <p>In the single intent template here, we
468 * have created our own private action called
469 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
470 * edit the title of a note. It must be invoked on a specific note
471 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
472 * view and edit actions, but here displays and edits the title contained
473 * in the note data.
474 *
475 * <p>In addition to supporting the default category as usual, our title editor
476 * also supports two other standard categories: ALTERNATIVE and
477 * SELECTED_ALTERNATIVE. Implementing
478 * these categories allows others to find the special action it provides
479 * without directly knowing about it, through the
480 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
481 * more often to build dynamic menu items with
482 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
483 * template here was also supply an explicit name for the template
484 * (via <code>android:label="@string/resolve_title"</code>) to better control
485 * what the user sees when presented with this activity as an alternative
486 * action to the data they are viewing.
487 *
488 * <p>Given these capabilities, the following intent will resolve to the
489 * TitleEditor activity:</p>
490 *
491 * <ul>
492 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
493 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
494 * displays and allows the user to edit the title associated
495 * with note <var>{ID}</var>.</p>
496 * </ul>
497 *
498 * <h3>Standard Activity Actions</h3>
499 *
500 * <p>These are the current standard actions that Intent defines for launching
501 * activities (usually through {@link Context#startActivity}. The most
502 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
503 * {@link #ACTION_EDIT}.
504 *
505 * <ul>
506 * <li> {@link #ACTION_MAIN}
507 * <li> {@link #ACTION_VIEW}
508 * <li> {@link #ACTION_ATTACH_DATA}
509 * <li> {@link #ACTION_EDIT}
510 * <li> {@link #ACTION_PICK}
511 * <li> {@link #ACTION_CHOOSER}
512 * <li> {@link #ACTION_GET_CONTENT}
513 * <li> {@link #ACTION_DIAL}
514 * <li> {@link #ACTION_CALL}
515 * <li> {@link #ACTION_SEND}
516 * <li> {@link #ACTION_SENDTO}
517 * <li> {@link #ACTION_ANSWER}
518 * <li> {@link #ACTION_INSERT}
519 * <li> {@link #ACTION_DELETE}
520 * <li> {@link #ACTION_RUN}
521 * <li> {@link #ACTION_SYNC}
522 * <li> {@link #ACTION_PICK_ACTIVITY}
523 * <li> {@link #ACTION_SEARCH}
524 * <li> {@link #ACTION_WEB_SEARCH}
525 * <li> {@link #ACTION_FACTORY_TEST}
526 * </ul>
527 *
528 * <h3>Standard Broadcast Actions</h3>
529 *
530 * <p>These are the current standard actions that Intent defines for receiving
531 * broadcasts (usually through {@link Context#registerReceiver} or a
532 * &lt;receiver&gt; tag in a manifest).
533 *
534 * <ul>
535 * <li> {@link #ACTION_TIME_TICK}
536 * <li> {@link #ACTION_TIME_CHANGED}
537 * <li> {@link #ACTION_TIMEZONE_CHANGED}
538 * <li> {@link #ACTION_BOOT_COMPLETED}
539 * <li> {@link #ACTION_PACKAGE_ADDED}
540 * <li> {@link #ACTION_PACKAGE_CHANGED}
541 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800542 * <li> {@link #ACTION_PACKAGE_RESTARTED}
543 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000544 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
545 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * <li> {@link #ACTION_UID_REMOVED}
547 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700548 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700549 * <li> {@link #ACTION_POWER_DISCONNECTED}
550 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700551 * </ul>
552 *
553 * <h3>Standard Categories</h3>
554 *
555 * <p>These are the current standard categories that can be used to further
556 * clarify an Intent via {@link #addCategory}.
557 *
558 * <ul>
559 * <li> {@link #CATEGORY_DEFAULT}
560 * <li> {@link #CATEGORY_BROWSABLE}
561 * <li> {@link #CATEGORY_TAB}
562 * <li> {@link #CATEGORY_ALTERNATIVE}
563 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
564 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700566 * <li> {@link #CATEGORY_HOME}
567 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700568 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400569 * <li> {@link #CATEGORY_CAR_DOCK}
570 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500571 * <li> {@link #CATEGORY_LE_DESK_DOCK}
572 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200573 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700574 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * </ul>
576 *
577 * <h3>Standard Extra Data</h3>
578 *
579 * <p>These are the current standard fields that can be used as extra data via
580 * {@link #putExtra}.
581 *
582 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_ALARM_COUNT}
584 * <li> {@link #EXTRA_BCC}
585 * <li> {@link #EXTRA_CC}
586 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
587 * <li> {@link #EXTRA_DATA_REMOVED}
588 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500589 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_DOCK_STATE_CAR}
592 * <li> {@link #EXTRA_DOCK_STATE_DESK}
593 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
594 * <li> {@link #EXTRA_DONT_KILL_APP}
595 * <li> {@link #EXTRA_EMAIL}
596 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700597 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700599 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700601 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
603 * <li> {@link #EXTRA_REPLACING}
604 * <li> {@link #EXTRA_SHORTCUT_ICON}
605 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
606 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_SHORTCUT_NAME}
609 * <li> {@link #EXTRA_SUBJECT}
610 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_TITLE}
613 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * </ul>
615 *
616 * <h3>Flags</h3>
617 *
618 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800619 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
620 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800622public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700623 private static final String ATTR_ACTION = "action";
624 private static final String TAG_CATEGORIES = "categories";
625 private static final String ATTR_CATEGORY = "category";
626 private static final String TAG_EXTRA = "extra";
627 private static final String ATTR_TYPE = "type";
628 private static final String ATTR_COMPONENT = "component";
629 private static final String ATTR_DATA = "data";
630 private static final String ATTR_FLAGS = "flags";
631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 // ---------------------------------------------------------------------
633 // ---------------------------------------------------------------------
634 // Standard intent activity actions (see action variable).
635
636 /**
637 * Activity Action: Start as a main entry point, does not expect to
638 * receive data.
639 * <p>Input: nothing
640 * <p>Output: nothing
641 */
642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700645 /**
646 * Activity Action: Display the data to the user. This is the most common
647 * action performed on data -- it is the generic action you can use on
648 * a piece of data to get the most reasonable thing to occur. For example,
649 * when used on a contacts entry it will view the entry; when used on a
650 * mailto: URI it will bring up a compose window filled with the information
651 * supplied by the URI; when used with a tel: URI it will invoke the
652 * dialer.
653 * <p>Input: {@link #getData} is URI from which to retrieve data.
654 * <p>Output: nothing.
655 */
656 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
657 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 /**
660 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
661 * performed on a piece of data.
662 */
663 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
Steve McKayc78bcb82015-07-31 14:35:22 -0700666 * Activity Action: Quick view the data.
667 * <p>Input: {@link #getData} is URI from which to retrieve data.
668 * <p>Output: nothing.
669 * @hide
670 */
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 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800758 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 *
760 * @see Intent#ACTION_CREATE_SHORTCUT
761 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800762 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
763 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 */
765 public static class ShortcutIconResource implements Parcelable {
766 /**
767 * The package name of the application containing the icon.
768 */
769 public String packageName;
770
771 /**
772 * The resource name of the icon, including package, name and type.
773 */
774 public String resourceName;
775
776 /**
777 * Creates a new ShortcutIconResource for the specified context and resource
778 * identifier.
779 *
780 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700781 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700782 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700783 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700784 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700785 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700786 ShortcutIconResource icon = new ShortcutIconResource();
787 icon.packageName = context.getPackageName();
788 icon.resourceName = context.getResources().getResourceName(resourceId);
789 return icon;
790 }
791
792 /**
793 * Used to read a ShortcutIconResource from a Parcel.
794 */
795 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
796 new Parcelable.Creator<ShortcutIconResource>() {
797
798 public ShortcutIconResource createFromParcel(Parcel source) {
799 ShortcutIconResource icon = new ShortcutIconResource();
800 icon.packageName = source.readString();
801 icon.resourceName = source.readString();
802 return icon;
803 }
804
805 public ShortcutIconResource[] newArray(int size) {
806 return new ShortcutIconResource[size];
807 }
808 };
809
810 /**
811 * No special parcel contents.
812 */
813 public int describeContents() {
814 return 0;
815 }
816
817 public void writeToParcel(Parcel dest, int flags) {
818 dest.writeString(packageName);
819 dest.writeString(resourceName);
820 }
821
822 @Override
823 public String toString() {
824 return resourceName;
825 }
826 }
827
828 /**
829 * Activity Action: Display an activity chooser, allowing the user to pick
830 * what they want to before proceeding. This can be used as an alternative
831 * to the standard activity picker that is displayed by the system when
832 * you try to start an activity with multiple possible matches, with these
833 * differences in behavior:
834 * <ul>
835 * <li>You can specify the title that will appear in the activity chooser.
836 * <li>The user does not have the option to make one of the matching
837 * activities a preferred activity, and all possible activities will
838 * always be shown even if one of them is currently marked as the
839 * preferred activity.
840 * </ul>
841 * <p>
842 * This action should be used when the user will naturally expect to
843 * select an activity in order to proceed. An example if when not to use
844 * it is when the user clicks on a "mailto:" link. They would naturally
845 * expect to go directly to their mail app, so startActivity() should be
846 * called directly: it will
847 * either launch the current preferred app, or put up a dialog allowing the
848 * user to pick an app to use and optionally marking that as preferred.
849 * <p>
850 * In contrast, if the user is selecting a menu item to send a picture
851 * they are viewing to someone else, there are many different things they
852 * may want to do at this point: send it through e-mail, upload it to a
853 * web service, etc. In this case the CHOOSER action should be used, to
854 * always present to the user a list of the things they can do, with a
855 * nice title given by the caller such as "Send this photo with:".
856 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700857 * If you need to grant URI permissions through a chooser, you must specify
858 * the permissions to be granted on the ACTION_CHOOSER Intent
859 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
860 * {@link #setClipData} to specify the URIs to be granted as well as
861 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
862 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
863 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700864 * As a convenience, an Intent of this form can be created with the
865 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700866 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700867 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700868 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
869 * and can optionally have a {@link #EXTRA_TITLE} field containing the
870 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700871 * <p>
872 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700873 */
874 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
875 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
876
877 /**
878 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
879 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700880 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
881 * target intent, also optionally supplying a title. If the target
882 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
883 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
884 * set in the returned chooser intent, with its ClipData set appropriately:
885 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500886 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700887 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700888 * @param target The Intent that the user will be selecting an activity
889 * to perform.
890 * @param title Optional title that will be displayed in the chooser.
891 * @return Return a new Intent object that you can hand to
892 * {@link Context#startActivity(Intent) Context.startActivity()} and
893 * related methods.
894 */
895 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700896 return createChooser(target, title, null);
897 }
898
899 /**
900 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
901 *
902 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
903 * target intent, also optionally supplying a title. If the target
904 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
905 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
906 * set in the returned chooser intent, with its ClipData set appropriately:
907 * either a direct reflection of {@link #getClipData()} if that is non-null,
908 * or a new ClipData built from {@link #getData()}.</p>
909 *
910 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
911 * when the user makes a choice. This can be useful if the calling application wants
912 * to remember the last chosen target and surface it as a more prominent or one-touch
913 * affordance elsewhere in the UI for next time.</p>
914 *
915 * @param target The Intent that the user will be selecting an activity
916 * to perform.
917 * @param title Optional title that will be displayed in the chooser.
918 * @param sender Optional IntentSender to be called when a choice is made.
919 * @return Return a new Intent object that you can hand to
920 * {@link Context#startActivity(Intent) Context.startActivity()} and
921 * related methods.
922 */
923 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700924 Intent intent = new Intent(ACTION_CHOOSER);
925 intent.putExtra(EXTRA_INTENT, target);
926 if (title != null) {
927 intent.putExtra(EXTRA_TITLE, title);
928 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700929
Adam Powell0b3c1122014-10-09 12:50:14 -0700930 if (sender != null) {
931 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
932 }
933
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700934 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700935 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
936 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
937 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700938 if (permFlags != 0) {
939 ClipData targetClipData = target.getClipData();
940 if (targetClipData == null && target.getData() != null) {
941 ClipData.Item item = new ClipData.Item(target.getData());
942 String[] mimeTypes;
943 if (target.getType() != null) {
944 mimeTypes = new String[] { target.getType() };
945 } else {
946 mimeTypes = new String[] { };
947 }
948 targetClipData = new ClipData(null, mimeTypes, item);
949 }
950 if (targetClipData != null) {
951 intent.setClipData(targetClipData);
952 intent.addFlags(permFlags);
953 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700954 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700955
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700956 return intent;
957 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700958
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700959 /**
960 * Activity Action: Allow the user to select a particular kind of data and
961 * return it. This is different than {@link #ACTION_PICK} in that here we
962 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800963 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700964 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900965 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700966 * etc.
967 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900968 * 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 -0700969 * of data, such as a person contact, you set the MIME type to the kind of
970 * data you want and launch it with {@link Context#startActivity(Intent)}.
971 * The system will then launch the best application to select that kind
972 * of data for you.
973 * <p>
974 * You may also be interested in any of a set of types of content the user
975 * can pick. For example, an e-mail application that wants to allow the
976 * user to add an attachment to an e-mail message can use this action to
977 * bring up a list of all of the types of content the user can attach.
978 * <p>
979 * In this case, you should wrap the GET_CONTENT intent with a chooser
980 * (through {@link #createChooser}), which will give the proper interface
981 * for the user to pick how to send your data and allow you to specify
982 * a prompt indicating what they are doing. You will usually specify a
983 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
984 * broad range of content types the user can select from.
985 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900986 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700987 * only pick from data that can be represented as a stream. This is
988 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
989 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800990 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900991 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800992 * is locally available on the device. For example, if this extra is set
993 * to true then an image picker should not show any pictures that are available
994 * from a remote server but not already on the local device (thus requiring
995 * they be downloaded when opened).
996 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800997 * If the caller can handle multiple returned items (the user performing
998 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
999 * to indicate this.
1000 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001001 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1002 * that no URI is supplied in the intent, as there are no constraints on
1003 * where the returned data originally comes from. You may also include the
1004 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001005 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001006 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1007 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 * <p>
1009 * Output: The URI of the item that was picked. This must be a content:
1010 * URI so that any receiver can access it.
1011 */
1012 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1013 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1014 /**
1015 * Activity Action: Dial a number as specified by the data. This shows a
1016 * UI with the number being dialed, allowing the user to explicitly
1017 * initiate the call.
1018 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1019 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1020 * number.
1021 * <p>Output: nothing.
1022 */
1023 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1024 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1025 /**
1026 * Activity Action: Perform a call to someone specified by the data.
1027 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1028 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1029 * number.
1030 * <p>Output: nothing.
1031 *
1032 * <p>Note: there will be restrictions on which applications can initiate a
1033 * call; most applications should use the {@link #ACTION_DIAL}.
1034 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1035 * numbers. Applications can <strong>dial</strong> emergency numbers using
1036 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001037 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001038 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001039 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001040 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001041 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001042 */
1043 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1044 public static final String ACTION_CALL = "android.intent.action.CALL";
1045 /**
1046 * Activity Action: Perform a call to an emergency number specified by the
1047 * data.
1048 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1049 * tel: URI of an explicit phone number.
1050 * <p>Output: nothing.
1051 * @hide
1052 */
1053 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1054 /**
1055 * Activity action: Perform a call to any number (emergency or not)
1056 * specified by the data.
1057 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1058 * tel: URI of an explicit phone number.
1059 * <p>Output: nothing.
1060 * @hide
1061 */
1062 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1063 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001064 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1065 * sending this intent is a no-op.
1066 * <p>Input: No data should be specified. get*Extra may have an optional
1067 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1068 * send the activation result.
1069 * <p>Output: nothing.
1070 * @hide
1071 */
1072 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1073 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1074 "android.intent.action.SIM_ACTIVATION_REQUEST";
1075 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001076 * Activity Action: Send a message to someone specified by the data.
1077 * <p>Input: {@link #getData} is URI describing the target.
1078 * <p>Output: nothing.
1079 */
1080 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1081 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1082 /**
1083 * Activity Action: Deliver some data to someone else. Who the data is
1084 * being delivered to is not specified; it is up to the receiver of this
1085 * action to ask the user where the data should be sent.
1086 * <p>
1087 * When launching a SEND intent, you should usually wrap it in a chooser
1088 * (through {@link #createChooser}), which will give the proper interface
1089 * for the user to pick how to send your data and allow you to specify
1090 * a prompt indicating what they are doing.
1091 * <p>
1092 * Input: {@link #getType} is the MIME type of the data being sent.
1093 * get*Extra can have either a {@link #EXTRA_TEXT}
1094 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1095 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1096 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1097 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001098 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1099 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1100 * your text with HTML formatting.
1101 * <p>
1102 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1103 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1104 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1105 * content: URIs and other advanced features of {@link ClipData}. If
1106 * using this approach, you still must supply the same data through the
1107 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1108 * for compatibility with old applications. If you don't set a ClipData,
1109 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001110 * <p>
1111 * Optional standard extras, which may be interpreted by some recipients as
1112 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1113 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1114 * <p>
1115 * Output: nothing.
1116 */
1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1118 public static final String ACTION_SEND = "android.intent.action.SEND";
1119 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001120 * Activity Action: Deliver multiple data to someone else.
1121 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001122 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001123 * <p>
1124 * Input: {@link #getType} is the MIME type of the data being sent.
1125 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001126 * #EXTRA_STREAM} field, containing the data to be sent. If using
1127 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1128 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001129 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001130 * Multiple types are supported, and receivers should handle mixed types
1131 * whenever possible. The right way for the receiver to check them is to
1132 * use the content resolver on each URI. The intent sender should try to
1133 * put the most concrete mime type in the intent type, but it can fall
1134 * back to {@literal <type>/*} or {@literal *}/* as needed.
1135 * <p>
1136 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1137 * be image/jpg, but if you are sending image/jpg and image/png, then the
1138 * intent's type should be image/*.
1139 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001140 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1141 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1142 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1143 * content: URIs and other advanced features of {@link ClipData}. If
1144 * using this approach, you still must supply the same data through the
1145 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1146 * for compatibility with old applications. If you don't set a ClipData,
1147 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1148 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001149 * Optional standard extras, which may be interpreted by some recipients as
1150 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1151 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1152 * <p>
1153 * Output: nothing.
1154 */
1155 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1156 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1157 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001158 * Activity Action: Handle an incoming phone call.
1159 * <p>Input: nothing.
1160 * <p>Output: nothing.
1161 */
1162 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1163 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1164 /**
1165 * Activity Action: Insert an empty item into the given container.
1166 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1167 * in which to place the data.
1168 * <p>Output: URI of the new data that was created.
1169 */
1170 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1171 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1172 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001173 * Activity Action: Create a new item in the given container, initializing it
1174 * from the current contents of the clipboard.
1175 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1176 * in which to place the data.
1177 * <p>Output: URI of the new data that was created.
1178 */
1179 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1180 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1181 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001182 * Activity Action: Delete the given data from its container.
1183 * <p>Input: {@link #getData} is URI of data to be deleted.
1184 * <p>Output: nothing.
1185 */
1186 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1188 /**
1189 * Activity Action: Run the data, whatever that means.
1190 * <p>Input: ? (Note: this is currently specific to the test harness.)
1191 * <p>Output: nothing.
1192 */
1193 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1194 public static final String ACTION_RUN = "android.intent.action.RUN";
1195 /**
1196 * Activity Action: Perform a data synchronization.
1197 * <p>Input: ?
1198 * <p>Output: ?
1199 */
1200 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1201 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1202 /**
1203 * Activity Action: Pick an activity given an intent, returning the class
1204 * selected.
1205 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1206 * used with {@link PackageManager#queryIntentActivities} to determine the
1207 * set of activities from which to pick.
1208 * <p>Output: Class name of the activity that was selected.
1209 */
1210 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1211 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1212 /**
1213 * Activity Action: Perform a search.
1214 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1215 * is the text to search for. If empty, simply
1216 * enter your search results Activity with the search UI activated.
1217 * <p>Output: nothing.
1218 */
1219 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1220 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1221 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001222 * Activity Action: Start the platform-defined tutorial
1223 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1224 * is the text to search for. If empty, simply
1225 * enter your search results Activity with the search UI activated.
1226 * <p>Output: nothing.
1227 */
1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1229 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1230 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001231 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001232 * <p>
1233 * Input: {@link android.app.SearchManager#QUERY
1234 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1235 * a url starts with http or https, the site will be opened. If it is plain
1236 * text, Google search will be applied.
1237 * <p>
1238 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001239 */
1240 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1241 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001242
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001243 /**
Jim Miller07994402012-05-02 14:22:27 -07001244 * Activity Action: Perform assist action.
1245 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001246 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1247 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001248 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1249 * information.
Jim Miller07994402012-05-02 14:22:27 -07001250 * Output: nothing.
1251 */
1252 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1253 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001254
1255 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001256 * Activity Action: Perform voice assist action.
1257 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001258 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1259 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001260 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001261 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001262 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1266
1267 /**
Adam Skory7140a252013-09-11 12:04:58 +01001268 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1269 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001270 */
1271 public static final String EXTRA_ASSIST_PACKAGE
1272 = "android.intent.extra.ASSIST_PACKAGE";
1273
1274 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001275 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1276 * application package at the time the assist was invoked.
1277 */
1278 public static final String EXTRA_ASSIST_UID
1279 = "android.intent.extra.ASSIST_UID";
1280
1281 /**
Adam Skory7140a252013-09-11 12:04:58 +01001282 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1283 * information supplied by the current foreground app at the time of the assist request.
1284 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001285 */
1286 public static final String EXTRA_ASSIST_CONTEXT
1287 = "android.intent.extra.ASSIST_CONTEXT";
1288
Jim Miller07994402012-05-02 14:22:27 -07001289 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001290 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1291 * keyboard as the primary input device for assistance.
1292 */
1293 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1294 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1295
1296 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001297 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1298 * that was used to invoke the assist.
1299 */
1300 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1301 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1302
1303 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001304 * Activity Action: List all available applications
1305 * <p>Input: Nothing.
1306 * <p>Output: nothing.
1307 */
1308 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1309 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1310 /**
1311 * Activity Action: Show settings for choosing wallpaper
1312 * <p>Input: Nothing.
1313 * <p>Output: Nothing.
1314 */
1315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1316 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1317
1318 /**
1319 * Activity Action: Show activity for reporting a bug.
1320 * <p>Input: Nothing.
1321 * <p>Output: Nothing.
1322 */
1323 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1324 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1325
1326 /**
1327 * Activity Action: Main entry point for factory tests. Only used when
1328 * the device is booting in factory test node. The implementing package
1329 * must be installed in the system image.
1330 * <p>Input: nothing
1331 * <p>Output: nothing
1332 */
1333 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1334
1335 /**
1336 * Activity Action: The user pressed the "call" button to go to the dialer
1337 * or other appropriate UI for placing a call.
1338 * <p>Input: Nothing.
1339 * <p>Output: Nothing.
1340 */
1341 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1342 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1343
1344 /**
1345 * Activity Action: Start Voice Command.
1346 * <p>Input: Nothing.
1347 * <p>Output: Nothing.
1348 */
1349 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1350 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001351
1352 /**
1353 * Activity Action: Start action associated with long pressing on the
1354 * search key.
1355 * <p>Input: Nothing.
1356 * <p>Output: Nothing.
1357 */
1358 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1359 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001360
Jacek Surazski86b6c532009-05-13 14:38:28 +02001361 /**
1362 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1363 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001364 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001365 * <p>Input: No data is specified. The bug report is passed in using
1366 * an {@link #EXTRA_BUG_REPORT} field.
1367 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001368 *
1369 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001370 */
1371 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1372 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001373
1374 /**
1375 * Activity Action: Show power usage information to the user.
1376 * <p>Input: Nothing.
1377 * <p>Output: Nothing.
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001381
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001382 /**
1383 * Activity Action: Setup wizard to launch after a platform update. This
1384 * activity should have a string meta-data field associated with it,
1385 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1386 * the platform for setup. The activity will be launched only if
1387 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1388 * same value.
1389 * <p>Input: Nothing.
1390 * <p>Output: Nothing.
1391 * @hide
1392 */
1393 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1394 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001395
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001396 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001397 * Activity Action: Show settings for managing network data usage of a
1398 * specific application. Applications should define an activity that offers
1399 * options to control data usage.
1400 */
1401 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1402 public static final String ACTION_MANAGE_NETWORK_USAGE =
1403 "android.intent.action.MANAGE_NETWORK_USAGE";
1404
1405 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001406 * Activity Action: Launch application installer.
1407 * <p>
1408 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001409 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1410 * you can also use "package:<package-name>" to install an application for the
1411 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001412 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1413 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1414 * <p>
1415 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1416 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001417 * <p>
1418 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1419 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1420 * in order to launch the application installer.
1421 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001422 *
1423 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1424 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1425 * @see #EXTRA_RETURN_RESULT
1426 */
1427 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1428 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1429
1430 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001431 * Activity Action: Launch ephemeral installer.
1432 * <p>
1433 * Input: The data must be a http: URI that the ephemeral application is registered
1434 * to handle.
1435 * <p class="note">
1436 * This is a protected intent that can only be sent by the system.
1437 * </p>
1438 *
1439 * @hide
1440 */
1441 @SystemApi
1442 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1443 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1444 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1445
1446 /**
1447 * Service Action: Resolve ephemeral application.
1448 * <p>
1449 * The system will have a persistent connection to this service.
1450 * This is a protected intent that can only be sent by the system.
1451 * </p>
1452 *
1453 * @hide
1454 */
1455 @SystemApi
1456 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1457 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1458 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1459
1460 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001461 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1462 * package. Specifies the installer package name; this package will receive the
1463 * {@link #ACTION_APP_ERROR} intent.
1464 */
1465 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1466 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1467
1468 /**
1469 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1470 * package. Specifies that the application being installed should not be
1471 * treated as coming from an unknown source, but as coming from the app
1472 * invoking the Intent. For this to work you must start the installer with
1473 * startActivityForResult().
1474 */
1475 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1476 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1477
1478 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001479 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1480 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001481 * data field originated from.
1482 */
rich cannings706e8ba2012-08-20 13:20:14 -07001483 public static final String EXTRA_ORIGINATING_URI
1484 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001485
1486 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001487 * This extra can be used with any Intent used to launch an activity, supplying information
1488 * about who is launching that activity. This field contains a {@link android.net.Uri}
1489 * object, typically an http: or https: URI of the web site that the referral came from;
1490 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1491 * a native application that it came from.
1492 *
1493 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1494 * instead of directly retrieving the extra. It is also valid for applications to
1495 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1496 * a string, not a Uri; the field here, if supplied, will always take precedence,
1497 * however.</p>
1498 *
1499 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001500 */
1501 public static final String EXTRA_REFERRER
1502 = "android.intent.extra.REFERRER";
1503
1504 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001505 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1506 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1507 * not be created, in particular when Intent extras are supplied through the
1508 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1509 * schemes.
1510 *
1511 * @see #EXTRA_REFERRER
1512 */
1513 public static final String EXTRA_REFERRER_NAME
1514 = "android.intent.extra.REFERRER_NAME";
1515
1516 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001517 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1518 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1519 * @hide
1520 */
1521 public static final String EXTRA_ORIGINATING_UID
1522 = "android.intent.extra.ORIGINATING_UID";
1523
1524 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001525 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1526 * package. Tells the installer UI to skip the confirmation with the user
1527 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001528 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1529 * will no longer show an interstitial message about updating existing
1530 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001531 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001532 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001533 public static final String EXTRA_ALLOW_REPLACE
1534 = "android.intent.extra.ALLOW_REPLACE";
1535
1536 /**
1537 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1538 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1539 * return to the application the result code of the install/uninstall. The returned result
1540 * code will be {@link android.app.Activity#RESULT_OK} on success or
1541 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1542 */
1543 public static final String EXTRA_RETURN_RESULT
1544 = "android.intent.extra.RETURN_RESULT";
1545
1546 /**
1547 * Package manager install result code. @hide because result codes are not
1548 * yet ready to be exposed.
1549 */
1550 public static final String EXTRA_INSTALL_RESULT
1551 = "android.intent.extra.INSTALL_RESULT";
1552
1553 /**
1554 * Activity Action: Launch application uninstaller.
1555 * <p>
1556 * Input: The data must be a package: URI whose scheme specific part is
1557 * the package name of the current installed package to be uninstalled.
1558 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1559 * <p>
1560 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1561 * succeeded.
1562 */
1563 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1564 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1565
1566 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001567 * Specify whether the package should be uninstalled for all users.
1568 * @hide because these should not be part of normal application flow.
1569 */
1570 public static final String EXTRA_UNINSTALL_ALL_USERS
1571 = "android.intent.extra.UNINSTALL_ALL_USERS";
1572
1573 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001574 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1575 * describing the last run version of the platform that was setup.
1576 * @hide
1577 */
1578 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1579
Svet Ganov3695b8a2015-03-24 16:30:25 -07001580 /**
1581 * Activity action: Launch UI to manage the permissions of an app.
1582 * <p>
1583 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1584 * will be managed by the launched UI.
1585 * </p>
1586 * <p>
1587 * Output: Nothing.
1588 * </p>
1589 *
1590 * @see #EXTRA_PACKAGE_NAME
1591 *
1592 * @hide
1593 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001594 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1595 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1596 "android.intent.action.MANAGE_APP_PERMISSIONS";
1597
1598 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001599 * Activity action: Launch UI to manage permissions.
1600 * <p>
1601 * Input: Nothing.
1602 * </p>
1603 * <p>
1604 * Output: Nothing.
1605 * </p>
1606 *
1607 * @hide
1608 */
Svet Ganov321f0152015-05-16 22:51:50 -07001609 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1610 public static final String ACTION_MANAGE_PERMISSIONS =
1611 "android.intent.action.MANAGE_PERMISSIONS";
1612
1613 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001614 * Activity action: Launch UI to review permissions for an app.
1615 * The system uses this intent if permission review for apps not
1616 * supporting the new runtime permissions model is enabled. In
1617 * this mode a permission review is required before any of the
1618 * app components can run.
1619 * <p>
1620 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1621 * permissions will be reviewed (mandatory).
1622 * </p>
1623 * <p>
1624 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1625 * be fired after the permission review (optional).
1626 * </p>
1627 * <p>
1628 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1629 * be invoked after the permission review (optional).
1630 * </p>
1631 * <p>
1632 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1633 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1634 * </p>
1635 * <p>
1636 * Output: Nothing.
1637 * </p>
1638 *
1639 * @see #EXTRA_PACKAGE_NAME
1640 * @see #EXTRA_INTENT
1641 * @see #EXTRA_REMOTE_CALLBACK
1642 * @see #EXTRA_RESULT_NEEDED
1643 *
1644 * @hide
1645 */
1646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1647 public static final String ACTION_REVIEW_PERMISSIONS =
1648 "android.intent.action.REVIEW_PERMISSIONS";
1649
1650 /**
1651 * Intent extra: A callback for reporting remote result as a bundle.
1652 * <p>
1653 * Type: IRemoteCallback
1654 * </p>
1655 *
1656 * @hide
1657 */
1658 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1659
1660 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001661 * Intent extra: An app package name.
1662 * <p>
1663 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001664 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001665 *
1666 * @hide
1667 */
1668 @SystemApi
1669 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1670
1671 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001672 * Intent extra: An extra for specifying whether a result is needed.
1673 * <p>
1674 * Type: boolean
1675 * </p>
1676 *
1677 * @hide
1678 */
1679 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1680
1681 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001682 * Broadcast action that requests current permission granted information. It will respond
1683 * to the request by sending a broadcast with action defined by
1684 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001685 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1686 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1687 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001688 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001689 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1690 * number of permissions requested and the number of granted additional permissions
1691 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001692 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001693 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1694 * of localized permission group names that are granted in
1695 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001696 *
1697 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1698 * permissions and the total number of apps requesting runtime permissions will be the first
1699 * and second elements respectively of an int[] in the response as
1700 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1701 *
1702 * @hide
1703 */
1704 public static final String ACTION_GET_PERMISSIONS_COUNT
1705 = "android.intent.action.GET_PERMISSIONS_COUNT";
1706
1707 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001708 * Broadcast action that requests list of all apps that have runtime permissions. It will
1709 * respond to the request by sending a broadcast with action defined by
1710 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1711 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1712 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1713 * a null upon failure.
1714 *
1715 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1716 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1717 * will contain the list of app labels corresponding ot the apps in the first list.
1718 *
1719 * @hide
1720 */
1721 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1722 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1723
1724 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001725 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1726 * @hide
1727 */
1728 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1729 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1730
1731 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001732 * List of CharSequence of localized permission group labels.
1733 * @hide
1734 */
1735 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1736 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1737
1738 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001739 * String list of apps that have one or more runtime permissions.
1740 * @hide
1741 */
1742 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1743 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1744
1745 /**
1746 * String list of app labels for apps that have one or more runtime permissions.
1747 * @hide
1748 */
1749 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1750 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1751
1752 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001753 * Boolean list describing if the app is a system app for apps that have one or more runtime
1754 * permissions.
1755 * @hide
1756 */
1757 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1758 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1759
1760 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001761 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001762 * @hide
1763 */
1764 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1765 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1766
1767 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001768 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1769 * @hide
1770 */
1771 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1772 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1773
1774 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001775 * Activity action: Launch UI to manage which apps have a given permission.
1776 * <p>
1777 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1778 * to which will be managed by the launched UI.
1779 * </p>
1780 * <p>
1781 * Output: Nothing.
1782 * </p>
1783 *
1784 * @see #EXTRA_PERMISSION_NAME
1785 *
1786 * @hide
1787 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001788 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1789 public static final String ACTION_MANAGE_PERMISSION_APPS =
1790 "android.intent.action.MANAGE_PERMISSION_APPS";
1791
1792 /**
1793 * Intent extra: The name of a permission.
1794 * <p>
1795 * Type: String
1796 * </p>
1797 *
1798 * @hide
1799 */
1800 @SystemApi
1801 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1802
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001803 // ---------------------------------------------------------------------
1804 // ---------------------------------------------------------------------
1805 // Standard intent broadcast actions (see action variable).
1806
1807 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001808 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1809 * <p>
1810 * For historical reasons, the name of this broadcast action refers to the power
1811 * state of the screen but it is actually sent in response to changes in the
1812 * overall interactive state of the device.
1813 * </p><p>
1814 * This broadcast is sent when the device becomes non-interactive which may have
1815 * nothing to do with the screen turning off. To determine the
1816 * actual state of the screen, use {@link android.view.Display#getState}.
1817 * </p><p>
1818 * See {@link android.os.PowerManager#isInteractive} for details.
1819 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001820 * You <em>cannot</em> receive this through components declared in
1821 * manifests, only by explicitly registering for it with
1822 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1823 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001824 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001825 * <p class="note">This is a protected intent that can only be sent
1826 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001827 */
1828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1829 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001830
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001831 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001832 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1833 * <p>
1834 * For historical reasons, the name of this broadcast action refers to the power
1835 * state of the screen but it is actually sent in response to changes in the
1836 * overall interactive state of the device.
1837 * </p><p>
1838 * This broadcast is sent when the device becomes interactive which may have
1839 * nothing to do with the screen turning on. To determine the
1840 * actual state of the screen, use {@link android.view.Display#getState}.
1841 * </p><p>
1842 * See {@link android.os.PowerManager#isInteractive} for details.
1843 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001844 * You <em>cannot</em> receive this through components declared in
1845 * manifests, only by explicitly registering for it with
1846 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1847 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001848 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001849 * <p class="note">This is a protected intent that can only be sent
1850 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001851 */
1852 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1853 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001854
1855 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001856 * Broadcast Action: Sent after the system stops dreaming.
1857 *
1858 * <p class="note">This is a protected intent that can only be sent by the system.
1859 * It is only sent to registered receivers.</p>
1860 */
1861 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1862 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1863
1864 /**
1865 * Broadcast Action: Sent after the system starts dreaming.
1866 *
1867 * <p class="note">This is a protected intent that can only be sent by the system.
1868 * It is only sent to registered receivers.</p>
1869 */
1870 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1871 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1872
1873 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001874 * 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 -07001875 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001876 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001877 * <p class="note">This is a protected intent that can only be sent
1878 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001879 */
1880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001881 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001882
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001883 /**
1884 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001885 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001886 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001887 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1888 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001889 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001890 * <p class="note">This is a protected intent that can only be sent
1891 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001892 */
1893 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1894 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1895 /**
1896 * Broadcast Action: The time was set.
1897 */
1898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1899 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1900 /**
1901 * Broadcast Action: The date has changed.
1902 */
1903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1904 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1905 /**
1906 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1907 * <ul>
1908 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1909 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001910 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001911 * <p class="note">This is a protected intent that can only be sent
1912 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001913 */
1914 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1915 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1916 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001917 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1918 * DNS entries should be tossed.
1919 * @hide
1920 */
1921 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1922 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1923 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001924 * Alarm Changed Action: This is broadcast when the AlarmClock
1925 * application's alarm is set or unset. It is used by the
1926 * AlarmClock application and the StatusBar service.
1927 * @hide
1928 */
1929 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1930 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001931
1932 /**
1933 * Broadcast Action: This is broadcast once, after the system has finished
1934 * booting and the user is in a "locked" state. A user is locked when their
1935 * credential-encrypted private app data storage is unavailable. Once the
1936 * user has entered their credentials (such as a lock pattern or PIN) for
1937 * the first time, the {@link #ACTION_BOOT_COMPLETED} broadcast will be
1938 * sent.
1939 * <p>
1940 * You must hold the
1941 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1942 * order to receive this broadcast.
1943 * <p class="note">
1944 * This is a protected intent that can only be sent by the system.
1945 */
1946 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1947 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1948
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001949 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001950 * Broadcast Action: This is broadcast once, after the system has finished
1951 * booting. It can be used to perform application-specific initialization,
1952 * such as installing alarms. You must hold the
1953 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1954 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001955 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001956 * <p class="note">This is a protected intent that can only be sent
1957 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001958 */
1959 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1960 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001961
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001962 /**
1963 * Broadcast Action: This is broadcast when a user action should request a
1964 * temporary system dialog to dismiss. Some examples of temporary system
1965 * dialogs are the notification window-shade and the recent tasks dialog.
1966 */
1967 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1968 /**
1969 * Broadcast Action: Trigger the download and eventual installation
1970 * of a package.
1971 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001972 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001973 * <p class="note">This is a protected intent that can only be sent
1974 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001975 *
1976 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001977 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001978 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1980 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1981 /**
1982 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001983 * device. The data contains the name of the package. Note that the
1984 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001985 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001986 * <ul>
1987 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1988 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1989 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1990 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001991 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001992 * <p class="note">This is a protected intent that can only be sent
1993 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001994 */
1995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1996 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1997 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001998 * Broadcast Action: A new version of an application package has been
1999 * installed, replacing an existing version that was previously installed.
2000 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002001 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002002 * <ul>
2003 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2004 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002005 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002006 * <p class="note">This is a protected intent that can only be sent
2007 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002008 */
2009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2010 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2011 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002012 * Broadcast Action: A new version of your application has been installed
2013 * over an existing one. This is only sent to the application that was
2014 * replaced. It does not contain any additional data; to receive it, just
2015 * use an intent filter for this action.
2016 *
2017 * <p class="note">This is a protected intent that can only be sent
2018 * by the system.
2019 */
2020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2021 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2022 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002023 * Broadcast Action: An existing application package has been removed from
2024 * the device. The data contains the name of the package. The package
2025 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002026 * <ul>
2027 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2028 * to the package.
2029 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2030 * application -- data and code -- is being removed.
2031 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2032 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2033 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002034 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002035 * <p class="note">This is a protected intent that can only be sent
2036 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002037 */
2038 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2039 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2040 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002041 * Broadcast Action: An existing application package has been completely
2042 * removed from the device. The data contains the name of the package.
2043 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2044 * {@link #EXTRA_DATA_REMOVED} is true and
2045 * {@link #EXTRA_REPLACING} is false of that broadcast.
2046 *
2047 * <ul>
2048 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2049 * to the package.
2050 * </ul>
2051 *
2052 * <p class="note">This is a protected intent that can only be sent
2053 * by the system.
2054 */
2055 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2056 public static final String ACTION_PACKAGE_FULLY_REMOVED
2057 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2058 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002059 * Broadcast Action: An existing application package has been changed (e.g.
2060 * a component has been enabled or disabled). The data contains the name of
2061 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002062 * <ul>
2063 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002064 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002065 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002066 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2067 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002068 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002069 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002070 * <p class="note">This is a protected intent that can only be sent
2071 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002072 */
2073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2074 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2075 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002076 * @hide
2077 * Broadcast Action: Ask system services if there is any reason to
2078 * restart the given package. The data contains the name of the
2079 * package.
2080 * <ul>
2081 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2082 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2083 * </ul>
2084 *
2085 * <p class="note">This is a protected intent that can only be sent
2086 * by the system.
2087 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002088 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2090 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2091 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002092 * Broadcast Action: The user has restarted a package, and all of its
2093 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002094 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002095 * be removed. Note that the restarted package does <em>not</em>
2096 * receive this broadcast.
2097 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002098 * <ul>
2099 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2100 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002101 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002102 * <p class="note">This is a protected intent that can only be sent
2103 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002104 */
2105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2106 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2107 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002108 * Broadcast Action: The user has cleared the data of a package. This should
2109 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002110 * its persistent data is erased and this broadcast sent.
2111 * Note that the cleared package does <em>not</em>
2112 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002113 * <ul>
2114 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2115 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002116 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002117 * <p class="note">This is a protected intent that can only be sent
2118 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002119 */
2120 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2121 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2122 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002123 * Broadcast Action: Packages have been suspended.
2124 * <p>Includes the following extras:
2125 * <ul>
2126 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2127 * </ul>
2128 *
2129 * <p class="note">This is a protected intent that can only be sent
2130 * by the system. It is only sent to registered receivers.
2131 */
2132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2133 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2134 /**
2135 * Broadcast Action: Packages have been unsuspended.
2136 * <p>Includes the following extras:
2137 * <ul>
2138 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2139 * </ul>
2140 *
2141 * <p class="note">This is a protected intent that can only be sent
2142 * by the system. It is only sent to registered receivers.
2143 */
2144 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2145 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2146 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002147 * Broadcast Action: A user ID has been removed from the system. The user
2148 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002149 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002150 * <p class="note">This is a protected intent that can only be sent
2151 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002152 */
2153 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2154 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002155
2156 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002157 * Broadcast Action: Sent to the installer package of an application
2158 * when that application is first launched (that is the first time it
2159 * is moved out of the stopped state). The data contains the name of the package.
2160 *
2161 * <p class="note">This is a protected intent that can only be sent
2162 * by the system.
2163 */
2164 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2165 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2166
2167 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002168 * Broadcast Action: Sent to the system package verifier when a package
2169 * needs to be verified. The data contains the package URI.
2170 * <p class="note">
2171 * This is a protected intent that can only be sent by the system.
2172 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002173 */
2174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2175 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2176
2177 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002178 * Broadcast Action: Sent to the system package verifier when a package is
2179 * verified. The data contains the package URI.
2180 * <p class="note">
2181 * This is a protected intent that can only be sent by the system.
2182 */
2183 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2184 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2185
2186 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002187 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2188 * needs to be verified. The data contains the filter data hosts to be verified against.
2189 * <p class="note">
2190 * This is a protected intent that can only be sent by the system.
2191 * </p>
2192 *
2193 * @hide
2194 */
2195 @SystemApi
2196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2197 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2198
2199 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002200 * Broadcast Action: Resources for a set of packages (which were
2201 * previously unavailable) are currently
2202 * available since the media on which they exist is available.
2203 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2204 * list of packages whose availability changed.
2205 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2206 * list of uids of packages whose availability changed.
2207 * Note that the
2208 * packages in this list do <em>not</em> receive this broadcast.
2209 * The specified set of packages are now available on the system.
2210 * <p>Includes the following extras:
2211 * <ul>
2212 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2213 * whose resources(were previously unavailable) are currently available.
2214 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2215 * packages whose resources(were previously unavailable)
2216 * are currently available.
2217 * </ul>
2218 *
2219 * <p class="note">This is a protected intent that can only be sent
2220 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002221 */
2222 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002223 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2224 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002225
2226 /**
2227 * Broadcast Action: Resources for a set of packages are currently
2228 * unavailable since the media on which they exist is unavailable.
2229 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2230 * list of packages whose availability changed.
2231 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2232 * list of uids of packages whose availability changed.
2233 * The specified set of packages can no longer be
2234 * launched and are practically unavailable on the system.
2235 * <p>Inclues the following extras:
2236 * <ul>
2237 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2238 * whose resources are no longer available.
2239 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2240 * whose resources are no longer available.
2241 * </ul>
2242 *
2243 * <p class="note">This is a protected intent that can only be sent
2244 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002245 */
2246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002247 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002248 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002249
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002250 /**
2251 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002252 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002253 * This should <em>only</em> be used to determine when the wallpaper
2254 * has changed to show the new wallpaper to the user. You should certainly
2255 * never, in response to this, change the wallpaper or other attributes of
2256 * it such as the suggested size. That would be crazy, right? You'd cause
2257 * all kinds of loops, especially if other apps are doing similar things,
2258 * right? Of course. So please don't do this.
2259 *
2260 * @deprecated Modern applications should use
2261 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2262 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2263 * shown behind their UI, rather than watching for this broadcast and
2264 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002265 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002266 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002267 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2268 /**
2269 * Broadcast Action: The current device {@link android.content.res.Configuration}
2270 * (orientation, locale, etc) has changed. When such a change happens, the
2271 * UIs (view hierarchy) will need to be rebuilt based on this new
2272 * information; for the most part, applications don't need to worry about
2273 * this, because the system will take care of stopping and restarting the
2274 * application to make sure it sees the new changes. Some system code that
2275 * can not be restarted will need to watch for this action and handle it
2276 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002277 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002278 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002279 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002280 * in manifests, only by explicitly registering for it with
2281 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2282 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002283 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002284 * <p class="note">This is a protected intent that can only be sent
2285 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002286 *
2287 * @see android.content.res.Configuration
2288 */
2289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2290 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2291 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002292 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002293 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002294 * <p class="note">This is a protected intent that can only be sent
2295 * by the system.
2296 */
2297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2298 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2299 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002300 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2301 * charging state, level, and other information about the battery.
2302 * See {@link android.os.BatteryManager} for documentation on the
2303 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002304 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002305 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002306 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002307 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002308 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002309 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2310 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2311 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2312 * broadcasts that are sent and can be received through manifest
2313 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002314 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002315 * <p class="note">This is a protected intent that can only be sent
2316 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002317 */
2318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2319 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2320 /**
2321 * Broadcast Action: Indicates low battery condition on the device.
2322 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002323 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002324 * <p class="note">This is a protected intent that can only be sent
2325 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002326 */
2327 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2328 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2329 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002330 * Broadcast Action: Indicates the battery is now okay after being low.
2331 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2332 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002333 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002334 * <p class="note">This is a protected intent that can only be sent
2335 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002336 */
2337 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2338 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2339 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002340 * Broadcast Action: External power has been connected to the device.
2341 * This is intended for applications that wish to register specifically to this notification.
2342 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2343 * stay active to receive this notification. This action can be used to implement actions
2344 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002345 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002346 * <p class="note">This is a protected intent that can only be sent
2347 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002348 */
2349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002350 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002351 /**
2352 * Broadcast Action: External power has been removed from the device.
2353 * This is intended for applications that wish to register specifically to this notification.
2354 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2355 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002356 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002357 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002358 * <p class="note">This is a protected intent that can only be sent
2359 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002360 */
2361 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002362 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002363 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002364 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002365 * Broadcast Action: Device is shutting down.
2366 * This is broadcast when the device is being shut down (completely turned
2367 * off, not sleeping). Once the broadcast is complete, the final shutdown
2368 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002369 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002370 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002371 * <p class="note">This is a protected intent that can only be sent
2372 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002373 * <p>May include the following extras:
2374 * <ul>
2375 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2376 * shutdown is only for userspace processes. If not set, assumed to be false.
2377 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002378 */
2379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002380 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002381 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002382 * Activity Action: Start this activity to request system shutdown.
2383 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002384 * to request confirmation from the user before shutting down. The optional boolean
2385 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2386 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002387 *
2388 * <p class="note">This is a protected intent that can only be sent
2389 * by the system.
2390 *
2391 * {@hide}
2392 */
2393 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2394 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002395 * Broadcast Action: A sticky broadcast that indicates low memory
2396 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002397 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002398 * <p class="note">This is a protected intent that can only be sent
2399 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002400 */
2401 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2402 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2403 /**
2404 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002405 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002406 * <p class="note">This is a protected intent that can only be sent
2407 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002408 */
2409 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2410 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2411 /**
Jake Hambybb371632010-08-23 18:16:48 -07002412 * Broadcast Action: A sticky broadcast that indicates a memory full
2413 * condition on the device. This is intended for activities that want
2414 * to be able to fill the data partition completely, leaving only
2415 * enough free space to prevent system-wide SQLite failures.
2416 *
2417 * <p class="note">This is a protected intent that can only be sent
2418 * by the system.
2419 *
2420 * {@hide}
2421 */
2422 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2423 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2424 /**
2425 * Broadcast Action: Indicates memory full condition on the device
2426 * no longer exists.
2427 *
2428 * <p class="note">This is a protected intent that can only be sent
2429 * by the system.
2430 *
2431 * {@hide}
2432 */
2433 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2434 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2435 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2437 * and package management should be started.
2438 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2439 * notification.
2440 */
2441 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2442 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2443 /**
2444 * Broadcast Action: The device has entered USB Mass Storage mode.
2445 * This is used mainly for the USB Settings panel.
2446 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2447 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002448 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002449 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002450 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002451 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2452
2453 /**
2454 * Broadcast Action: The device has exited USB Mass Storage mode.
2455 * This is used mainly for the USB Settings panel.
2456 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2457 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002458 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002459 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002460 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002461 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2462
2463 /**
2464 * Broadcast Action: External media has been removed.
2465 * The path to the mount point for the removed media is contained in the Intent.mData field.
2466 */
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2468 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2469
2470 /**
2471 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002472 * 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 -07002473 */
2474 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2475 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2476
2477 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002478 * Broadcast Action: External media is present, and being disk-checked
2479 * 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 -08002480 */
2481 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2482 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2483
2484 /**
2485 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2486 * 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 -08002487 */
2488 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2489 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2490
2491 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002492 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002493 * 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 -07002494 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2495 * media was mounted read only.
2496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2498 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2499
2500 /**
2501 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002502 * 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 -07002503 */
2504 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2505 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2506
2507 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002508 * Broadcast Action: External media is no longer being shared via USB mass storage.
2509 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2510 *
2511 * @hide
2512 */
2513 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2514
2515 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002516 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2517 * The path to the mount point for the removed media is contained in the Intent.mData field.
2518 */
2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2520 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2521
2522 /**
2523 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002524 * 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 -07002525 */
2526 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2527 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2528
2529 /**
2530 * Broadcast Action: User has expressed the desire to remove the external storage media.
2531 * Applications should close all files they have open within the mount point when they receive this intent.
2532 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2533 */
2534 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2535 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2536
2537 /**
2538 * Broadcast Action: The media scanner has started scanning a directory.
2539 * The path to the directory being scanned is contained in the Intent.mData field.
2540 */
2541 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2542 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2543
2544 /**
2545 * Broadcast Action: The media scanner has finished scanning a directory.
2546 * The path to the scanned directory is contained in the Intent.mData field.
2547 */
2548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2549 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2550
2551 /**
2552 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2553 * The path to the file is contained in the Intent.mData field.
2554 */
2555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2556 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2557
2558 /**
2559 * Broadcast Action: The "Media Button" was pressed. Includes a single
2560 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2561 * caused the broadcast.
2562 */
2563 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2564 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2565
Jaewan Kim52632e22016-01-14 18:01:52 +09002566 /**
2567 * Broadcast Action: The "Picture-in-picture (PIP) Button" was pressed.
2568 * Includes a single extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2569 * caused the broadcast.
2570 * @hide
2571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2573 public static final String ACTION_PICTURE_IN_PICTURE_BUTTON =
2574 "android.intent.action.PICTURE_IN_PICTURE_BUTTON";
2575
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002576 /**
2577 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2578 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2579 * caused the broadcast.
2580 */
2581 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2582 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2583
2584 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2585 // location; they are not general-purpose actions.
2586
2587 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002588 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 */
2590 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2591 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2592 "android.intent.action.GTALK_CONNECTED";
2593
2594 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002595 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002596 */
2597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2598 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2599 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002600
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002601 /**
2602 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002603 */
2604 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2605 public static final String ACTION_INPUT_METHOD_CHANGED =
2606 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002607
2608 /**
2609 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2610 * more radios have been turned off or on. The intent will have the following extra value:</p>
2611 * <ul>
2612 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2613 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2614 * turned off</li>
2615 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002616 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002617 * <p class="note">This is a protected intent that can only be sent
2618 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2622
2623 /**
2624 * Broadcast Action: Some content providers have parts of their namespace
2625 * where they publish new events or items that the user may be especially
2626 * interested in. For these things, they may broadcast this action when the
2627 * set of interesting items change.
2628 *
2629 * For example, GmailProvider sends this notification when the set of unread
2630 * mail in the inbox changes.
2631 *
2632 * <p>The data of the intent identifies which part of which provider
2633 * changed. When queried through the content resolver, the data URI will
2634 * return the data set in question.
2635 *
2636 * <p>The intent will have the following extra values:
2637 * <ul>
2638 * <li><em>count</em> - The number of items in the data set. This is the
2639 * same as the number of items in the cursor returned by querying the
2640 * data URI. </li>
2641 * </ul>
2642 *
2643 * This intent will be sent at boot (if the count is non-zero) and when the
2644 * data set changes. It is possible for the data set to change without the
2645 * count changing (for example, if a new unread message arrives in the same
2646 * sync operation in which a message is archived). The phone should still
2647 * ring/vibrate/etc as normal in this case.
2648 */
2649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2650 public static final String ACTION_PROVIDER_CHANGED =
2651 "android.intent.action.PROVIDER_CHANGED";
2652
2653 /**
2654 * Broadcast Action: Wired Headset plugged in or unplugged.
2655 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002656 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2657 * and documentation.
2658 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002659 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002660 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002661 */
2662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002663 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002664
2665 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002666 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2667 * <ul>
2668 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2669 * </ul>
2670 *
2671 * <p class="note">This is a protected intent that can only be sent
2672 * by the system.
2673 *
2674 * @hide
2675 */
2676 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2677 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2678 = "android.intent.action.ADVANCED_SETTINGS";
2679
2680 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002681 * Broadcast Action: Sent after application restrictions are changed.
2682 *
2683 * <p class="note">This is a protected intent that can only be sent
2684 * by the system.</p>
2685 */
2686 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2687 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2688 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2689
2690 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002691 * Broadcast Action: An outgoing call is about to be placed.
2692 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002693 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002694 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002695 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002696 * the phone number originally intended to be dialed.</li>
2697 * </ul>
2698 * <p>Once the broadcast is finished, the resultData is used as the actual
2699 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002700 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002701 * outgoing call in turn: for example, a parental control application
2702 * might verify that the user is authorized to place the call at that
2703 * time, then a number-rewriting application might add an area code if
2704 * one was not specified.</p>
2705 * <p>For consistency, any receiver whose purpose is to prohibit phone
2706 * calls should have a priority of 0, to ensure it will see the final
2707 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002708 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002709 * should have a positive priority.
2710 * Negative priorities are reserved for the system for this broadcast;
2711 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002712 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2713 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002714 * <p>Emergency calls cannot be intercepted using this mechanism, and
2715 * other calls cannot be modified to call emergency numbers using this
2716 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002717 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2718 * call to use their own service instead. Those apps should first prevent
2719 * the call from being placed by setting resultData to <code>null</code>
2720 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002721 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002722 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2723 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002724 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002725 * <p class="note">This is a protected intent that can only be sent
2726 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002727 */
2728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2729 public static final String ACTION_NEW_OUTGOING_CALL =
2730 "android.intent.action.NEW_OUTGOING_CALL";
2731
2732 /**
2733 * Broadcast Action: Have the device reboot. This is only for use by
2734 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002735 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002736 * <p class="note">This is a protected intent that can only be sent
2737 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002738 */
2739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2740 public static final String ACTION_REBOOT =
2741 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002742
Wei Huang97ecc9c2009-05-11 17:44:20 -07002743 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002744 * Broadcast Action: A sticky broadcast for changes in the physical
2745 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002746 *
2747 * <p>The intent will have the following extra values:
2748 * <ul>
2749 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002750 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002751 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002752 * <p>This is intended for monitoring the current physical dock state.
2753 * See {@link android.app.UiModeManager} for the normal API dealing with
2754 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002755 */
2756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2757 public static final String ACTION_DOCK_EVENT =
2758 "android.intent.action.DOCK_EVENT";
2759
2760 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002761 * Broadcast Action: A broadcast when idle maintenance can be started.
2762 * This means that the user is not interacting with the device and is
2763 * not expected to do so soon. Typical use of the idle maintenance is
2764 * to perform somehow expensive tasks that can be postponed at a moment
2765 * when they will not degrade user experience.
2766 * <p>
2767 * <p class="note">In order to keep the device responsive in case of an
2768 * unexpected user interaction, implementations of a maintenance task
2769 * should be interruptible. In such a scenario a broadcast with action
2770 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2771 * should not do the maintenance work in
2772 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2773 * maintenance service by {@link Context#startService(Intent)}. Also
2774 * you should hold a wake lock while your maintenance service is running
2775 * to prevent the device going to sleep.
2776 * </p>
2777 * <p>
2778 * <p class="note">This is a protected intent that can only be sent by
2779 * the system.
2780 * </p>
2781 *
2782 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002783 *
2784 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002785 */
2786 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2787 public static final String ACTION_IDLE_MAINTENANCE_START =
2788 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2789
2790 /**
2791 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2792 * This means that the user was not interacting with the device as a result
2793 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2794 * was sent and now the user started interacting with the device. Typical
2795 * use of the idle maintenance is to perform somehow expensive tasks that
2796 * can be postponed at a moment when they will not degrade user experience.
2797 * <p>
2798 * <p class="note">In order to keep the device responsive in case of an
2799 * unexpected user interaction, implementations of a maintenance task
2800 * should be interruptible. Hence, on receiving a broadcast with this
2801 * action, the maintenance task should be interrupted as soon as possible.
2802 * In other words, you should not do the maintenance work in
2803 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2804 * maintenance service that was started on receiving of
2805 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2806 * lock you acquired when your maintenance service started.
2807 * </p>
2808 * <p class="note">This is a protected intent that can only be sent
2809 * by the system.
2810 *
2811 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002812 *
2813 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002814 */
2815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2816 public static final String ACTION_IDLE_MAINTENANCE_END =
2817 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2818
2819 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002820 * Broadcast Action: a remote intent is to be broadcasted.
2821 *
2822 * A remote intent is used for remote RPC between devices. The remote intent
2823 * is serialized and sent from one device to another device. The receiving
2824 * device parses the remote intent and broadcasts it. Note that anyone can
2825 * broadcast a remote intent. However, if the intent receiver of the remote intent
2826 * does not trust intent broadcasts from arbitrary intent senders, it should require
2827 * the sender to hold certain permissions so only trusted sender's broadcast will be
2828 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002829 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002830 */
2831 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002832 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002833
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002834 /**
2835 * Broadcast Action: hook for permforming cleanup after a system update.
2836 *
2837 * The broadcast is sent when the system is booting, before the
2838 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2839 * image. A receiver for this should do its work and then disable itself
2840 * so that it does not get run again at the next boot.
2841 * @hide
2842 */
2843 public static final String ACTION_PRE_BOOT_COMPLETED =
2844 "android.intent.action.PRE_BOOT_COMPLETED";
2845
Amith Yamasani13593602012-03-22 16:16:17 -07002846 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002847 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002848 * on restricted users. The broadcast intent contains an extra
2849 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2850 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2851 * String[] depending on the restriction type.<p/>
2852 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002853 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2854 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2855 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002856 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2857 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002858 * @see RestrictionEntry
2859 */
2860 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2861 "android.intent.action.GET_RESTRICTION_ENTRIES";
2862
2863 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002864 * Sent the first time a user is starting, to allow system apps to
2865 * perform one time initialization. (This will not be seen by third
2866 * party applications because a newly initialized user does not have any
2867 * third party applications installed for it.) This is sent early in
2868 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002869 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2870 * broadcast, since it is part of a visible user interaction; be as quick
2871 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002872 */
2873 public static final String ACTION_USER_INITIALIZE =
2874 "android.intent.action.USER_INITIALIZE";
2875
2876 /**
2877 * Sent when a user switch is happening, causing the process's user to be
2878 * brought to the foreground. This is only sent to receivers registered
2879 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2880 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002881 * foreground. This is sent as a foreground
2882 * broadcast, since it is part of a visible user interaction; be as quick
2883 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002884 */
2885 public static final String ACTION_USER_FOREGROUND =
2886 "android.intent.action.USER_FOREGROUND";
2887
2888 /**
2889 * Sent when a user switch is happening, causing the process's user to be
2890 * sent to the background. This is only sent to receivers registered
2891 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2892 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002893 * background. This is sent as a foreground
2894 * broadcast, since it is part of a visible user interaction; be as quick
2895 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002896 */
2897 public static final String ACTION_USER_BACKGROUND =
2898 "android.intent.action.USER_BACKGROUND";
2899
2900 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002901 * Broadcast sent to the system when a user is added. Carries an extra
2902 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2903 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002904 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002905 * @hide
2906 */
2907 public static final String ACTION_USER_ADDED =
2908 "android.intent.action.USER_ADDED";
2909
2910 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002911 * Broadcast sent by the system when a user is started. Carries an extra
2912 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002913 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002914 * that has been started. This is sent as a foreground
2915 * broadcast, since it is part of a visible user interaction; be as quick
2916 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002917 * @hide
2918 */
2919 public static final String ACTION_USER_STARTED =
2920 "android.intent.action.USER_STARTED";
2921
2922 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002923 * Broadcast sent when a user is in the process of starting. Carries an extra
2924 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2925 * sent to registered receivers, not manifest receivers. It is sent to all
2926 * users (including the one that is being started). You must hold
2927 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2928 * this broadcast. This is sent as a background broadcast, since
2929 * its result is not part of the primary UX flow; to safely keep track of
2930 * started/stopped state of a user you can use this in conjunction with
2931 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2932 * other user state broadcasts since those are foreground broadcasts so can
2933 * execute in a different order.
2934 * @hide
2935 */
2936 public static final String ACTION_USER_STARTING =
2937 "android.intent.action.USER_STARTING";
2938
2939 /**
2940 * Broadcast sent when a user is going to be stopped. Carries an extra
2941 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2942 * sent to registered receivers, not manifest receivers. It is sent to all
2943 * users (including the one that is being stopped). You must hold
2944 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2945 * this broadcast. The user will not stop until all receivers have
2946 * handled the broadcast. This is sent as a background broadcast, since
2947 * its result is not part of the primary UX flow; to safely keep track of
2948 * started/stopped state of a user you can use this in conjunction with
2949 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2950 * other user state broadcasts since those are foreground broadcasts so can
2951 * execute in a different order.
2952 * @hide
2953 */
2954 public static final String ACTION_USER_STOPPING =
2955 "android.intent.action.USER_STOPPING";
2956
2957 /**
2958 * Broadcast sent to the system when a user is stopped. Carries an extra
2959 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2960 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2961 * specific package. This is only sent to registered receivers, not manifest
2962 * receivers. It is sent to all running users <em>except</em> the one that
2963 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002964 * @hide
2965 */
2966 public static final String ACTION_USER_STOPPED =
2967 "android.intent.action.USER_STOPPED";
2968
2969 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002970 * 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 -07002971 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002972 * one that has been removed. The user will not be completely removed until all receivers have
2973 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002974 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002975 * @hide
2976 */
2977 public static final String ACTION_USER_REMOVED =
2978 "android.intent.action.USER_REMOVED";
2979
2980 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002981 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002982 * the userHandle of the user to become the current one. This is only sent to
2983 * registered receivers, not manifest receivers. It is sent to all running users.
2984 * You must hold
2985 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002986 * @hide
2987 */
2988 public static final String ACTION_USER_SWITCHED =
2989 "android.intent.action.USER_SWITCHED";
2990
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002991 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002992 * Broadcast Action: Sent when the credential-encrypted private storage has
2993 * become unlocked for the target user. This is only sent to registered
2994 * receivers, not manifest receivers.
2995 */
2996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2997 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
2998
2999 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003000 * Broadcast sent to the system when a user's information changes. Carries an extra
3001 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003002 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003003 * @hide
3004 */
3005 public static final String ACTION_USER_INFO_CHANGED =
3006 "android.intent.action.USER_INFO_CHANGED";
3007
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003008 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003009 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3010 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003011 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3012 * that need to display merged content across both primary and managed profiles need to
3013 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003014 * not manifest receivers.
3015 */
3016 public static final String ACTION_MANAGED_PROFILE_ADDED =
3017 "android.intent.action.MANAGED_PROFILE_ADDED";
3018
3019 /**
3020 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003021 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3022 * Only applications (for example Launchers) that need to display merged content across both
3023 * primary and managed profiles need to worry about this broadcast. This is only sent to
3024 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003025 */
3026 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3027 "android.intent.action.MANAGED_PROFILE_REMOVED";
3028
3029 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003030 * Broadcast sent to the primary user when an associated managed profile's availability has
Rubin Xuf13c9802016-01-21 18:06:00 +00003031 * changed. This includes when the user toggles the profile's quiet mode. Carries an extra
3032 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3033 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3034 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003035 */
3036 public static final String ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED =
3037 "android.intent.action.MANAGED_PROFILE_AVAILABILITY_CHANGED";
3038
3039 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003040 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3041 */
3042 public static final String ACTION_QUICK_CLOCK =
3043 "android.intent.action.QUICK_CLOCK";
3044
Michael Wright0087a142013-02-05 16:29:39 -08003045 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003046 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003047 * @hide
3048 */
3049 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3050 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3051
Justin Kohd378ad72013-04-01 12:18:26 -07003052 /**
3053 * Broadcast Action: A global button was pressed. Includes a single
3054 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3055 * caused the broadcast.
3056 * @hide
3057 */
3058 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3059
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003060 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003061 * Broadcast Action: Sent when media resource is granted.
3062 * <p>
3063 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3064 * granted.
3065 * </p>
3066 * <p class="note">
3067 * This is a protected intent that can only be sent by the system.
3068 * </p>
3069 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003070 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003071 * </p>
3072 *
3073 * @hide
3074 */
3075 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3076 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3077
3078 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003079 * Activity Action: Allow the user to select and return one or more existing
3080 * documents. When invoked, the system will display the various
3081 * {@link DocumentsProvider} instances installed on the device, letting the
3082 * user interactively navigate through them. These documents include local
3083 * media, such as photos and video, and documents provided by installed
3084 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003085 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003086 * Each document is represented as a {@code content://} URI backed by a
3087 * {@link DocumentsProvider}, which can be opened as a stream with
3088 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3089 * {@link android.provider.DocumentsContract.Document} metadata.
3090 * <p>
3091 * All selected documents are returned to the calling application with
3092 * persistable read and write permission grants. If you want to maintain
3093 * access to the documents across device reboots, you need to explicitly
3094 * take the persistable permissions using
3095 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3096 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003097 * Callers must indicate the acceptable document MIME types through
3098 * {@link #setType(String)}. For example, to select photos, use
3099 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3100 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3101 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003102 * <p>
3103 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003104 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3105 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003106 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003107 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3108 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003109 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003110 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003111 * Output: The URI of the item that was picked, returned in
3112 * {@link #getData()}. This must be a {@code content://} URI so that any
3113 * receiver can access it. If multiple documents were selected, they are
3114 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003115 *
3116 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003117 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003118 * @see #ACTION_CREATE_DOCUMENT
3119 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003120 */
3121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3122 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3123
3124 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003125 * Activity Action: Allow the user to create a new document. When invoked,
3126 * the system will display the various {@link DocumentsProvider} instances
3127 * installed on the device, letting the user navigate through them. The
3128 * returned document may be a newly created document with no content, or it
3129 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003130 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003131 * Each document is represented as a {@code content://} URI backed by a
3132 * {@link DocumentsProvider}, which can be opened as a stream with
3133 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3134 * {@link android.provider.DocumentsContract.Document} metadata.
3135 * <p>
3136 * Callers must indicate the concrete MIME type of the document being
3137 * created by setting {@link #setType(String)}. This MIME type cannot be
3138 * changed after the document is created.
3139 * <p>
3140 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3141 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003142 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003143 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3144 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003145 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003146 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003147 * Output: The URI of the item that was created. This must be a
3148 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003149 *
3150 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003151 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003152 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003153 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003154 */
3155 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3156 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3157
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003158 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003159 * Activity Action: Allow the user to pick a directory subtree. When
3160 * invoked, the system will display the various {@link DocumentsProvider}
3161 * instances installed on the device, letting the user navigate through
3162 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003163 * <p>
3164 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003165 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3166 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3167 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003168 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003169 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003170 *
3171 * @see DocumentsContract
3172 */
3173 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003174 public static final String
3175 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003176
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003177 /** {@hide} */
3178 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3179
Christopher Tate6597e342015-02-17 12:15:25 -08003180 /**
3181 * Broadcast action: report that a settings element is being restored from backup. The intent
3182 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3183 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3184 * is the value of that settings entry prior to the restore operation. All of these values are
3185 * represented as strings.
3186 *
3187 * <p>This broadcast is sent only for settings provider entries known to require special handling
3188 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3189 * the provider's backup agent implementation.
3190 *
3191 * @see #EXTRA_SETTING_NAME
3192 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3193 * @see #EXTRA_SETTING_NEW_VALUE
3194 * {@hide}
3195 */
3196 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3197
3198 /** {@hide} */
3199 public static final String EXTRA_SETTING_NAME = "setting_name";
3200 /** {@hide} */
3201 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3202 /** {@hide} */
3203 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3204
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003205 /**
3206 * Activity Action: Process a piece of text.
3207 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3208 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3209 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3210 */
3211 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3212 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3213 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003214 * The name of the extra used to define the text to be processed, as a
3215 * CharSequence. Note that this may be a styled CharSequence, so you must use
3216 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003217 */
3218 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3219 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003220 * 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 +00003221 */
3222 public static final String EXTRA_PROCESS_TEXT_READONLY =
3223 "android.intent.extra.PROCESS_TEXT_READONLY";
3224
Bryce Leebc58f592015-09-25 16:43:01 -07003225 /**
3226 * Broadcast action: reports when a new thermal event has been reached. When the device
3227 * is reaching its maximum temperatue, the thermal level reported
3228 * {@hide}
3229 */
3230 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3231 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3232
3233 /** {@hide} */
3234 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3235
3236 /**
3237 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003238 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003239 * {@hide}
3240 */
3241 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3242
3243 /**
3244 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003245 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003246 * {@hide}
3247 */
3248 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3249
3250 /**
3251 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003252 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003253 * {@hide}
3254 */
3255 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3256
3257
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003258 // ---------------------------------------------------------------------
3259 // ---------------------------------------------------------------------
3260 // Standard intent categories (see addCategory()).
3261
3262 /**
3263 * Set if the activity should be an option for the default action
3264 * (center press) to perform on a piece of data. Setting this will
3265 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003266 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003267 * Intent when initiating an action -- it is for use in intent filters
3268 * specified in packages.
3269 */
3270 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3271 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3272 /**
3273 * Activities that can be safely invoked from a browser must support this
3274 * category. For example, if the user is viewing a web page or an e-mail
3275 * and clicks on a link in the text, the Intent generated execute that
3276 * link will require the BROWSABLE category, so that only activities
3277 * supporting this category will be considered as possible actions. By
3278 * supporting this category, you are promising that there is nothing
3279 * damaging (without user intervention) that can happen by invoking any
3280 * matching Intent.
3281 */
3282 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3283 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3284 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003285 * Categories for activities that can participate in voice interaction.
3286 * An activity that supports this category must be prepared to run with
3287 * no UI shown at all (though in some case it may have a UI shown), and
3288 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3289 */
3290 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3291 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3292 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003293 * Set if the activity should be considered as an alternative action to
3294 * the data the user is currently viewing. See also
3295 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3296 * applies to the selection in a list of items.
3297 *
3298 * <p>Supporting this category means that you would like your activity to be
3299 * displayed in the set of alternative things the user can do, usually as
3300 * part of the current activity's options menu. You will usually want to
3301 * include a specific label in the &lt;intent-filter&gt; of this action
3302 * describing to the user what it does.
3303 *
3304 * <p>The action of IntentFilter with this category is important in that it
3305 * describes the specific action the target will perform. This generally
3306 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3307 * a specific name such as "com.android.camera.action.CROP. Only one
3308 * alternative of any particular action will be shown to the user, so using
3309 * a specific action like this makes sure that your alternative will be
3310 * displayed while also allowing other applications to provide their own
3311 * overrides of that particular action.
3312 */
3313 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3314 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3315 /**
3316 * Set if the activity should be considered as an alternative selection
3317 * action to the data the user has currently selected. This is like
3318 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3319 * of items from which the user can select, giving them alternatives to the
3320 * default action that will be performed on it.
3321 */
3322 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3323 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3324 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003325 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003326 */
3327 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3328 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3329 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003330 * Should be displayed in the top-level launcher.
3331 */
3332 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3333 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3334 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003335 * Indicates an activity optimized for Leanback mode, and that should
3336 * be displayed in the Leanback launcher.
3337 */
3338 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3339 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3340 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003341 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3342 * @hide
3343 */
3344 @SystemApi
3345 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3346 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003347 * Provides information about the package it is in; typically used if
3348 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3349 * a front-door to the user without having to be shown in the all apps list.
3350 */
3351 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3352 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3353 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003354 * This is the home activity, that is the first activity that is displayed
3355 * when the device boots.
3356 */
3357 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3358 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3359 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003360 * This is the home activity that is displayed when the device is finished setting up and ready
3361 * for use.
3362 * @hide
3363 */
3364 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3365 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3366 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003367 * This is the setup wizard activity, that is the first activity that is displayed
3368 * when the user sets up the device for the first time.
3369 * @hide
3370 */
3371 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3372 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3373 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003374 * This activity is a preference panel.
3375 */
3376 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3377 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3378 /**
3379 * This activity is a development preference panel.
3380 */
3381 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3382 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3383 /**
3384 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003385 */
3386 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3387 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3388 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003389 * This activity allows the user to browse and download new applications.
3390 */
3391 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3392 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3393 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003394 * This activity may be exercised by the monkey or other automated test tools.
3395 */
3396 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3397 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3398 /**
3399 * To be used as a test (not part of the normal user experience).
3400 */
3401 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3402 /**
3403 * To be used as a unit test (run through the Test Harness).
3404 */
3405 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3406 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003407 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003408 * experience).
3409 */
3410 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003411
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003412 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003413 * Used to indicate that an intent only wants URIs that can be opened with
3414 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3415 * must support at least the columns defined in {@link OpenableColumns} when
3416 * queried.
3417 *
3418 * @see #ACTION_GET_CONTENT
3419 * @see #ACTION_OPEN_DOCUMENT
3420 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003421 */
3422 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3423 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3424
3425 /**
3426 * To be used as code under test for framework instrumentation tests.
3427 */
3428 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3429 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003430 /**
3431 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003432 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3433 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003434 */
3435 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3436 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3437 /**
3438 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003439 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3440 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003441 */
3442 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3443 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003444 /**
3445 * An activity to run when device is inserted into a analog (low end) dock.
3446 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3447 * information, see {@link android.app.UiModeManager}.
3448 */
3449 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3450 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3451
3452 /**
3453 * An activity to run when device is inserted into a digital (high end) dock.
3454 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3455 * information, see {@link android.app.UiModeManager}.
3456 */
3457 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3458 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003459
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003460 /**
3461 * Used to indicate that the activity can be used in a car environment.
3462 */
3463 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3464 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3465
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003466 // ---------------------------------------------------------------------
3467 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003468 // Application launch intent categories (see addCategory()).
3469
3470 /**
3471 * Used with {@link #ACTION_MAIN} to launch the browser application.
3472 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003473 * <p>NOTE: This should not be used as the primary key of an Intent,
3474 * since it will not result in the app launching with the correct
3475 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003476 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003477 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003478 */
3479 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3480 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3481
3482 /**
3483 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3484 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003485 * <p>NOTE: This should not be used as the primary key of an Intent,
3486 * since it will not result in the app launching with the correct
3487 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003488 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003489 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003490 */
3491 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3492 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3493
3494 /**
3495 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3496 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003497 * <p>NOTE: This should not be used as the primary key of an Intent,
3498 * since it will not result in the app launching with the correct
3499 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003500 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003501 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003502 */
3503 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3504 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3505
3506 /**
3507 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3508 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003509 * <p>NOTE: This should not be used as the primary key of an Intent,
3510 * since it will not result in the app launching with the correct
3511 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003512 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003513 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003514 */
3515 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3516 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3517
3518 /**
3519 * Used with {@link #ACTION_MAIN} to launch the email application.
3520 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003521 * <p>NOTE: This should not be used as the primary key of an Intent,
3522 * since it will not result in the app launching with the correct
3523 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003524 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003525 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003526 */
3527 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3528 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3529
3530 /**
3531 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3532 * The activity should be able to view and manipulate image and video files
3533 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003534 * <p>NOTE: This should not be used as the primary key of an Intent,
3535 * since it will not result in the app launching with the correct
3536 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003537 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003538 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003539 */
3540 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3541 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3542
3543 /**
3544 * Used with {@link #ACTION_MAIN} to launch the maps application.
3545 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003546 * <p>NOTE: This should not be used as the primary key of an Intent,
3547 * since it will not result in the app launching with the correct
3548 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003549 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003550 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003551 */
3552 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3553 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3554
3555 /**
3556 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3557 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003558 * <p>NOTE: This should not be used as the primary key of an Intent,
3559 * since it will not result in the app launching with the correct
3560 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003561 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003562 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003563 */
3564 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3565 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3566
3567 /**
3568 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003569 * The activity should be able to play, browse, or manipulate music files
3570 * stored on the device.
3571 * <p>NOTE: This should not be used as the primary key of an Intent,
3572 * since it will not result in the app launching with the correct
3573 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003574 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003575 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003576 */
3577 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3578 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3579
3580 // ---------------------------------------------------------------------
3581 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003582 // Standard extra data keys.
3583
3584 /**
3585 * The initial data to place in a newly created record. Use with
3586 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3587 * fields as would be given to the underlying ContentProvider.insert()
3588 * call.
3589 */
3590 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3591
3592 /**
3593 * A constant CharSequence that is associated with the Intent, used with
3594 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3595 * this may be a styled CharSequence, so you must use
3596 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3597 * retrieve it.
3598 */
3599 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3600
3601 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003602 * A constant String that is associated with the Intent, used with
3603 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3604 * as HTML formatted text. Note that you <em>must</em> also supply
3605 * {@link #EXTRA_TEXT}.
3606 */
3607 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3608
3609 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003610 * A content: URI holding a stream of data associated with the Intent,
3611 * used with {@link #ACTION_SEND} to supply the data being sent.
3612 */
3613 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3614
3615 /**
3616 * A String[] holding e-mail addresses that should be delivered to.
3617 */
3618 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3619
3620 /**
3621 * A String[] holding e-mail addresses that should be carbon copied.
3622 */
3623 public static final String EXTRA_CC = "android.intent.extra.CC";
3624
3625 /**
3626 * A String[] holding e-mail addresses that should be blind carbon copied.
3627 */
3628 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3629
3630 /**
3631 * A constant string holding the desired subject line of a message.
3632 */
3633 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3634
3635 /**
3636 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003637 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003638 */
3639 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3640
3641 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003642 * An int representing the user id to be used.
3643 *
3644 * @hide
3645 */
3646 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3647
3648 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003649 * An int representing the task id to be retrieved. This is used when a launch from recents is
3650 * intercepted by another action such as credentials confirmation to remember which task should
3651 * be resumed when complete.
3652 *
3653 * @hide
3654 */
3655 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3656
3657 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003658 * An Intent[] describing additional, alternate choices you would like shown with
3659 * {@link #ACTION_CHOOSER}.
3660 *
3661 * <p>An app may be capable of providing several different payload types to complete a
3662 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3663 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3664 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3665 * photo data or a hosted link where the photos can be viewed.</p>
3666 *
3667 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3668 * first/primary/preferred intent in the set. Additional intents specified in
3669 * this extra are ordered; by default intents that appear earlier in the array will be
3670 * preferred over intents that appear later in the array as matches for the same
3671 * target component. To alter this preference, a calling app may also supply
3672 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3673 */
3674 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3675
3676 /**
3677 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3678 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3679 *
3680 * <p>An app preparing an action for another app to complete may wish to allow the user to
3681 * disambiguate between several options for completing the action based on the chosen target
3682 * or otherwise refine the action before it is invoked.
3683 * </p>
3684 *
3685 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3686 * <ul>
3687 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3688 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3689 * chosen target beyond the first</li>
3690 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3691 * should fill in and send once the disambiguation is complete</li>
3692 * </ul>
3693 */
3694 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3695 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3696
3697 /**
3698 * A {@link ResultReceiver} used to return data back to the sender.
3699 *
3700 * <p>Used to complete an app-specific
3701 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3702 *
3703 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3704 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3705 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3706 * when the user selects a target component from the chooser. It is up to the recipient
3707 * to send a result to this ResultReceiver to signal that disambiguation is complete
3708 * and that the chooser should invoke the user's choice.</p>
3709 *
3710 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3711 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3712 * to match and fill in the final Intent or ChooserTarget before starting it.
3713 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3714 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3715 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3716 *
3717 * <p>The result code passed to the ResultReceiver should be
3718 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3719 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3720 * the chooser should finish without starting a target.</p>
3721 */
3722 public static final String EXTRA_RESULT_RECEIVER
3723 = "android.intent.extra.RESULT_RECEIVER";
3724
3725 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003726 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003727 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003728 */
3729 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3730
3731 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003732 * A Parcelable[] of {@link Intent} or
3733 * {@link android.content.pm.LabeledIntent} objects as set with
3734 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3735 * a the front of the list of choices, when shown to the user with a
3736 * {@link #ACTION_CHOOSER}.
3737 */
3738 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3739
3740 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003741 * A {@link IntentSender} to start after ephemeral installation success.
3742 * @hide
3743 */
3744 @SystemApi
3745 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3746
3747 /**
3748 * A {@link IntentSender} to start after ephemeral installation failure.
3749 * @hide
3750 */
3751 @SystemApi
3752 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3753
3754 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003755 * A Bundle forming a mapping of potential target package names to different extras Bundles
3756 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3757 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3758 * be currently installed on the device.
3759 *
3760 * <p>An application may choose to provide alternate extras for the case where a user
3761 * selects an activity from a predetermined set of target packages. If the activity
3762 * the user selects from the chooser belongs to a package with its package name as
3763 * a key in this bundle, the corresponding extras for that package will be merged with
3764 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3765 * extra has the same key as an extra already present in the intent it will overwrite
3766 * the extra from the intent.</p>
3767 *
3768 * <p><em>Examples:</em>
3769 * <ul>
3770 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3771 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3772 * parameters for that target.</li>
3773 * <li>An application may offer additional metadata for known targets of a given intent
3774 * to pass along information only relevant to that target such as account or content
3775 * identifiers already known to that application.</li>
3776 * </ul></p>
3777 */
3778 public static final String EXTRA_REPLACEMENT_EXTRAS =
3779 "android.intent.extra.REPLACEMENT_EXTRAS";
3780
3781 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003782 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3783 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3784 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3785 * {@link ComponentName} of the chosen component.
3786 *
3787 * <p>In some situations this callback may never come, for example if the user abandons
3788 * the chooser, switches to another task or any number of other reasons. Apps should not
3789 * be written assuming that this callback will always occur.</p>
3790 */
3791 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3792 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3793
3794 /**
3795 * The {@link ComponentName} chosen by the user to complete an action.
3796 *
3797 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3798 */
3799 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3800
3801 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003802 * A {@link android.view.KeyEvent} object containing the event that
3803 * triggered the creation of the Intent it is in.
3804 */
3805 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3806
3807 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003808 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3809 * before shutting down.
3810 *
3811 * {@hide}
3812 */
3813 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3814
3815 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003816 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3817 * requested by the user.
3818 *
3819 * {@hide}
3820 */
3821 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3822 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3823
3824 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003825 * 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 -07003826 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3827 * of restarting the application.
3828 */
3829 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3830
3831 /**
3832 * A String holding the phone number originally entered in
3833 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3834 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3835 */
3836 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003837
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003838 /**
3839 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3840 * intents to supply the uid the package had been assigned. Also an optional
3841 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3842 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3843 * purpose.
3844 */
3845 public static final String EXTRA_UID = "android.intent.extra.UID";
3846
3847 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003848 * @hide String array of package names.
3849 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003850 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003851 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3852
3853 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003854 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3855 * intents to indicate whether this represents a full uninstall (removing
3856 * both the code and its data) or a partial uninstall (leaving its data,
3857 * implying that this is an update).
3858 */
3859 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003860
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003861 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003862 * @hide
3863 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3864 * intents to indicate that at this point the package has been removed for
3865 * all users on the device.
3866 */
3867 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3868 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3869
3870 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003871 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3872 * intents to indicate that this is a replacement of the package, so this
3873 * broadcast will immediately be followed by an add broadcast for a
3874 * different version of the same package.
3875 */
3876 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003877
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003878 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003879 * Used as an int extra field in {@link android.app.AlarmManager} intents
3880 * to tell the application being invoked how many pending alarms are being
3881 * delievered with the intent. For one-shot alarms this will always be 1.
3882 * For recurring alarms, this might be greater than 1 if the device was
3883 * asleep or powered off at the time an earlier alarm would have been
3884 * delivered.
3885 */
3886 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003887
Jacek Surazski86b6c532009-05-13 14:38:28 +02003888 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003889 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3890 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003891 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3892 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003893 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3894 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3895 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003896 */
3897 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3898
3899 /**
3900 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3901 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003902 */
3903 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3904
3905 /**
3906 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3907 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003908 */
3909 public static final int EXTRA_DOCK_STATE_DESK = 1;
3910
3911 /**
3912 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3913 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003914 */
3915 public static final int EXTRA_DOCK_STATE_CAR = 2;
3916
3917 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003918 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3919 * to represent that the phone is in a analog (low end) dock.
3920 */
3921 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3922
3923 /**
3924 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3925 * to represent that the phone is in a digital (high end) dock.
3926 */
3927 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3928
3929 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003930 * Boolean that can be supplied as meta-data with a dock activity, to
3931 * indicate that the dock should take over the home key when it is active.
3932 */
3933 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003934
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003935 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003936 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3937 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003938 */
3939 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3940
3941 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003942 * Used in the extra field in the remote intent. It's astring token passed with the
3943 * remote intent.
3944 */
3945 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3946 "android.intent.extra.remote_intent_token";
3947
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003948 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003949 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003950 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003951 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003952 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003953 "android.intent.extra.changed_component_name";
3954
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003955 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003956 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003957 * and contains a string array of all of the components that have changed. If
3958 * the state of the overall package has changed, then it will contain an entry
3959 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003960 */
3961 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3962 "android.intent.extra.changed_component_name_list";
3963
3964 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003965 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003966 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00003967 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
3968 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
3969 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003970 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003971 */
3972 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3973 "android.intent.extra.changed_package_list";
3974
3975 /**
3976 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003977 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3978 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003979 * and contains an integer array of uids of all of the components
3980 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003981 */
3982 public static final String EXTRA_CHANGED_UID_LIST =
3983 "android.intent.extra.changed_uid_list";
3984
3985 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003986 * @hide
3987 * Magic extra system code can use when binding, to give a label for
3988 * who it is that has bound to a service. This is an integer giving
3989 * a framework string resource that can be displayed to the user.
3990 */
3991 public static final String EXTRA_CLIENT_LABEL =
3992 "android.intent.extra.client_label";
3993
3994 /**
3995 * @hide
3996 * Magic extra system code can use when binding, to give a PendingIntent object
3997 * that can be launched for the user to disable the system's use of this
3998 * service.
3999 */
4000 public static final String EXTRA_CLIENT_INTENT =
4001 "android.intent.extra.client_intent";
4002
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004003 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004004 * Extra used to indicate that an intent should only return data that is on
4005 * the local device. This is a boolean extra; the default is false. If true,
4006 * an implementation should only allow the user to select data that is
4007 * already on the device, not requiring it be downloaded from a remote
4008 * service when opened.
4009 *
4010 * @see #ACTION_GET_CONTENT
4011 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004012 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004013 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004014 */
4015 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004016 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004017
Amith Yamasani13593602012-03-22 16:16:17 -07004018 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004019 * Extra used to indicate that an intent can allow the user to select and
4020 * return multiple items. This is a boolean extra; the default is false. If
4021 * true, an implementation is allowed to present the user with a UI where
4022 * they can pick multiple items that are all returned to the caller. When
4023 * this happens, they should be returned as the {@link #getClipData()} part
4024 * of the result Intent.
4025 *
4026 * @see #ACTION_GET_CONTENT
4027 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004028 */
4029 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004030 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004031
4032 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004033 * The integer userHandle carried with broadcast intents related to addition, removal and
4034 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4035 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4036 *
Amith Yamasani13593602012-03-22 16:16:17 -07004037 * @hide
4038 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004039 public static final String EXTRA_USER_HANDLE =
4040 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004041
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004042 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004043 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4044 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4045 */
4046 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004047 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004048
4049 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004050 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004051 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4052 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004053 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004054 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4055
4056 /**
4057 * Extra sent in the intent to the BroadcastReceiver that handles
4058 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4059 * the restrictions as key/value pairs.
4060 */
4061 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4062 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004063
Amith Yamasani86118ba2013-03-28 14:33:16 -07004064 /**
4065 * Extra used in the response from a BroadcastReceiver that handles
4066 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4067 */
4068 public static final String EXTRA_RESTRICTIONS_INTENT =
4069 "android.intent.extra.restrictions_intent";
4070
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004071 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004072 * Extra used to communicate a set of acceptable MIME types. The type of the
4073 * extra is {@code String[]}. Values may be a combination of concrete MIME
4074 * types (such as "image/png") and/or partial MIME types (such as
4075 * "audio/*").
4076 *
4077 * @see #ACTION_GET_CONTENT
4078 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004079 */
4080 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4081
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004082 /**
4083 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4084 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004085 * When this is true, hardware devices can use this information to determine that
4086 * they shouldn't do a complete shutdown of their device since this is not a
4087 * complete shutdown down to the kernel, but only user space restarting.
4088 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004089 */
4090 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4091 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4092
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004093 /**
4094 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4095 * user has set their time format preferences to the 24 hour format.
4096 *
4097 * @hide for internal use only.
4098 */
4099 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4100 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4101
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004102 /** {@hide} */
4103 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4104
Rubin Xue8490f12015-06-25 12:17:48 +01004105 /** {@hide} */
4106 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4107
Santos Cordon15a13782015-03-31 18:32:31 -07004108 /**
4109 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4110 * activation request.
4111 * TODO: Add information about the structure and response data used with the pending intent.
4112 * @hide
4113 */
4114 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4115 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4116
Steve McKay6eaf38632015-08-04 10:11:01 -07004117 /** {@hide} */
4118 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4119
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004120 /**
4121 * Optional boolean extra indicating whether quiet mode has been switched on or off.
4122 */
4123 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004124
4125 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004126 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004127 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004128 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4129 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004130 *
4131 * @hide
4132 */
4133 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4134 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4135
4136 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004137 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004138 * to represent that a video codec is allowed to use.
4139 *
4140 * @hide
4141 */
4142 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4143
4144 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004145 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004146 * to represent that a audio codec is allowed to use.
4147 *
4148 * @hide
4149 */
4150 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4151
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004152 // ---------------------------------------------------------------------
4153 // ---------------------------------------------------------------------
4154 // Intent flags (see mFlags variable).
4155
Tor Norbyed9273d62013-05-30 15:59:53 -07004156 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004157 @IntDef(flag = true, value = {
4158 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4159 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004160 @Retention(RetentionPolicy.SOURCE)
4161 public @interface GrantUriMode {}
4162
Jeff Sharkey846318a2014-04-04 12:12:41 -07004163 /** @hide */
4164 @IntDef(flag = true, value = {
4165 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4166 @Retention(RetentionPolicy.SOURCE)
4167 public @interface AccessUriMode {}
4168
4169 /**
4170 * Test if given mode flags specify an access mode, which must be at least
4171 * read and/or write.
4172 *
4173 * @hide
4174 */
4175 public static boolean isAccessUriMode(int modeFlags) {
4176 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4177 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4178 }
4179
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004180 /**
4181 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004182 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004183 * specified in its ClipData. When applying to an Intent's ClipData,
4184 * all URIs as well as recursive traversals through data or other ClipData
4185 * in Intent items will be granted; only the grant flags of the top-level
4186 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004187 */
4188 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4189 /**
4190 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004191 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004192 * specified in its ClipData. When applying to an Intent's ClipData,
4193 * all URIs as well as recursive traversals through data or other ClipData
4194 * in Intent items will be granted; only the grant flags of the top-level
4195 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004196 */
4197 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4198 /**
4199 * Can be set by the caller to indicate that this Intent is coming from
4200 * a background operation, not from direct user interaction.
4201 */
4202 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4203 /**
4204 * A flag you can enable for debugging: when set, log messages will be
4205 * printed during the resolution of this intent to show you what has
4206 * been found to create the final resolved list.
4207 */
4208 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004209 /**
4210 * If set, this intent will not match any components in packages that
4211 * are currently stopped. If this is not set, then the default behavior
4212 * is to include such applications in the result.
4213 */
4214 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4215 /**
4216 * If set, this intent will always match any components in packages that
4217 * are currently stopped. This is the default behavior when
4218 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4219 * flags are set, this one wins (it allows overriding of exclude for
4220 * places where the framework may automatically set the exclude flag).
4221 */
4222 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004223
4224 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004225 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004226 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004227 * persisted across device reboots until explicitly revoked with
4228 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4229 * grant for possible persisting; the receiving application must call
4230 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4231 * actually persist.
4232 *
4233 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4234 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4235 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004236 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004237 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004238 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004239
4240 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004241 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4242 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4243 * applies to any URI that is a prefix match against the original granted
4244 * URI. (Without this flag, the URI must match exactly for access to be
4245 * granted.) Another URI is considered a prefix match only when scheme,
4246 * authority, and all path segments defined by the prefix are an exact
4247 * match.
4248 */
4249 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4250
4251 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004252 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004253 * homework and verified that they correctly handle packages and components
4254 * that come and go over time. In particular:
4255 * <ul>
4256 * <li>Apps installed on external storage, which will appear to be
4257 * uninstalled while the the device is ejected.
4258 * <li>Apps with encryption unaware components, which will appear to not
4259 * exist while the device is locked.
4260 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004261 *
4262 * @hide
4263 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004264 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004265
4266 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004267 * If set, the new activity is not kept in the history stack. As soon as
4268 * the user navigates away from it, the activity is finished. This may also
4269 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4270 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004271 *
4272 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4273 * is never invoked when the current activity starts a new activity which
4274 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004275 */
4276 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4277 /**
4278 * If set, the activity will not be launched if it is already running
4279 * at the top of the history stack.
4280 */
4281 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4282 /**
4283 * If set, this activity will become the start of a new task on this
4284 * history stack. A task (from the activity that started it to the
4285 * next task activity) defines an atomic group of activities that the
4286 * user can move to. Tasks can be moved to the foreground and background;
4287 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004288 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004289 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4290 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004291 *
4292 * <p>This flag is generally used by activities that want
4293 * to present a "launcher" style behavior: they give the user a list of
4294 * separate things that can be done, which otherwise run completely
4295 * independently of the activity launching them.
4296 *
4297 * <p>When using this flag, if a task is already running for the activity
4298 * you are now starting, then a new activity will not be started; instead,
4299 * the current task will simply be brought to the front of the screen with
4300 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4301 * to disable this behavior.
4302 *
4303 * <p>This flag can not be used when the caller is requesting a result from
4304 * the activity being launched.
4305 */
4306 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4307 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004308 * This flag is used to create a new task and launch an activity into it.
4309 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4310 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4311 * search through existing tasks for ones matching this Intent. Only if no such
4312 * task is found would a new task be created. When paired with
4313 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4314 * the search for a matching task and unconditionally start a new task.
4315 *
4316 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4317 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004318 * top-level application launcher.</strong> Used in conjunction with
4319 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4320 * behavior of bringing an existing task to the foreground. When set,
4321 * a new task is <em>always</em> started to host the Activity for the
4322 * Intent, regardless of whether there is already an existing task running
4323 * the same thing.
4324 *
4325 * <p><strong>Because the default system does not include graphical task management,
4326 * you should not use this flag unless you provide some way for a user to
4327 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004328 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004329 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4330 * creating new document tasks.
4331 *
4332 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004333 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004334 *
Scott Main7aee61f2011-02-08 11:25:01 -08004335 * <p>See
4336 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4337 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004338 *
4339 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4340 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004341 */
4342 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4343 /**
4344 * If set, and the activity being launched is already running in the
4345 * current task, then instead of launching a new instance of that activity,
4346 * all of the other activities on top of it will be closed and this Intent
4347 * will be delivered to the (now on top) old activity as a new Intent.
4348 *
4349 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4350 * If D calls startActivity() with an Intent that resolves to the component
4351 * of activity B, then C and D will be finished and B receive the given
4352 * Intent, resulting in the stack now being: A, B.
4353 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004354 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004355 * either receive the new intent you are starting here in its
4356 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004357 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004358 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4359 * the same intent, then it will be finished and re-created; for all other
4360 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4361 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004362 *
4363 * <p>This launch mode can also be used to good effect in conjunction with
4364 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4365 * of a task, it will bring any currently running instance of that task
4366 * to the foreground, and then clear it to its root state. This is
4367 * especially useful, for example, when launching an activity from the
4368 * notification manager.
4369 *
Scott Main7aee61f2011-02-08 11:25:01 -08004370 * <p>See
4371 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4372 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004373 */
4374 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4375 /**
4376 * If set and this intent is being used to launch a new activity from an
4377 * existing one, then the reply target of the existing activity will be
4378 * transfered to the new activity. This way the new activity can call
4379 * {@link android.app.Activity#setResult} and have that result sent back to
4380 * the reply target of the original activity.
4381 */
4382 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4383 /**
4384 * If set and this intent is being used to launch a new activity from an
4385 * existing one, the current activity will not be counted as the top
4386 * activity for deciding whether the new intent should be delivered to
4387 * the top instead of starting a new one. The previous activity will
4388 * be used as the top, with the assumption being that the current activity
4389 * will finish itself immediately.
4390 */
4391 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4392 /**
4393 * If set, the new activity is not kept in the list of recently launched
4394 * activities.
4395 */
4396 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4397 /**
4398 * This flag is not normally set by application code, but set for you by
4399 * the system as described in the
4400 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4401 * launchMode} documentation for the singleTask mode.
4402 */
4403 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4404 /**
4405 * If set, and this activity is either being started in a new task or
4406 * bringing to the top an existing task, then it will be launched as
4407 * the front door of the task. This will result in the application of
4408 * any affinities needed to have that task in the proper state (either
4409 * moving activities to or from it), or simply resetting that task to
4410 * its initial state if needed.
4411 */
4412 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4413 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004414 * This flag is not normally set by application code, but set for you by
4415 * the system if this activity is being launched from history
4416 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004417 */
4418 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004419 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004420 * @deprecated As of API 21 this performs identically to
4421 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004422 */
4423 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004424 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004425 * This flag is used to open a document into a new task rooted at the activity launched
4426 * by this Intent. Through the use of this flag, or its equivalent attribute,
4427 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004428 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004429 *
Craig Mautner026596b2014-05-21 15:35:44 -07004430 * <p>The use of the activity attribute form of this,
4431 * {@link android.R.attr#documentLaunchMode}, is
4432 * preferred over the Intent flag described here. The attribute form allows the
4433 * Activity to specify multiple document behavior for all launchers of the Activity
4434 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004435 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004436 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4437 * it is kept after the activity is finished is different than the use of
4438 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4439 * this flag is being used to create a new recents entry, then by default that entry
4440 * will be removed once the activity is finished. You can modify this behavior with
4441 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4442 *
Craig Mautner026596b2014-05-21 15:35:44 -07004443 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4444 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4445 * equivalent of the Activity manifest specifying {@link
4446 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4447 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4448 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004449 *
Craig Mautner026596b2014-05-21 15:35:44 -07004450 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004451 *
Craig Mautner026596b2014-05-21 15:35:44 -07004452 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004453 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4454 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004455 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004456 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004457 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004458 * callback from occurring on the current frontmost activity before it is
4459 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004460 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004461 * <p>Typically, an activity can rely on that callback to indicate that an
4462 * explicit user action has caused their activity to be moved out of the
4463 * foreground. The callback marks an appropriate point in the activity's
4464 * lifecycle for it to dismiss any notifications that it intends to display
4465 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004466 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004467 * <p>If an activity is ever started via any non-user-driven events such as
4468 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4469 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004470 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004471 */
4472 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004473 /**
4474 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4475 * this flag will cause the launched activity to be brought to the front of its
4476 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004477 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004478 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4479 * If D calls startActivity() with an Intent that resolves to the component
4480 * of activity B, then B will be brought to the front of the history stack,
4481 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004482 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004483 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004484 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004485 */
4486 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004487 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004488 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4489 * this flag will prevent the system from applying an activity transition
4490 * animation to go to the next activity state. This doesn't mean an
4491 * animation will never run -- if another activity change happens that doesn't
4492 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004493 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004494 * when you are going to do a series of activity operations but the
4495 * animation seen by the user shouldn't be driven by the first activity
4496 * change but rather a later one.
4497 */
4498 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4499 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004500 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4501 * this flag will cause any existing task that would be associated with the
4502 * activity to be cleared before the activity is started. That is, the activity
4503 * becomes the new root of an otherwise empty task, and any old activities
4504 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4505 */
4506 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4507 /**
4508 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4509 * this flag will cause a newly launching task to be placed on top of the current
4510 * home activity task (if there is one). That is, pressing back from the task
4511 * will always return the user to home even if that was not the last activity they
4512 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4513 */
4514 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4515 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004516 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4517 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004518 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004519 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004520 * this flag. When set and the task's activity is finished, the recents
4521 * entry will remain in the interface for the user to re-launch it, like a
4522 * recents entry for a top-level application.
4523 * <p>
4524 * The receiving activity can override this request with
4525 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4526 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004527 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004528 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004529 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004530
4531 /**
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004532 * This flag is only used in the multi-window mode. The new activity will be displayed on
4533 * the other side than the one that is launching it. This can only be used in conjunction with
4534 * {@link #FLAG_ACTIVITY_NEW_TASK}.
4535 */
4536 public static final int FLAG_ACTIVITY_LAUNCH_TO_SIDE = 0x00001000;
4537
4538 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004539 * If set, when sending a broadcast only registered receivers will be
4540 * called -- no BroadcastReceiver components will be launched.
4541 */
4542 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004543 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004544 * If set, when sending a broadcast the new broadcast will replace
4545 * any existing pending broadcast that matches it. Matching is defined
4546 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4547 * true for the intents of the two broadcasts. When a match is found,
4548 * the new broadcast (and receivers associated with it) will replace the
4549 * existing one in the pending broadcast list, remaining at the same
4550 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004551 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004552 * <p>This flag is most typically used with sticky broadcasts, which
4553 * only care about delivering the most recent values of the broadcast
4554 * to their receivers.
4555 */
4556 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4557 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004558 * If set, when sending a broadcast the recipient is allowed to run at
4559 * foreground priority, with a shorter timeout interval. During normal
4560 * broadcasts the receivers are not automatically hoisted out of the
4561 * background priority class.
4562 */
4563 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4564 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004565 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4566 * They can still propagate results through to later receivers, but they can not prevent
4567 * later receivers from seeing the broadcast.
4568 */
4569 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4570 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004571 * If set, when sending a broadcast <i>before boot has completed</i> only
4572 * registered receivers will be called -- no BroadcastReceiver components
4573 * will be launched. Sticky intent state will be recorded properly even
4574 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4575 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004576 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004577 * <p>This flag is only for use by system sevices as a convenience to
4578 * avoid having to implement a more complex mechanism around detection
4579 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004580 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004581 * @hide
4582 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004583 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004584 /**
4585 * Set when this broadcast is for a boot upgrade, a special mode that
4586 * allows the broadcast to be sent before the system is ready and launches
4587 * the app process with no providers running in it.
4588 * @hide
4589 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004590 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004591 /**
4592 * If set, the broadcast will always go to manifest receivers in background (cached
4593 * or not running) apps, regardless of whether that would be done by default. By
4594 * default they will only receive broadcasts if the broadcast has specified an
4595 * explicit component or package name.
4596 * @hide
4597 */
4598 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4599 /**
4600 * If set, the broadcast will never go to manifest receivers in background (cached
4601 * or not running) apps, regardless of whether that would be done by default. By
4602 * default they will receive broadcasts if the broadcast has specified an
4603 * explicit component or package name.
4604 * @hide
4605 */
4606 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004607
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004608 /**
4609 * @hide Flags that can't be changed with PendingIntent.
4610 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004611 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4612 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4613 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004614
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004615 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004616 // ---------------------------------------------------------------------
4617 // toUri() and parseUri() options.
4618
4619 /**
4620 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4621 * always has the "intent:" scheme. This syntax can be used when you want
4622 * to later disambiguate between URIs that are intended to describe an
4623 * Intent vs. all others that should be treated as raw URIs. When used
4624 * with {@link #parseUri}, any other scheme will result in a generic
4625 * VIEW action for that raw URI.
4626 */
4627 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004628
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004629 /**
4630 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4631 * always has the "android-app:" scheme. This is a variation of
4632 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4633 * http/https URI being delivered to a specific package name. The format
4634 * is:
4635 *
4636 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004637 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004638 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004639 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4640 * you must also include a scheme; including a path also requires both a host and a scheme.
4641 * The final #Intent; fragment can be used without a scheme, host, or path.
4642 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004643 * used with intents that have a {@link #setSelector}, since the base intent
4644 * will always have an explicit package name.</p>
4645 *
4646 * <p>Some examples of how this scheme maps to Intent objects:</p>
4647 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4648 * <colgroup align="left" />
4649 * <colgroup align="left" />
4650 * <thead>
4651 * <tr><th>URI</th> <th>Intent</th></tr>
4652 * </thead>
4653 *
4654 * <tbody>
4655 * <tr><td><code>android-app://com.example.app</code></td>
4656 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4657 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4658 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4659 * </table></td>
4660 * </tr>
4661 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4662 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4663 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4664 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4665 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4666 * </table></td>
4667 * </tr>
4668 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4669 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4670 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4671 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4672 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4673 * </table></td>
4674 * </tr>
4675 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4676 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4677 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4678 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4679 * </table></td>
4680 * </tr>
4681 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4682 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4683 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4684 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4685 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4686 * </table></td>
4687 * </tr>
4688 * <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>
4689 * <td><table border="" style="margin:0" >
4690 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4691 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4692 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4693 * </table></td>
4694 * </tr>
4695 * </tbody>
4696 * </table>
4697 */
4698 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4699
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004700 /**
4701 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4702 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4703 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4704 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4705 * generated Intent can not cause unexpected data access to happen.
4706 *
4707 * <p>If you do not trust the source of the URI being parsed, you should still do further
4708 * processing to protect yourself from it. In particular, when using it to start an
4709 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4710 * that can handle it.</p>
4711 */
4712 public static final int URI_ALLOW_UNSAFE = 1<<2;
4713
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004714 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004715
4716 private String mAction;
4717 private Uri mData;
4718 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004719 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004720 private ComponentName mComponent;
4721 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004722 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004723 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004724 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004725 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004726 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004727 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004728
4729 // ---------------------------------------------------------------------
4730
4731 /**
4732 * Create an empty intent.
4733 */
4734 public Intent() {
4735 }
4736
4737 /**
4738 * Copy constructor.
4739 */
4740 public Intent(Intent o) {
4741 this.mAction = o.mAction;
4742 this.mData = o.mData;
4743 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004744 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004745 this.mComponent = o.mComponent;
4746 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004747 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004748 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004749 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004750 }
4751 if (o.mExtras != null) {
4752 this.mExtras = new Bundle(o.mExtras);
4753 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004754 if (o.mSourceBounds != null) {
4755 this.mSourceBounds = new Rect(o.mSourceBounds);
4756 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004757 if (o.mSelector != null) {
4758 this.mSelector = new Intent(o.mSelector);
4759 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004760 if (o.mClipData != null) {
4761 this.mClipData = new ClipData(o.mClipData);
4762 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004763 }
4764
4765 @Override
4766 public Object clone() {
4767 return new Intent(this);
4768 }
4769
4770 private Intent(Intent o, boolean all) {
4771 this.mAction = o.mAction;
4772 this.mData = o.mData;
4773 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004774 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004775 this.mComponent = o.mComponent;
4776 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004777 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004778 }
4779 }
4780
4781 /**
4782 * Make a clone of only the parts of the Intent that are relevant for
4783 * filter matching: the action, data, type, component, and categories.
4784 */
4785 public Intent cloneFilter() {
4786 return new Intent(this, false);
4787 }
4788
4789 /**
4790 * Create an intent with a given action. All other fields (data, type,
4791 * class) are null. Note that the action <em>must</em> be in a
4792 * namespace because Intents are used globally in the system -- for
4793 * example the system VIEW action is android.intent.action.VIEW; an
4794 * application's custom action would be something like
4795 * com.google.app.myapp.CUSTOM_ACTION.
4796 *
4797 * @param action The Intent action, such as ACTION_VIEW.
4798 */
4799 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004800 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004801 }
4802
4803 /**
4804 * Create an intent with a given action and for a given data url. Note
4805 * that the action <em>must</em> be in a namespace because Intents are
4806 * used globally in the system -- for example the system VIEW action is
4807 * android.intent.action.VIEW; an application's custom action would be
4808 * something like com.google.app.myapp.CUSTOM_ACTION.
4809 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004810 * <p><em>Note: scheme and host name matching in the Android framework is
4811 * case-sensitive, unlike the formal RFC. As a result,
4812 * you should always ensure that you write your Uri with these elements
4813 * using lower case letters, and normalize any Uris you receive from
4814 * outside of Android to ensure the scheme and host is lower case.</em></p>
4815 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004816 * @param action The Intent action, such as ACTION_VIEW.
4817 * @param uri The Intent data URI.
4818 */
4819 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004820 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004821 mData = uri;
4822 }
4823
4824 /**
4825 * Create an intent for a specific component. All other fields (action, data,
4826 * type, class) are null, though they can be modified later with explicit
4827 * calls. This provides a convenient way to create an intent that is
4828 * intended to execute a hard-coded class name, rather than relying on the
4829 * system to find an appropriate class for you; see {@link #setComponent}
4830 * for more information on the repercussions of this.
4831 *
4832 * @param packageContext A Context of the application package implementing
4833 * this class.
4834 * @param cls The component class that is to be used for the intent.
4835 *
4836 * @see #setClass
4837 * @see #setComponent
4838 * @see #Intent(String, android.net.Uri , Context, Class)
4839 */
4840 public Intent(Context packageContext, Class<?> cls) {
4841 mComponent = new ComponentName(packageContext, cls);
4842 }
4843
4844 /**
4845 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004846 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004847 * construct the Intent and then calling {@link #setClass} to set its
4848 * class.
4849 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004850 * <p><em>Note: scheme and host name matching in the Android framework is
4851 * case-sensitive, unlike the formal RFC. As a result,
4852 * you should always ensure that you write your Uri with these elements
4853 * using lower case letters, and normalize any Uris you receive from
4854 * outside of Android to ensure the scheme and host is lower case.</em></p>
4855 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004856 * @param action The Intent action, such as ACTION_VIEW.
4857 * @param uri The Intent data URI.
4858 * @param packageContext A Context of the application package implementing
4859 * this class.
4860 * @param cls The component class that is to be used for the intent.
4861 *
4862 * @see #Intent(String, android.net.Uri)
4863 * @see #Intent(Context, Class)
4864 * @see #setClass
4865 * @see #setComponent
4866 */
4867 public Intent(String action, Uri uri,
4868 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004869 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004870 mData = uri;
4871 mComponent = new ComponentName(packageContext, cls);
4872 }
4873
4874 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004875 * Create an intent to launch the main (root) activity of a task. This
4876 * is the Intent that is started when the application's is launched from
4877 * Home. For anything else that wants to launch an application in the
4878 * same way, it is important that they use an Intent structured the same
4879 * way, and can use this function to ensure this is the case.
4880 *
4881 * <p>The returned Intent has the given Activity component as its explicit
4882 * component, {@link #ACTION_MAIN} as its action, and includes the
4883 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4884 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4885 * to do that through {@link #addFlags(int)} on the returned Intent.
4886 *
4887 * @param mainActivity The main activity component that this Intent will
4888 * launch.
4889 * @return Returns a newly created Intent that can be used to launch the
4890 * activity as a main application entry.
4891 *
4892 * @see #setClass
4893 * @see #setComponent
4894 */
4895 public static Intent makeMainActivity(ComponentName mainActivity) {
4896 Intent intent = new Intent(ACTION_MAIN);
4897 intent.setComponent(mainActivity);
4898 intent.addCategory(CATEGORY_LAUNCHER);
4899 return intent;
4900 }
4901
4902 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004903 * Make an Intent for the main activity of an application, without
4904 * specifying a specific activity to run but giving a selector to find
4905 * the activity. This results in a final Intent that is structured
4906 * the same as when the application is launched from
4907 * Home. For anything else that wants to launch an application in the
4908 * same way, it is important that they use an Intent structured the same
4909 * way, and can use this function to ensure this is the case.
4910 *
4911 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4912 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4913 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4914 * to do that through {@link #addFlags(int)} on the returned Intent.
4915 *
4916 * @param selectorAction The action name of the Intent's selector.
4917 * @param selectorCategory The name of a category to add to the Intent's
4918 * selector.
4919 * @return Returns a newly created Intent that can be used to launch the
4920 * activity as a main application entry.
4921 *
4922 * @see #setSelector(Intent)
4923 */
4924 public static Intent makeMainSelectorActivity(String selectorAction,
4925 String selectorCategory) {
4926 Intent intent = new Intent(ACTION_MAIN);
4927 intent.addCategory(CATEGORY_LAUNCHER);
4928 Intent selector = new Intent();
4929 selector.setAction(selectorAction);
4930 selector.addCategory(selectorCategory);
4931 intent.setSelector(selector);
4932 return intent;
4933 }
4934
4935 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004936 * Make an Intent that can be used to re-launch an application's task
4937 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4938 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4939 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4940 *
4941 * @param mainActivity The activity component that is the root of the
4942 * task; this is the activity that has been published in the application's
4943 * manifest as the main launcher icon.
4944 *
4945 * @return Returns a newly created Intent that can be used to relaunch the
4946 * activity's task in its root state.
4947 */
4948 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4949 Intent intent = makeMainActivity(mainActivity);
4950 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4951 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4952 return intent;
4953 }
4954
4955 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004956 * Call {@link #parseUri} with 0 flags.
4957 * @deprecated Use {@link #parseUri} instead.
4958 */
4959 @Deprecated
4960 public static Intent getIntent(String uri) throws URISyntaxException {
4961 return parseUri(uri, 0);
4962 }
Tom Taylord4a47292009-12-21 13:59:18 -08004963
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004964 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004965 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004966 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004967 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004968 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004969 *
4970 * <p>The URI given here must not be relative -- that is, it must include
4971 * the scheme and full path.
4972 *
4973 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004974 * @param flags Additional processing flags. Either 0,
4975 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004976 *
4977 * @return Intent The newly created Intent object.
4978 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004979 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4980 * it bad (as parsed by the Uri class) or the Intent data within the
4981 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004982 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004983 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004984 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004985 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004986 int i = 0;
4987 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004988 final boolean androidApp = uri.startsWith("android-app:");
4989
4990 // Validate intent scheme if requested.
4991 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4992 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004993 Intent intent = new Intent(ACTION_VIEW);
4994 try {
4995 intent.setData(Uri.parse(uri));
4996 } catch (IllegalArgumentException e) {
4997 throw new URISyntaxException(uri, e.getMessage());
4998 }
4999 return intent;
5000 }
5001 }
Tom Taylord4a47292009-12-21 13:59:18 -08005002
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005003 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005004 // simple case
5005 if (i == -1) {
5006 if (!androidApp) {
5007 return new Intent(ACTION_VIEW, Uri.parse(uri));
5008 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005009
5010 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005011 } else if (!uri.startsWith("#Intent;", i)) {
5012 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005013 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005014 } else {
5015 i = -1;
5016 }
5017 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005018
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005019 // new format
5020 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005021 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005022 boolean explicitAction = false;
5023 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005024
5025 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005026 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005027 String data;
5028 if (i >= 0) {
5029 data = uri.substring(0, i);
5030 i += 8; // length of "#Intent;"
5031 } else {
5032 data = uri;
5033 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005034
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005035 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005036 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005037 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005038 if (eq < 0) eq = i-1;
5039 int semi = uri.indexOf(';', i);
5040 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005041
5042 // action
5043 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005044 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005045 if (!inSelector) {
5046 explicitAction = true;
5047 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005048 }
5049
5050 // categories
5051 else if (uri.startsWith("category=", i)) {
5052 intent.addCategory(value);
5053 }
5054
5055 // type
5056 else if (uri.startsWith("type=", i)) {
5057 intent.mType = value;
5058 }
5059
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005060 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005061 else if (uri.startsWith("launchFlags=", i)) {
5062 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005063 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5064 intent.mFlags &= ~IMMUTABLE_FLAGS;
5065 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005066 }
5067
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005068 // package
5069 else if (uri.startsWith("package=", i)) {
5070 intent.mPackage = value;
5071 }
5072
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005073 // component
5074 else if (uri.startsWith("component=", i)) {
5075 intent.mComponent = ComponentName.unflattenFromString(value);
5076 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005077
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005078 // scheme
5079 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005080 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005081 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005082 } else {
5083 scheme = value;
5084 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005085 }
5086
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005087 // source bounds
5088 else if (uri.startsWith("sourceBounds=", i)) {
5089 intent.mSourceBounds = Rect.unflattenFromString(value);
5090 }
5091
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005092 // selector
5093 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5094 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005095 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005096 }
5097
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005098 // extra
5099 else {
5100 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005101 // create Bundle if it doesn't already exist
5102 if (intent.mExtras == null) intent.mExtras = new Bundle();
5103 Bundle b = intent.mExtras;
5104 // add EXTRA
5105 if (uri.startsWith("S.", i)) b.putString(key, value);
5106 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5107 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5108 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5109 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5110 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5111 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5112 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5113 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5114 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5115 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005116
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005117 // move to the next item
5118 i = semi + 1;
5119 }
5120
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005121 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005122 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005123 if (baseIntent.mPackage == null) {
5124 baseIntent.setSelector(intent);
5125 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005126 intent = baseIntent;
5127 }
5128
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005129 if (data != null) {
5130 if (data.startsWith("intent:")) {
5131 data = data.substring(7);
5132 if (scheme != null) {
5133 data = scheme + ':' + data;
5134 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005135 } else if (data.startsWith("android-app:")) {
5136 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5137 // Correctly formed android-app, first part is package name.
5138 int end = data.indexOf('/', 14);
5139 if (end < 0) {
5140 // All we have is a package name.
5141 intent.mPackage = data.substring(14);
5142 if (!explicitAction) {
5143 intent.setAction(ACTION_MAIN);
5144 }
5145 data = "";
5146 } else {
5147 // Target the Intent at the given package name always.
5148 String authority = null;
5149 intent.mPackage = data.substring(14, end);
5150 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005151 if ((end+1) < data.length()) {
5152 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5153 // Found a scheme, remember it.
5154 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005155 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005156 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5157 // Found a authority, remember it.
5158 authority = data.substring(end+1, newEnd);
5159 end = newEnd;
5160 }
5161 } else {
5162 // All we have is a scheme.
5163 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005164 }
5165 }
5166 if (scheme == null) {
5167 // If there was no scheme, then this just targets the package.
5168 if (!explicitAction) {
5169 intent.setAction(ACTION_MAIN);
5170 }
5171 data = "";
5172 } else if (authority == null) {
5173 data = scheme + ":";
5174 } else {
5175 data = scheme + "://" + authority + data.substring(end);
5176 }
5177 }
5178 } else {
5179 data = "";
5180 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005181 }
Tom Taylord4a47292009-12-21 13:59:18 -08005182
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005183 if (data.length() > 0) {
5184 try {
5185 intent.mData = Uri.parse(data);
5186 } catch (IllegalArgumentException e) {
5187 throw new URISyntaxException(uri, e.getMessage());
5188 }
5189 }
5190 }
Tom Taylord4a47292009-12-21 13:59:18 -08005191
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005192 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005193
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005194 } catch (IndexOutOfBoundsException e) {
5195 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5196 }
5197 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005198
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005199 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005200 return getIntentOld(uri, 0);
5201 }
5202
5203 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005204 Intent intent;
5205
5206 int i = uri.lastIndexOf('#');
5207 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005208 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005209 final int intentFragmentStart = i;
5210 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005211
5212 i++;
5213
5214 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005215 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005216 i += 7;
5217 int j = uri.indexOf(')', i);
5218 action = uri.substring(i, j);
5219 i = j + 1;
5220 }
5221
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005222 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005223
5224 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005225 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005226 i += 11;
5227 int j = uri.indexOf(')', i);
5228 while (i < j) {
5229 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005230 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005231 if (i < sep) {
5232 intent.addCategory(uri.substring(i, sep));
5233 }
5234 i = sep + 1;
5235 }
5236 i = j + 1;
5237 }
5238
5239 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005240 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005241 i += 5;
5242 int j = uri.indexOf(')', i);
5243 intent.mType = uri.substring(i, j);
5244 i = j + 1;
5245 }
5246
5247 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005248 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005249 i += 12;
5250 int j = uri.indexOf(')', i);
5251 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005252 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5253 intent.mFlags &= ~IMMUTABLE_FLAGS;
5254 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005255 i = j + 1;
5256 }
5257
5258 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005259 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005260 i += 10;
5261 int j = uri.indexOf(')', i);
5262 int sep = uri.indexOf('!', i);
5263 if (sep >= 0 && sep < j) {
5264 String pkg = uri.substring(i, sep);
5265 String cls = uri.substring(sep + 1, j);
5266 intent.mComponent = new ComponentName(pkg, cls);
5267 }
5268 i = j + 1;
5269 }
5270
5271 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005272 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005273 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005274
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005275 final int closeParen = uri.indexOf(')', i);
5276 if (closeParen == -1) throw new URISyntaxException(uri,
5277 "EXTRA missing trailing ')'", i);
5278
5279 while (i < closeParen) {
5280 // fetch the key value
5281 int j = uri.indexOf('=', i);
5282 if (j <= i + 1 || i >= closeParen) {
5283 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5284 }
5285 char type = uri.charAt(i);
5286 i++;
5287 String key = uri.substring(i, j);
5288 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005289
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005290 // get type-value
5291 j = uri.indexOf('!', i);
5292 if (j == -1 || j >= closeParen) j = closeParen;
5293 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5294 String value = uri.substring(i, j);
5295 i = j;
5296
5297 // create Bundle if it doesn't already exist
5298 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005299
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005300 // add item to bundle
5301 try {
5302 switch (type) {
5303 case 'S':
5304 intent.mExtras.putString(key, Uri.decode(value));
5305 break;
5306 case 'B':
5307 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5308 break;
5309 case 'b':
5310 intent.mExtras.putByte(key, Byte.parseByte(value));
5311 break;
5312 case 'c':
5313 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5314 break;
5315 case 'd':
5316 intent.mExtras.putDouble(key, Double.parseDouble(value));
5317 break;
5318 case 'f':
5319 intent.mExtras.putFloat(key, Float.parseFloat(value));
5320 break;
5321 case 'i':
5322 intent.mExtras.putInt(key, Integer.parseInt(value));
5323 break;
5324 case 'l':
5325 intent.mExtras.putLong(key, Long.parseLong(value));
5326 break;
5327 case 's':
5328 intent.mExtras.putShort(key, Short.parseShort(value));
5329 break;
5330 default:
5331 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5332 }
5333 } catch (NumberFormatException e) {
5334 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5335 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005336
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005337 char ch = uri.charAt(i);
5338 if (ch == ')') break;
5339 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5340 i++;
5341 }
5342 }
5343
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005344 if (isIntentFragment) {
5345 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5346 } else {
5347 intent.mData = Uri.parse(uri);
5348 }
Tom Taylord4a47292009-12-21 13:59:18 -08005349
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005350 if (intent.mAction == null) {
5351 // By default, if no action is specified, then use VIEW.
5352 intent.mAction = ACTION_VIEW;
5353 }
5354
5355 } else {
5356 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5357 }
5358
5359 return intent;
5360 }
5361
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005362 /** @hide */
5363 public interface CommandOptionHandler {
5364 boolean handleOption(String opt, ShellCommand cmd);
5365 }
5366
5367 /** @hide */
5368 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5369 throws URISyntaxException {
5370 Intent intent = new Intent();
5371 Intent baseIntent = intent;
5372 boolean hasIntentInfo = false;
5373
5374 Uri data = null;
5375 String type = null;
5376
5377 String opt;
5378 while ((opt=cmd.getNextOption()) != null) {
5379 switch (opt) {
5380 case "-a":
5381 intent.setAction(cmd.getNextArgRequired());
5382 if (intent == baseIntent) {
5383 hasIntentInfo = true;
5384 }
5385 break;
5386 case "-d":
5387 data = Uri.parse(cmd.getNextArgRequired());
5388 if (intent == baseIntent) {
5389 hasIntentInfo = true;
5390 }
5391 break;
5392 case "-t":
5393 type = cmd.getNextArgRequired();
5394 if (intent == baseIntent) {
5395 hasIntentInfo = true;
5396 }
5397 break;
5398 case "-c":
5399 intent.addCategory(cmd.getNextArgRequired());
5400 if (intent == baseIntent) {
5401 hasIntentInfo = true;
5402 }
5403 break;
5404 case "-e":
5405 case "--es": {
5406 String key = cmd.getNextArgRequired();
5407 String value = cmd.getNextArgRequired();
5408 intent.putExtra(key, value);
5409 }
5410 break;
5411 case "--esn": {
5412 String key = cmd.getNextArgRequired();
5413 intent.putExtra(key, (String) null);
5414 }
5415 break;
5416 case "--ei": {
5417 String key = cmd.getNextArgRequired();
5418 String value = cmd.getNextArgRequired();
5419 intent.putExtra(key, Integer.decode(value));
5420 }
5421 break;
5422 case "--eu": {
5423 String key = cmd.getNextArgRequired();
5424 String value = cmd.getNextArgRequired();
5425 intent.putExtra(key, Uri.parse(value));
5426 }
5427 break;
5428 case "--ecn": {
5429 String key = cmd.getNextArgRequired();
5430 String value = cmd.getNextArgRequired();
5431 ComponentName cn = ComponentName.unflattenFromString(value);
5432 if (cn == null)
5433 throw new IllegalArgumentException("Bad component name: " + value);
5434 intent.putExtra(key, cn);
5435 }
5436 break;
5437 case "--eia": {
5438 String key = cmd.getNextArgRequired();
5439 String value = cmd.getNextArgRequired();
5440 String[] strings = value.split(",");
5441 int[] list = new int[strings.length];
5442 for (int i = 0; i < strings.length; i++) {
5443 list[i] = Integer.decode(strings[i]);
5444 }
5445 intent.putExtra(key, list);
5446 }
5447 break;
5448 case "--eial": {
5449 String key = cmd.getNextArgRequired();
5450 String value = cmd.getNextArgRequired();
5451 String[] strings = value.split(",");
5452 ArrayList<Integer> list = new ArrayList<>(strings.length);
5453 for (int i = 0; i < strings.length; i++) {
5454 list.add(Integer.decode(strings[i]));
5455 }
5456 intent.putExtra(key, list);
5457 }
5458 break;
5459 case "--el": {
5460 String key = cmd.getNextArgRequired();
5461 String value = cmd.getNextArgRequired();
5462 intent.putExtra(key, Long.valueOf(value));
5463 }
5464 break;
5465 case "--ela": {
5466 String key = cmd.getNextArgRequired();
5467 String value = cmd.getNextArgRequired();
5468 String[] strings = value.split(",");
5469 long[] list = new long[strings.length];
5470 for (int i = 0; i < strings.length; i++) {
5471 list[i] = Long.valueOf(strings[i]);
5472 }
5473 intent.putExtra(key, list);
5474 hasIntentInfo = true;
5475 }
5476 break;
5477 case "--elal": {
5478 String key = cmd.getNextArgRequired();
5479 String value = cmd.getNextArgRequired();
5480 String[] strings = value.split(",");
5481 ArrayList<Long> list = new ArrayList<>(strings.length);
5482 for (int i = 0; i < strings.length; i++) {
5483 list.add(Long.valueOf(strings[i]));
5484 }
5485 intent.putExtra(key, list);
5486 hasIntentInfo = true;
5487 }
5488 break;
5489 case "--ef": {
5490 String key = cmd.getNextArgRequired();
5491 String value = cmd.getNextArgRequired();
5492 intent.putExtra(key, Float.valueOf(value));
5493 hasIntentInfo = true;
5494 }
5495 break;
5496 case "--efa": {
5497 String key = cmd.getNextArgRequired();
5498 String value = cmd.getNextArgRequired();
5499 String[] strings = value.split(",");
5500 float[] list = new float[strings.length];
5501 for (int i = 0; i < strings.length; i++) {
5502 list[i] = Float.valueOf(strings[i]);
5503 }
5504 intent.putExtra(key, list);
5505 hasIntentInfo = true;
5506 }
5507 break;
5508 case "--efal": {
5509 String key = cmd.getNextArgRequired();
5510 String value = cmd.getNextArgRequired();
5511 String[] strings = value.split(",");
5512 ArrayList<Float> list = new ArrayList<>(strings.length);
5513 for (int i = 0; i < strings.length; i++) {
5514 list.add(Float.valueOf(strings[i]));
5515 }
5516 intent.putExtra(key, list);
5517 hasIntentInfo = true;
5518 }
5519 break;
5520 case "--esa": {
5521 String key = cmd.getNextArgRequired();
5522 String value = cmd.getNextArgRequired();
5523 // Split on commas unless they are preceeded by an escape.
5524 // The escape character must be escaped for the string and
5525 // again for the regex, thus four escape characters become one.
5526 String[] strings = value.split("(?<!\\\\),");
5527 intent.putExtra(key, strings);
5528 hasIntentInfo = true;
5529 }
5530 break;
5531 case "--esal": {
5532 String key = cmd.getNextArgRequired();
5533 String value = cmd.getNextArgRequired();
5534 // Split on commas unless they are preceeded by an escape.
5535 // The escape character must be escaped for the string and
5536 // again for the regex, thus four escape characters become one.
5537 String[] strings = value.split("(?<!\\\\),");
5538 ArrayList<String> list = new ArrayList<>(strings.length);
5539 for (int i = 0; i < strings.length; i++) {
5540 list.add(strings[i]);
5541 }
5542 intent.putExtra(key, list);
5543 hasIntentInfo = true;
5544 }
5545 break;
5546 case "--ez": {
5547 String key = cmd.getNextArgRequired();
5548 String value = cmd.getNextArgRequired().toLowerCase();
5549 // Boolean.valueOf() results in false for anything that is not "true", which is
5550 // error-prone in shell commands
5551 boolean arg;
5552 if ("true".equals(value) || "t".equals(value)) {
5553 arg = true;
5554 } else if ("false".equals(value) || "f".equals(value)) {
5555 arg = false;
5556 } else {
5557 try {
5558 arg = Integer.decode(value) != 0;
5559 } catch (NumberFormatException ex) {
5560 throw new IllegalArgumentException("Invalid boolean value: " + value);
5561 }
5562 }
5563
5564 intent.putExtra(key, arg);
5565 }
5566 break;
5567 case "-n": {
5568 String str = cmd.getNextArgRequired();
5569 ComponentName cn = ComponentName.unflattenFromString(str);
5570 if (cn == null)
5571 throw new IllegalArgumentException("Bad component name: " + str);
5572 intent.setComponent(cn);
5573 if (intent == baseIntent) {
5574 hasIntentInfo = true;
5575 }
5576 }
5577 break;
5578 case "-p": {
5579 String str = cmd.getNextArgRequired();
5580 intent.setPackage(str);
5581 if (intent == baseIntent) {
5582 hasIntentInfo = true;
5583 }
5584 }
5585 break;
5586 case "-f":
5587 String str = cmd.getNextArgRequired();
5588 intent.setFlags(Integer.decode(str).intValue());
5589 break;
5590 case "--grant-read-uri-permission":
5591 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5592 break;
5593 case "--grant-write-uri-permission":
5594 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5595 break;
5596 case "--grant-persistable-uri-permission":
5597 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5598 break;
5599 case "--grant-prefix-uri-permission":
5600 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5601 break;
5602 case "--exclude-stopped-packages":
5603 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5604 break;
5605 case "--include-stopped-packages":
5606 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5607 break;
5608 case "--debug-log-resolution":
5609 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5610 break;
5611 case "--activity-brought-to-front":
5612 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5613 break;
5614 case "--activity-clear-top":
5615 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5616 break;
5617 case "--activity-clear-when-task-reset":
5618 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5619 break;
5620 case "--activity-exclude-from-recents":
5621 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5622 break;
5623 case "--activity-launched-from-history":
5624 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5625 break;
5626 case "--activity-multiple-task":
5627 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5628 break;
5629 case "--activity-no-animation":
5630 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5631 break;
5632 case "--activity-no-history":
5633 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5634 break;
5635 case "--activity-no-user-action":
5636 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5637 break;
5638 case "--activity-previous-is-top":
5639 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5640 break;
5641 case "--activity-reorder-to-front":
5642 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5643 break;
5644 case "--activity-reset-task-if-needed":
5645 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5646 break;
5647 case "--activity-single-top":
5648 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5649 break;
5650 case "--activity-clear-task":
5651 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5652 break;
5653 case "--activity-task-on-home":
5654 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5655 break;
5656 case "--receiver-registered-only":
5657 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5658 break;
5659 case "--receiver-replace-pending":
5660 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5661 break;
5662 case "--selector":
5663 intent.setDataAndType(data, type);
5664 intent = new Intent();
5665 break;
5666 default:
5667 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5668 // Okay, caller handled this option.
5669 } else {
5670 throw new IllegalArgumentException("Unknown option: " + opt);
5671 }
5672 break;
5673 }
5674 }
5675 intent.setDataAndType(data, type);
5676
5677 final boolean hasSelector = intent != baseIntent;
5678 if (hasSelector) {
5679 // A selector was specified; fix up.
5680 baseIntent.setSelector(intent);
5681 intent = baseIntent;
5682 }
5683
5684 String arg = cmd.getNextArg();
5685 baseIntent = null;
5686 if (arg == null) {
5687 if (hasSelector) {
5688 // If a selector has been specified, and no arguments
5689 // have been supplied for the main Intent, then we can
5690 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5691 // need to have a component name specified yet, the
5692 // selector will take care of that.
5693 baseIntent = new Intent(Intent.ACTION_MAIN);
5694 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5695 }
5696 } else if (arg.indexOf(':') >= 0) {
5697 // The argument is a URI. Fully parse it, and use that result
5698 // to fill in any data not specified so far.
5699 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5700 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5701 } else if (arg.indexOf('/') >= 0) {
5702 // The argument is a component name. Build an Intent to launch
5703 // it.
5704 baseIntent = new Intent(Intent.ACTION_MAIN);
5705 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5706 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5707 } else {
5708 // Assume the argument is a package name.
5709 baseIntent = new Intent(Intent.ACTION_MAIN);
5710 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5711 baseIntent.setPackage(arg);
5712 }
5713 if (baseIntent != null) {
5714 Bundle extras = intent.getExtras();
5715 intent.replaceExtras((Bundle)null);
5716 Bundle uriExtras = baseIntent.getExtras();
5717 baseIntent.replaceExtras((Bundle)null);
5718 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5719 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5720 for (String c : cats) {
5721 baseIntent.removeCategory(c);
5722 }
5723 }
5724 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5725 if (extras == null) {
5726 extras = uriExtras;
5727 } else if (uriExtras != null) {
5728 uriExtras.putAll(extras);
5729 extras = uriExtras;
5730 }
5731 intent.replaceExtras(extras);
5732 hasIntentInfo = true;
5733 }
5734
5735 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5736 return intent;
5737 }
5738
5739 /** @hide */
5740 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5741 final String[] lines = new String[] {
5742 "<INTENT> specifications include these flags and arguments:",
5743 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5744 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5745 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5746 " [--esn <EXTRA_KEY> ...]",
5747 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5748 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5749 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5750 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5751 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5752 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5753 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5754 " (mutiple extras passed as Integer[])",
5755 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5756 " (mutiple extras passed as List<Integer>)",
5757 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5758 " (mutiple extras passed as Long[])",
5759 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5760 " (mutiple extras passed as List<Long>)",
5761 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5762 " (mutiple extras passed as Float[])",
5763 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5764 " (mutiple extras passed as List<Float>)",
5765 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5766 " (mutiple extras passed as String[]; to embed a comma into a string,",
5767 " escape it using \"\\,\")",
5768 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5769 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5770 " escape it using \"\\,\")",
5771 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5772 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5773 " [--debug-log-resolution] [--exclude-stopped-packages]",
5774 " [--include-stopped-packages]",
5775 " [--activity-brought-to-front] [--activity-clear-top]",
5776 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5777 " [--activity-launched-from-history] [--activity-multiple-task]",
5778 " [--activity-no-animation] [--activity-no-history]",
5779 " [--activity-no-user-action] [--activity-previous-is-top]",
5780 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5781 " [--activity-single-top] [--activity-clear-task]",
5782 " [--activity-task-on-home]",
5783 " [--receiver-registered-only] [--receiver-replace-pending]",
5784 " [--selector]",
5785 " [<URI> | <PACKAGE> | <COMPONENT>]"
5786 };
5787 for (String line : lines) {
5788 pw.print(prefix);
5789 pw.println(line);
5790 }
5791 }
5792
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005793 /**
5794 * Retrieve the general action to be performed, such as
5795 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5796 * the information in the intent should be interpreted -- most importantly,
5797 * what to do with the data returned by {@link #getData}.
5798 *
5799 * @return The action of this intent or null if none is specified.
5800 *
5801 * @see #setAction
5802 */
5803 public String getAction() {
5804 return mAction;
5805 }
5806
5807 /**
5808 * Retrieve data this intent is operating on. This URI specifies the name
5809 * of the data; often it uses the content: scheme, specifying data in a
5810 * content provider. Other schemes may be handled by specific activities,
5811 * such as http: by the web browser.
5812 *
5813 * @return The URI of the data this intent is targeting or null.
5814 *
5815 * @see #getScheme
5816 * @see #setData
5817 */
5818 public Uri getData() {
5819 return mData;
5820 }
5821
5822 /**
5823 * The same as {@link #getData()}, but returns the URI as an encoded
5824 * String.
5825 */
5826 public String getDataString() {
5827 return mData != null ? mData.toString() : null;
5828 }
5829
5830 /**
5831 * Return the scheme portion of the intent's data. If the data is null or
5832 * does not include a scheme, null is returned. Otherwise, the scheme
5833 * prefix without the final ':' is returned, i.e. "http".
5834 *
5835 * <p>This is the same as calling getData().getScheme() (and checking for
5836 * null data).
5837 *
5838 * @return The scheme of this intent.
5839 *
5840 * @see #getData
5841 */
5842 public String getScheme() {
5843 return mData != null ? mData.getScheme() : null;
5844 }
5845
5846 /**
5847 * Retrieve any explicit MIME type included in the intent. This is usually
5848 * null, as the type is determined by the intent data.
5849 *
5850 * @return If a type was manually set, it is returned; else null is
5851 * returned.
5852 *
5853 * @see #resolveType(ContentResolver)
5854 * @see #setType
5855 */
5856 public String getType() {
5857 return mType;
5858 }
5859
5860 /**
5861 * Return the MIME data type of this intent. If the type field is
5862 * explicitly set, that is simply returned. Otherwise, if the data is set,
5863 * the type of that data is returned. If neither fields are set, a null is
5864 * returned.
5865 *
5866 * @return The MIME type of this intent.
5867 *
5868 * @see #getType
5869 * @see #resolveType(ContentResolver)
5870 */
5871 public String resolveType(Context context) {
5872 return resolveType(context.getContentResolver());
5873 }
5874
5875 /**
5876 * Return the MIME data type of this intent. If the type field is
5877 * explicitly set, that is simply returned. Otherwise, if the data is set,
5878 * the type of that data is returned. If neither fields are set, a null is
5879 * returned.
5880 *
5881 * @param resolver A ContentResolver that can be used to determine the MIME
5882 * type of the intent's data.
5883 *
5884 * @return The MIME type of this intent.
5885 *
5886 * @see #getType
5887 * @see #resolveType(Context)
5888 */
5889 public String resolveType(ContentResolver resolver) {
5890 if (mType != null) {
5891 return mType;
5892 }
5893 if (mData != null) {
5894 if ("content".equals(mData.getScheme())) {
5895 return resolver.getType(mData);
5896 }
5897 }
5898 return null;
5899 }
5900
5901 /**
5902 * Return the MIME data type of this intent, only if it will be needed for
5903 * intent resolution. This is not generally useful for application code;
5904 * it is used by the frameworks for communicating with back-end system
5905 * services.
5906 *
5907 * @param resolver A ContentResolver that can be used to determine the MIME
5908 * type of the intent's data.
5909 *
5910 * @return The MIME type of this intent, or null if it is unknown or not
5911 * needed.
5912 */
5913 public String resolveTypeIfNeeded(ContentResolver resolver) {
5914 if (mComponent != null) {
5915 return mType;
5916 }
5917 return resolveType(resolver);
5918 }
5919
5920 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005921 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005922 *
5923 * @param category The category to check.
5924 *
5925 * @return boolean True if the intent contains the category, else false.
5926 *
5927 * @see #getCategories
5928 * @see #addCategory
5929 */
5930 public boolean hasCategory(String category) {
5931 return mCategories != null && mCategories.contains(category);
5932 }
5933
5934 /**
5935 * Return the set of all categories in the intent. If there are no categories,
5936 * returns NULL.
5937 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005938 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005939 *
5940 * @see #hasCategory
5941 * @see #addCategory
5942 */
5943 public Set<String> getCategories() {
5944 return mCategories;
5945 }
5946
5947 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005948 * Return the specific selector associated with this Intent. If there is
5949 * none, returns null. See {@link #setSelector} for more information.
5950 *
5951 * @see #setSelector
5952 */
5953 public Intent getSelector() {
5954 return mSelector;
5955 }
5956
5957 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005958 * Return the {@link ClipData} associated with this Intent. If there is
5959 * none, returns null. See {@link #setClipData} for more information.
5960 *
John Spurlock125d1332013-11-25 11:58:37 -05005961 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005962 */
5963 public ClipData getClipData() {
5964 return mClipData;
5965 }
5966
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005967 /** @hide */
5968 public int getContentUserHint() {
5969 return mContentUserHint;
5970 }
5971
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005972 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005973 * Sets the ClassLoader that will be used when unmarshalling
5974 * any Parcelable values from the extras of this Intent.
5975 *
5976 * @param loader a ClassLoader, or null to use the default loader
5977 * at the time of unmarshalling.
5978 */
5979 public void setExtrasClassLoader(ClassLoader loader) {
5980 if (mExtras != null) {
5981 mExtras.setClassLoader(loader);
5982 }
5983 }
5984
5985 /**
5986 * Returns true if an extra value is associated with the given name.
5987 * @param name the extra's name
5988 * @return true if the given extra is present.
5989 */
5990 public boolean hasExtra(String name) {
5991 return mExtras != null && mExtras.containsKey(name);
5992 }
5993
5994 /**
5995 * Returns true if the Intent's extras contain a parcelled file descriptor.
5996 * @return true if the Intent contains a parcelled file descriptor.
5997 */
5998 public boolean hasFileDescriptors() {
5999 return mExtras != null && mExtras.hasFileDescriptors();
6000 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006001
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006002 /** @hide */
6003 public void setAllowFds(boolean allowFds) {
6004 if (mExtras != null) {
6005 mExtras.setAllowFds(allowFds);
6006 }
6007 }
6008
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006009 /**
6010 * Retrieve extended data from the intent.
6011 *
6012 * @param name The name of the desired item.
6013 *
6014 * @return the value of an item that previously added with putExtra()
6015 * or null if none was found.
6016 *
6017 * @deprecated
6018 * @hide
6019 */
6020 @Deprecated
6021 public Object getExtra(String name) {
6022 return getExtra(name, null);
6023 }
6024
6025 /**
6026 * Retrieve extended data from the intent.
6027 *
6028 * @param name The name of the desired item.
6029 * @param defaultValue the value to be returned if no value of the desired
6030 * type is stored with the given name.
6031 *
6032 * @return the value of an item that previously added with putExtra()
6033 * or the default value if none was found.
6034 *
6035 * @see #putExtra(String, boolean)
6036 */
6037 public boolean getBooleanExtra(String name, boolean defaultValue) {
6038 return mExtras == null ? defaultValue :
6039 mExtras.getBoolean(name, defaultValue);
6040 }
6041
6042 /**
6043 * Retrieve extended data from the intent.
6044 *
6045 * @param name The name of the desired item.
6046 * @param defaultValue the value to be returned if no value of the desired
6047 * type is stored with the given name.
6048 *
6049 * @return the value of an item that previously added with putExtra()
6050 * or the default value if none was found.
6051 *
6052 * @see #putExtra(String, byte)
6053 */
6054 public byte getByteExtra(String name, byte defaultValue) {
6055 return mExtras == null ? defaultValue :
6056 mExtras.getByte(name, defaultValue);
6057 }
6058
6059 /**
6060 * Retrieve extended data from the intent.
6061 *
6062 * @param name The name of the desired item.
6063 * @param defaultValue the value to be returned if no value of the desired
6064 * type is stored with the given name.
6065 *
6066 * @return the value of an item that previously added with putExtra()
6067 * or the default value if none was found.
6068 *
6069 * @see #putExtra(String, short)
6070 */
6071 public short getShortExtra(String name, short defaultValue) {
6072 return mExtras == null ? defaultValue :
6073 mExtras.getShort(name, defaultValue);
6074 }
6075
6076 /**
6077 * Retrieve extended data from the intent.
6078 *
6079 * @param name The name of the desired item.
6080 * @param defaultValue the value to be returned if no value of the desired
6081 * type is stored with the given name.
6082 *
6083 * @return the value of an item that previously added with putExtra()
6084 * or the default value if none was found.
6085 *
6086 * @see #putExtra(String, char)
6087 */
6088 public char getCharExtra(String name, char defaultValue) {
6089 return mExtras == null ? defaultValue :
6090 mExtras.getChar(name, defaultValue);
6091 }
6092
6093 /**
6094 * Retrieve extended data from the intent.
6095 *
6096 * @param name The name of the desired item.
6097 * @param defaultValue the value to be returned if no value of the desired
6098 * type is stored with the given name.
6099 *
6100 * @return the value of an item that previously added with putExtra()
6101 * or the default value if none was found.
6102 *
6103 * @see #putExtra(String, int)
6104 */
6105 public int getIntExtra(String name, int defaultValue) {
6106 return mExtras == null ? defaultValue :
6107 mExtras.getInt(name, defaultValue);
6108 }
6109
6110 /**
6111 * Retrieve extended data from the intent.
6112 *
6113 * @param name The name of the desired item.
6114 * @param defaultValue the value to be returned if no value of the desired
6115 * type is stored with the given name.
6116 *
6117 * @return the value of an item that previously added with putExtra()
6118 * or the default value if none was found.
6119 *
6120 * @see #putExtra(String, long)
6121 */
6122 public long getLongExtra(String name, long defaultValue) {
6123 return mExtras == null ? defaultValue :
6124 mExtras.getLong(name, defaultValue);
6125 }
6126
6127 /**
6128 * Retrieve extended data from the intent.
6129 *
6130 * @param name The name of the desired item.
6131 * @param defaultValue the value to be returned if no value of the desired
6132 * type is stored with the given name.
6133 *
6134 * @return the value of an item that previously added with putExtra(),
6135 * or the default value if no such item is present
6136 *
6137 * @see #putExtra(String, float)
6138 */
6139 public float getFloatExtra(String name, float defaultValue) {
6140 return mExtras == null ? defaultValue :
6141 mExtras.getFloat(name, defaultValue);
6142 }
6143
6144 /**
6145 * Retrieve extended data from the intent.
6146 *
6147 * @param name The name of the desired item.
6148 * @param defaultValue the value to be returned if no value of the desired
6149 * type is stored with the given name.
6150 *
6151 * @return the value of an item that previously added with putExtra()
6152 * or the default value if none was found.
6153 *
6154 * @see #putExtra(String, double)
6155 */
6156 public double getDoubleExtra(String name, double defaultValue) {
6157 return mExtras == null ? defaultValue :
6158 mExtras.getDouble(name, defaultValue);
6159 }
6160
6161 /**
6162 * Retrieve extended data from the intent.
6163 *
6164 * @param name The name of the desired item.
6165 *
6166 * @return the value of an item that previously added with putExtra()
6167 * or null if no String value was found.
6168 *
6169 * @see #putExtra(String, String)
6170 */
6171 public String getStringExtra(String name) {
6172 return mExtras == null ? null : mExtras.getString(name);
6173 }
6174
6175 /**
6176 * Retrieve extended data from the intent.
6177 *
6178 * @param name The name of the desired item.
6179 *
6180 * @return the value of an item that previously added with putExtra()
6181 * or null if no CharSequence value was found.
6182 *
6183 * @see #putExtra(String, CharSequence)
6184 */
6185 public CharSequence getCharSequenceExtra(String name) {
6186 return mExtras == null ? null : mExtras.getCharSequence(name);
6187 }
6188
6189 /**
6190 * Retrieve extended data from the intent.
6191 *
6192 * @param name The name of the desired item.
6193 *
6194 * @return the value of an item that previously added with putExtra()
6195 * or null if no Parcelable value was found.
6196 *
6197 * @see #putExtra(String, Parcelable)
6198 */
6199 public <T extends Parcelable> T getParcelableExtra(String name) {
6200 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6201 }
6202
6203 /**
6204 * Retrieve extended data from the intent.
6205 *
6206 * @param name The name of the desired item.
6207 *
6208 * @return the value of an item that previously added with putExtra()
6209 * or null if no Parcelable[] value was found.
6210 *
6211 * @see #putExtra(String, Parcelable[])
6212 */
6213 public Parcelable[] getParcelableArrayExtra(String name) {
6214 return mExtras == null ? null : mExtras.getParcelableArray(name);
6215 }
6216
6217 /**
6218 * Retrieve extended data from the intent.
6219 *
6220 * @param name The name of the desired item.
6221 *
6222 * @return the value of an item that previously added with putExtra()
6223 * or null if no ArrayList<Parcelable> value was found.
6224 *
6225 * @see #putParcelableArrayListExtra(String, ArrayList)
6226 */
6227 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6228 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6229 }
6230
6231 /**
6232 * Retrieve extended data from the intent.
6233 *
6234 * @param name The name of the desired item.
6235 *
6236 * @return the value of an item that previously added with putExtra()
6237 * or null if no Serializable value was found.
6238 *
6239 * @see #putExtra(String, Serializable)
6240 */
6241 public Serializable getSerializableExtra(String name) {
6242 return mExtras == null ? null : mExtras.getSerializable(name);
6243 }
6244
6245 /**
6246 * Retrieve extended data from the intent.
6247 *
6248 * @param name The name of the desired item.
6249 *
6250 * @return the value of an item that previously added with putExtra()
6251 * or null if no ArrayList<Integer> value was found.
6252 *
6253 * @see #putIntegerArrayListExtra(String, ArrayList)
6254 */
6255 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6256 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6257 }
6258
6259 /**
6260 * Retrieve extended data from the intent.
6261 *
6262 * @param name The name of the desired item.
6263 *
6264 * @return the value of an item that previously added with putExtra()
6265 * or null if no ArrayList<String> value was found.
6266 *
6267 * @see #putStringArrayListExtra(String, ArrayList)
6268 */
6269 public ArrayList<String> getStringArrayListExtra(String name) {
6270 return mExtras == null ? null : mExtras.getStringArrayList(name);
6271 }
6272
6273 /**
6274 * Retrieve extended data from the intent.
6275 *
6276 * @param name The name of the desired item.
6277 *
6278 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006279 * or null if no ArrayList<CharSequence> value was found.
6280 *
6281 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6282 */
6283 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6284 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6285 }
6286
6287 /**
6288 * Retrieve extended data from the intent.
6289 *
6290 * @param name The name of the desired item.
6291 *
6292 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006293 * or null if no boolean array value was found.
6294 *
6295 * @see #putExtra(String, boolean[])
6296 */
6297 public boolean[] getBooleanArrayExtra(String name) {
6298 return mExtras == null ? null : mExtras.getBooleanArray(name);
6299 }
6300
6301 /**
6302 * Retrieve extended data from the intent.
6303 *
6304 * @param name The name of the desired item.
6305 *
6306 * @return the value of an item that previously added with putExtra()
6307 * or null if no byte array value was found.
6308 *
6309 * @see #putExtra(String, byte[])
6310 */
6311 public byte[] getByteArrayExtra(String name) {
6312 return mExtras == null ? null : mExtras.getByteArray(name);
6313 }
6314
6315 /**
6316 * Retrieve extended data from the intent.
6317 *
6318 * @param name The name of the desired item.
6319 *
6320 * @return the value of an item that previously added with putExtra()
6321 * or null if no short array value was found.
6322 *
6323 * @see #putExtra(String, short[])
6324 */
6325 public short[] getShortArrayExtra(String name) {
6326 return mExtras == null ? null : mExtras.getShortArray(name);
6327 }
6328
6329 /**
6330 * Retrieve extended data from the intent.
6331 *
6332 * @param name The name of the desired item.
6333 *
6334 * @return the value of an item that previously added with putExtra()
6335 * or null if no char array value was found.
6336 *
6337 * @see #putExtra(String, char[])
6338 */
6339 public char[] getCharArrayExtra(String name) {
6340 return mExtras == null ? null : mExtras.getCharArray(name);
6341 }
6342
6343 /**
6344 * Retrieve extended data from the intent.
6345 *
6346 * @param name The name of the desired item.
6347 *
6348 * @return the value of an item that previously added with putExtra()
6349 * or null if no int array value was found.
6350 *
6351 * @see #putExtra(String, int[])
6352 */
6353 public int[] getIntArrayExtra(String name) {
6354 return mExtras == null ? null : mExtras.getIntArray(name);
6355 }
6356
6357 /**
6358 * Retrieve extended data from the intent.
6359 *
6360 * @param name The name of the desired item.
6361 *
6362 * @return the value of an item that previously added with putExtra()
6363 * or null if no long array value was found.
6364 *
6365 * @see #putExtra(String, long[])
6366 */
6367 public long[] getLongArrayExtra(String name) {
6368 return mExtras == null ? null : mExtras.getLongArray(name);
6369 }
6370
6371 /**
6372 * Retrieve extended data from the intent.
6373 *
6374 * @param name The name of the desired item.
6375 *
6376 * @return the value of an item that previously added with putExtra()
6377 * or null if no float array value was found.
6378 *
6379 * @see #putExtra(String, float[])
6380 */
6381 public float[] getFloatArrayExtra(String name) {
6382 return mExtras == null ? null : mExtras.getFloatArray(name);
6383 }
6384
6385 /**
6386 * Retrieve extended data from the intent.
6387 *
6388 * @param name The name of the desired item.
6389 *
6390 * @return the value of an item that previously added with putExtra()
6391 * or null if no double array value was found.
6392 *
6393 * @see #putExtra(String, double[])
6394 */
6395 public double[] getDoubleArrayExtra(String name) {
6396 return mExtras == null ? null : mExtras.getDoubleArray(name);
6397 }
6398
6399 /**
6400 * Retrieve extended data from the intent.
6401 *
6402 * @param name The name of the desired item.
6403 *
6404 * @return the value of an item that previously added with putExtra()
6405 * or null if no String array value was found.
6406 *
6407 * @see #putExtra(String, String[])
6408 */
6409 public String[] getStringArrayExtra(String name) {
6410 return mExtras == null ? null : mExtras.getStringArray(name);
6411 }
6412
6413 /**
6414 * Retrieve extended data from the intent.
6415 *
6416 * @param name The name of the desired item.
6417 *
6418 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006419 * or null if no CharSequence array value was found.
6420 *
6421 * @see #putExtra(String, CharSequence[])
6422 */
6423 public CharSequence[] getCharSequenceArrayExtra(String name) {
6424 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6425 }
6426
6427 /**
6428 * Retrieve extended data from the intent.
6429 *
6430 * @param name The name of the desired item.
6431 *
6432 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006433 * or null if no Bundle value was found.
6434 *
6435 * @see #putExtra(String, Bundle)
6436 */
6437 public Bundle getBundleExtra(String name) {
6438 return mExtras == null ? null : mExtras.getBundle(name);
6439 }
6440
6441 /**
6442 * Retrieve extended data from the intent.
6443 *
6444 * @param name The name of the desired item.
6445 *
6446 * @return the value of an item that previously added with putExtra()
6447 * or null if no IBinder value was found.
6448 *
6449 * @see #putExtra(String, IBinder)
6450 *
6451 * @deprecated
6452 * @hide
6453 */
6454 @Deprecated
6455 public IBinder getIBinderExtra(String name) {
6456 return mExtras == null ? null : mExtras.getIBinder(name);
6457 }
6458
6459 /**
6460 * Retrieve extended data from the intent.
6461 *
6462 * @param name The name of the desired item.
6463 * @param defaultValue The default value to return in case no item is
6464 * associated with the key 'name'
6465 *
6466 * @return the value of an item that previously added with putExtra()
6467 * or defaultValue if none was found.
6468 *
6469 * @see #putExtra
6470 *
6471 * @deprecated
6472 * @hide
6473 */
6474 @Deprecated
6475 public Object getExtra(String name, Object defaultValue) {
6476 Object result = defaultValue;
6477 if (mExtras != null) {
6478 Object result2 = mExtras.get(name);
6479 if (result2 != null) {
6480 result = result2;
6481 }
6482 }
6483
6484 return result;
6485 }
6486
6487 /**
6488 * Retrieves a map of extended data from the intent.
6489 *
6490 * @return the map of all extras previously added with putExtra(),
6491 * or null if none have been added.
6492 */
6493 public Bundle getExtras() {
6494 return (mExtras != null)
6495 ? new Bundle(mExtras)
6496 : null;
6497 }
6498
6499 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006500 * Filter extras to only basic types.
6501 * @hide
6502 */
6503 public void removeUnsafeExtras() {
6504 if (mExtras != null) {
6505 mExtras.filterValues();
6506 }
6507 }
6508
6509 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006510 * Retrieve any special flags associated with this intent. You will
6511 * normally just set them with {@link #setFlags} and let the system
6512 * take the appropriate action with them.
6513 *
6514 * @return int The currently set flags.
6515 *
6516 * @see #setFlags
6517 */
6518 public int getFlags() {
6519 return mFlags;
6520 }
6521
Dianne Hackborne7f97212011-02-24 14:40:20 -08006522 /** @hide */
6523 public boolean isExcludingStopped() {
6524 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6525 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6526 }
6527
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006528 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006529 * Retrieve the application package name this Intent is limited to. When
6530 * resolving an Intent, if non-null this limits the resolution to only
6531 * components in the given application package.
6532 *
6533 * @return The name of the application package for the Intent.
6534 *
6535 * @see #resolveActivity
6536 * @see #setPackage
6537 */
6538 public String getPackage() {
6539 return mPackage;
6540 }
6541
6542 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006543 * Retrieve the concrete component associated with the intent. When receiving
6544 * an intent, this is the component that was found to best handle it (that is,
6545 * yourself) and will always be non-null; in all other cases it will be
6546 * null unless explicitly set.
6547 *
6548 * @return The name of the application component to handle the intent.
6549 *
6550 * @see #resolveActivity
6551 * @see #setComponent
6552 */
6553 public ComponentName getComponent() {
6554 return mComponent;
6555 }
6556
6557 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006558 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6559 * used as a hint to the receiver for animations and the like. Null means that there
6560 * is no source bounds.
6561 */
6562 public Rect getSourceBounds() {
6563 return mSourceBounds;
6564 }
6565
6566 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006567 * Return the Activity component that should be used to handle this intent.
6568 * The appropriate component is determined based on the information in the
6569 * intent, evaluated as follows:
6570 *
6571 * <p>If {@link #getComponent} returns an explicit class, that is returned
6572 * without any further consideration.
6573 *
6574 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6575 * category to be considered.
6576 *
6577 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6578 * action.
6579 *
6580 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6581 * this type.
6582 *
6583 * <p>If {@link #addCategory} has added any categories, the activity must
6584 * handle ALL of the categories specified.
6585 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006586 * <p>If {@link #getPackage} is non-NULL, only activity components in
6587 * that application package will be considered.
6588 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006589 * <p>If there are no activities that satisfy all of these conditions, a
6590 * null string is returned.
6591 *
6592 * <p>If multiple activities are found to satisfy the intent, the one with
6593 * the highest priority will be used. If there are multiple activities
6594 * with the same priority, the system will either pick the best activity
6595 * based on user preference, or resolve to a system class that will allow
6596 * the user to pick an activity and forward from there.
6597 *
6598 * <p>This method is implemented simply by calling
6599 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6600 * true.</p>
6601 * <p> This API is called for you as part of starting an activity from an
6602 * intent. You do not normally need to call it yourself.</p>
6603 *
6604 * @param pm The package manager with which to resolve the Intent.
6605 *
6606 * @return Name of the component implementing an activity that can
6607 * display the intent.
6608 *
6609 * @see #setComponent
6610 * @see #getComponent
6611 * @see #resolveActivityInfo
6612 */
6613 public ComponentName resolveActivity(PackageManager pm) {
6614 if (mComponent != null) {
6615 return mComponent;
6616 }
6617
6618 ResolveInfo info = pm.resolveActivity(
6619 this, PackageManager.MATCH_DEFAULT_ONLY);
6620 if (info != null) {
6621 return new ComponentName(
6622 info.activityInfo.applicationInfo.packageName,
6623 info.activityInfo.name);
6624 }
6625
6626 return null;
6627 }
6628
6629 /**
6630 * Resolve the Intent into an {@link ActivityInfo}
6631 * describing the activity that should execute the intent. Resolution
6632 * follows the same rules as described for {@link #resolveActivity}, but
6633 * you get back the completely information about the resolved activity
6634 * instead of just its class name.
6635 *
6636 * @param pm The package manager with which to resolve the Intent.
6637 * @param flags Addition information to retrieve as per
6638 * {@link PackageManager#getActivityInfo(ComponentName, int)
6639 * PackageManager.getActivityInfo()}.
6640 *
6641 * @return PackageManager.ActivityInfo
6642 *
6643 * @see #resolveActivity
6644 */
6645 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6646 ActivityInfo ai = null;
6647 if (mComponent != null) {
6648 try {
6649 ai = pm.getActivityInfo(mComponent, flags);
6650 } catch (PackageManager.NameNotFoundException e) {
6651 // ignore
6652 }
6653 } else {
6654 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006655 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006656 if (info != null) {
6657 ai = info.activityInfo;
6658 }
6659 }
6660
6661 return ai;
6662 }
6663
6664 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006665 * Special function for use by the system to resolve service
6666 * intents to system apps. Throws an exception if there are
6667 * multiple potential matches to the Intent. Returns null if
6668 * there are no matches.
6669 * @hide
6670 */
6671 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6672 if (mComponent != null) {
6673 return mComponent;
6674 }
6675
6676 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6677 if (results == null) {
6678 return null;
6679 }
6680 ComponentName comp = null;
6681 for (int i=0; i<results.size(); i++) {
6682 ResolveInfo ri = results.get(i);
6683 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6684 continue;
6685 }
6686 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6687 ri.serviceInfo.name);
6688 if (comp != null) {
6689 throw new IllegalStateException("Multiple system services handle " + this
6690 + ": " + comp + ", " + foundComp);
6691 }
6692 comp = foundComp;
6693 }
6694 return comp;
6695 }
6696
6697 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006698 * Set the general action to be performed.
6699 *
6700 * @param action An action name, such as ACTION_VIEW. Application-specific
6701 * actions should be prefixed with the vendor's package name.
6702 *
6703 * @return Returns the same Intent object, for chaining multiple calls
6704 * into a single statement.
6705 *
6706 * @see #getAction
6707 */
6708 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006709 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006710 return this;
6711 }
6712
6713 /**
6714 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006715 * clears any type that was previously set by {@link #setType} or
6716 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006717 *
Nick Pellyccae4122012-01-09 14:12:58 -08006718 * <p><em>Note: scheme matching in the Android framework is
6719 * case-sensitive, unlike the formal RFC. As a result,
6720 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006721 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006722 * {@link #setDataAndNormalize}
6723 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006724 *
Nick Pellyccae4122012-01-09 14:12:58 -08006725 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006726 *
6727 * @return Returns the same Intent object, for chaining multiple calls
6728 * into a single statement.
6729 *
6730 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006731 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006732 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006733 */
6734 public Intent setData(Uri data) {
6735 mData = data;
6736 mType = null;
6737 return this;
6738 }
6739
6740 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006741 * Normalize and set the data this intent is operating on.
6742 *
6743 * <p>This method automatically clears any type that was
6744 * previously set (for example, by {@link #setType}).
6745 *
6746 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006747 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006748 * so really this is just a convenience method for
6749 * <pre>
6750 * setData(data.normalize())
6751 * </pre>
6752 *
6753 * @param data The Uri of the data this intent is now targeting.
6754 *
6755 * @return Returns the same Intent object, for chaining multiple calls
6756 * into a single statement.
6757 *
6758 * @see #getData
6759 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006760 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006761 */
6762 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006763 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006764 }
6765
6766 /**
6767 * Set an explicit MIME data type.
6768 *
6769 * <p>This is used to create intents that only specify a type and not data,
6770 * for example to indicate the type of data to return.
6771 *
6772 * <p>This method automatically clears any data that was
6773 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006774 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006775 * <p><em>Note: MIME type matching in the Android framework is
6776 * case-sensitive, unlike formal RFC MIME types. As a result,
6777 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006778 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6779 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006780 *
6781 * @param type The MIME type of the data being handled by this intent.
6782 *
6783 * @return Returns the same Intent object, for chaining multiple calls
6784 * into a single statement.
6785 *
6786 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006787 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006788 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006789 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006790 */
6791 public Intent setType(String type) {
6792 mData = null;
6793 mType = type;
6794 return this;
6795 }
6796
6797 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006798 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006799 *
Nick Pellyccae4122012-01-09 14:12:58 -08006800 * <p>This is used to create intents that only specify a type and not data,
6801 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006802 *
Nick Pellyccae4122012-01-09 14:12:58 -08006803 * <p>This method automatically clears any data that was
6804 * previously set (for example by {@link #setData}).
6805 *
6806 * <p>The MIME type is normalized using
6807 * {@link #normalizeMimeType} before it is set,
6808 * so really this is just a convenience method for
6809 * <pre>
6810 * setType(Intent.normalizeMimeType(type))
6811 * </pre>
6812 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006813 * @param type The MIME type of the data being handled by this intent.
6814 *
6815 * @return Returns the same Intent object, for chaining multiple calls
6816 * into a single statement.
6817 *
Nick Pellyccae4122012-01-09 14:12:58 -08006818 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006819 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006820 * @see #normalizeMimeType
6821 */
6822 public Intent setTypeAndNormalize(String type) {
6823 return setType(normalizeMimeType(type));
6824 }
6825
6826 /**
6827 * (Usually optional) Set the data for the intent along with an explicit
6828 * MIME data type. This method should very rarely be used -- it allows you
6829 * to override the MIME type that would ordinarily be inferred from the
6830 * data with your own type given here.
6831 *
6832 * <p><em>Note: MIME type and Uri scheme matching in the
6833 * Android framework is case-sensitive, unlike the formal RFC definitions.
6834 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006835 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006836 * {@link #setDataAndTypeAndNormalize}
6837 * to ensure that they are converted to lower case.</em>
6838 *
6839 * @param data The Uri of the data this intent is now targeting.
6840 * @param type The MIME type of the data being handled by this intent.
6841 *
6842 * @return Returns the same Intent object, for chaining multiple calls
6843 * into a single statement.
6844 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006845 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006846 * @see #setData
6847 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006848 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006849 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006850 */
6851 public Intent setDataAndType(Uri data, String type) {
6852 mData = data;
6853 mType = type;
6854 return this;
6855 }
6856
6857 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006858 * (Usually optional) Normalize and set both the data Uri and an explicit
6859 * MIME data type. This method should very rarely be used -- it allows you
6860 * to override the MIME type that would ordinarily be inferred from the
6861 * data with your own type given here.
6862 *
6863 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006864 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006865 * before they are set, so really this is just a convenience method for
6866 * <pre>
6867 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6868 * </pre>
6869 *
6870 * @param data The Uri of the data this intent is now targeting.
6871 * @param type The MIME type of the data being handled by this intent.
6872 *
6873 * @return Returns the same Intent object, for chaining multiple calls
6874 * into a single statement.
6875 *
6876 * @see #setType
6877 * @see #setData
6878 * @see #setDataAndType
6879 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006880 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006881 */
6882 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006883 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006884 }
6885
6886 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006887 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006888 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006889 * activities that provide <em>all</em> of the requested categories will be
6890 * used.
6891 *
6892 * @param category The desired category. This can be either one of the
6893 * predefined Intent categories, or a custom category in your own
6894 * namespace.
6895 *
6896 * @return Returns the same Intent object, for chaining multiple calls
6897 * into a single statement.
6898 *
6899 * @see #hasCategory
6900 * @see #removeCategory
6901 */
6902 public Intent addCategory(String category) {
6903 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006904 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006905 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006906 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006907 return this;
6908 }
6909
6910 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006911 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006912 *
6913 * @param category The category to remove.
6914 *
6915 * @see #addCategory
6916 */
6917 public void removeCategory(String category) {
6918 if (mCategories != null) {
6919 mCategories.remove(category);
6920 if (mCategories.size() == 0) {
6921 mCategories = null;
6922 }
6923 }
6924 }
6925
6926 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006927 * Set a selector for this Intent. This is a modification to the kinds of
6928 * things the Intent will match. If the selector is set, it will be used
6929 * when trying to find entities that can handle the Intent, instead of the
6930 * main contents of the Intent. This allows you build an Intent containing
6931 * a generic protocol while targeting it more specifically.
6932 *
6933 * <p>An example of where this may be used is with things like
6934 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6935 * Intent that will launch the Browser application. However, the correct
6936 * main entry point of an application is actually {@link #ACTION_MAIN}
6937 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6938 * used to specify the actual Activity to launch. If you launch the browser
6939 * with something different, undesired behavior may happen if the user has
6940 * previously or later launches it the normal way, since they do not match.
6941 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6942 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6943 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6944 *
6945 * <p>Setting a selector does not impact the behavior of
6946 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6947 * desired behavior of a selector -- it does not impact the base meaning
6948 * of the Intent, just what kinds of things will be matched against it
6949 * when determining who can handle it.</p>
6950 *
6951 * <p>You can not use both a selector and {@link #setPackage(String)} on
6952 * the same base Intent.</p>
6953 *
6954 * @param selector The desired selector Intent; set to null to not use
6955 * a special selector.
6956 */
6957 public void setSelector(Intent selector) {
6958 if (selector == this) {
6959 throw new IllegalArgumentException(
6960 "Intent being set as a selector of itself");
6961 }
6962 if (selector != null && mPackage != null) {
6963 throw new IllegalArgumentException(
6964 "Can't set selector when package name is already set");
6965 }
6966 mSelector = selector;
6967 }
6968
6969 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006970 * Set a {@link ClipData} associated with this Intent. This replaces any
6971 * previously set ClipData.
6972 *
6973 * <p>The ClipData in an intent is not used for Intent matching or other
6974 * such operations. Semantically it is like extras, used to transmit
6975 * additional data with the Intent. The main feature of using this over
6976 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6977 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6978 * items included in the clip data. This is useful, in particular, if
6979 * you want to transmit an Intent containing multiple <code>content:</code>
6980 * URIs for which the recipient may not have global permission to access the
6981 * content provider.
6982 *
6983 * <p>If the ClipData contains items that are themselves Intents, any
6984 * grant flags in those Intents will be ignored. Only the top-level flags
6985 * of the main Intent are respected, and will be applied to all Uri or
6986 * Intent items in the clip (or sub-items of the clip).
6987 *
6988 * <p>The MIME type, label, and icon in the ClipData object are not
6989 * directly used by Intent. Applications should generally rely on the
6990 * MIME type of the Intent itself, not what it may find in the ClipData.
6991 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006992 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006993 *
6994 * @param clip The new clip to set. May be null to clear the current clip.
6995 */
6996 public void setClipData(ClipData clip) {
6997 mClipData = clip;
6998 }
6999
7000 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007001 * This is NOT a secure mechanism to identify the user who sent the intent.
7002 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7003 * who sent the intent.
7004 * @hide
7005 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007006 public void prepareToLeaveUser(int userId) {
7007 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7008 // We want mContentUserHint to refer to the original user, so don't do anything.
7009 if (mContentUserHint == UserHandle.USER_CURRENT) {
7010 mContentUserHint = userId;
7011 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007012 }
7013
7014 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007015 * Add extended data to the intent. The name must include a package
7016 * prefix, for example the app com.android.contacts would use names
7017 * like "com.android.contacts.ShowAll".
7018 *
7019 * @param name The name of the extra data, with package prefix.
7020 * @param value The boolean data value.
7021 *
7022 * @return Returns the same Intent object, for chaining multiple calls
7023 * into a single statement.
7024 *
7025 * @see #putExtras
7026 * @see #removeExtra
7027 * @see #getBooleanExtra(String, boolean)
7028 */
7029 public Intent putExtra(String name, boolean value) {
7030 if (mExtras == null) {
7031 mExtras = new Bundle();
7032 }
7033 mExtras.putBoolean(name, value);
7034 return this;
7035 }
7036
7037 /**
7038 * Add extended data to the intent. The name must include a package
7039 * prefix, for example the app com.android.contacts would use names
7040 * like "com.android.contacts.ShowAll".
7041 *
7042 * @param name The name of the extra data, with package prefix.
7043 * @param value The byte data value.
7044 *
7045 * @return Returns the same Intent object, for chaining multiple calls
7046 * into a single statement.
7047 *
7048 * @see #putExtras
7049 * @see #removeExtra
7050 * @see #getByteExtra(String, byte)
7051 */
7052 public Intent putExtra(String name, byte value) {
7053 if (mExtras == null) {
7054 mExtras = new Bundle();
7055 }
7056 mExtras.putByte(name, value);
7057 return this;
7058 }
7059
7060 /**
7061 * Add extended data to the intent. The name must include a package
7062 * prefix, for example the app com.android.contacts would use names
7063 * like "com.android.contacts.ShowAll".
7064 *
7065 * @param name The name of the extra data, with package prefix.
7066 * @param value The char data value.
7067 *
7068 * @return Returns the same Intent object, for chaining multiple calls
7069 * into a single statement.
7070 *
7071 * @see #putExtras
7072 * @see #removeExtra
7073 * @see #getCharExtra(String, char)
7074 */
7075 public Intent putExtra(String name, char value) {
7076 if (mExtras == null) {
7077 mExtras = new Bundle();
7078 }
7079 mExtras.putChar(name, value);
7080 return this;
7081 }
7082
7083 /**
7084 * Add extended data to the intent. The name must include a package
7085 * prefix, for example the app com.android.contacts would use names
7086 * like "com.android.contacts.ShowAll".
7087 *
7088 * @param name The name of the extra data, with package prefix.
7089 * @param value The short data value.
7090 *
7091 * @return Returns the same Intent object, for chaining multiple calls
7092 * into a single statement.
7093 *
7094 * @see #putExtras
7095 * @see #removeExtra
7096 * @see #getShortExtra(String, short)
7097 */
7098 public Intent putExtra(String name, short value) {
7099 if (mExtras == null) {
7100 mExtras = new Bundle();
7101 }
7102 mExtras.putShort(name, value);
7103 return this;
7104 }
7105
7106 /**
7107 * Add extended data to the intent. The name must include a package
7108 * prefix, for example the app com.android.contacts would use names
7109 * like "com.android.contacts.ShowAll".
7110 *
7111 * @param name The name of the extra data, with package prefix.
7112 * @param value The integer data value.
7113 *
7114 * @return Returns the same Intent object, for chaining multiple calls
7115 * into a single statement.
7116 *
7117 * @see #putExtras
7118 * @see #removeExtra
7119 * @see #getIntExtra(String, int)
7120 */
7121 public Intent putExtra(String name, int value) {
7122 if (mExtras == null) {
7123 mExtras = new Bundle();
7124 }
7125 mExtras.putInt(name, value);
7126 return this;
7127 }
7128
7129 /**
7130 * Add extended data to the intent. The name must include a package
7131 * prefix, for example the app com.android.contacts would use names
7132 * like "com.android.contacts.ShowAll".
7133 *
7134 * @param name The name of the extra data, with package prefix.
7135 * @param value The long data value.
7136 *
7137 * @return Returns the same Intent object, for chaining multiple calls
7138 * into a single statement.
7139 *
7140 * @see #putExtras
7141 * @see #removeExtra
7142 * @see #getLongExtra(String, long)
7143 */
7144 public Intent putExtra(String name, long value) {
7145 if (mExtras == null) {
7146 mExtras = new Bundle();
7147 }
7148 mExtras.putLong(name, value);
7149 return this;
7150 }
7151
7152 /**
7153 * Add extended data to the intent. The name must include a package
7154 * prefix, for example the app com.android.contacts would use names
7155 * like "com.android.contacts.ShowAll".
7156 *
7157 * @param name The name of the extra data, with package prefix.
7158 * @param value The float data value.
7159 *
7160 * @return Returns the same Intent object, for chaining multiple calls
7161 * into a single statement.
7162 *
7163 * @see #putExtras
7164 * @see #removeExtra
7165 * @see #getFloatExtra(String, float)
7166 */
7167 public Intent putExtra(String name, float value) {
7168 if (mExtras == null) {
7169 mExtras = new Bundle();
7170 }
7171 mExtras.putFloat(name, value);
7172 return this;
7173 }
7174
7175 /**
7176 * Add extended data to the intent. The name must include a package
7177 * prefix, for example the app com.android.contacts would use names
7178 * like "com.android.contacts.ShowAll".
7179 *
7180 * @param name The name of the extra data, with package prefix.
7181 * @param value The double data value.
7182 *
7183 * @return Returns the same Intent object, for chaining multiple calls
7184 * into a single statement.
7185 *
7186 * @see #putExtras
7187 * @see #removeExtra
7188 * @see #getDoubleExtra(String, double)
7189 */
7190 public Intent putExtra(String name, double value) {
7191 if (mExtras == null) {
7192 mExtras = new Bundle();
7193 }
7194 mExtras.putDouble(name, value);
7195 return this;
7196 }
7197
7198 /**
7199 * Add extended data to the intent. The name must include a package
7200 * prefix, for example the app com.android.contacts would use names
7201 * like "com.android.contacts.ShowAll".
7202 *
7203 * @param name The name of the extra data, with package prefix.
7204 * @param value The String data value.
7205 *
7206 * @return Returns the same Intent object, for chaining multiple calls
7207 * into a single statement.
7208 *
7209 * @see #putExtras
7210 * @see #removeExtra
7211 * @see #getStringExtra(String)
7212 */
7213 public Intent putExtra(String name, String value) {
7214 if (mExtras == null) {
7215 mExtras = new Bundle();
7216 }
7217 mExtras.putString(name, value);
7218 return this;
7219 }
7220
7221 /**
7222 * Add extended data to the intent. The name must include a package
7223 * prefix, for example the app com.android.contacts would use names
7224 * like "com.android.contacts.ShowAll".
7225 *
7226 * @param name The name of the extra data, with package prefix.
7227 * @param value The CharSequence data value.
7228 *
7229 * @return Returns the same Intent object, for chaining multiple calls
7230 * into a single statement.
7231 *
7232 * @see #putExtras
7233 * @see #removeExtra
7234 * @see #getCharSequenceExtra(String)
7235 */
7236 public Intent putExtra(String name, CharSequence value) {
7237 if (mExtras == null) {
7238 mExtras = new Bundle();
7239 }
7240 mExtras.putCharSequence(name, value);
7241 return this;
7242 }
7243
7244 /**
7245 * Add extended data to the intent. The name must include a package
7246 * prefix, for example the app com.android.contacts would use names
7247 * like "com.android.contacts.ShowAll".
7248 *
7249 * @param name The name of the extra data, with package prefix.
7250 * @param value The Parcelable data value.
7251 *
7252 * @return Returns the same Intent object, for chaining multiple calls
7253 * into a single statement.
7254 *
7255 * @see #putExtras
7256 * @see #removeExtra
7257 * @see #getParcelableExtra(String)
7258 */
7259 public Intent putExtra(String name, Parcelable value) {
7260 if (mExtras == null) {
7261 mExtras = new Bundle();
7262 }
7263 mExtras.putParcelable(name, value);
7264 return this;
7265 }
7266
7267 /**
7268 * Add extended data to the intent. The name must include a package
7269 * prefix, for example the app com.android.contacts would use names
7270 * like "com.android.contacts.ShowAll".
7271 *
7272 * @param name The name of the extra data, with package prefix.
7273 * @param value The Parcelable[] data value.
7274 *
7275 * @return Returns the same Intent object, for chaining multiple calls
7276 * into a single statement.
7277 *
7278 * @see #putExtras
7279 * @see #removeExtra
7280 * @see #getParcelableArrayExtra(String)
7281 */
7282 public Intent putExtra(String name, Parcelable[] value) {
7283 if (mExtras == null) {
7284 mExtras = new Bundle();
7285 }
7286 mExtras.putParcelableArray(name, value);
7287 return this;
7288 }
7289
7290 /**
7291 * Add extended data to the intent. The name must include a package
7292 * prefix, for example the app com.android.contacts would use names
7293 * like "com.android.contacts.ShowAll".
7294 *
7295 * @param name The name of the extra data, with package prefix.
7296 * @param value The ArrayList<Parcelable> data value.
7297 *
7298 * @return Returns the same Intent object, for chaining multiple calls
7299 * into a single statement.
7300 *
7301 * @see #putExtras
7302 * @see #removeExtra
7303 * @see #getParcelableArrayListExtra(String)
7304 */
7305 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7306 if (mExtras == null) {
7307 mExtras = new Bundle();
7308 }
7309 mExtras.putParcelableArrayList(name, value);
7310 return this;
7311 }
7312
7313 /**
7314 * Add extended data to the intent. The name must include a package
7315 * prefix, for example the app com.android.contacts would use names
7316 * like "com.android.contacts.ShowAll".
7317 *
7318 * @param name The name of the extra data, with package prefix.
7319 * @param value The ArrayList<Integer> data value.
7320 *
7321 * @return Returns the same Intent object, for chaining multiple calls
7322 * into a single statement.
7323 *
7324 * @see #putExtras
7325 * @see #removeExtra
7326 * @see #getIntegerArrayListExtra(String)
7327 */
7328 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7329 if (mExtras == null) {
7330 mExtras = new Bundle();
7331 }
7332 mExtras.putIntegerArrayList(name, value);
7333 return this;
7334 }
7335
7336 /**
7337 * Add extended data to the intent. The name must include a package
7338 * prefix, for example the app com.android.contacts would use names
7339 * like "com.android.contacts.ShowAll".
7340 *
7341 * @param name The name of the extra data, with package prefix.
7342 * @param value The ArrayList<String> data value.
7343 *
7344 * @return Returns the same Intent object, for chaining multiple calls
7345 * into a single statement.
7346 *
7347 * @see #putExtras
7348 * @see #removeExtra
7349 * @see #getStringArrayListExtra(String)
7350 */
7351 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7352 if (mExtras == null) {
7353 mExtras = new Bundle();
7354 }
7355 mExtras.putStringArrayList(name, value);
7356 return this;
7357 }
7358
7359 /**
7360 * Add extended data to the intent. The name must include a package
7361 * prefix, for example the app com.android.contacts would use names
7362 * like "com.android.contacts.ShowAll".
7363 *
7364 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007365 * @param value The ArrayList<CharSequence> data value.
7366 *
7367 * @return Returns the same Intent object, for chaining multiple calls
7368 * into a single statement.
7369 *
7370 * @see #putExtras
7371 * @see #removeExtra
7372 * @see #getCharSequenceArrayListExtra(String)
7373 */
7374 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7375 if (mExtras == null) {
7376 mExtras = new Bundle();
7377 }
7378 mExtras.putCharSequenceArrayList(name, value);
7379 return this;
7380 }
7381
7382 /**
7383 * Add extended data to the intent. The name must include a package
7384 * prefix, for example the app com.android.contacts would use names
7385 * like "com.android.contacts.ShowAll".
7386 *
7387 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007388 * @param value The Serializable data value.
7389 *
7390 * @return Returns the same Intent object, for chaining multiple calls
7391 * into a single statement.
7392 *
7393 * @see #putExtras
7394 * @see #removeExtra
7395 * @see #getSerializableExtra(String)
7396 */
7397 public Intent putExtra(String name, Serializable value) {
7398 if (mExtras == null) {
7399 mExtras = new Bundle();
7400 }
7401 mExtras.putSerializable(name, value);
7402 return this;
7403 }
7404
7405 /**
7406 * Add extended data to the intent. The name must include a package
7407 * prefix, for example the app com.android.contacts would use names
7408 * like "com.android.contacts.ShowAll".
7409 *
7410 * @param name The name of the extra data, with package prefix.
7411 * @param value The boolean array data value.
7412 *
7413 * @return Returns the same Intent object, for chaining multiple calls
7414 * into a single statement.
7415 *
7416 * @see #putExtras
7417 * @see #removeExtra
7418 * @see #getBooleanArrayExtra(String)
7419 */
7420 public Intent putExtra(String name, boolean[] value) {
7421 if (mExtras == null) {
7422 mExtras = new Bundle();
7423 }
7424 mExtras.putBooleanArray(name, value);
7425 return this;
7426 }
7427
7428 /**
7429 * Add extended data to the intent. The name must include a package
7430 * prefix, for example the app com.android.contacts would use names
7431 * like "com.android.contacts.ShowAll".
7432 *
7433 * @param name The name of the extra data, with package prefix.
7434 * @param value The byte array data value.
7435 *
7436 * @return Returns the same Intent object, for chaining multiple calls
7437 * into a single statement.
7438 *
7439 * @see #putExtras
7440 * @see #removeExtra
7441 * @see #getByteArrayExtra(String)
7442 */
7443 public Intent putExtra(String name, byte[] value) {
7444 if (mExtras == null) {
7445 mExtras = new Bundle();
7446 }
7447 mExtras.putByteArray(name, value);
7448 return this;
7449 }
7450
7451 /**
7452 * Add extended data to the intent. The name must include a package
7453 * prefix, for example the app com.android.contacts would use names
7454 * like "com.android.contacts.ShowAll".
7455 *
7456 * @param name The name of the extra data, with package prefix.
7457 * @param value The short array data value.
7458 *
7459 * @return Returns the same Intent object, for chaining multiple calls
7460 * into a single statement.
7461 *
7462 * @see #putExtras
7463 * @see #removeExtra
7464 * @see #getShortArrayExtra(String)
7465 */
7466 public Intent putExtra(String name, short[] value) {
7467 if (mExtras == null) {
7468 mExtras = new Bundle();
7469 }
7470 mExtras.putShortArray(name, value);
7471 return this;
7472 }
7473
7474 /**
7475 * Add extended data to the intent. The name must include a package
7476 * prefix, for example the app com.android.contacts would use names
7477 * like "com.android.contacts.ShowAll".
7478 *
7479 * @param name The name of the extra data, with package prefix.
7480 * @param value The char array data value.
7481 *
7482 * @return Returns the same Intent object, for chaining multiple calls
7483 * into a single statement.
7484 *
7485 * @see #putExtras
7486 * @see #removeExtra
7487 * @see #getCharArrayExtra(String)
7488 */
7489 public Intent putExtra(String name, char[] value) {
7490 if (mExtras == null) {
7491 mExtras = new Bundle();
7492 }
7493 mExtras.putCharArray(name, value);
7494 return this;
7495 }
7496
7497 /**
7498 * Add extended data to the intent. The name must include a package
7499 * prefix, for example the app com.android.contacts would use names
7500 * like "com.android.contacts.ShowAll".
7501 *
7502 * @param name The name of the extra data, with package prefix.
7503 * @param value The int array data value.
7504 *
7505 * @return Returns the same Intent object, for chaining multiple calls
7506 * into a single statement.
7507 *
7508 * @see #putExtras
7509 * @see #removeExtra
7510 * @see #getIntArrayExtra(String)
7511 */
7512 public Intent putExtra(String name, int[] value) {
7513 if (mExtras == null) {
7514 mExtras = new Bundle();
7515 }
7516 mExtras.putIntArray(name, value);
7517 return this;
7518 }
7519
7520 /**
7521 * Add extended data to the intent. The name must include a package
7522 * prefix, for example the app com.android.contacts would use names
7523 * like "com.android.contacts.ShowAll".
7524 *
7525 * @param name The name of the extra data, with package prefix.
7526 * @param value The byte array data value.
7527 *
7528 * @return Returns the same Intent object, for chaining multiple calls
7529 * into a single statement.
7530 *
7531 * @see #putExtras
7532 * @see #removeExtra
7533 * @see #getLongArrayExtra(String)
7534 */
7535 public Intent putExtra(String name, long[] value) {
7536 if (mExtras == null) {
7537 mExtras = new Bundle();
7538 }
7539 mExtras.putLongArray(name, value);
7540 return this;
7541 }
7542
7543 /**
7544 * Add extended data to the intent. The name must include a package
7545 * prefix, for example the app com.android.contacts would use names
7546 * like "com.android.contacts.ShowAll".
7547 *
7548 * @param name The name of the extra data, with package prefix.
7549 * @param value The float array data value.
7550 *
7551 * @return Returns the same Intent object, for chaining multiple calls
7552 * into a single statement.
7553 *
7554 * @see #putExtras
7555 * @see #removeExtra
7556 * @see #getFloatArrayExtra(String)
7557 */
7558 public Intent putExtra(String name, float[] value) {
7559 if (mExtras == null) {
7560 mExtras = new Bundle();
7561 }
7562 mExtras.putFloatArray(name, value);
7563 return this;
7564 }
7565
7566 /**
7567 * Add extended data to the intent. The name must include a package
7568 * prefix, for example the app com.android.contacts would use names
7569 * like "com.android.contacts.ShowAll".
7570 *
7571 * @param name The name of the extra data, with package prefix.
7572 * @param value The double array data value.
7573 *
7574 * @return Returns the same Intent object, for chaining multiple calls
7575 * into a single statement.
7576 *
7577 * @see #putExtras
7578 * @see #removeExtra
7579 * @see #getDoubleArrayExtra(String)
7580 */
7581 public Intent putExtra(String name, double[] value) {
7582 if (mExtras == null) {
7583 mExtras = new Bundle();
7584 }
7585 mExtras.putDoubleArray(name, value);
7586 return this;
7587 }
7588
7589 /**
7590 * Add extended data to the intent. The name must include a package
7591 * prefix, for example the app com.android.contacts would use names
7592 * like "com.android.contacts.ShowAll".
7593 *
7594 * @param name The name of the extra data, with package prefix.
7595 * @param value The String array data value.
7596 *
7597 * @return Returns the same Intent object, for chaining multiple calls
7598 * into a single statement.
7599 *
7600 * @see #putExtras
7601 * @see #removeExtra
7602 * @see #getStringArrayExtra(String)
7603 */
7604 public Intent putExtra(String name, String[] value) {
7605 if (mExtras == null) {
7606 mExtras = new Bundle();
7607 }
7608 mExtras.putStringArray(name, value);
7609 return this;
7610 }
7611
7612 /**
7613 * Add extended data to the intent. The name must include a package
7614 * prefix, for example the app com.android.contacts would use names
7615 * like "com.android.contacts.ShowAll".
7616 *
7617 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007618 * @param value The CharSequence array data value.
7619 *
7620 * @return Returns the same Intent object, for chaining multiple calls
7621 * into a single statement.
7622 *
7623 * @see #putExtras
7624 * @see #removeExtra
7625 * @see #getCharSequenceArrayExtra(String)
7626 */
7627 public Intent putExtra(String name, CharSequence[] value) {
7628 if (mExtras == null) {
7629 mExtras = new Bundle();
7630 }
7631 mExtras.putCharSequenceArray(name, value);
7632 return this;
7633 }
7634
7635 /**
7636 * Add extended data to the intent. The name must include a package
7637 * prefix, for example the app com.android.contacts would use names
7638 * like "com.android.contacts.ShowAll".
7639 *
7640 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007641 * @param value The Bundle data value.
7642 *
7643 * @return Returns the same Intent object, for chaining multiple calls
7644 * into a single statement.
7645 *
7646 * @see #putExtras
7647 * @see #removeExtra
7648 * @see #getBundleExtra(String)
7649 */
7650 public Intent putExtra(String name, Bundle value) {
7651 if (mExtras == null) {
7652 mExtras = new Bundle();
7653 }
7654 mExtras.putBundle(name, value);
7655 return this;
7656 }
7657
7658 /**
7659 * Add extended data to the intent. The name must include a package
7660 * prefix, for example the app com.android.contacts would use names
7661 * like "com.android.contacts.ShowAll".
7662 *
7663 * @param name The name of the extra data, with package prefix.
7664 * @param value The IBinder data value.
7665 *
7666 * @return Returns the same Intent object, for chaining multiple calls
7667 * into a single statement.
7668 *
7669 * @see #putExtras
7670 * @see #removeExtra
7671 * @see #getIBinderExtra(String)
7672 *
7673 * @deprecated
7674 * @hide
7675 */
7676 @Deprecated
7677 public Intent putExtra(String name, IBinder value) {
7678 if (mExtras == null) {
7679 mExtras = new Bundle();
7680 }
7681 mExtras.putIBinder(name, value);
7682 return this;
7683 }
7684
7685 /**
7686 * Copy all extras in 'src' in to this intent.
7687 *
7688 * @param src Contains the extras to copy.
7689 *
7690 * @see #putExtra
7691 */
7692 public Intent putExtras(Intent src) {
7693 if (src.mExtras != null) {
7694 if (mExtras == null) {
7695 mExtras = new Bundle(src.mExtras);
7696 } else {
7697 mExtras.putAll(src.mExtras);
7698 }
7699 }
7700 return this;
7701 }
7702
7703 /**
7704 * Add a set of extended data to the intent. The keys 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 extras The Bundle of extras to add to this intent.
7709 *
7710 * @see #putExtra
7711 * @see #removeExtra
7712 */
7713 public Intent putExtras(Bundle extras) {
7714 if (mExtras == null) {
7715 mExtras = new Bundle();
7716 }
7717 mExtras.putAll(extras);
7718 return this;
7719 }
7720
7721 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007722 * Completely replace the extras in the Intent with the extras in the
7723 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007724 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007725 * @param src The exact extras contained in this Intent are copied
7726 * into the target intent, replacing any that were previously there.
7727 */
7728 public Intent replaceExtras(Intent src) {
7729 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7730 return this;
7731 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007732
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007733 /**
7734 * Completely replace the extras in the Intent with the given Bundle of
7735 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007736 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007737 * @param extras The new set of extras in the Intent, or null to erase
7738 * all extras.
7739 */
7740 public Intent replaceExtras(Bundle extras) {
7741 mExtras = extras != null ? new Bundle(extras) : null;
7742 return this;
7743 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007744
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007745 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007746 * Remove extended data from the intent.
7747 *
7748 * @see #putExtra
7749 */
7750 public void removeExtra(String name) {
7751 if (mExtras != null) {
7752 mExtras.remove(name);
7753 if (mExtras.size() == 0) {
7754 mExtras = null;
7755 }
7756 }
7757 }
7758
7759 /**
7760 * Set special flags controlling how this intent is handled. Most values
7761 * here depend on the type of component being executed by the Intent,
7762 * specifically the FLAG_ACTIVITY_* flags are all for use with
7763 * {@link Context#startActivity Context.startActivity()} and the
7764 * FLAG_RECEIVER_* flags are all for use with
7765 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7766 *
Scott Main7aee61f2011-02-08 11:25:01 -08007767 * <p>See the
7768 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7769 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007770 * the behavior of your application.
7771 *
7772 * @param flags The desired flags.
7773 *
7774 * @return Returns the same Intent object, for chaining multiple calls
7775 * into a single statement.
7776 *
7777 * @see #getFlags
7778 * @see #addFlags
7779 *
7780 * @see #FLAG_GRANT_READ_URI_PERMISSION
7781 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007782 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7783 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007784 * @see #FLAG_DEBUG_LOG_RESOLUTION
7785 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007786 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007787 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007788 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007789 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007790 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7791 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007792 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007793 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007794 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007796 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007797 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007798 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007799 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7800 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007801 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007802 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007803 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007804 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7805 */
7806 public Intent setFlags(int flags) {
7807 mFlags = flags;
7808 return this;
7809 }
7810
7811 /**
7812 * Add additional flags to the intent (or with existing flags
7813 * value).
7814 *
7815 * @param flags The new flags to set.
7816 *
7817 * @return Returns the same Intent object, for chaining multiple calls
7818 * into a single statement.
7819 *
7820 * @see #setFlags
7821 */
7822 public Intent addFlags(int flags) {
7823 mFlags |= flags;
7824 return this;
7825 }
7826
7827 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007828 * (Usually optional) Set an explicit application package name that limits
7829 * the components this Intent will resolve to. If left to the default
7830 * value of null, all components in all applications will considered.
7831 * If non-null, the Intent can only match the components in the given
7832 * application package.
7833 *
7834 * @param packageName The name of the application package to handle the
7835 * intent, or null to allow any application package.
7836 *
7837 * @return Returns the same Intent object, for chaining multiple calls
7838 * into a single statement.
7839 *
7840 * @see #getPackage
7841 * @see #resolveActivity
7842 */
7843 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007844 if (packageName != null && mSelector != null) {
7845 throw new IllegalArgumentException(
7846 "Can't set package name when selector is already set");
7847 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007848 mPackage = packageName;
7849 return this;
7850 }
7851
7852 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007853 * (Usually optional) Explicitly set the component to handle the intent.
7854 * If left with the default value of null, the system will determine the
7855 * appropriate class to use based on the other fields (action, data,
7856 * type, categories) in the Intent. If this class is defined, the
7857 * specified class will always be used regardless of the other fields. You
7858 * should only set this value when you know you absolutely want a specific
7859 * class to be used; otherwise it is better to let the system find the
7860 * appropriate class so that you will respect the installed applications
7861 * and user preferences.
7862 *
7863 * @param component The name of the application component to handle the
7864 * intent, or null to let the system find one for you.
7865 *
7866 * @return Returns the same Intent object, for chaining multiple calls
7867 * into a single statement.
7868 *
7869 * @see #setClass
7870 * @see #setClassName(Context, String)
7871 * @see #setClassName(String, String)
7872 * @see #getComponent
7873 * @see #resolveActivity
7874 */
7875 public Intent setComponent(ComponentName component) {
7876 mComponent = component;
7877 return this;
7878 }
7879
7880 /**
7881 * Convenience for calling {@link #setComponent} with an
7882 * explicit class name.
7883 *
7884 * @param packageContext A Context of the application package implementing
7885 * this class.
7886 * @param className The name of a class inside of the application package
7887 * that will be used as the component for this Intent.
7888 *
7889 * @return Returns the same Intent object, for chaining multiple calls
7890 * into a single statement.
7891 *
7892 * @see #setComponent
7893 * @see #setClass
7894 */
7895 public Intent setClassName(Context packageContext, String className) {
7896 mComponent = new ComponentName(packageContext, className);
7897 return this;
7898 }
7899
7900 /**
7901 * Convenience for calling {@link #setComponent} with an
7902 * explicit application package name and class name.
7903 *
7904 * @param packageName The name of the package implementing the desired
7905 * component.
7906 * @param className The name of a class inside of the application package
7907 * that will be used as the component for this Intent.
7908 *
7909 * @return Returns the same Intent object, for chaining multiple calls
7910 * into a single statement.
7911 *
7912 * @see #setComponent
7913 * @see #setClass
7914 */
7915 public Intent setClassName(String packageName, String className) {
7916 mComponent = new ComponentName(packageName, className);
7917 return this;
7918 }
7919
7920 /**
7921 * Convenience for calling {@link #setComponent(ComponentName)} with the
7922 * name returned by a {@link Class} object.
7923 *
7924 * @param packageContext A Context of the application package implementing
7925 * this class.
7926 * @param cls The class name to set, equivalent to
7927 * <code>setClassName(context, cls.getName())</code>.
7928 *
7929 * @return Returns the same Intent object, for chaining multiple calls
7930 * into a single statement.
7931 *
7932 * @see #setComponent
7933 */
7934 public Intent setClass(Context packageContext, Class<?> cls) {
7935 mComponent = new ComponentName(packageContext, cls);
7936 return this;
7937 }
7938
7939 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007940 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7941 * used as a hint to the receiver for animations and the like. Null means that there
7942 * is no source bounds.
7943 */
7944 public void setSourceBounds(Rect r) {
7945 if (r != null) {
7946 mSourceBounds = new Rect(r);
7947 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007948 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007949 }
7950 }
7951
Tor Norbyed9273d62013-05-30 15:59:53 -07007952 /** @hide */
7953 @IntDef(flag = true,
7954 value = {
7955 FILL_IN_ACTION,
7956 FILL_IN_DATA,
7957 FILL_IN_CATEGORIES,
7958 FILL_IN_COMPONENT,
7959 FILL_IN_PACKAGE,
7960 FILL_IN_SOURCE_BOUNDS,
7961 FILL_IN_SELECTOR,
7962 FILL_IN_CLIP_DATA
7963 })
7964 @Retention(RetentionPolicy.SOURCE)
7965 public @interface FillInFlags {}
7966
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007967 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007968 * Use with {@link #fillIn} to allow the current action value to be
7969 * overwritten, even if it is already set.
7970 */
7971 public static final int FILL_IN_ACTION = 1<<0;
7972
7973 /**
7974 * Use with {@link #fillIn} to allow the current data or type value
7975 * overwritten, even if it is already set.
7976 */
7977 public static final int FILL_IN_DATA = 1<<1;
7978
7979 /**
7980 * Use with {@link #fillIn} to allow the current categories to be
7981 * overwritten, even if they are already set.
7982 */
7983 public static final int FILL_IN_CATEGORIES = 1<<2;
7984
7985 /**
7986 * Use with {@link #fillIn} to allow the current component value to be
7987 * overwritten, even if it is already set.
7988 */
7989 public static final int FILL_IN_COMPONENT = 1<<3;
7990
7991 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007992 * Use with {@link #fillIn} to allow the current package value to be
7993 * overwritten, even if it is already set.
7994 */
7995 public static final int FILL_IN_PACKAGE = 1<<4;
7996
7997 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007998 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007999 * overwritten, even if it is already set.
8000 */
8001 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8002
8003 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008004 * Use with {@link #fillIn} to allow the current selector to be
8005 * overwritten, even if it is already set.
8006 */
8007 public static final int FILL_IN_SELECTOR = 1<<6;
8008
8009 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008010 * Use with {@link #fillIn} to allow the current ClipData to be
8011 * overwritten, even if it is already set.
8012 */
8013 public static final int FILL_IN_CLIP_DATA = 1<<7;
8014
8015 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008016 * Copy the contents of <var>other</var> in to this object, but only
8017 * where fields are not defined by this object. For purposes of a field
8018 * being defined, the following pieces of data in the Intent are
8019 * considered to be separate fields:
8020 *
8021 * <ul>
8022 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008023 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008024 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8025 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008026 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008027 * <li> component, as set by {@link #setComponent(ComponentName)} or
8028 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008029 * <li> source bounds, as set by {@link #setSourceBounds}.
8030 * <li> selector, as set by {@link #setSelector(Intent)}.
8031 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008032 * <li> each top-level name in the associated extras.
8033 * </ul>
8034 *
8035 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008036 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008037 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8038 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8039 * the restriction where the corresponding field will not be replaced if
8040 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008041 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008042 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8043 * is explicitly specified. The selector will only be copied if
8044 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008045 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008046 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8047 * and Intent B with {action="gotit", data-type="some/thing",
8048 * categories="one","two"}.
8049 *
8050 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8051 * containing: {action="gotit", data-type="some/thing",
8052 * categories="bar"}.
8053 *
8054 * @param other Another Intent whose values are to be used to fill in
8055 * the current one.
8056 * @param flags Options to control which fields can be filled in.
8057 *
8058 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008059 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008060 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8061 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8062 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008063 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008064 @FillInFlags
8065 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008066 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008067 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008068 if (other.mAction != null
8069 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008070 mAction = other.mAction;
8071 changes |= FILL_IN_ACTION;
8072 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008073 if ((other.mData != null || other.mType != null)
8074 && ((mData == null && mType == null)
8075 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008076 mData = other.mData;
8077 mType = other.mType;
8078 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008079 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008080 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008081 if (other.mCategories != null
8082 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008083 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008084 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008085 }
8086 changes |= FILL_IN_CATEGORIES;
8087 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008088 if (other.mPackage != null
8089 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008090 // Only do this if mSelector is not set.
8091 if (mSelector == null) {
8092 mPackage = other.mPackage;
8093 changes |= FILL_IN_PACKAGE;
8094 }
8095 }
8096 // Selector is special: it can only be set if explicitly allowed,
8097 // for the same reason as the component name.
8098 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8099 if (mPackage == null) {
8100 mSelector = new Intent(other.mSelector);
8101 mPackage = null;
8102 changes |= FILL_IN_SELECTOR;
8103 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008104 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008105 if (other.mClipData != null
8106 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8107 mClipData = other.mClipData;
8108 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008109 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008110 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008111 // Component is special: it can -only- be set if explicitly allowed,
8112 // since otherwise the sender could force the intent somewhere the
8113 // originator didn't intend.
8114 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008115 mComponent = other.mComponent;
8116 changes |= FILL_IN_COMPONENT;
8117 }
8118 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008119 if (other.mSourceBounds != null
8120 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8121 mSourceBounds = new Rect(other.mSourceBounds);
8122 changes |= FILL_IN_SOURCE_BOUNDS;
8123 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008124 if (mExtras == null) {
8125 if (other.mExtras != null) {
8126 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008127 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008128 }
8129 } else if (other.mExtras != null) {
8130 try {
8131 Bundle newb = new Bundle(other.mExtras);
8132 newb.putAll(mExtras);
8133 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008134 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008135 } catch (RuntimeException e) {
8136 // Modifying the extras can cause us to unparcel the contents
8137 // of the bundle, and if we do this in the system process that
8138 // may fail. We really should handle this (i.e., the Bundle
8139 // impl shouldn't be on top of a plain map), but for now just
8140 // ignore it and keep the original contents. :(
8141 Log.w("Intent", "Failure filling in extras", e);
8142 }
8143 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008144 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8145 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8146 mContentUserHint = other.mContentUserHint;
8147 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008148 return changes;
8149 }
8150
8151 /**
8152 * Wrapper class holding an Intent and implementing comparisons on it for
8153 * the purpose of filtering. The class implements its
8154 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8155 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8156 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8157 * on the wrapped Intent.
8158 */
8159 public static final class FilterComparison {
8160 private final Intent mIntent;
8161 private final int mHashCode;
8162
8163 public FilterComparison(Intent intent) {
8164 mIntent = intent;
8165 mHashCode = intent.filterHashCode();
8166 }
8167
8168 /**
8169 * Return the Intent that this FilterComparison represents.
8170 * @return Returns the Intent held by the FilterComparison. Do
8171 * not modify!
8172 */
8173 public Intent getIntent() {
8174 return mIntent;
8175 }
8176
8177 @Override
8178 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008179 if (obj instanceof FilterComparison) {
8180 Intent other = ((FilterComparison)obj).mIntent;
8181 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008182 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008183 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008184 }
8185
8186 @Override
8187 public int hashCode() {
8188 return mHashCode;
8189 }
8190 }
8191
8192 /**
8193 * Determine if two intents are the same for the purposes of intent
8194 * resolution (filtering). That is, if their action, data, type,
8195 * class, and categories are the same. This does <em>not</em> compare
8196 * any extra data included in the intents.
8197 *
8198 * @param other The other Intent to compare against.
8199 *
8200 * @return Returns true if action, data, type, class, and categories
8201 * are the same.
8202 */
8203 public boolean filterEquals(Intent other) {
8204 if (other == null) {
8205 return false;
8206 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008207 if (!Objects.equals(this.mAction, other.mAction)) return false;
8208 if (!Objects.equals(this.mData, other.mData)) return false;
8209 if (!Objects.equals(this.mType, other.mType)) return false;
8210 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8211 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8212 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008213
8214 return true;
8215 }
8216
8217 /**
8218 * Generate hash code that matches semantics of filterEquals().
8219 *
8220 * @return Returns the hash value of the action, data, type, class, and
8221 * categories.
8222 *
8223 * @see #filterEquals
8224 */
8225 public int filterHashCode() {
8226 int code = 0;
8227 if (mAction != null) {
8228 code += mAction.hashCode();
8229 }
8230 if (mData != null) {
8231 code += mData.hashCode();
8232 }
8233 if (mType != null) {
8234 code += mType.hashCode();
8235 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008236 if (mPackage != null) {
8237 code += mPackage.hashCode();
8238 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008239 if (mComponent != null) {
8240 code += mComponent.hashCode();
8241 }
8242 if (mCategories != null) {
8243 code += mCategories.hashCode();
8244 }
8245 return code;
8246 }
8247
8248 @Override
8249 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008250 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008251
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008252 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008253 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008254 b.append(" }");
8255
8256 return b.toString();
8257 }
8258
8259 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008260 public String toInsecureString() {
8261 StringBuilder b = new StringBuilder(128);
8262
8263 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008264 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008265 b.append(" }");
8266
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008267 return b.toString();
8268 }
Romain Guy4969af72009-06-17 10:53:19 -07008269
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008270 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008271 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008272 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008273
8274 b.append("Intent { ");
8275 toShortString(b, false, true, true, true);
8276 b.append(" }");
8277
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008278 return b.toString();
8279 }
8280
8281 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008282 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8283 StringBuilder b = new StringBuilder(128);
8284 toShortString(b, secure, comp, extras, clip);
8285 return b.toString();
8286 }
8287
8288 /** @hide */
8289 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8290 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008291 boolean first = true;
8292 if (mAction != null) {
8293 b.append("act=").append(mAction);
8294 first = false;
8295 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008296 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008297 if (!first) {
8298 b.append(' ');
8299 }
8300 first = false;
8301 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008302 for (int i=0; i<mCategories.size(); i++) {
8303 if (i > 0) b.append(',');
8304 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008305 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008306 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008307 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008308 if (mData != null) {
8309 if (!first) {
8310 b.append(' ');
8311 }
8312 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008313 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008314 if (secure) {
8315 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008316 } else {
8317 b.append(mData);
8318 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008319 }
8320 if (mType != null) {
8321 if (!first) {
8322 b.append(' ');
8323 }
8324 first = false;
8325 b.append("typ=").append(mType);
8326 }
8327 if (mFlags != 0) {
8328 if (!first) {
8329 b.append(' ');
8330 }
8331 first = false;
8332 b.append("flg=0x").append(Integer.toHexString(mFlags));
8333 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008334 if (mPackage != null) {
8335 if (!first) {
8336 b.append(' ');
8337 }
8338 first = false;
8339 b.append("pkg=").append(mPackage);
8340 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008341 if (comp && mComponent != null) {
8342 if (!first) {
8343 b.append(' ');
8344 }
8345 first = false;
8346 b.append("cmp=").append(mComponent.flattenToShortString());
8347 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008348 if (mSourceBounds != null) {
8349 if (!first) {
8350 b.append(' ');
8351 }
8352 first = false;
8353 b.append("bnds=").append(mSourceBounds.toShortString());
8354 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008355 if (mClipData != null) {
8356 if (!first) {
8357 b.append(' ');
8358 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008359 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008360 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008361 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008362 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008363 if (mClipData.getDescription() != null) {
8364 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8365 } else {
8366 first = true;
8367 }
8368 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008369 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008370 first = false;
8371 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008372 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008373 if (extras && mExtras != null) {
8374 if (!first) {
8375 b.append(' ');
8376 }
8377 first = false;
8378 b.append("(has extras)");
8379 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008380 if (mContentUserHint != UserHandle.USER_CURRENT) {
8381 if (!first) {
8382 b.append(' ');
8383 }
8384 first = false;
8385 b.append("u=").append(mContentUserHint);
8386 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008387 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008388 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008389 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008390 b.append("}");
8391 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008392 }
8393
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008394 /**
8395 * Call {@link #toUri} with 0 flags.
8396 * @deprecated Use {@link #toUri} instead.
8397 */
8398 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008399 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008400 return toUri(0);
8401 }
8402
8403 /**
8404 * Convert this Intent into a String holding a URI representation of it.
8405 * The returned URI string has been properly URI encoded, so it can be
8406 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8407 * Intent's data as the base URI, with an additional fragment describing
8408 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008409 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008410 * <p>You can convert the returned string back to an Intent with
8411 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008412 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008413 * @param flags Additional operating flags. Either 0,
8414 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008415 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008416 * @return Returns a URI encoding URI string describing the entire contents
8417 * of the Intent.
8418 */
8419 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008420 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008421 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8422 if (mPackage == null) {
8423 throw new IllegalArgumentException(
8424 "Intent must include an explicit package name to build an android-app: "
8425 + this);
8426 }
8427 uri.append("android-app://");
8428 uri.append(mPackage);
8429 String scheme = null;
8430 if (mData != null) {
8431 scheme = mData.getScheme();
8432 if (scheme != null) {
8433 uri.append('/');
8434 uri.append(scheme);
8435 String authority = mData.getEncodedAuthority();
8436 if (authority != null) {
8437 uri.append('/');
8438 uri.append(authority);
8439 String path = mData.getEncodedPath();
8440 if (path != null) {
8441 uri.append(path);
8442 }
8443 String queryParams = mData.getEncodedQuery();
8444 if (queryParams != null) {
8445 uri.append('?');
8446 uri.append(queryParams);
8447 }
8448 String fragment = mData.getEncodedFragment();
8449 if (fragment != null) {
8450 uri.append('#');
8451 uri.append(fragment);
8452 }
8453 }
8454 }
8455 }
8456 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8457 mPackage, flags);
8458 return uri.toString();
8459 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008460 String scheme = null;
8461 if (mData != null) {
8462 String data = mData.toString();
8463 if ((flags&URI_INTENT_SCHEME) != 0) {
8464 final int N = data.length();
8465 for (int i=0; i<N; i++) {
8466 char c = data.charAt(i);
8467 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8468 || c == '.' || c == '-') {
8469 continue;
8470 }
8471 if (c == ':' && i > 0) {
8472 // Valid scheme.
8473 scheme = data.substring(0, i);
8474 uri.append("intent:");
8475 data = data.substring(i+1);
8476 break;
8477 }
Tom Taylord4a47292009-12-21 13:59:18 -08008478
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008479 // No scheme.
8480 break;
8481 }
8482 }
8483 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008484
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008485 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8486 uri.append("intent:");
8487 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008488
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008489 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008490
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008491 return uri.toString();
8492 }
8493
8494 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8495 String defPackage, int flags) {
8496 StringBuilder frag = new StringBuilder(128);
8497
8498 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008499 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008500 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008501 // Note that for now we are not going to try to handle the
8502 // data part; not clear how to represent this as a URI, and
8503 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008504 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8505 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008506 }
8507
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008508 if (frag.length() > 0) {
8509 uri.append("#Intent;");
8510 uri.append(frag);
8511 uri.append("end");
8512 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008513 }
8514
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008515 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8516 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008517 if (scheme != null) {
8518 uri.append("scheme=").append(scheme).append(';');
8519 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008520 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008521 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008522 }
8523 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008524 for (int i=0; i<mCategories.size(); i++) {
8525 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008526 }
8527 }
8528 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008529 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008530 }
8531 if (mFlags != 0) {
8532 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8533 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008534 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008535 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8536 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008537 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008538 uri.append("component=").append(Uri.encode(
8539 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008540 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008541 if (mSourceBounds != null) {
8542 uri.append("sourceBounds=")
8543 .append(Uri.encode(mSourceBounds.flattenToString()))
8544 .append(';');
8545 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008546 if (mExtras != null) {
8547 for (String key : mExtras.keySet()) {
8548 final Object value = mExtras.get(key);
8549 char entryType =
8550 value instanceof String ? 'S' :
8551 value instanceof Boolean ? 'B' :
8552 value instanceof Byte ? 'b' :
8553 value instanceof Character ? 'c' :
8554 value instanceof Double ? 'd' :
8555 value instanceof Float ? 'f' :
8556 value instanceof Integer ? 'i' :
8557 value instanceof Long ? 'l' :
8558 value instanceof Short ? 's' :
8559 '\0';
8560
8561 if (entryType != '\0') {
8562 uri.append(entryType);
8563 uri.append('.');
8564 uri.append(Uri.encode(key));
8565 uri.append('=');
8566 uri.append(Uri.encode(value.toString()));
8567 uri.append(';');
8568 }
8569 }
8570 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008571 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008572
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008573 public int describeContents() {
8574 return (mExtras != null) ? mExtras.describeContents() : 0;
8575 }
8576
8577 public void writeToParcel(Parcel out, int flags) {
8578 out.writeString(mAction);
8579 Uri.writeToParcel(out, mData);
8580 out.writeString(mType);
8581 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008582 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 ComponentName.writeToParcel(mComponent, out);
8584
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008585 if (mSourceBounds != null) {
8586 out.writeInt(1);
8587 mSourceBounds.writeToParcel(out, flags);
8588 } else {
8589 out.writeInt(0);
8590 }
8591
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008592 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008593 final int N = mCategories.size();
8594 out.writeInt(N);
8595 for (int i=0; i<N; i++) {
8596 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008597 }
8598 } else {
8599 out.writeInt(0);
8600 }
8601
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008602 if (mSelector != null) {
8603 out.writeInt(1);
8604 mSelector.writeToParcel(out, flags);
8605 } else {
8606 out.writeInt(0);
8607 }
8608
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008609 if (mClipData != null) {
8610 out.writeInt(1);
8611 mClipData.writeToParcel(out, flags);
8612 } else {
8613 out.writeInt(0);
8614 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008615 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008616 out.writeBundle(mExtras);
8617 }
8618
8619 public static final Parcelable.Creator<Intent> CREATOR
8620 = new Parcelable.Creator<Intent>() {
8621 public Intent createFromParcel(Parcel in) {
8622 return new Intent(in);
8623 }
8624 public Intent[] newArray(int size) {
8625 return new Intent[size];
8626 }
8627 };
8628
Dianne Hackborneb034652009-09-07 00:49:58 -07008629 /** @hide */
8630 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008631 readFromParcel(in);
8632 }
8633
8634 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008635 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008636 mData = Uri.CREATOR.createFromParcel(in);
8637 mType = in.readString();
8638 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008639 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008640 mComponent = ComponentName.readFromParcel(in);
8641
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008642 if (in.readInt() != 0) {
8643 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8644 }
8645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008646 int N = in.readInt();
8647 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008648 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008649 int i;
8650 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008651 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008652 }
8653 } else {
8654 mCategories = null;
8655 }
8656
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008657 if (in.readInt() != 0) {
8658 mSelector = new Intent(in);
8659 }
8660
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008661 if (in.readInt() != 0) {
8662 mClipData = new ClipData(in);
8663 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008664 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008665 mExtras = in.readBundle();
8666 }
8667
8668 /**
8669 * Parses the "intent" element (and its children) from XML and instantiates
8670 * an Intent object. The given XML parser should be located at the tag
8671 * where parsing should start (often named "intent"), from which the
8672 * basic action, data, type, and package and class name will be
8673 * retrieved. The function will then parse in to any child elements,
8674 * looking for <category android:name="xxx"> tags to add categories and
8675 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8676 * to the intent.
8677 *
8678 * @param resources The Resources to use when inflating resources.
8679 * @param parser The XML parser pointing at an "intent" tag.
8680 * @param attrs The AttributeSet interface for retrieving extended
8681 * attribute data at the current <var>parser</var> location.
8682 * @return An Intent object matching the XML data.
8683 * @throws XmlPullParserException If there was an XML parsing error.
8684 * @throws IOException If there was an I/O error.
8685 */
8686 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8687 throws XmlPullParserException, IOException {
8688 Intent intent = new Intent();
8689
8690 TypedArray sa = resources.obtainAttributes(attrs,
8691 com.android.internal.R.styleable.Intent);
8692
8693 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8694
8695 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8696 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8697 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8698
8699 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8700 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8701 if (packageName != null && className != null) {
8702 intent.setComponent(new ComponentName(packageName, className));
8703 }
8704
8705 sa.recycle();
8706
8707 int outerDepth = parser.getDepth();
8708 int type;
8709 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8710 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8711 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8712 continue;
8713 }
8714
8715 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008716 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008717 sa = resources.obtainAttributes(attrs,
8718 com.android.internal.R.styleable.IntentCategory);
8719 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8720 sa.recycle();
8721
8722 if (cat != null) {
8723 intent.addCategory(cat);
8724 }
8725 XmlUtils.skipCurrentTag(parser);
8726
Craig Mautner21d24a22014-04-23 11:45:37 -07008727 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008728 if (intent.mExtras == null) {
8729 intent.mExtras = new Bundle();
8730 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008731 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008732 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008733
8734 } else {
8735 XmlUtils.skipCurrentTag(parser);
8736 }
8737 }
8738
8739 return intent;
8740 }
Nick Pellyccae4122012-01-09 14:12:58 -08008741
Craig Mautner21d24a22014-04-23 11:45:37 -07008742 /** @hide */
8743 public void saveToXml(XmlSerializer out) throws IOException {
8744 if (mAction != null) {
8745 out.attribute(null, ATTR_ACTION, mAction);
8746 }
8747 if (mData != null) {
8748 out.attribute(null, ATTR_DATA, mData.toString());
8749 }
8750 if (mType != null) {
8751 out.attribute(null, ATTR_TYPE, mType);
8752 }
8753 if (mComponent != null) {
8754 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8755 }
8756 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8757
8758 if (mCategories != null) {
8759 out.startTag(null, TAG_CATEGORIES);
8760 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8761 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8762 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008763 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008764 }
8765 }
8766
8767 /** @hide */
8768 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8769 XmlPullParserException {
8770 Intent intent = new Intent();
8771 final int outerDepth = in.getDepth();
8772
8773 int attrCount = in.getAttributeCount();
8774 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8775 final String attrName = in.getAttributeName(attrNdx);
8776 final String attrValue = in.getAttributeValue(attrNdx);
8777 if (ATTR_ACTION.equals(attrName)) {
8778 intent.setAction(attrValue);
8779 } else if (ATTR_DATA.equals(attrName)) {
8780 intent.setData(Uri.parse(attrValue));
8781 } else if (ATTR_TYPE.equals(attrName)) {
8782 intent.setType(attrValue);
8783 } else if (ATTR_COMPONENT.equals(attrName)) {
8784 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8785 } else if (ATTR_FLAGS.equals(attrName)) {
8786 intent.setFlags(Integer.valueOf(attrValue, 16));
8787 } else {
8788 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8789 }
8790 }
8791
8792 int event;
8793 String name;
8794 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8795 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8796 if (event == XmlPullParser.START_TAG) {
8797 name = in.getName();
8798 if (TAG_CATEGORIES.equals(name)) {
8799 attrCount = in.getAttributeCount();
8800 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8801 intent.addCategory(in.getAttributeValue(attrNdx));
8802 }
8803 } else {
8804 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8805 XmlUtils.skipCurrentTag(in);
8806 }
8807 }
8808 }
8809
8810 return intent;
8811 }
8812
Nick Pellyccae4122012-01-09 14:12:58 -08008813 /**
8814 * Normalize a MIME data type.
8815 *
8816 * <p>A normalized MIME type has white-space trimmed,
8817 * content-type parameters removed, and is lower-case.
8818 * This aligns the type with Android best practices for
8819 * intent filtering.
8820 *
8821 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8822 * "text/x-vCard" becomes "text/x-vcard".
8823 *
8824 * <p>All MIME types received from outside Android (such as user input,
8825 * or external sources like Bluetooth, NFC, or the Internet) should
8826 * be normalized before they are used to create an Intent.
8827 *
8828 * @param type MIME data type to normalize
8829 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008830 * @see #setType
8831 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008832 */
8833 public static String normalizeMimeType(String type) {
8834 if (type == null) {
8835 return null;
8836 }
8837
Elliott Hughescb64d432013-08-02 10:00:44 -07008838 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008839
8840 final int semicolonIndex = type.indexOf(';');
8841 if (semicolonIndex != -1) {
8842 type = type.substring(0, semicolonIndex);
8843 }
8844 return type;
8845 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008846
8847 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008848 * Prepare this {@link Intent} to leave an app process.
8849 *
8850 * @hide
8851 */
8852 public void prepareToLeaveProcess() {
8853 setAllowFds(false);
8854
8855 if (mSelector != null) {
8856 mSelector.prepareToLeaveProcess();
8857 }
8858 if (mClipData != null) {
8859 mClipData.prepareToLeaveProcess();
8860 }
8861
8862 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8863 // There are several ACTION_MEDIA_* broadcasts that send file://
8864 // Uris, so only check common actions.
8865 if (ACTION_VIEW.equals(mAction) ||
8866 ACTION_EDIT.equals(mAction) ||
8867 ACTION_ATTACH_DATA.equals(mAction)) {
8868 mData.checkFileUriExposed("Intent.getData()");
8869 }
8870 }
8871 }
8872
8873 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008874 * @hide
8875 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008876 public void prepareToEnterProcess() {
8877 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008878 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8879 fixUris(mContentUserHint);
8880 mContentUserHint = UserHandle.USER_CURRENT;
8881 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008882 }
8883 }
8884
8885 /**
8886 * @hide
8887 */
8888 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008889 Uri data = getData();
8890 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008891 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008892 }
8893 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008894 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008895 }
8896 String action = getAction();
8897 if (ACTION_SEND.equals(action)) {
8898 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8899 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008900 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008901 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008902 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008903 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8904 if (streams != null) {
8905 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8906 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008907 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008908 }
8909 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8910 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008911 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8912 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8913 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8914 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8915 if (output != null) {
8916 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8917 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008918 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008919 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008920
8921 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008922 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008923 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8924 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008925 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008926 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008927 * @hide
8928 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008929 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008930 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008931 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008932
8933 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008934 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008935
8936 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008937 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008938 // Inspect contained intents to see if we need to migrate extras. We
8939 // don't promote ClipData to the parent, since ChooserActivity will
8940 // already start the picked item as the caller, and we can't combine
8941 // the flags in a safe way.
8942
8943 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008944 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008945 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8946 if (intent != null) {
8947 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008948 }
8949 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008950 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008951 try {
8952 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8953 if (intents != null) {
8954 for (int i = 0; i < intents.length; i++) {
8955 final Intent intent = (Intent) intents[i];
8956 if (intent != null) {
8957 migrated |= intent.migrateExtraStreamToClipData();
8958 }
8959 }
8960 }
8961 } catch (ClassCastException e) {
8962 }
8963 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008964
8965 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008966 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008967 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8968 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8969 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8970 if (stream != null || text != null || htmlText != null) {
8971 final ClipData clipData = new ClipData(
8972 null, new String[] { getType() },
8973 new ClipData.Item(text, htmlText, null, stream));
8974 setClipData(clipData);
8975 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008976 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008977 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008978 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008979 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008980
8981 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008982 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008983 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8984 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8985 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8986 int num = -1;
8987 if (streams != null) {
8988 num = streams.size();
8989 }
8990 if (texts != null) {
8991 if (num >= 0 && num != texts.size()) {
8992 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008993 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008994 }
8995 num = texts.size();
8996 }
8997 if (htmlTexts != null) {
8998 if (num >= 0 && num != htmlTexts.size()) {
8999 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009000 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009001 }
9002 num = htmlTexts.size();
9003 }
9004 if (num > 0) {
9005 final ClipData clipData = new ClipData(
9006 null, new String[] { getType() },
9007 makeClipItem(streams, texts, htmlTexts, 0));
9008
9009 for (int i = 1; i < num; i++) {
9010 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9011 }
9012
9013 setClipData(clipData);
9014 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009015 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009016 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009017 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009018 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009019 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9020 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9021 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9022 final Uri output;
9023 try {
9024 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9025 } catch (ClassCastException e) {
9026 return false;
9027 }
9028 if (output != null) {
9029 setClipData(ClipData.newRawUri("", output));
9030 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9031 return true;
9032 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009033 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009034
9035 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009036 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009037
9038 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9039 ArrayList<String> htmlTexts, int which) {
9040 Uri uri = streams != null ? streams.get(which) : null;
9041 CharSequence text = texts != null ? texts.get(which) : null;
9042 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9043 return new ClipData.Item(text, htmlText, null, uri);
9044 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009045
9046 /** @hide */
9047 public boolean isDocument() {
9048 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9049 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009050}