blob: c211788ef454265a080f22b8237ba365398ef8a6 [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;
Felipe Lemec7b1f892016-01-15 15:02:31 -080044import android.os.Environment;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070045import android.os.IBinder;
46import android.os.Parcel;
47import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000048import android.os.Process;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070049import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010050import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070051import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070052import android.provider.DocumentsProvider;
53import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070054import android.util.AttributeSet;
55import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080056
57import com.android.internal.util.XmlUtils;
Jose Lima73915cf2014-07-29 17:16:31 -070058
Craig Mautner21d24a22014-04-23 11:45:37 -070059import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070060
61import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080062import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070063import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070064import java.lang.annotation.Retention;
65import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066import java.net.URISyntaxException;
67import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080068import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070069import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080070import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070071import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072import java.util.Set;
73
74/**
75 * An intent is an abstract description of an operation to be performed. It
76 * can be used with {@link Context#startActivity(Intent) startActivity} to
77 * launch an {@link android.app.Activity},
78 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
79 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
80 * and {@link android.content.Context#startService} or
81 * {@link android.content.Context#bindService} to communicate with a
82 * background {@link android.app.Service}.
83 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070084 * <p>An Intent provides a facility for performing late runtime binding between the code in
85 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070086 * can be thought of as the glue between activities. It is basically a passive data structure
87 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070088 *
89 * <div class="special reference">
90 * <h3>Developer Guides</h3>
91 * <p>For information about how to create and resolve intents, read the
92 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
93 * developer guide.</p>
94 * </div>
95 *
96 * <a name="IntentStructure"></a>
97 * <h3>Intent Structure</h3>
98 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070099 *
100 * <ul>
101 * <li> <p><b>action</b> -- The general action to be performed, such as
102 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
103 * etc.</p>
104 * </li>
105 * <li> <p><b>data</b> -- The data to operate on, such as a person record
106 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
107 * </li>
108 * </ul>
109 *
110 *
111 * <p>Some examples of action/data pairs are:</p>
112 *
113 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700114 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700115 * information about the person whose identifier is "1".</p>
116 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700117 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700118 * the phone dialer with the person filled in.</p>
119 * </li>
120 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
121 * the phone dialer with the given number filled in. Note how the
122 * VIEW action does what what is considered the most reasonable thing for
123 * a particular URI.</p>
124 * </li>
125 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
126 * the phone dialer with the given number filled in.</p>
127 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700128 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700129 * information about the person whose identifier is "1".</p>
130 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700131 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700132 * a list of people, which the user can browse through. This example is a
133 * typical top-level entry into the Contacts application, showing you the
134 * list of people. Selecting a particular person to view would result in a
135 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
136 * being used to start an activity to display that person.</p>
137 * </li>
138 * </ul>
139 *
140 * <p>In addition to these primary attributes, there are a number of secondary
141 * attributes that you can also include with an intent:</p>
142 *
143 * <ul>
144 * <li> <p><b>category</b> -- Gives additional information about the action
145 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
146 * appear in the Launcher as a top-level application, while
147 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
148 * of alternative actions the user can perform on a piece of data.</p>
149 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
150 * intent data. Normally the type is inferred from the data itself.
151 * By setting this attribute, you disable that evaluation and force
152 * an explicit type.</p>
153 * <li> <p><b>component</b> -- Specifies an explicit name of a component
154 * class to use for the intent. Normally this is determined by looking
155 * at the other information in the intent (the action, data/type, and
156 * categories) and matching that with a component that can handle it.
157 * If this attribute is set then none of the evaluation is performed,
158 * and this component is used exactly as is. By specifying this attribute,
159 * all of the other Intent attributes become optional.</p>
160 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
161 * This can be used to provide extended information to the component.
162 * For example, if we have a action to send an e-mail message, we could
163 * also include extra pieces of data here to supply a subject, body,
164 * etc.</p>
165 * </ul>
166 *
167 * <p>Here are some examples of other operations you can specify as intents
168 * using these additional parameters:</p>
169 *
170 * <ul>
171 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
172 * Launch the home screen.</p>
173 * </li>
174 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
175 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
176 * vnd.android.cursor.item/phone}</i></b>
177 * -- Display the list of people's phone numbers, allowing the user to
178 * browse through them and pick one and return it to the parent activity.</p>
179 * </li>
180 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
181 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
182 * -- Display all pickers for data that can be opened with
183 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
184 * allowing the user to pick one of them and then some data inside of it
185 * and returning the resulting URI to the caller. This can be used,
186 * for example, in an e-mail application to allow the user to pick some
187 * data to include as an attachment.</p>
188 * </li>
189 * </ul>
190 *
191 * <p>There are a variety of standard Intent action and category constants
192 * defined in the Intent class, but applications can also define their own.
193 * These strings use java style scoping, to ensure they are unique -- for
194 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700195 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700196 *
197 * <p>Put together, the set of actions, data types, categories, and extra data
198 * defines a language for the system allowing for the expression of phrases
199 * such as "call john smith's cell". As applications are added to the system,
200 * they can extend this language by adding new actions, types, and categories, or
201 * they can modify the behavior of existing phrases by supplying their own
202 * activities that handle them.</p>
203 *
204 * <a name="IntentResolution"></a>
205 * <h3>Intent Resolution</h3>
206 *
207 * <p>There are two primary forms of intents you will use.
208 *
209 * <ul>
210 * <li> <p><b>Explicit Intents</b> have specified a component (via
211 * {@link #setComponent} or {@link #setClass}), which provides the exact
212 * class to be run. Often these will not include any other information,
213 * simply being a way for an application to launch various internal
214 * activities it has as the user interacts with the application.
215 *
216 * <li> <p><b>Implicit Intents</b> have not specified a component;
217 * instead, they must include enough information for the system to
218 * determine which of the available components is best to run for that
219 * intent.
220 * </ul>
221 *
222 * <p>When using implicit intents, given such an arbitrary intent we need to
223 * know what to do with it. This is handled by the process of <em>Intent
224 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
225 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
226 * more activities/receivers) that can handle it.</p>
227 *
228 * <p>The intent resolution mechanism basically revolves around matching an
229 * Intent against all of the &lt;intent-filter&gt; descriptions in the
230 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
231 * objects explicitly registered with {@link Context#registerReceiver}.) More
232 * details on this can be found in the documentation on the {@link
233 * IntentFilter} class.</p>
234 *
235 * <p>There are three pieces of information in the Intent that are used for
236 * resolution: the action, type, and category. Using this information, a query
237 * is done on the {@link PackageManager} for a component that can handle the
238 * intent. The appropriate component is determined based on the intent
239 * information supplied in the <code>AndroidManifest.xml</code> file as
240 * follows:</p>
241 *
242 * <ul>
243 * <li> <p>The <b>action</b>, if given, must be listed by the component as
244 * one it handles.</p>
245 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
246 * already supplied in the Intent. Like the action, if a type is
247 * included in the intent (either explicitly or implicitly in its
248 * data), then this must be listed by the component as one it handles.</p>
249 * <li> For data that is not a <code>content:</code> URI and where no explicit
250 * type is included in the Intent, instead the <b>scheme</b> of the
251 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
252 * considered. Again like the action, if we are matching a scheme it
253 * must be listed by the component as one it can handle.
254 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
255 * by the activity as categories it handles. That is, if you include
256 * the categories {@link #CATEGORY_LAUNCHER} and
257 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
258 * with an intent that lists <em>both</em> of those categories.
259 * Activities will very often need to support the
260 * {@link #CATEGORY_DEFAULT} so that they can be found by
261 * {@link Context#startActivity Context.startActivity()}.</p>
262 * </ul>
263 *
264 * <p>For example, consider the Note Pad sample application that
265 * allows user to browse through a list of notes data and view details about
266 * individual items. Text in italics indicate places were you would replace a
267 * name with one specific to your own package.</p>
268 *
269 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
270 * package="<i>com.android.notepad</i>"&gt;
271 * &lt;application android:icon="@drawable/app_notes"
272 * android:label="@string/app_name"&gt;
273 *
274 * &lt;provider class=".NotePadProvider"
275 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
276 *
277 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.MAIN" /&gt;
280 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700281 * &lt;/intent-filter&gt;
282 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700283 * &lt;action android:name="android.intent.action.VIEW" /&gt;
284 * &lt;action android:name="android.intent.action.EDIT" /&gt;
285 * &lt;action android:name="android.intent.action.PICK" /&gt;
286 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
287 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700288 * &lt;/intent-filter&gt;
289 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700290 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
291 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
292 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700293 * &lt;/intent-filter&gt;
294 * &lt;/activity&gt;
295 *
296 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
297 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700298 * &lt;action android:name="android.intent.action.VIEW" /&gt;
299 * &lt;action android:name="android.intent.action.EDIT" /&gt;
300 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
301 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700302 * &lt;/intent-filter&gt;
303 *
304 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700305 * &lt;action android:name="android.intent.action.INSERT" /&gt;
306 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
307 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700308 * &lt;/intent-filter&gt;
309 *
310 * &lt;/activity&gt;
311 *
312 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
313 * android:theme="@android:style/Theme.Dialog"&gt;
314 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700315 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
316 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
317 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
318 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
319 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700320 * &lt;/intent-filter&gt;
321 * &lt;/activity&gt;
322 *
323 * &lt;/application&gt;
324 * &lt;/manifest&gt;</pre>
325 *
326 * <p>The first activity,
327 * <code>com.android.notepad.NotesList</code>, serves as our main
328 * entry into the app. It can do three things as described by its three intent
329 * templates:
330 * <ol>
331 * <li><pre>
332 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700333 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
334 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700335 * &lt;/intent-filter&gt;</pre>
336 * <p>This provides a top-level entry into the NotePad application: the standard
337 * MAIN action is a main entry point (not requiring any other information in
338 * the Intent), and the LAUNCHER category says that this entry point should be
339 * listed in the application launcher.</p>
340 * <li><pre>
341 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700342 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
343 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
344 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
345 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
346 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700347 * &lt;/intent-filter&gt;</pre>
348 * <p>This declares the things that the activity can do on a directory of
349 * notes. The type being supported is given with the &lt;type&gt; tag, where
350 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
351 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
352 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
353 * The activity allows the user to view or edit the directory of data (via
354 * the VIEW and EDIT actions), or to pick a particular note and return it
355 * to the caller (via the PICK action). Note also the DEFAULT category
356 * supplied here: this is <em>required</em> for the
357 * {@link Context#startActivity Context.startActivity} method to resolve your
358 * activity when its component name is not explicitly specified.</p>
359 * <li><pre>
360 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700361 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
362 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
363 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700364 * &lt;/intent-filter&gt;</pre>
365 * <p>This filter describes the ability return to the caller a note selected by
366 * the user without needing to know where it came from. The data type
367 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
368 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
369 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
370 * The GET_CONTENT action is similar to the PICK action, where the activity
371 * will return to its caller a piece of data selected by the user. Here,
372 * however, the caller specifies the type of data they desire instead of
373 * the type of data the user will be picking from.</p>
374 * </ol>
375 *
376 * <p>Given these capabilities, the following intents will resolve to the
377 * NotesList activity:</p>
378 *
379 * <ul>
380 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
381 * activities that can be used as top-level entry points into an
382 * application.</p>
383 * <li> <p><b>{ action=android.app.action.MAIN,
384 * category=android.app.category.LAUNCHER }</b> is the actual intent
385 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700386 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700387 * data=content://com.google.provider.NotePad/notes }</b>
388 * displays a list of all the notes under
389 * "content://com.google.provider.NotePad/notes", which
390 * the user can browse through and see the details on.</p>
391 * <li> <p><b>{ action=android.app.action.PICK
392 * data=content://com.google.provider.NotePad/notes }</b>
393 * provides a list of the notes under
394 * "content://com.google.provider.NotePad/notes", from which
395 * the user can pick a note whose data URL is returned back to the caller.</p>
396 * <li> <p><b>{ action=android.app.action.GET_CONTENT
397 * type=vnd.android.cursor.item/vnd.google.note }</b>
398 * is similar to the pick action, but allows the caller to specify the
399 * kind of data they want back so that the system can find the appropriate
400 * activity to pick something of that data type.</p>
401 * </ul>
402 *
403 * <p>The second activity,
404 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
405 * note entry and allows them to edit it. It can do two things as described
406 * by its two intent templates:
407 * <ol>
408 * <li><pre>
409 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700410 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
411 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
412 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
413 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700414 * &lt;/intent-filter&gt;</pre>
415 * <p>The first, primary, purpose of this activity is to let the user interact
416 * with a single note, as decribed by the MIME type
417 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
418 * either VIEW a note or allow the user to EDIT it. Again we support the
419 * DEFAULT category to allow the activity to be launched without explicitly
420 * specifying its component.</p>
421 * <li><pre>
422 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700423 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
424 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
425 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700426 * &lt;/intent-filter&gt;</pre>
427 * <p>The secondary use of this activity is to insert a new note entry into
428 * an existing directory of notes. This is used when the user creates a new
429 * note: the INSERT action is executed on the directory of notes, causing
430 * this activity to run and have the user create the new note data which
431 * it then adds to the content provider.</p>
432 * </ol>
433 *
434 * <p>Given these capabilities, the following intents will resolve to the
435 * NoteEditor activity:</p>
436 *
437 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700438 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700439 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
440 * shows the user the content of note <var>{ID}</var>.</p>
441 * <li> <p><b>{ action=android.app.action.EDIT
442 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
443 * allows the user to edit the content of note <var>{ID}</var>.</p>
444 * <li> <p><b>{ action=android.app.action.INSERT
445 * data=content://com.google.provider.NotePad/notes }</b>
446 * creates a new, empty note in the notes list at
447 * "content://com.google.provider.NotePad/notes"
448 * and allows the user to edit it. If they keep their changes, the URI
449 * of the newly created note is returned to the caller.</p>
450 * </ul>
451 *
452 * <p>The last activity,
453 * <code>com.android.notepad.TitleEditor</code>, allows the user to
454 * edit the title of a note. This could be implemented as a class that the
455 * application directly invokes (by explicitly setting its component in
456 * the Intent), but here we show a way you can publish alternative
457 * operations on existing data:</p>
458 *
459 * <pre>
460 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700461 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
463 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
464 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
465 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700466 * &lt;/intent-filter&gt;</pre>
467 *
468 * <p>In the single intent template here, we
469 * have created our own private action called
470 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
471 * edit the title of a note. It must be invoked on a specific note
472 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
473 * view and edit actions, but here displays and edits the title contained
474 * in the note data.
475 *
476 * <p>In addition to supporting the default category as usual, our title editor
477 * also supports two other standard categories: ALTERNATIVE and
478 * SELECTED_ALTERNATIVE. Implementing
479 * these categories allows others to find the special action it provides
480 * without directly knowing about it, through the
481 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
482 * more often to build dynamic menu items with
483 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
484 * template here was also supply an explicit name for the template
485 * (via <code>android:label="@string/resolve_title"</code>) to better control
486 * what the user sees when presented with this activity as an alternative
487 * action to the data they are viewing.
488 *
489 * <p>Given these capabilities, the following intent will resolve to the
490 * TitleEditor activity:</p>
491 *
492 * <ul>
493 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
494 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
495 * displays and allows the user to edit the title associated
496 * with note <var>{ID}</var>.</p>
497 * </ul>
498 *
499 * <h3>Standard Activity Actions</h3>
500 *
501 * <p>These are the current standard actions that Intent defines for launching
502 * activities (usually through {@link Context#startActivity}. The most
503 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
504 * {@link #ACTION_EDIT}.
505 *
506 * <ul>
507 * <li> {@link #ACTION_MAIN}
508 * <li> {@link #ACTION_VIEW}
509 * <li> {@link #ACTION_ATTACH_DATA}
510 * <li> {@link #ACTION_EDIT}
511 * <li> {@link #ACTION_PICK}
512 * <li> {@link #ACTION_CHOOSER}
513 * <li> {@link #ACTION_GET_CONTENT}
514 * <li> {@link #ACTION_DIAL}
515 * <li> {@link #ACTION_CALL}
516 * <li> {@link #ACTION_SEND}
517 * <li> {@link #ACTION_SENDTO}
518 * <li> {@link #ACTION_ANSWER}
519 * <li> {@link #ACTION_INSERT}
520 * <li> {@link #ACTION_DELETE}
521 * <li> {@link #ACTION_RUN}
522 * <li> {@link #ACTION_SYNC}
523 * <li> {@link #ACTION_PICK_ACTIVITY}
524 * <li> {@link #ACTION_SEARCH}
525 * <li> {@link #ACTION_WEB_SEARCH}
526 * <li> {@link #ACTION_FACTORY_TEST}
527 * </ul>
528 *
529 * <h3>Standard Broadcast Actions</h3>
530 *
531 * <p>These are the current standard actions that Intent defines for receiving
532 * broadcasts (usually through {@link Context#registerReceiver} or a
533 * &lt;receiver&gt; tag in a manifest).
534 *
535 * <ul>
536 * <li> {@link #ACTION_TIME_TICK}
537 * <li> {@link #ACTION_TIME_CHANGED}
538 * <li> {@link #ACTION_TIMEZONE_CHANGED}
539 * <li> {@link #ACTION_BOOT_COMPLETED}
540 * <li> {@link #ACTION_PACKAGE_ADDED}
541 * <li> {@link #ACTION_PACKAGE_CHANGED}
542 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 * <li> {@link #ACTION_PACKAGE_RESTARTED}
544 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000545 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
546 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700547 * <li> {@link #ACTION_UID_REMOVED}
548 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700549 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700550 * <li> {@link #ACTION_POWER_DISCONNECTED}
551 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700552 * </ul>
553 *
554 * <h3>Standard Categories</h3>
555 *
556 * <p>These are the current standard categories that can be used to further
557 * clarify an Intent via {@link #addCategory}.
558 *
559 * <ul>
560 * <li> {@link #CATEGORY_DEFAULT}
561 * <li> {@link #CATEGORY_BROWSABLE}
562 * <li> {@link #CATEGORY_TAB}
563 * <li> {@link #CATEGORY_ALTERNATIVE}
564 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
565 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800566 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * <li> {@link #CATEGORY_HOME}
568 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700569 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400570 * <li> {@link #CATEGORY_CAR_DOCK}
571 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500572 * <li> {@link #CATEGORY_LE_DESK_DOCK}
573 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200574 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700575 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700576 * </ul>
577 *
578 * <h3>Standard Extra Data</h3>
579 *
580 * <p>These are the current standard fields that can be used as extra data via
581 * {@link #putExtra}.
582 *
583 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800584 * <li> {@link #EXTRA_ALARM_COUNT}
585 * <li> {@link #EXTRA_BCC}
586 * <li> {@link #EXTRA_CC}
587 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
588 * <li> {@link #EXTRA_DATA_REMOVED}
589 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500590 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
591 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800592 * <li> {@link #EXTRA_DOCK_STATE_CAR}
593 * <li> {@link #EXTRA_DOCK_STATE_DESK}
594 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
595 * <li> {@link #EXTRA_DONT_KILL_APP}
596 * <li> {@link #EXTRA_EMAIL}
597 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700598 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700600 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800601 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700602 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
604 * <li> {@link #EXTRA_REPLACING}
605 * <li> {@link #EXTRA_SHORTCUT_ICON}
606 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
607 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_SHORTCUT_NAME}
610 * <li> {@link #EXTRA_SUBJECT}
611 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800613 * <li> {@link #EXTRA_TITLE}
614 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 * </ul>
616 *
617 * <h3>Flags</h3>
618 *
619 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800620 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
621 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700622 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800623public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700624 private static final String ATTR_ACTION = "action";
625 private static final String TAG_CATEGORIES = "categories";
626 private static final String ATTR_CATEGORY = "category";
627 private static final String TAG_EXTRA = "extra";
628 private static final String ATTR_TYPE = "type";
629 private static final String ATTR_COMPONENT = "component";
630 private static final String ATTR_DATA = "data";
631 private static final String ATTR_FLAGS = "flags";
632
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700633 // ---------------------------------------------------------------------
634 // ---------------------------------------------------------------------
635 // Standard intent activity actions (see action variable).
636
637 /**
638 * Activity Action: Start as a main entry point, does not expect to
639 * receive data.
640 * <p>Input: nothing
641 * <p>Output: nothing
642 */
643 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
644 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700646 /**
647 * Activity Action: Display the data to the user. This is the most common
648 * action performed on data -- it is the generic action you can use on
649 * a piece of data to get the most reasonable thing to occur. For example,
650 * when used on a contacts entry it will view the entry; when used on a
651 * mailto: URI it will bring up a compose window filled with the information
652 * supplied by the URI; when used with a tel: URI it will invoke the
653 * dialer.
654 * <p>Input: {@link #getData} is URI from which to retrieve data.
655 * <p>Output: nothing.
656 */
657 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
658 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 /**
661 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
662 * performed on a piece of data.
663 */
664 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800665
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700666 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900667 * Activity Action: Quick view the data. Launches a quick viewer for
668 * a URI or a list of URIs.
669 * <p>Input: {@link #getData} is a mandatory content URI of the item to
670 * preview. {@link #getClipData} contains an optional list of content URIs
671 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
672 * optional index of the URI in the clip data to show first.
Steve McKayc78bcb82015-07-31 14:35:22 -0700673 * <p>Output: nothing.
Steve McKayc78bcb82015-07-31 14:35:22 -0700674 */
675 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
676 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
677
678 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700679 * Used to indicate that some piece of data should be attached to some other
680 * place. For example, image data could be attached to a contact. It is up
681 * to the recipient to decide where the data should be attached; the intent
682 * does not specify the ultimate destination.
683 * <p>Input: {@link #getData} is URI of data to be attached.
684 * <p>Output: nothing.
685 */
686 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
687 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800688
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700689 /**
690 * Activity Action: Provide explicit editable access to the given data.
691 * <p>Input: {@link #getData} is URI of data to be edited.
692 * <p>Output: nothing.
693 */
694 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
695 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800696
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700697 /**
698 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
699 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
700 * The extras can contain type specific data to pass through to the editing/creating
701 * activity.
702 * <p>Output: The URI of the item that was picked. This must be a content:
703 * URI so that any receiver can access it.
704 */
705 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
706 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800707
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700708 /**
709 * Activity Action: Pick an item from the data, returning what was selected.
710 * <p>Input: {@link #getData} is URI containing a directory of data
711 * (vnd.android.cursor.dir/*) from which to pick an item.
712 * <p>Output: The URI of the item that was picked.
713 */
714 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
715 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800716
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700717 /**
718 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800719 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700720 * <p>Output: An Intent representing the shortcut. The intent must contain three
721 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
722 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800723 * (value: ShortcutIconResource).</p>
724 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 * @see #EXTRA_SHORTCUT_INTENT
726 * @see #EXTRA_SHORTCUT_NAME
727 * @see #EXTRA_SHORTCUT_ICON
728 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
729 * @see android.content.Intent.ShortcutIconResource
730 */
731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
732 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
733
734 /**
735 * The name of the extra used to define the Intent of a shortcut.
736 *
737 * @see #ACTION_CREATE_SHORTCUT
738 */
739 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
740 /**
741 * The name of the extra used to define the name of a shortcut.
742 *
743 * @see #ACTION_CREATE_SHORTCUT
744 */
745 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
746 /**
747 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
748 *
749 * @see #ACTION_CREATE_SHORTCUT
750 */
751 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
752 /**
753 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
754 *
755 * @see #ACTION_CREATE_SHORTCUT
756 * @see android.content.Intent.ShortcutIconResource
757 */
758 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
759 "android.intent.extra.shortcut.ICON_RESOURCE";
760
761 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800762 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700763 *
764 * @see Intent#ACTION_CREATE_SHORTCUT
765 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800766 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
767 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 */
769 public static class ShortcutIconResource implements Parcelable {
770 /**
771 * The package name of the application containing the icon.
772 */
773 public String packageName;
774
775 /**
776 * The resource name of the icon, including package, name and type.
777 */
778 public String resourceName;
779
780 /**
781 * Creates a new ShortcutIconResource for the specified context and resource
782 * identifier.
783 *
784 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700785 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700786 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700787 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700788 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700789 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700790 ShortcutIconResource icon = new ShortcutIconResource();
791 icon.packageName = context.getPackageName();
792 icon.resourceName = context.getResources().getResourceName(resourceId);
793 return icon;
794 }
795
796 /**
797 * Used to read a ShortcutIconResource from a Parcel.
798 */
799 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
800 new Parcelable.Creator<ShortcutIconResource>() {
801
802 public ShortcutIconResource createFromParcel(Parcel source) {
803 ShortcutIconResource icon = new ShortcutIconResource();
804 icon.packageName = source.readString();
805 icon.resourceName = source.readString();
806 return icon;
807 }
808
809 public ShortcutIconResource[] newArray(int size) {
810 return new ShortcutIconResource[size];
811 }
812 };
813
814 /**
815 * No special parcel contents.
816 */
817 public int describeContents() {
818 return 0;
819 }
820
821 public void writeToParcel(Parcel dest, int flags) {
822 dest.writeString(packageName);
823 dest.writeString(resourceName);
824 }
825
826 @Override
827 public String toString() {
828 return resourceName;
829 }
830 }
831
832 /**
833 * Activity Action: Display an activity chooser, allowing the user to pick
834 * what they want to before proceeding. This can be used as an alternative
835 * to the standard activity picker that is displayed by the system when
836 * you try to start an activity with multiple possible matches, with these
837 * differences in behavior:
838 * <ul>
839 * <li>You can specify the title that will appear in the activity chooser.
840 * <li>The user does not have the option to make one of the matching
841 * activities a preferred activity, and all possible activities will
842 * always be shown even if one of them is currently marked as the
843 * preferred activity.
844 * </ul>
845 * <p>
846 * This action should be used when the user will naturally expect to
847 * select an activity in order to proceed. An example if when not to use
848 * it is when the user clicks on a "mailto:" link. They would naturally
849 * expect to go directly to their mail app, so startActivity() should be
850 * called directly: it will
851 * either launch the current preferred app, or put up a dialog allowing the
852 * user to pick an app to use and optionally marking that as preferred.
853 * <p>
854 * In contrast, if the user is selecting a menu item to send a picture
855 * they are viewing to someone else, there are many different things they
856 * may want to do at this point: send it through e-mail, upload it to a
857 * web service, etc. In this case the CHOOSER action should be used, to
858 * always present to the user a list of the things they can do, with a
859 * nice title given by the caller such as "Send this photo with:".
860 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700861 * If you need to grant URI permissions through a chooser, you must specify
862 * the permissions to be granted on the ACTION_CHOOSER Intent
863 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
864 * {@link #setClipData} to specify the URIs to be granted as well as
865 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
866 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
867 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700868 * As a convenience, an Intent of this form can be created with the
869 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700870 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700871 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700872 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
873 * and can optionally have a {@link #EXTRA_TITLE} field containing the
874 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700875 * <p>
876 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700877 */
878 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
879 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
880
881 /**
882 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
883 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700884 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
885 * target intent, also optionally supplying a title. If the target
886 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
887 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
888 * set in the returned chooser intent, with its ClipData set appropriately:
889 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500890 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700891 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700892 * @param target The Intent that the user will be selecting an activity
893 * to perform.
894 * @param title Optional title that will be displayed in the chooser.
895 * @return Return a new Intent object that you can hand to
896 * {@link Context#startActivity(Intent) Context.startActivity()} and
897 * related methods.
898 */
899 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700900 return createChooser(target, title, null);
901 }
902
903 /**
904 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
905 *
906 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
907 * target intent, also optionally supplying a title. If the target
908 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
909 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
910 * set in the returned chooser intent, with its ClipData set appropriately:
911 * either a direct reflection of {@link #getClipData()} if that is non-null,
912 * or a new ClipData built from {@link #getData()}.</p>
913 *
914 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
915 * when the user makes a choice. This can be useful if the calling application wants
916 * to remember the last chosen target and surface it as a more prominent or one-touch
917 * affordance elsewhere in the UI for next time.</p>
918 *
919 * @param target The Intent that the user will be selecting an activity
920 * to perform.
921 * @param title Optional title that will be displayed in the chooser.
922 * @param sender Optional IntentSender to be called when a choice is made.
923 * @return Return a new Intent object that you can hand to
924 * {@link Context#startActivity(Intent) Context.startActivity()} and
925 * related methods.
926 */
927 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700928 Intent intent = new Intent(ACTION_CHOOSER);
929 intent.putExtra(EXTRA_INTENT, target);
930 if (title != null) {
931 intent.putExtra(EXTRA_TITLE, title);
932 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700933
Adam Powell0b3c1122014-10-09 12:50:14 -0700934 if (sender != null) {
935 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
936 }
937
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700938 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700939 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
940 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
941 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700942 if (permFlags != 0) {
943 ClipData targetClipData = target.getClipData();
944 if (targetClipData == null && target.getData() != null) {
945 ClipData.Item item = new ClipData.Item(target.getData());
946 String[] mimeTypes;
947 if (target.getType() != null) {
948 mimeTypes = new String[] { target.getType() };
949 } else {
950 mimeTypes = new String[] { };
951 }
952 targetClipData = new ClipData(null, mimeTypes, item);
953 }
954 if (targetClipData != null) {
955 intent.setClipData(targetClipData);
956 intent.addFlags(permFlags);
957 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700958 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700959
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700960 return intent;
961 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700962
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700963 /**
964 * Activity Action: Allow the user to select a particular kind of data and
965 * return it. This is different than {@link #ACTION_PICK} in that here we
966 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800967 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700968 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900969 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700970 * etc.
971 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900972 * 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 -0700973 * of data, such as a person contact, you set the MIME type to the kind of
974 * data you want and launch it with {@link Context#startActivity(Intent)}.
975 * The system will then launch the best application to select that kind
976 * of data for you.
977 * <p>
978 * You may also be interested in any of a set of types of content the user
979 * can pick. For example, an e-mail application that wants to allow the
980 * user to add an attachment to an e-mail message can use this action to
981 * bring up a list of all of the types of content the user can attach.
982 * <p>
983 * In this case, you should wrap the GET_CONTENT intent with a chooser
984 * (through {@link #createChooser}), which will give the proper interface
985 * for the user to pick how to send your data and allow you to specify
986 * a prompt indicating what they are doing. You will usually specify a
987 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
988 * broad range of content types the user can select from.
989 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900990 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700991 * only pick from data that can be represented as a stream. This is
992 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
993 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800994 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900995 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800996 * is locally available on the device. For example, if this extra is set
997 * to true then an image picker should not show any pictures that are available
998 * from a remote server but not already on the local device (thus requiring
999 * they be downloaded when opened).
1000 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001001 * If the caller can handle multiple returned items (the user performing
1002 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1003 * to indicate this.
1004 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001005 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1006 * that no URI is supplied in the intent, as there are no constraints on
1007 * where the returned data originally comes from. You may also include the
1008 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001009 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001010 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1011 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001012 * <p>
1013 * Output: The URI of the item that was picked. This must be a content:
1014 * URI so that any receiver can access it.
1015 */
1016 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1017 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1018 /**
1019 * Activity Action: Dial a number as specified by the data. This shows a
1020 * UI with the number being dialed, allowing the user to explicitly
1021 * initiate the call.
1022 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1023 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1024 * number.
1025 * <p>Output: nothing.
1026 */
1027 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1028 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1029 /**
1030 * Activity Action: Perform a call to someone specified by the data.
1031 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1032 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1033 * number.
1034 * <p>Output: nothing.
1035 *
1036 * <p>Note: there will be restrictions on which applications can initiate a
1037 * call; most applications should use the {@link #ACTION_DIAL}.
1038 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1039 * numbers. Applications can <strong>dial</strong> emergency numbers using
1040 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001041 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001042 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001043 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001044 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001045 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001046 */
1047 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1048 public static final String ACTION_CALL = "android.intent.action.CALL";
1049 /**
1050 * Activity Action: Perform a call to an emergency number specified by the
1051 * data.
1052 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1053 * tel: URI of an explicit phone number.
1054 * <p>Output: nothing.
1055 * @hide
1056 */
1057 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1058 /**
1059 * Activity action: Perform a call to any number (emergency or not)
1060 * specified by the data.
1061 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1062 * tel: URI of an explicit phone number.
1063 * <p>Output: nothing.
1064 * @hide
1065 */
1066 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1067 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001068 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1069 * sending this intent is a no-op.
1070 * <p>Input: No data should be specified. get*Extra may have an optional
1071 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1072 * send the activation result.
1073 * <p>Output: nothing.
1074 * @hide
1075 */
1076 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1077 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1078 "android.intent.action.SIM_ACTIVATION_REQUEST";
1079 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001080 * Activity Action: Send a message to someone specified by the data.
1081 * <p>Input: {@link #getData} is URI describing the target.
1082 * <p>Output: nothing.
1083 */
1084 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1085 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1086 /**
1087 * Activity Action: Deliver some data to someone else. Who the data is
1088 * being delivered to is not specified; it is up to the receiver of this
1089 * action to ask the user where the data should be sent.
1090 * <p>
1091 * When launching a SEND intent, you should usually wrap it in a chooser
1092 * (through {@link #createChooser}), which will give the proper interface
1093 * for the user to pick how to send your data and allow you to specify
1094 * a prompt indicating what they are doing.
1095 * <p>
1096 * Input: {@link #getType} is the MIME type of the data being sent.
1097 * get*Extra can have either a {@link #EXTRA_TEXT}
1098 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1099 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1100 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1101 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001102 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1103 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1104 * your text with HTML formatting.
1105 * <p>
1106 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1107 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1108 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1109 * content: URIs and other advanced features of {@link ClipData}. If
1110 * using this approach, you still must supply the same data through the
1111 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1112 * for compatibility with old applications. If you don't set a ClipData,
1113 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001114 * <p>
1115 * Optional standard extras, which may be interpreted by some recipients as
1116 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1117 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1118 * <p>
1119 * Output: nothing.
1120 */
1121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1122 public static final String ACTION_SEND = "android.intent.action.SEND";
1123 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001124 * Activity Action: Deliver multiple data to someone else.
1125 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001126 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001127 * <p>
1128 * Input: {@link #getType} is the MIME type of the data being sent.
1129 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001130 * #EXTRA_STREAM} field, containing the data to be sent. If using
1131 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1132 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001133 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001134 * Multiple types are supported, and receivers should handle mixed types
1135 * whenever possible. The right way for the receiver to check them is to
1136 * use the content resolver on each URI. The intent sender should try to
1137 * put the most concrete mime type in the intent type, but it can fall
1138 * back to {@literal <type>/*} or {@literal *}/* as needed.
1139 * <p>
1140 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1141 * be image/jpg, but if you are sending image/jpg and image/png, then the
1142 * intent's type should be image/*.
1143 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001144 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1145 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1146 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1147 * content: URIs and other advanced features of {@link ClipData}. If
1148 * using this approach, you still must supply the same data through the
1149 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1150 * for compatibility with old applications. If you don't set a ClipData,
1151 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1152 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001153 * Optional standard extras, which may be interpreted by some recipients as
1154 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1155 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1156 * <p>
1157 * Output: nothing.
1158 */
1159 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1160 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1161 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001162 * Activity Action: Handle an incoming phone call.
1163 * <p>Input: nothing.
1164 * <p>Output: nothing.
1165 */
1166 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1167 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1168 /**
1169 * Activity Action: Insert an empty item into the given container.
1170 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1171 * in which to place the data.
1172 * <p>Output: URI of the new data that was created.
1173 */
1174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1175 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1176 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001177 * Activity Action: Create a new item in the given container, initializing it
1178 * from the current contents of the clipboard.
1179 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1180 * in which to place the data.
1181 * <p>Output: URI of the new data that was created.
1182 */
1183 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1184 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1185 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001186 * Activity Action: Delete the given data from its container.
1187 * <p>Input: {@link #getData} is URI of data to be deleted.
1188 * <p>Output: nothing.
1189 */
1190 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1191 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1192 /**
1193 * Activity Action: Run the data, whatever that means.
1194 * <p>Input: ? (Note: this is currently specific to the test harness.)
1195 * <p>Output: nothing.
1196 */
1197 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1198 public static final String ACTION_RUN = "android.intent.action.RUN";
1199 /**
1200 * Activity Action: Perform a data synchronization.
1201 * <p>Input: ?
1202 * <p>Output: ?
1203 */
1204 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1205 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1206 /**
1207 * Activity Action: Pick an activity given an intent, returning the class
1208 * selected.
1209 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1210 * used with {@link PackageManager#queryIntentActivities} to determine the
1211 * set of activities from which to pick.
1212 * <p>Output: Class name of the activity that was selected.
1213 */
1214 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1215 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1216 /**
1217 * Activity Action: Perform a search.
1218 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1219 * is the text to search for. If empty, simply
1220 * enter your search results Activity with the search UI activated.
1221 * <p>Output: nothing.
1222 */
1223 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1224 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1225 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001226 * Activity Action: Start the platform-defined tutorial
1227 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1228 * is the text to search for. If empty, simply
1229 * enter your search results Activity with the search UI activated.
1230 * <p>Output: nothing.
1231 */
1232 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1233 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1234 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001235 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001236 * <p>
1237 * Input: {@link android.app.SearchManager#QUERY
1238 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1239 * a url starts with http or https, the site will be opened. If it is plain
1240 * text, Google search will be applied.
1241 * <p>
1242 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001243 */
1244 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1245 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001246
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001247 /**
Jim Miller07994402012-05-02 14:22:27 -07001248 * Activity Action: Perform assist action.
1249 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001250 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1251 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001252 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1253 * information.
Jim Miller07994402012-05-02 14:22:27 -07001254 * Output: nothing.
1255 */
1256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001258
1259 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001260 * Activity Action: Perform voice assist action.
1261 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001262 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1263 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001264 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001265 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001266 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001267 */
1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1269 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1270
1271 /**
Adam Skory7140a252013-09-11 12:04:58 +01001272 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1273 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001274 */
1275 public static final String EXTRA_ASSIST_PACKAGE
1276 = "android.intent.extra.ASSIST_PACKAGE";
1277
1278 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001279 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1280 * application package at the time the assist was invoked.
1281 */
1282 public static final String EXTRA_ASSIST_UID
1283 = "android.intent.extra.ASSIST_UID";
1284
1285 /**
Adam Skory7140a252013-09-11 12:04:58 +01001286 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1287 * information supplied by the current foreground app at the time of the assist request.
1288 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001289 */
1290 public static final String EXTRA_ASSIST_CONTEXT
1291 = "android.intent.extra.ASSIST_CONTEXT";
1292
Jim Miller07994402012-05-02 14:22:27 -07001293 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001294 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1295 * keyboard as the primary input device for assistance.
1296 */
1297 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1298 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1299
1300 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001301 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1302 * that was used to invoke the assist.
1303 */
1304 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1305 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1306
1307 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001308 * Activity Action: List all available applications
1309 * <p>Input: Nothing.
1310 * <p>Output: nothing.
1311 */
1312 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1313 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1314 /**
1315 * Activity Action: Show settings for choosing wallpaper
1316 * <p>Input: Nothing.
1317 * <p>Output: Nothing.
1318 */
1319 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1320 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1321
1322 /**
1323 * Activity Action: Show activity for reporting a bug.
1324 * <p>Input: Nothing.
1325 * <p>Output: Nothing.
1326 */
1327 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1328 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1329
1330 /**
1331 * Activity Action: Main entry point for factory tests. Only used when
1332 * the device is booting in factory test node. The implementing package
1333 * must be installed in the system image.
1334 * <p>Input: nothing
1335 * <p>Output: nothing
1336 */
1337 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1338
1339 /**
1340 * Activity Action: The user pressed the "call" button to go to the dialer
1341 * or other appropriate UI for placing a call.
1342 * <p>Input: Nothing.
1343 * <p>Output: Nothing.
1344 */
1345 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1346 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1347
1348 /**
1349 * Activity Action: Start Voice Command.
1350 * <p>Input: Nothing.
1351 * <p>Output: Nothing.
1352 */
1353 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1354 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001355
1356 /**
1357 * Activity Action: Start action associated with long pressing on the
1358 * search key.
1359 * <p>Input: Nothing.
1360 * <p>Output: Nothing.
1361 */
1362 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1363 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001364
Jacek Surazski86b6c532009-05-13 14:38:28 +02001365 /**
1366 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1367 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001368 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001369 * <p>Input: No data is specified. The bug report is passed in using
1370 * an {@link #EXTRA_BUG_REPORT} field.
1371 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001372 *
1373 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001374 */
1375 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1376 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001377
1378 /**
1379 * Activity Action: Show power usage information to the user.
1380 * <p>Input: Nothing.
1381 * <p>Output: Nothing.
1382 */
1383 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1384 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001385
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001386 /**
1387 * Activity Action: Setup wizard to launch after a platform update. This
1388 * activity should have a string meta-data field associated with it,
1389 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1390 * the platform for setup. The activity will be launched only if
1391 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1392 * same value.
1393 * <p>Input: Nothing.
1394 * <p>Output: Nothing.
1395 * @hide
1396 */
1397 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1398 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001399
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001400 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001401 * Activity Action: Show settings for managing network data usage of a
1402 * specific application. Applications should define an activity that offers
1403 * options to control data usage.
1404 */
1405 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1406 public static final String ACTION_MANAGE_NETWORK_USAGE =
1407 "android.intent.action.MANAGE_NETWORK_USAGE";
1408
1409 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001410 * Activity Action: Launch application installer.
1411 * <p>
1412 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001413 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1414 * you can also use "package:<package-name>" to install an application for the
1415 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001416 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1417 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1418 * <p>
1419 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1420 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001421 * <p>
1422 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1423 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1424 * in order to launch the application installer.
1425 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001426 *
1427 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1428 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1429 * @see #EXTRA_RETURN_RESULT
1430 */
1431 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1432 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1433
1434 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001435 * Activity Action: Launch ephemeral installer.
1436 * <p>
1437 * Input: The data must be a http: URI that the ephemeral application is registered
1438 * to handle.
1439 * <p class="note">
1440 * This is a protected intent that can only be sent by the system.
1441 * </p>
1442 *
1443 * @hide
1444 */
1445 @SystemApi
1446 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1447 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1448 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1449
1450 /**
1451 * Service Action: Resolve ephemeral application.
1452 * <p>
1453 * The system will have a persistent connection to this service.
1454 * This is a protected intent that can only be sent by the system.
1455 * </p>
1456 *
1457 * @hide
1458 */
1459 @SystemApi
1460 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1461 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1462 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1463
1464 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001465 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1466 * package. Specifies the installer package name; this package will receive the
1467 * {@link #ACTION_APP_ERROR} intent.
1468 */
1469 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1470 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1471
1472 /**
1473 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1474 * package. Specifies that the application being installed should not be
1475 * treated as coming from an unknown source, but as coming from the app
1476 * invoking the Intent. For this to work you must start the installer with
1477 * startActivityForResult().
1478 */
1479 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1480 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1481
1482 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001483 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1484 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001485 * data field originated from.
1486 */
rich cannings706e8ba2012-08-20 13:20:14 -07001487 public static final String EXTRA_ORIGINATING_URI
1488 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001489
1490 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001491 * This extra can be used with any Intent used to launch an activity, supplying information
1492 * about who is launching that activity. This field contains a {@link android.net.Uri}
1493 * object, typically an http: or https: URI of the web site that the referral came from;
1494 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1495 * a native application that it came from.
1496 *
1497 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1498 * instead of directly retrieving the extra. It is also valid for applications to
1499 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1500 * a string, not a Uri; the field here, if supplied, will always take precedence,
1501 * however.</p>
1502 *
1503 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001504 */
1505 public static final String EXTRA_REFERRER
1506 = "android.intent.extra.REFERRER";
1507
1508 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001509 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1510 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1511 * not be created, in particular when Intent extras are supplied through the
1512 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1513 * schemes.
1514 *
1515 * @see #EXTRA_REFERRER
1516 */
1517 public static final String EXTRA_REFERRER_NAME
1518 = "android.intent.extra.REFERRER_NAME";
1519
1520 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001521 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1522 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1523 * @hide
1524 */
1525 public static final String EXTRA_ORIGINATING_UID
1526 = "android.intent.extra.ORIGINATING_UID";
1527
1528 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001529 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1530 * package. Tells the installer UI to skip the confirmation with the user
1531 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001532 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1533 * will no longer show an interstitial message about updating existing
1534 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001535 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001536 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001537 public static final String EXTRA_ALLOW_REPLACE
1538 = "android.intent.extra.ALLOW_REPLACE";
1539
1540 /**
1541 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1542 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1543 * return to the application the result code of the install/uninstall. The returned result
1544 * code will be {@link android.app.Activity#RESULT_OK} on success or
1545 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1546 */
1547 public static final String EXTRA_RETURN_RESULT
1548 = "android.intent.extra.RETURN_RESULT";
1549
1550 /**
1551 * Package manager install result code. @hide because result codes are not
1552 * yet ready to be exposed.
1553 */
1554 public static final String EXTRA_INSTALL_RESULT
1555 = "android.intent.extra.INSTALL_RESULT";
1556
1557 /**
1558 * Activity Action: Launch application uninstaller.
1559 * <p>
1560 * Input: The data must be a package: URI whose scheme specific part is
1561 * the package name of the current installed package to be uninstalled.
1562 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1563 * <p>
1564 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1565 * succeeded.
1566 */
1567 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1568 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1569
1570 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001571 * Specify whether the package should be uninstalled for all users.
1572 * @hide because these should not be part of normal application flow.
1573 */
1574 public static final String EXTRA_UNINSTALL_ALL_USERS
1575 = "android.intent.extra.UNINSTALL_ALL_USERS";
1576
1577 /**
Suprabh Shukla74a2fe42016-01-27 12:57:24 -08001578 * Specified when the uninstall confirmation dialog is not required to be shown.
1579 * Use with {@link #ACTION_UNINSTALL_PACKAGE}
1580 * @hide
1581 */
1582 public static final String EXTRA_SKIP_UNINSTALL_CONFIRMATION =
1583 "android.intent.extra.SKIP_UNINSTALL_CONFIRMATION";
1584
1585 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001586 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1587 * describing the last run version of the platform that was setup.
1588 * @hide
1589 */
1590 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1591
Svet Ganov3695b8a2015-03-24 16:30:25 -07001592 /**
1593 * Activity action: Launch UI to manage the permissions of an app.
1594 * <p>
1595 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1596 * will be managed by the launched UI.
1597 * </p>
1598 * <p>
1599 * Output: Nothing.
1600 * </p>
1601 *
1602 * @see #EXTRA_PACKAGE_NAME
1603 *
1604 * @hide
1605 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001606 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1607 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1608 "android.intent.action.MANAGE_APP_PERMISSIONS";
1609
1610 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001611 * Activity action: Launch UI to manage permissions.
1612 * <p>
1613 * Input: Nothing.
1614 * </p>
1615 * <p>
1616 * Output: Nothing.
1617 * </p>
1618 *
1619 * @hide
1620 */
Svet Ganov321f0152015-05-16 22:51:50 -07001621 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1622 public static final String ACTION_MANAGE_PERMISSIONS =
1623 "android.intent.action.MANAGE_PERMISSIONS";
1624
1625 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001626 * Activity action: Launch UI to review permissions for an app.
1627 * The system uses this intent if permission review for apps not
1628 * supporting the new runtime permissions model is enabled. In
1629 * this mode a permission review is required before any of the
1630 * app components can run.
1631 * <p>
1632 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1633 * permissions will be reviewed (mandatory).
1634 * </p>
1635 * <p>
1636 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1637 * be fired after the permission review (optional).
1638 * </p>
1639 * <p>
1640 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1641 * be invoked after the permission review (optional).
1642 * </p>
1643 * <p>
1644 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1645 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1646 * </p>
1647 * <p>
1648 * Output: Nothing.
1649 * </p>
1650 *
1651 * @see #EXTRA_PACKAGE_NAME
1652 * @see #EXTRA_INTENT
1653 * @see #EXTRA_REMOTE_CALLBACK
1654 * @see #EXTRA_RESULT_NEEDED
1655 *
1656 * @hide
1657 */
1658 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1659 public static final String ACTION_REVIEW_PERMISSIONS =
1660 "android.intent.action.REVIEW_PERMISSIONS";
1661
1662 /**
1663 * Intent extra: A callback for reporting remote result as a bundle.
1664 * <p>
1665 * Type: IRemoteCallback
1666 * </p>
1667 *
1668 * @hide
1669 */
1670 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1671
1672 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001673 * Intent extra: An app package name.
1674 * <p>
1675 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001676 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001677 *
1678 * @hide
1679 */
1680 @SystemApi
1681 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1682
1683 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001684 * Intent extra: An extra for specifying whether a result is needed.
1685 * <p>
1686 * Type: boolean
1687 * </p>
1688 *
1689 * @hide
1690 */
1691 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1692
1693 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001694 * Broadcast action that requests current permission granted information. It will respond
1695 * to the request by sending a broadcast with action defined by
1696 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001697 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1698 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1699 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001700 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001701 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1702 * number of permissions requested and the number of granted additional permissions
1703 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001704 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001705 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1706 * of localized permission group names that are granted in
1707 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001708 *
1709 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1710 * permissions and the total number of apps requesting runtime permissions will be the first
1711 * and second elements respectively of an int[] in the response as
1712 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1713 *
1714 * @hide
1715 */
1716 public static final String ACTION_GET_PERMISSIONS_COUNT
1717 = "android.intent.action.GET_PERMISSIONS_COUNT";
1718
1719 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001720 * Broadcast action that requests list of all apps that have runtime permissions. It will
1721 * respond to the request by sending a broadcast with action defined by
1722 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1723 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1724 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1725 * a null upon failure.
1726 *
1727 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1728 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1729 * will contain the list of app labels corresponding ot the apps in the first list.
1730 *
1731 * @hide
1732 */
1733 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1734 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1735
1736 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001737 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1738 * @hide
1739 */
1740 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1741 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1742
1743 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001744 * List of CharSequence of localized permission group labels.
1745 * @hide
1746 */
1747 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1748 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1749
1750 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001751 * String list of apps that have one or more runtime permissions.
1752 * @hide
1753 */
1754 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1755 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1756
1757 /**
1758 * String list of app labels for apps that have one or more runtime permissions.
1759 * @hide
1760 */
1761 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1762 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1763
1764 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001765 * Boolean list describing if the app is a system app for apps that have one or more runtime
1766 * permissions.
1767 * @hide
1768 */
1769 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1770 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1771
1772 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001773 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001774 * @hide
1775 */
1776 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1777 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1778
1779 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001780 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1781 * @hide
1782 */
1783 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1784 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1785
1786 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001787 * Activity action: Launch UI to manage which apps have a given permission.
1788 * <p>
1789 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1790 * to which will be managed by the launched UI.
1791 * </p>
1792 * <p>
1793 * Output: Nothing.
1794 * </p>
1795 *
1796 * @see #EXTRA_PERMISSION_NAME
1797 *
1798 * @hide
1799 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001800 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1801 public static final String ACTION_MANAGE_PERMISSION_APPS =
1802 "android.intent.action.MANAGE_PERMISSION_APPS";
1803
1804 /**
1805 * Intent extra: The name of a permission.
1806 * <p>
1807 * Type: String
1808 * </p>
1809 *
1810 * @hide
1811 */
1812 @SystemApi
1813 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1814
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001815 // ---------------------------------------------------------------------
1816 // ---------------------------------------------------------------------
1817 // Standard intent broadcast actions (see action variable).
1818
1819 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001820 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1821 * <p>
1822 * For historical reasons, the name of this broadcast action refers to the power
1823 * state of the screen but it is actually sent in response to changes in the
1824 * overall interactive state of the device.
1825 * </p><p>
1826 * This broadcast is sent when the device becomes non-interactive which may have
1827 * nothing to do with the screen turning off. To determine the
1828 * actual state of the screen, use {@link android.view.Display#getState}.
1829 * </p><p>
1830 * See {@link android.os.PowerManager#isInteractive} for details.
1831 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001832 * You <em>cannot</em> receive this through components declared in
1833 * manifests, only by explicitly registering for it with
1834 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1835 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001836 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001837 * <p class="note">This is a protected intent that can only be sent
1838 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001839 */
1840 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1841 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001842
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001843 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001844 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1845 * <p>
1846 * For historical reasons, the name of this broadcast action refers to the power
1847 * state of the screen but it is actually sent in response to changes in the
1848 * overall interactive state of the device.
1849 * </p><p>
1850 * This broadcast is sent when the device becomes interactive which may have
1851 * nothing to do with the screen turning on. To determine the
1852 * actual state of the screen, use {@link android.view.Display#getState}.
1853 * </p><p>
1854 * See {@link android.os.PowerManager#isInteractive} for details.
1855 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001856 * You <em>cannot</em> receive this through components declared in
1857 * manifests, only by explicitly registering for it with
1858 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1859 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001860 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001861 * <p class="note">This is a protected intent that can only be sent
1862 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001863 */
1864 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1865 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001866
1867 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001868 * Broadcast Action: Sent after the system stops dreaming.
1869 *
1870 * <p class="note">This is a protected intent that can only be sent by the system.
1871 * It is only sent to registered receivers.</p>
1872 */
1873 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1874 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1875
1876 /**
1877 * Broadcast Action: Sent after the system starts dreaming.
1878 *
1879 * <p class="note">This is a protected intent that can only be sent by the system.
1880 * It is only sent to registered receivers.</p>
1881 */
1882 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1883 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1884
1885 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001886 * 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 -07001887 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001888 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001889 * <p class="note">This is a protected intent that can only be sent
1890 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001891 */
1892 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001893 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001894
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001895 /**
1896 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001897 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001898 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001899 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1900 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001901 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001902 * <p class="note">This is a protected intent that can only be sent
1903 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001904 */
1905 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1906 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1907 /**
1908 * Broadcast Action: The time was set.
1909 */
1910 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1911 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1912 /**
1913 * Broadcast Action: The date has changed.
1914 */
1915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1916 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1917 /**
1918 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1919 * <ul>
1920 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1921 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001922 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001923 * <p class="note">This is a protected intent that can only be sent
1924 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001925 */
1926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1927 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1928 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001929 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1930 * DNS entries should be tossed.
1931 * @hide
1932 */
1933 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1934 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1935 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001936 * Alarm Changed Action: This is broadcast when the AlarmClock
1937 * application's alarm is set or unset. It is used by the
1938 * AlarmClock application and the StatusBar service.
1939 * @hide
1940 */
1941 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1942 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001943
1944 /**
1945 * Broadcast Action: This is broadcast once, after the system has finished
1946 * booting and the user is in a "locked" state. A user is locked when their
1947 * credential-encrypted private app data storage is unavailable. Once the
1948 * user has entered their credentials (such as a lock pattern or PIN) for
1949 * the first time, the {@link #ACTION_BOOT_COMPLETED} broadcast will be
1950 * sent.
1951 * <p>
1952 * You must hold the
1953 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1954 * order to receive this broadcast.
1955 * <p class="note">
1956 * This is a protected intent that can only be sent by the system.
1957 */
1958 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1959 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1960
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001961 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001962 * Broadcast Action: This is broadcast once, after the system has finished
1963 * booting. It can be used to perform application-specific initialization,
1964 * such as installing alarms. You must hold the
1965 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1966 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001967 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001968 * <p class="note">This is a protected intent that can only be sent
1969 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001970 */
1971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1972 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001973
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001974 /**
1975 * Broadcast Action: This is broadcast when a user action should request a
1976 * temporary system dialog to dismiss. Some examples of temporary system
1977 * dialogs are the notification window-shade and the recent tasks dialog.
1978 */
1979 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1980 /**
1981 * Broadcast Action: Trigger the download and eventual installation
1982 * of a package.
1983 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001984 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001985 * <p class="note">This is a protected intent that can only be sent
1986 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001987 *
1988 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001989 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001990 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1992 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1993 /**
1994 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001995 * device. The data contains the name of the package. Note that the
1996 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001997 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001998 * <ul>
1999 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2000 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2001 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2002 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002003 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002004 * <p class="note">This is a protected intent that can only be sent
2005 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002006 */
2007 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2008 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2009 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002010 * Broadcast Action: A new version of an application package has been
2011 * installed, replacing an existing version that was previously installed.
2012 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002013 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002014 * <ul>
2015 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2016 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002017 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002018 * <p class="note">This is a protected intent that can only be sent
2019 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002020 */
2021 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2022 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2023 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002024 * Broadcast Action: A new version of your application has been installed
2025 * over an existing one. This is only sent to the application that was
2026 * replaced. It does not contain any additional data; to receive it, just
2027 * use an intent filter for this action.
2028 *
2029 * <p class="note">This is a protected intent that can only be sent
2030 * by the system.
2031 */
2032 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2033 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2034 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002035 * Broadcast Action: An existing application package has been removed from
2036 * the device. The data contains the name of the package. The package
2037 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002038 * <ul>
2039 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2040 * to the package.
2041 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2042 * application -- data and code -- is being removed.
2043 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2044 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2045 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002046 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002047 * <p class="note">This is a protected intent that can only be sent
2048 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002049 */
2050 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2051 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2052 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002053 * Broadcast Action: An existing application package has been completely
2054 * removed from the device. The data contains the name of the package.
2055 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2056 * {@link #EXTRA_DATA_REMOVED} is true and
2057 * {@link #EXTRA_REPLACING} is false of that broadcast.
2058 *
2059 * <ul>
2060 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2061 * to the package.
2062 * </ul>
2063 *
2064 * <p class="note">This is a protected intent that can only be sent
2065 * by the system.
2066 */
2067 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2068 public static final String ACTION_PACKAGE_FULLY_REMOVED
2069 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2070 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002071 * Broadcast Action: An existing application package has been changed (e.g.
2072 * a component has been enabled or disabled). The data contains the name of
2073 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002074 * <ul>
2075 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002076 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002077 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002078 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2079 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002080 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002081 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002082 * <p class="note">This is a protected intent that can only be sent
2083 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002084 */
2085 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2086 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2087 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002088 * @hide
2089 * Broadcast Action: Ask system services if there is any reason to
2090 * restart the given package. The data contains the name of the
2091 * package.
2092 * <ul>
2093 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2094 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2095 * </ul>
2096 *
2097 * <p class="note">This is a protected intent that can only be sent
2098 * by the system.
2099 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002100 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002101 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2102 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2103 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002104 * Broadcast Action: The user has restarted a package, and all of its
2105 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002106 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002107 * be removed. Note that the restarted package does <em>not</em>
2108 * receive this broadcast.
2109 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002110 * <ul>
2111 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2112 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002113 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002114 * <p class="note">This is a protected intent that can only be sent
2115 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002116 */
2117 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2118 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2119 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002120 * Broadcast Action: The user has cleared the data of a package. This should
2121 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002122 * its persistent data is erased and this broadcast sent.
2123 * Note that the cleared package does <em>not</em>
2124 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002125 * <ul>
2126 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2127 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002128 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002129 * <p class="note">This is a protected intent that can only be sent
2130 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002131 */
2132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2133 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2134 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002135 * Broadcast Action: Packages have been suspended.
2136 * <p>Includes the following extras:
2137 * <ul>
2138 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
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_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2146 /**
2147 * Broadcast Action: Packages have been unsuspended.
2148 * <p>Includes the following extras:
2149 * <ul>
2150 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2151 * </ul>
2152 *
2153 * <p class="note">This is a protected intent that can only be sent
2154 * by the system. It is only sent to registered receivers.
2155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2157 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2158 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002159 * Broadcast Action: A user ID has been removed from the system. The user
2160 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002161 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002162 * <p class="note">This is a protected intent that can only be sent
2163 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002164 */
2165 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2166 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002167
2168 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002169 * Broadcast Action: Sent to the installer package of an application
2170 * when that application is first launched (that is the first time it
2171 * is moved out of the stopped state). The data contains the name of the package.
2172 *
2173 * <p class="note">This is a protected intent that can only be sent
2174 * by the system.
2175 */
2176 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2177 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2178
2179 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002180 * Broadcast Action: Sent to the system package verifier when a package
2181 * needs to be verified. The data contains the package URI.
2182 * <p class="note">
2183 * This is a protected intent that can only be sent by the system.
2184 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002185 */
2186 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2187 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2188
2189 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002190 * Broadcast Action: Sent to the system package verifier when a package is
2191 * verified. The data contains the package URI.
2192 * <p class="note">
2193 * This is a protected intent that can only be sent by the system.
2194 */
2195 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2196 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2197
2198 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002199 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2200 * needs to be verified. The data contains the filter data hosts to be verified against.
2201 * <p class="note">
2202 * This is a protected intent that can only be sent by the system.
2203 * </p>
2204 *
2205 * @hide
2206 */
2207 @SystemApi
2208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2209 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2210
2211 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002212 * Broadcast Action: Resources for a set of packages (which were
2213 * previously unavailable) are currently
2214 * available since the media on which they exist is available.
2215 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2216 * list of packages whose availability changed.
2217 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2218 * list of uids of packages whose availability changed.
2219 * Note that the
2220 * packages in this list do <em>not</em> receive this broadcast.
2221 * The specified set of packages are now available on the system.
2222 * <p>Includes the following extras:
2223 * <ul>
2224 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2225 * whose resources(were previously unavailable) are currently available.
2226 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2227 * packages whose resources(were previously unavailable)
2228 * are currently available.
2229 * </ul>
2230 *
2231 * <p class="note">This is a protected intent that can only be sent
2232 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002233 */
2234 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002235 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2236 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002237
2238 /**
2239 * Broadcast Action: Resources for a set of packages are currently
2240 * unavailable since the media on which they exist is unavailable.
2241 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2242 * list of packages whose availability changed.
2243 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2244 * list of uids of packages whose availability changed.
2245 * The specified set of packages can no longer be
2246 * launched and are practically unavailable on the system.
2247 * <p>Inclues the following extras:
2248 * <ul>
2249 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2250 * whose resources are no longer available.
2251 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2252 * whose resources are no longer available.
2253 * </ul>
2254 *
2255 * <p class="note">This is a protected intent that can only be sent
2256 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002259 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002260 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002261
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002262 /**
2263 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002264 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002265 * This should <em>only</em> be used to determine when the wallpaper
2266 * has changed to show the new wallpaper to the user. You should certainly
2267 * never, in response to this, change the wallpaper or other attributes of
2268 * it such as the suggested size. That would be crazy, right? You'd cause
2269 * all kinds of loops, especially if other apps are doing similar things,
2270 * right? Of course. So please don't do this.
2271 *
2272 * @deprecated Modern applications should use
2273 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2274 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2275 * shown behind their UI, rather than watching for this broadcast and
2276 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002277 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002278 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002279 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2280 /**
2281 * Broadcast Action: The current device {@link android.content.res.Configuration}
2282 * (orientation, locale, etc) has changed. When such a change happens, the
2283 * UIs (view hierarchy) will need to be rebuilt based on this new
2284 * information; for the most part, applications don't need to worry about
2285 * this, because the system will take care of stopping and restarting the
2286 * application to make sure it sees the new changes. Some system code that
2287 * can not be restarted will need to watch for this action and handle it
2288 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002289 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002290 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002291 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002292 * in manifests, only by explicitly registering for it with
2293 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2294 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002295 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002296 * <p class="note">This is a protected intent that can only be sent
2297 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002298 *
2299 * @see android.content.res.Configuration
2300 */
2301 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2302 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2303 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002304 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002305 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002306 * <p class="note">This is a protected intent that can only be sent
2307 * by the system.
2308 */
2309 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2310 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2311 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002312 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2313 * charging state, level, and other information about the battery.
2314 * See {@link android.os.BatteryManager} for documentation on the
2315 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002316 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002317 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002318 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002319 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002320 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002321 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2322 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2323 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2324 * broadcasts that are sent and can be received through manifest
2325 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002326 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002327 * <p class="note">This is a protected intent that can only be sent
2328 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002329 */
2330 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2331 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2332 /**
2333 * Broadcast Action: Indicates low battery condition on the device.
2334 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002335 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002336 * <p class="note">This is a protected intent that can only be sent
2337 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002338 */
2339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2340 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2341 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002342 * Broadcast Action: Indicates the battery is now okay after being low.
2343 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2344 * gone back up to an okay state.
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.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002348 */
2349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2350 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2351 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002352 * Broadcast Action: External power has been connected to 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
2356 * 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)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002362 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002363 /**
2364 * Broadcast Action: External power has been removed from the device.
2365 * This is intended for applications that wish to register specifically to this notification.
2366 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2367 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002368 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002369 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002370 * <p class="note">This is a protected intent that can only be sent
2371 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002372 */
2373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002374 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002375 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002376 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002377 * Broadcast Action: Device is shutting down.
2378 * This is broadcast when the device is being shut down (completely turned
2379 * off, not sleeping). Once the broadcast is complete, the final shutdown
2380 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002381 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002382 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002383 * <p class="note">This is a protected intent that can only be sent
2384 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002385 * <p>May include the following extras:
2386 * <ul>
2387 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2388 * shutdown is only for userspace processes. If not set, assumed to be false.
2389 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002390 */
2391 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002392 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002393 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002394 * Activity Action: Start this activity to request system shutdown.
2395 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002396 * to request confirmation from the user before shutting down. The optional boolean
2397 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2398 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002399 *
2400 * <p class="note">This is a protected intent that can only be sent
2401 * by the system.
2402 *
2403 * {@hide}
2404 */
2405 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2406 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002407 * Broadcast Action: A sticky broadcast that indicates low memory
2408 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002409 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002410 * <p class="note">This is a protected intent that can only be sent
2411 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002412 */
2413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2414 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2415 /**
2416 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002417 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002418 * <p class="note">This is a protected intent that can only be sent
2419 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002420 */
2421 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2422 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2423 /**
Jake Hambybb371632010-08-23 18:16:48 -07002424 * Broadcast Action: A sticky broadcast that indicates a memory full
2425 * condition on the device. This is intended for activities that want
2426 * to be able to fill the data partition completely, leaving only
2427 * enough free space to prevent system-wide SQLite failures.
2428 *
2429 * <p class="note">This is a protected intent that can only be sent
2430 * by the system.
2431 *
2432 * {@hide}
2433 */
2434 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2435 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2436 /**
2437 * Broadcast Action: Indicates memory full condition on the device
2438 * no longer exists.
2439 *
2440 * <p class="note">This is a protected intent that can only be sent
2441 * by the system.
2442 *
2443 * {@hide}
2444 */
2445 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2446 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2447 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002448 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2449 * and package management should be started.
2450 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2451 * notification.
2452 */
2453 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2454 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2455 /**
2456 * Broadcast Action: The device has entered USB Mass Storage mode.
2457 * This is used mainly for the USB Settings panel.
2458 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2459 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002460 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002461 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002462 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002463 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2464
2465 /**
2466 * Broadcast Action: The device has exited USB Mass Storage mode.
2467 * This is used mainly for the USB Settings panel.
2468 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2469 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002470 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002471 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002472 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002473 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2474
2475 /**
2476 * Broadcast Action: External media has been removed.
2477 * The path to the mount point for the removed media is contained in the Intent.mData field.
2478 */
2479 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2480 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2481
2482 /**
2483 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002484 * 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 -07002485 */
2486 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2487 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2488
2489 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002490 * Broadcast Action: External media is present, and being disk-checked
2491 * 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 -08002492 */
2493 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2494 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2495
2496 /**
2497 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2498 * 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 -08002499 */
2500 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2501 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2502
2503 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002504 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002505 * 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 -07002506 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2507 * media was mounted read only.
2508 */
2509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2510 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2511
2512 /**
2513 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002514 * 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 -07002515 */
2516 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2517 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2518
2519 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002520 * Broadcast Action: External media is no longer being shared via USB mass storage.
2521 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2522 *
2523 * @hide
2524 */
2525 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2526
2527 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002528 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2529 * The path to the mount point for the removed media is contained in the Intent.mData field.
2530 */
2531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2532 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2533
2534 /**
2535 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002536 * 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 -07002537 */
2538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2539 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2540
2541 /**
2542 * Broadcast Action: User has expressed the desire to remove the external storage media.
2543 * Applications should close all files they have open within the mount point when they receive this intent.
2544 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2545 */
2546 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2547 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2548
2549 /**
2550 * Broadcast Action: The media scanner has started scanning a directory.
2551 * The path to the directory being scanned is contained in the Intent.mData field.
2552 */
2553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2554 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2555
2556 /**
2557 * Broadcast Action: The media scanner has finished scanning a directory.
2558 * The path to the scanned directory is contained in the Intent.mData field.
2559 */
2560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2561 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2562
2563 /**
2564 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2565 * The path to the file is contained in the Intent.mData field.
2566 */
2567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2568 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2569
2570 /**
2571 * Broadcast Action: The "Media Button" was pressed. Includes a single
2572 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2573 * caused the broadcast.
2574 */
2575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2576 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2577
2578 /**
2579 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2580 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2581 * caused the broadcast.
2582 */
2583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2584 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2585
2586 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2587 // location; they are not general-purpose actions.
2588
2589 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002590 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002591 */
2592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2593 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2594 "android.intent.action.GTALK_CONNECTED";
2595
2596 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002597 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002598 */
2599 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2600 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2601 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002602
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002603 /**
2604 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002605 */
2606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2607 public static final String ACTION_INPUT_METHOD_CHANGED =
2608 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002609
2610 /**
2611 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2612 * more radios have been turned off or on. The intent will have the following extra value:</p>
2613 * <ul>
2614 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2615 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2616 * turned off</li>
2617 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002618 *
Peng Xua35b5532016-01-20 00:05:45 -08002619 * <p class="note">This is a protected intent that can only be sent by the system.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2623
2624 /**
2625 * Broadcast Action: Some content providers have parts of their namespace
2626 * where they publish new events or items that the user may be especially
2627 * interested in. For these things, they may broadcast this action when the
2628 * set of interesting items change.
2629 *
2630 * For example, GmailProvider sends this notification when the set of unread
2631 * mail in the inbox changes.
2632 *
2633 * <p>The data of the intent identifies which part of which provider
2634 * changed. When queried through the content resolver, the data URI will
2635 * return the data set in question.
2636 *
2637 * <p>The intent will have the following extra values:
2638 * <ul>
2639 * <li><em>count</em> - The number of items in the data set. This is the
2640 * same as the number of items in the cursor returned by querying the
2641 * data URI. </li>
2642 * </ul>
2643 *
2644 * This intent will be sent at boot (if the count is non-zero) and when the
2645 * data set changes. It is possible for the data set to change without the
2646 * count changing (for example, if a new unread message arrives in the same
2647 * sync operation in which a message is archived). The phone should still
2648 * ring/vibrate/etc as normal in this case.
2649 */
2650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2651 public static final String ACTION_PROVIDER_CHANGED =
2652 "android.intent.action.PROVIDER_CHANGED";
2653
2654 /**
2655 * Broadcast Action: Wired Headset plugged in or unplugged.
2656 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002657 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2658 * and documentation.
2659 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002660 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002661 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002662 */
2663 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002664 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002665
2666 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002667 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2668 * <ul>
2669 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2670 * </ul>
2671 *
2672 * <p class="note">This is a protected intent that can only be sent
2673 * by the system.
2674 *
2675 * @hide
2676 */
2677 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2678 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2679 = "android.intent.action.ADVANCED_SETTINGS";
2680
2681 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002682 * Broadcast Action: Sent after application restrictions are changed.
2683 *
2684 * <p class="note">This is a protected intent that can only be sent
2685 * by the system.</p>
2686 */
2687 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2688 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2689 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2690
2691 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002692 * Broadcast Action: An outgoing call is about to be placed.
2693 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002694 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002695 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002696 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002697 * the phone number originally intended to be dialed.</li>
2698 * </ul>
2699 * <p>Once the broadcast is finished, the resultData is used as the actual
2700 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002701 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002702 * outgoing call in turn: for example, a parental control application
2703 * might verify that the user is authorized to place the call at that
2704 * time, then a number-rewriting application might add an area code if
2705 * one was not specified.</p>
2706 * <p>For consistency, any receiver whose purpose is to prohibit phone
2707 * calls should have a priority of 0, to ensure it will see the final
2708 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002709 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002710 * should have a positive priority.
2711 * Negative priorities are reserved for the system for this broadcast;
2712 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002713 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2714 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002715 * <p>Emergency calls cannot be intercepted using this mechanism, and
2716 * other calls cannot be modified to call emergency numbers using this
2717 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002718 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2719 * call to use their own service instead. Those apps should first prevent
2720 * the call from being placed by setting resultData to <code>null</code>
2721 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002722 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002723 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2724 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002725 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002726 * <p class="note">This is a protected intent that can only be sent
2727 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002728 */
2729 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2730 public static final String ACTION_NEW_OUTGOING_CALL =
2731 "android.intent.action.NEW_OUTGOING_CALL";
2732
2733 /**
2734 * Broadcast Action: Have the device reboot. This is only for use by
2735 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002736 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002737 * <p class="note">This is a protected intent that can only be sent
2738 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002739 */
2740 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2741 public static final String ACTION_REBOOT =
2742 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002743
Wei Huang97ecc9c2009-05-11 17:44:20 -07002744 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002745 * Broadcast Action: A sticky broadcast for changes in the physical
2746 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002747 *
2748 * <p>The intent will have the following extra values:
2749 * <ul>
2750 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002751 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002752 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002753 * <p>This is intended for monitoring the current physical dock state.
2754 * See {@link android.app.UiModeManager} for the normal API dealing with
2755 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002756 */
2757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2758 public static final String ACTION_DOCK_EVENT =
2759 "android.intent.action.DOCK_EVENT";
2760
2761 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002762 * Broadcast Action: A broadcast when idle maintenance can be started.
2763 * This means that the user is not interacting with the device and is
2764 * not expected to do so soon. Typical use of the idle maintenance is
2765 * to perform somehow expensive tasks that can be postponed at a moment
2766 * when they will not degrade user experience.
2767 * <p>
2768 * <p class="note">In order to keep the device responsive in case of an
2769 * unexpected user interaction, implementations of a maintenance task
2770 * should be interruptible. In such a scenario a broadcast with action
2771 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2772 * should not do the maintenance work in
2773 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2774 * maintenance service by {@link Context#startService(Intent)}. Also
2775 * you should hold a wake lock while your maintenance service is running
2776 * to prevent the device going to sleep.
2777 * </p>
2778 * <p>
2779 * <p class="note">This is a protected intent that can only be sent by
2780 * the system.
2781 * </p>
2782 *
2783 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002784 *
2785 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002786 */
2787 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2788 public static final String ACTION_IDLE_MAINTENANCE_START =
2789 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2790
2791 /**
2792 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2793 * This means that the user was not interacting with the device as a result
2794 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2795 * was sent and now the user started interacting with the device. Typical
2796 * use of the idle maintenance is to perform somehow expensive tasks that
2797 * can be postponed at a moment when they will not degrade user experience.
2798 * <p>
2799 * <p class="note">In order to keep the device responsive in case of an
2800 * unexpected user interaction, implementations of a maintenance task
2801 * should be interruptible. Hence, on receiving a broadcast with this
2802 * action, the maintenance task should be interrupted as soon as possible.
2803 * In other words, you should not do the maintenance work in
2804 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2805 * maintenance service that was started on receiving of
2806 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2807 * lock you acquired when your maintenance service started.
2808 * </p>
2809 * <p class="note">This is a protected intent that can only be sent
2810 * by the system.
2811 *
2812 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002813 *
2814 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002815 */
2816 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2817 public static final String ACTION_IDLE_MAINTENANCE_END =
2818 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2819
2820 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002821 * Broadcast Action: a remote intent is to be broadcasted.
2822 *
2823 * A remote intent is used for remote RPC between devices. The remote intent
2824 * is serialized and sent from one device to another device. The receiving
2825 * device parses the remote intent and broadcasts it. Note that anyone can
2826 * broadcast a remote intent. However, if the intent receiver of the remote intent
2827 * does not trust intent broadcasts from arbitrary intent senders, it should require
2828 * the sender to hold certain permissions so only trusted sender's broadcast will be
2829 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002830 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002831 */
2832 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002833 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002834
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002835 /**
2836 * Broadcast Action: hook for permforming cleanup after a system update.
2837 *
2838 * The broadcast is sent when the system is booting, before the
2839 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2840 * image. A receiver for this should do its work and then disable itself
2841 * so that it does not get run again at the next boot.
2842 * @hide
2843 */
2844 public static final String ACTION_PRE_BOOT_COMPLETED =
2845 "android.intent.action.PRE_BOOT_COMPLETED";
2846
Amith Yamasani13593602012-03-22 16:16:17 -07002847 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002848 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002849 * on restricted users. The broadcast intent contains an extra
2850 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2851 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2852 * String[] depending on the restriction type.<p/>
2853 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002854 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2855 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2856 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002857 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2858 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002859 * @see RestrictionEntry
2860 */
2861 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2862 "android.intent.action.GET_RESTRICTION_ENTRIES";
2863
2864 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002865 * Sent the first time a user is starting, to allow system apps to
2866 * perform one time initialization. (This will not be seen by third
2867 * party applications because a newly initialized user does not have any
2868 * third party applications installed for it.) This is sent early in
2869 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002870 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2871 * broadcast, since it is part of a visible user interaction; be as quick
2872 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002873 */
2874 public static final String ACTION_USER_INITIALIZE =
2875 "android.intent.action.USER_INITIALIZE";
2876
2877 /**
2878 * Sent when a user switch is happening, causing the process's user to be
2879 * brought to the foreground. This is only sent to receivers registered
2880 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2881 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002882 * foreground. This is sent as a foreground
2883 * broadcast, since it is part of a visible user interaction; be as quick
2884 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002885 */
2886 public static final String ACTION_USER_FOREGROUND =
2887 "android.intent.action.USER_FOREGROUND";
2888
2889 /**
2890 * Sent when a user switch is happening, causing the process's user to be
2891 * sent to the background. This is only sent to receivers registered
2892 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2893 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002894 * background. This is sent as a foreground
2895 * broadcast, since it is part of a visible user interaction; be as quick
2896 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002897 */
2898 public static final String ACTION_USER_BACKGROUND =
2899 "android.intent.action.USER_BACKGROUND";
2900
2901 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002902 * Broadcast sent to the system when a user is added. Carries an extra
2903 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2904 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002905 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002906 * @hide
2907 */
2908 public static final String ACTION_USER_ADDED =
2909 "android.intent.action.USER_ADDED";
2910
2911 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002912 * Broadcast sent by the system when a user is started. Carries an extra
2913 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002914 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002915 * that has been started. This is sent as a foreground
2916 * broadcast, since it is part of a visible user interaction; be as quick
2917 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002918 * @hide
2919 */
2920 public static final String ACTION_USER_STARTED =
2921 "android.intent.action.USER_STARTED";
2922
2923 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002924 * Broadcast sent when a user is in the process of starting. Carries an extra
2925 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2926 * sent to registered receivers, not manifest receivers. It is sent to all
2927 * users (including the one that is being started). You must hold
2928 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2929 * this broadcast. This is sent as a background broadcast, since
2930 * its result is not part of the primary UX flow; to safely keep track of
2931 * started/stopped state of a user you can use this in conjunction with
2932 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2933 * other user state broadcasts since those are foreground broadcasts so can
2934 * execute in a different order.
2935 * @hide
2936 */
2937 public static final String ACTION_USER_STARTING =
2938 "android.intent.action.USER_STARTING";
2939
2940 /**
2941 * Broadcast sent when a user is going to be stopped. Carries an extra
2942 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2943 * sent to registered receivers, not manifest receivers. It is sent to all
2944 * users (including the one that is being stopped). You must hold
2945 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2946 * this broadcast. The user will not stop until all receivers have
2947 * handled the broadcast. This is sent as a background broadcast, since
2948 * its result is not part of the primary UX flow; to safely keep track of
2949 * started/stopped state of a user you can use this in conjunction with
2950 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2951 * other user state broadcasts since those are foreground broadcasts so can
2952 * execute in a different order.
2953 * @hide
2954 */
2955 public static final String ACTION_USER_STOPPING =
2956 "android.intent.action.USER_STOPPING";
2957
2958 /**
2959 * Broadcast sent to the system when a user is stopped. Carries an extra
2960 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2961 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2962 * specific package. This is only sent to registered receivers, not manifest
2963 * receivers. It is sent to all running users <em>except</em> the one that
2964 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002965 * @hide
2966 */
2967 public static final String ACTION_USER_STOPPED =
2968 "android.intent.action.USER_STOPPED";
2969
2970 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002971 * 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 -07002972 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002973 * one that has been removed. The user will not be completely removed until all receivers have
2974 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002975 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002976 * @hide
2977 */
2978 public static final String ACTION_USER_REMOVED =
2979 "android.intent.action.USER_REMOVED";
2980
2981 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002982 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002983 * the userHandle of the user to become the current one. This is only sent to
2984 * registered receivers, not manifest receivers. It is sent to all running users.
2985 * You must hold
2986 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002987 * @hide
2988 */
2989 public static final String ACTION_USER_SWITCHED =
2990 "android.intent.action.USER_SWITCHED";
2991
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002992 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002993 * Broadcast Action: Sent when the credential-encrypted private storage has
2994 * become unlocked for the target user. This is only sent to registered
2995 * receivers, not manifest receivers.
2996 */
2997 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2998 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
2999
3000 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003001 * Broadcast sent to the system when a user's information changes. Carries an extra
3002 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003003 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003004 * @hide
3005 */
3006 public static final String ACTION_USER_INFO_CHANGED =
3007 "android.intent.action.USER_INFO_CHANGED";
3008
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003009 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003010 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3011 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003012 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3013 * that need to display merged content across both primary and managed profiles need to
3014 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003015 * not manifest receivers.
3016 */
3017 public static final String ACTION_MANAGED_PROFILE_ADDED =
3018 "android.intent.action.MANAGED_PROFILE_ADDED";
3019
3020 /**
3021 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003022 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3023 * Only applications (for example Launchers) that need to display merged content across both
3024 * primary and managed profiles need to worry about this broadcast. This is only sent to
3025 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003026 */
3027 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3028 "android.intent.action.MANAGED_PROFILE_REMOVED";
3029
3030 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003031 * Broadcast sent to the primary user when an associated managed profile's availability has
Rubin Xuf13c9802016-01-21 18:06:00 +00003032 * changed. This includes when the user toggles the profile's quiet mode. Carries an extra
3033 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3034 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3035 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003036 */
3037 public static final String ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED =
3038 "android.intent.action.MANAGED_PROFILE_AVAILABILITY_CHANGED";
3039
3040 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003041 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3042 */
3043 public static final String ACTION_QUICK_CLOCK =
3044 "android.intent.action.QUICK_CLOCK";
3045
Michael Wright0087a142013-02-05 16:29:39 -08003046 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003047 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003048 * @hide
3049 */
3050 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3051 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3052
Justin Kohd378ad72013-04-01 12:18:26 -07003053 /**
3054 * Broadcast Action: A global button was pressed. Includes a single
3055 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3056 * caused the broadcast.
3057 * @hide
3058 */
3059 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3060
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003061 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003062 * Broadcast Action: Sent when media resource is granted.
3063 * <p>
3064 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3065 * granted.
3066 * </p>
3067 * <p class="note">
3068 * This is a protected intent that can only be sent by the system.
3069 * </p>
3070 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003071 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003072 * </p>
3073 *
3074 * @hide
3075 */
3076 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3077 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3078
3079 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003080 * Activity Action: Allow the user to select and return one or more existing
3081 * documents. When invoked, the system will display the various
3082 * {@link DocumentsProvider} instances installed on the device, letting the
3083 * user interactively navigate through them. These documents include local
3084 * media, such as photos and video, and documents provided by installed
3085 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003086 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003087 * Each document is represented as a {@code content://} URI backed by a
3088 * {@link DocumentsProvider}, which can be opened as a stream with
3089 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3090 * {@link android.provider.DocumentsContract.Document} metadata.
3091 * <p>
3092 * All selected documents are returned to the calling application with
3093 * persistable read and write permission grants. If you want to maintain
3094 * access to the documents across device reboots, you need to explicitly
3095 * take the persistable permissions using
3096 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3097 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003098 * Callers must indicate the acceptable document MIME types through
3099 * {@link #setType(String)}. For example, to select photos, use
3100 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3101 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3102 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003103 * <p>
3104 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003105 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3106 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003107 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003108 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3109 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003110 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003111 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003112 * Output: The URI of the item that was picked, returned in
3113 * {@link #getData()}. This must be a {@code content://} URI so that any
3114 * receiver can access it. If multiple documents were selected, they are
3115 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003116 *
3117 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003118 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003119 * @see #ACTION_CREATE_DOCUMENT
3120 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003121 */
3122 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3123 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3124
3125 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003126 * Activity Action: Allow the user to create a new document. When invoked,
3127 * the system will display the various {@link DocumentsProvider} instances
3128 * installed on the device, letting the user navigate through them. The
3129 * returned document may be a newly created document with no content, or it
3130 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003131 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003132 * Each document is represented as a {@code content://} URI backed by a
3133 * {@link DocumentsProvider}, which can be opened as a stream with
3134 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3135 * {@link android.provider.DocumentsContract.Document} metadata.
3136 * <p>
3137 * Callers must indicate the concrete MIME type of the document being
3138 * created by setting {@link #setType(String)}. This MIME type cannot be
3139 * changed after the document is created.
3140 * <p>
3141 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3142 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003143 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003144 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3145 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003146 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003147 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003148 * Output: The URI of the item that was created. This must be a
3149 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003150 *
3151 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003152 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003153 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003154 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003155 */
3156 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3157 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3158
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003159 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003160 * Activity Action: Allow the user to pick a directory subtree. When
3161 * invoked, the system will display the various {@link DocumentsProvider}
3162 * instances installed on the device, letting the user navigate through
3163 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003164 * <p>
3165 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003166 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3167 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3168 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003169 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003170 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003171 *
3172 * @see DocumentsContract
3173 */
3174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003175 public static final String
3176 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003177
Felipe Lemec7b1f892016-01-15 15:02:31 -08003178 /**
3179 * Activity Action: Give access to a standard storage directory after obtaining the user's
3180 * approval.
3181 * <p>
3182 * When invoked, the system will ask the user to grant access to the requested directory (and
3183 * its descendants).
3184 * <p>
3185 * To gain access to descendant (child, grandchild, etc) documents, use
3186 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3187 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} with the returned URI.
3188 * <p>
3189 * Input: full path to a standard directory, in the form of
3190 * {@code STORAGE_ROOT + STANDARD_DIRECTORY}, where {@code STORAGE_ROOT} is the physical path of
3191 * a storage container, and {@code STANDARD_DIRECTORY} is one of
3192 * {@link Environment#DIRECTORY_MUSIC}, {@link Environment#DIRECTORY_PODCASTS},
3193 * {@link Environment#DIRECTORY_RINGTONES}, {@link Environment#DIRECTORY_ALARMS},
3194 * {@link Environment#DIRECTORY_NOTIFICATIONS}, {@link Environment#DIRECTORY_PICTURES},
3195 * {@link Environment#DIRECTORY_MOVIES}, {@link Environment#DIRECTORY_DOWNLOADS},
3196 * {@link Environment#DIRECTORY_DCIM}, or {@link Environment#DIRECTORY_DOCUMENTS}
3197 * <p>
3198 * For example, to open the "Pictures" folder in the default external storage, the intent's data
3199 * would be: {@code Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
3200 * Environment.DIRECTORY_PICTURES))}.
3201 * <p>
3202 * Output: The URI representing the requested directory tree.
3203 *
3204 * @see DocumentsContract
3205 */
3206 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3207 public static final String
3208 ACTION_OPEN_EXTERNAL_DIRECTORY = "android.intent.action.OPEN_EXTERNAL_DIRECTORY";
3209
Peng Xua35b5532016-01-20 00:05:45 -08003210 /**
3211 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3212 * exisiting sensor being disconnected.
3213 *
3214 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3215 *
3216 * {@hide}
3217 */
3218 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3219 public static final String
3220 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3221
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003222 /** {@hide} */
3223 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3224
Christopher Tate6597e342015-02-17 12:15:25 -08003225 /**
3226 * Broadcast action: report that a settings element is being restored from backup. The intent
3227 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3228 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3229 * is the value of that settings entry prior to the restore operation. All of these values are
3230 * represented as strings.
3231 *
3232 * <p>This broadcast is sent only for settings provider entries known to require special handling
3233 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3234 * the provider's backup agent implementation.
3235 *
3236 * @see #EXTRA_SETTING_NAME
3237 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3238 * @see #EXTRA_SETTING_NEW_VALUE
3239 * {@hide}
3240 */
3241 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3242
3243 /** {@hide} */
3244 public static final String EXTRA_SETTING_NAME = "setting_name";
3245 /** {@hide} */
3246 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3247 /** {@hide} */
3248 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3249
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003250 /**
3251 * Activity Action: Process a piece of text.
3252 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3253 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3254 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3255 */
3256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3257 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3258 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003259 * The name of the extra used to define the text to be processed, as a
3260 * CharSequence. Note that this may be a styled CharSequence, so you must use
3261 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003262 */
3263 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3264 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003265 * 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 +00003266 */
3267 public static final String EXTRA_PROCESS_TEXT_READONLY =
3268 "android.intent.extra.PROCESS_TEXT_READONLY";
3269
Bryce Leebc58f592015-09-25 16:43:01 -07003270 /**
3271 * Broadcast action: reports when a new thermal event has been reached. When the device
3272 * is reaching its maximum temperatue, the thermal level reported
3273 * {@hide}
3274 */
3275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3276 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3277
3278 /** {@hide} */
3279 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3280
3281 /**
3282 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003283 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003284 * {@hide}
3285 */
3286 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3287
3288 /**
3289 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003290 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003291 * {@hide}
3292 */
3293 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3294
3295 /**
3296 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003297 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003298 * {@hide}
3299 */
3300 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3301
3302
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003303 // ---------------------------------------------------------------------
3304 // ---------------------------------------------------------------------
3305 // Standard intent categories (see addCategory()).
3306
3307 /**
3308 * Set if the activity should be an option for the default action
3309 * (center press) to perform on a piece of data. Setting this will
3310 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003311 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003312 * Intent when initiating an action -- it is for use in intent filters
3313 * specified in packages.
3314 */
3315 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3316 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3317 /**
3318 * Activities that can be safely invoked from a browser must support this
3319 * category. For example, if the user is viewing a web page or an e-mail
3320 * and clicks on a link in the text, the Intent generated execute that
3321 * link will require the BROWSABLE category, so that only activities
3322 * supporting this category will be considered as possible actions. By
3323 * supporting this category, you are promising that there is nothing
3324 * damaging (without user intervention) that can happen by invoking any
3325 * matching Intent.
3326 */
3327 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3328 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3329 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003330 * Categories for activities that can participate in voice interaction.
3331 * An activity that supports this category must be prepared to run with
3332 * no UI shown at all (though in some case it may have a UI shown), and
3333 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3334 */
3335 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3336 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3337 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003338 * Set if the activity should be considered as an alternative action to
3339 * the data the user is currently viewing. See also
3340 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3341 * applies to the selection in a list of items.
3342 *
3343 * <p>Supporting this category means that you would like your activity to be
3344 * displayed in the set of alternative things the user can do, usually as
3345 * part of the current activity's options menu. You will usually want to
3346 * include a specific label in the &lt;intent-filter&gt; of this action
3347 * describing to the user what it does.
3348 *
3349 * <p>The action of IntentFilter with this category is important in that it
3350 * describes the specific action the target will perform. This generally
3351 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3352 * a specific name such as "com.android.camera.action.CROP. Only one
3353 * alternative of any particular action will be shown to the user, so using
3354 * a specific action like this makes sure that your alternative will be
3355 * displayed while also allowing other applications to provide their own
3356 * overrides of that particular action.
3357 */
3358 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3359 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3360 /**
3361 * Set if the activity should be considered as an alternative selection
3362 * action to the data the user has currently selected. This is like
3363 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3364 * of items from which the user can select, giving them alternatives to the
3365 * default action that will be performed on it.
3366 */
3367 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3368 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3369 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003370 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003371 */
3372 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3373 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3374 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003375 * Should be displayed in the top-level launcher.
3376 */
3377 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3378 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3379 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003380 * Indicates an activity optimized for Leanback mode, and that should
3381 * be displayed in the Leanback launcher.
3382 */
3383 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3384 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3385 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003386 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3387 * @hide
3388 */
3389 @SystemApi
3390 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3391 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003392 * Provides information about the package it is in; typically used if
3393 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3394 * a front-door to the user without having to be shown in the all apps list.
3395 */
3396 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3397 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3398 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003399 * This is the home activity, that is the first activity that is displayed
3400 * when the device boots.
3401 */
3402 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3403 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3404 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003405 * This is the home activity that is displayed when the device is finished setting up and ready
3406 * for use.
3407 * @hide
3408 */
3409 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3410 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3411 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003412 * This is the setup wizard activity, that is the first activity that is displayed
3413 * when the user sets up the device for the first time.
3414 * @hide
3415 */
3416 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3417 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3418 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003419 * This activity is a preference panel.
3420 */
3421 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3422 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3423 /**
3424 * This activity is a development preference panel.
3425 */
3426 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3427 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3428 /**
3429 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003430 */
3431 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3432 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3433 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003434 * This activity allows the user to browse and download new applications.
3435 */
3436 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3437 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3438 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003439 * This activity may be exercised by the monkey or other automated test tools.
3440 */
3441 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3442 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3443 /**
3444 * To be used as a test (not part of the normal user experience).
3445 */
3446 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3447 /**
3448 * To be used as a unit test (run through the Test Harness).
3449 */
3450 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3451 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003452 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003453 * experience).
3454 */
3455 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003456
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003457 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003458 * Used to indicate that an intent only wants URIs that can be opened with
3459 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3460 * must support at least the columns defined in {@link OpenableColumns} when
3461 * queried.
3462 *
3463 * @see #ACTION_GET_CONTENT
3464 * @see #ACTION_OPEN_DOCUMENT
3465 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003466 */
3467 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3468 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3469
3470 /**
3471 * To be used as code under test for framework instrumentation tests.
3472 */
3473 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3474 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003475 /**
3476 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003477 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3478 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003479 */
3480 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3481 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3482 /**
3483 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003484 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3485 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003486 */
3487 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3488 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003489 /**
3490 * An activity to run when device is inserted into a analog (low end) dock.
3491 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3492 * information, see {@link android.app.UiModeManager}.
3493 */
3494 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3495 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3496
3497 /**
3498 * An activity to run when device is inserted into a digital (high end) dock.
3499 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3500 * information, see {@link android.app.UiModeManager}.
3501 */
3502 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3503 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003504
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003505 /**
3506 * Used to indicate that the activity can be used in a car environment.
3507 */
3508 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3509 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3510
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003511 // ---------------------------------------------------------------------
3512 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003513 // Application launch intent categories (see addCategory()).
3514
3515 /**
3516 * Used with {@link #ACTION_MAIN} to launch the browser application.
3517 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003518 * <p>NOTE: This should not be used as the primary key of an Intent,
3519 * since it will not result in the app launching with the correct
3520 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003521 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003522 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003523 */
3524 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3525 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3526
3527 /**
3528 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3529 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003530 * <p>NOTE: This should not be used as the primary key of an Intent,
3531 * since it will not result in the app launching with the correct
3532 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003533 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003534 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003535 */
3536 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3537 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3538
3539 /**
3540 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3541 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003542 * <p>NOTE: This should not be used as the primary key of an Intent,
3543 * since it will not result in the app launching with the correct
3544 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003545 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003546 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003547 */
3548 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3549 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3550
3551 /**
3552 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3553 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003554 * <p>NOTE: This should not be used as the primary key of an Intent,
3555 * since it will not result in the app launching with the correct
3556 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003557 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003558 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003559 */
3560 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3561 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3562
3563 /**
3564 * Used with {@link #ACTION_MAIN} to launch the email application.
3565 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003566 * <p>NOTE: This should not be used as the primary key of an Intent,
3567 * since it will not result in the app launching with the correct
3568 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003569 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003570 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003571 */
3572 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3573 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3574
3575 /**
3576 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3577 * The activity should be able to view and manipulate image and video files
3578 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003579 * <p>NOTE: This should not be used as the primary key of an Intent,
3580 * since it will not result in the app launching with the correct
3581 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003582 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003583 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003584 */
3585 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3586 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3587
3588 /**
3589 * Used with {@link #ACTION_MAIN} to launch the maps application.
3590 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003591 * <p>NOTE: This should not be used as the primary key of an Intent,
3592 * since it will not result in the app launching with the correct
3593 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003594 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003595 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003596 */
3597 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3598 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3599
3600 /**
3601 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3602 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003603 * <p>NOTE: This should not be used as the primary key of an Intent,
3604 * since it will not result in the app launching with the correct
3605 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003606 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003607 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003608 */
3609 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3610 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3611
3612 /**
3613 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003614 * The activity should be able to play, browse, or manipulate music files
3615 * stored on the device.
3616 * <p>NOTE: This should not be used as the primary key of an Intent,
3617 * since it will not result in the app launching with the correct
3618 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003619 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003620 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003621 */
3622 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3623 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3624
3625 // ---------------------------------------------------------------------
3626 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003627 // Standard extra data keys.
3628
3629 /**
3630 * The initial data to place in a newly created record. Use with
3631 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3632 * fields as would be given to the underlying ContentProvider.insert()
3633 * call.
3634 */
3635 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3636
3637 /**
3638 * A constant CharSequence that is associated with the Intent, used with
3639 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3640 * this may be a styled CharSequence, so you must use
3641 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3642 * retrieve it.
3643 */
3644 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3645
3646 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003647 * A constant String that is associated with the Intent, used with
3648 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3649 * as HTML formatted text. Note that you <em>must</em> also supply
3650 * {@link #EXTRA_TEXT}.
3651 */
3652 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3653
3654 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003655 * A content: URI holding a stream of data associated with the Intent,
3656 * used with {@link #ACTION_SEND} to supply the data being sent.
3657 */
3658 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3659
3660 /**
3661 * A String[] holding e-mail addresses that should be delivered to.
3662 */
3663 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3664
3665 /**
3666 * A String[] holding e-mail addresses that should be carbon copied.
3667 */
3668 public static final String EXTRA_CC = "android.intent.extra.CC";
3669
3670 /**
3671 * A String[] holding e-mail addresses that should be blind carbon copied.
3672 */
3673 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3674
3675 /**
3676 * A constant string holding the desired subject line of a message.
3677 */
3678 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3679
3680 /**
3681 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003682 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003683 */
3684 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3685
3686 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003687 * An int representing the user id to be used.
3688 *
3689 * @hide
3690 */
3691 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3692
3693 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003694 * An int representing the task id to be retrieved. This is used when a launch from recents is
3695 * intercepted by another action such as credentials confirmation to remember which task should
3696 * be resumed when complete.
3697 *
3698 * @hide
3699 */
3700 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3701
3702 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003703 * An Intent[] describing additional, alternate choices you would like shown with
3704 * {@link #ACTION_CHOOSER}.
3705 *
3706 * <p>An app may be capable of providing several different payload types to complete a
3707 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3708 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3709 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3710 * photo data or a hosted link where the photos can be viewed.</p>
3711 *
3712 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3713 * first/primary/preferred intent in the set. Additional intents specified in
3714 * this extra are ordered; by default intents that appear earlier in the array will be
3715 * preferred over intents that appear later in the array as matches for the same
3716 * target component. To alter this preference, a calling app may also supply
3717 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3718 */
3719 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3720
3721 /**
3722 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3723 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3724 *
3725 * <p>An app preparing an action for another app to complete may wish to allow the user to
3726 * disambiguate between several options for completing the action based on the chosen target
3727 * or otherwise refine the action before it is invoked.
3728 * </p>
3729 *
3730 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3731 * <ul>
3732 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3733 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3734 * chosen target beyond the first</li>
3735 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3736 * should fill in and send once the disambiguation is complete</li>
3737 * </ul>
3738 */
3739 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3740 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3741
3742 /**
3743 * A {@link ResultReceiver} used to return data back to the sender.
3744 *
3745 * <p>Used to complete an app-specific
3746 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3747 *
3748 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3749 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3750 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3751 * when the user selects a target component from the chooser. It is up to the recipient
3752 * to send a result to this ResultReceiver to signal that disambiguation is complete
3753 * and that the chooser should invoke the user's choice.</p>
3754 *
3755 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3756 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3757 * to match and fill in the final Intent or ChooserTarget before starting it.
3758 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3759 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3760 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3761 *
3762 * <p>The result code passed to the ResultReceiver should be
3763 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3764 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3765 * the chooser should finish without starting a target.</p>
3766 */
3767 public static final String EXTRA_RESULT_RECEIVER
3768 = "android.intent.extra.RESULT_RECEIVER";
3769
3770 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003771 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003772 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003773 */
3774 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3775
3776 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003777 * A Parcelable[] of {@link Intent} or
3778 * {@link android.content.pm.LabeledIntent} objects as set with
3779 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3780 * a the front of the list of choices, when shown to the user with a
3781 * {@link #ACTION_CHOOSER}.
3782 */
3783 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3784
3785 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003786 * A {@link IntentSender} to start after ephemeral installation success.
3787 * @hide
3788 */
3789 @SystemApi
3790 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3791
3792 /**
3793 * A {@link IntentSender} to start after ephemeral installation failure.
3794 * @hide
3795 */
3796 @SystemApi
3797 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3798
3799 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003800 * A Bundle forming a mapping of potential target package names to different extras Bundles
3801 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3802 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3803 * be currently installed on the device.
3804 *
3805 * <p>An application may choose to provide alternate extras for the case where a user
3806 * selects an activity from a predetermined set of target packages. If the activity
3807 * the user selects from the chooser belongs to a package with its package name as
3808 * a key in this bundle, the corresponding extras for that package will be merged with
3809 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3810 * extra has the same key as an extra already present in the intent it will overwrite
3811 * the extra from the intent.</p>
3812 *
3813 * <p><em>Examples:</em>
3814 * <ul>
3815 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3816 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3817 * parameters for that target.</li>
3818 * <li>An application may offer additional metadata for known targets of a given intent
3819 * to pass along information only relevant to that target such as account or content
3820 * identifiers already known to that application.</li>
3821 * </ul></p>
3822 */
3823 public static final String EXTRA_REPLACEMENT_EXTRAS =
3824 "android.intent.extra.REPLACEMENT_EXTRAS";
3825
3826 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003827 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3828 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3829 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3830 * {@link ComponentName} of the chosen component.
3831 *
3832 * <p>In some situations this callback may never come, for example if the user abandons
3833 * the chooser, switches to another task or any number of other reasons. Apps should not
3834 * be written assuming that this callback will always occur.</p>
3835 */
3836 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3837 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3838
3839 /**
3840 * The {@link ComponentName} chosen by the user to complete an action.
3841 *
3842 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3843 */
3844 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3845
3846 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003847 * A {@link android.view.KeyEvent} object containing the event that
3848 * triggered the creation of the Intent it is in.
3849 */
3850 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3851
3852 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003853 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3854 * before shutting down.
3855 *
3856 * {@hide}
3857 */
3858 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3859
3860 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003861 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3862 * requested by the user.
3863 *
3864 * {@hide}
3865 */
3866 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3867 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3868
3869 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003870 * 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 -07003871 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3872 * of restarting the application.
3873 */
3874 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3875
3876 /**
3877 * A String holding the phone number originally entered in
3878 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3879 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3880 */
3881 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003882
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003883 /**
3884 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3885 * intents to supply the uid the package had been assigned. Also an optional
3886 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3887 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3888 * purpose.
3889 */
3890 public static final String EXTRA_UID = "android.intent.extra.UID";
3891
3892 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003893 * @hide String array of package names.
3894 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003895 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003896 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3897
3898 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003899 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3900 * intents to indicate whether this represents a full uninstall (removing
3901 * both the code and its data) or a partial uninstall (leaving its data,
3902 * implying that this is an update).
3903 */
3904 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003905
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003906 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003907 * @hide
3908 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3909 * intents to indicate that at this point the package has been removed for
3910 * all users on the device.
3911 */
3912 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3913 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3914
3915 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003916 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3917 * intents to indicate that this is a replacement of the package, so this
3918 * broadcast will immediately be followed by an add broadcast for a
3919 * different version of the same package.
3920 */
3921 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003922
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003923 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003924 * Used as an int extra field in {@link android.app.AlarmManager} intents
3925 * to tell the application being invoked how many pending alarms are being
3926 * delievered with the intent. For one-shot alarms this will always be 1.
3927 * For recurring alarms, this might be greater than 1 if the device was
3928 * asleep or powered off at the time an earlier alarm would have been
3929 * delivered.
3930 */
3931 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003932
Jacek Surazski86b6c532009-05-13 14:38:28 +02003933 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003934 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3935 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003936 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3937 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003938 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3939 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3940 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003941 */
3942 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3943
3944 /**
3945 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3946 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003947 */
3948 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3949
3950 /**
3951 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3952 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003953 */
3954 public static final int EXTRA_DOCK_STATE_DESK = 1;
3955
3956 /**
3957 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3958 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003959 */
3960 public static final int EXTRA_DOCK_STATE_CAR = 2;
3961
3962 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003963 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3964 * to represent that the phone is in a analog (low end) dock.
3965 */
3966 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3967
3968 /**
3969 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3970 * to represent that the phone is in a digital (high end) dock.
3971 */
3972 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3973
3974 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003975 * Boolean that can be supplied as meta-data with a dock activity, to
3976 * indicate that the dock should take over the home key when it is active.
3977 */
3978 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003979
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003980 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003981 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3982 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003983 */
3984 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3985
3986 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003987 * Used in the extra field in the remote intent. It's astring token passed with the
3988 * remote intent.
3989 */
3990 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3991 "android.intent.extra.remote_intent_token";
3992
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003993 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003994 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003995 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003996 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003997 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003998 "android.intent.extra.changed_component_name";
3999
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004000 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004001 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004002 * and contains a string array of all of the components that have changed. If
4003 * the state of the overall package has changed, then it will contain an entry
4004 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004005 */
4006 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4007 "android.intent.extra.changed_component_name_list";
4008
4009 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004010 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004011 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004012 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4013 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4014 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004015 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004016 */
4017 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4018 "android.intent.extra.changed_package_list";
4019
4020 /**
4021 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004022 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4023 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004024 * and contains an integer array of uids of all of the components
4025 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004026 */
4027 public static final String EXTRA_CHANGED_UID_LIST =
4028 "android.intent.extra.changed_uid_list";
4029
4030 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004031 * @hide
4032 * Magic extra system code can use when binding, to give a label for
4033 * who it is that has bound to a service. This is an integer giving
4034 * a framework string resource that can be displayed to the user.
4035 */
4036 public static final String EXTRA_CLIENT_LABEL =
4037 "android.intent.extra.client_label";
4038
4039 /**
4040 * @hide
4041 * Magic extra system code can use when binding, to give a PendingIntent object
4042 * that can be launched for the user to disable the system's use of this
4043 * service.
4044 */
4045 public static final String EXTRA_CLIENT_INTENT =
4046 "android.intent.extra.client_intent";
4047
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004048 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004049 * Extra used to indicate that an intent should only return data that is on
4050 * the local device. This is a boolean extra; the default is false. If true,
4051 * an implementation should only allow the user to select data that is
4052 * already on the device, not requiring it be downloaded from a remote
4053 * service when opened.
4054 *
4055 * @see #ACTION_GET_CONTENT
4056 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004057 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004058 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004059 */
4060 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004061 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004062
Amith Yamasani13593602012-03-22 16:16:17 -07004063 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004064 * Extra used to indicate that an intent can allow the user to select and
4065 * return multiple items. This is a boolean extra; the default is false. If
4066 * true, an implementation is allowed to present the user with a UI where
4067 * they can pick multiple items that are all returned to the caller. When
4068 * this happens, they should be returned as the {@link #getClipData()} part
4069 * of the result Intent.
4070 *
4071 * @see #ACTION_GET_CONTENT
4072 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004073 */
4074 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004075 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004076
4077 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004078 * The integer userHandle carried with broadcast intents related to addition, removal and
4079 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4080 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4081 *
Amith Yamasani13593602012-03-22 16:16:17 -07004082 * @hide
4083 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004084 public static final String EXTRA_USER_HANDLE =
4085 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004086
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004087 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004088 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4089 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4090 */
4091 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004092 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004093
4094 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004095 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004096 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4097 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004098 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004099 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4100
4101 /**
4102 * Extra sent in the intent to the BroadcastReceiver that handles
4103 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4104 * the restrictions as key/value pairs.
4105 */
4106 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4107 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004108
Amith Yamasani86118ba2013-03-28 14:33:16 -07004109 /**
4110 * Extra used in the response from a BroadcastReceiver that handles
4111 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4112 */
4113 public static final String EXTRA_RESTRICTIONS_INTENT =
4114 "android.intent.extra.restrictions_intent";
4115
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004116 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004117 * Extra used to communicate a set of acceptable MIME types. The type of the
4118 * extra is {@code String[]}. Values may be a combination of concrete MIME
4119 * types (such as "image/png") and/or partial MIME types (such as
4120 * "audio/*").
4121 *
4122 * @see #ACTION_GET_CONTENT
4123 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004124 */
4125 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4126
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004127 /**
4128 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4129 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004130 * When this is true, hardware devices can use this information to determine that
4131 * they shouldn't do a complete shutdown of their device since this is not a
4132 * complete shutdown down to the kernel, but only user space restarting.
4133 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004134 */
4135 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4136 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4137
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004138 /**
4139 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4140 * user has set their time format preferences to the 24 hour format.
4141 *
4142 * @hide for internal use only.
4143 */
4144 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4145 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4146
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004147 /** {@hide} */
4148 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4149
Rubin Xue8490f12015-06-25 12:17:48 +01004150 /** {@hide} */
4151 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4152
Santos Cordon15a13782015-03-31 18:32:31 -07004153 /**
4154 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4155 * activation request.
4156 * TODO: Add information about the structure and response data used with the pending intent.
4157 * @hide
4158 */
4159 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4160 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4161
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004162 /**
4163 * Optional index with semantics depending on the intent action.
4164 * @see #ACTION_QUICK_VIEW
4165 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004166 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4167
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004168 /**
4169 * Optional boolean extra indicating whether quiet mode has been switched on or off.
4170 */
4171 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004172
4173 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004174 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004175 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004176 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4177 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004178 *
4179 * @hide
4180 */
4181 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4182 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4183
4184 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004185 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004186 * to represent that a video codec is allowed to use.
4187 *
4188 * @hide
4189 */
4190 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4191
4192 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004193 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004194 * to represent that a audio codec is allowed to use.
4195 *
4196 * @hide
4197 */
4198 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4199
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004200 // ---------------------------------------------------------------------
4201 // ---------------------------------------------------------------------
4202 // Intent flags (see mFlags variable).
4203
Tor Norbyed9273d62013-05-30 15:59:53 -07004204 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004205 @IntDef(flag = true, value = {
4206 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4207 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004208 @Retention(RetentionPolicy.SOURCE)
4209 public @interface GrantUriMode {}
4210
Jeff Sharkey846318a2014-04-04 12:12:41 -07004211 /** @hide */
4212 @IntDef(flag = true, value = {
4213 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4214 @Retention(RetentionPolicy.SOURCE)
4215 public @interface AccessUriMode {}
4216
4217 /**
4218 * Test if given mode flags specify an access mode, which must be at least
4219 * read and/or write.
4220 *
4221 * @hide
4222 */
4223 public static boolean isAccessUriMode(int modeFlags) {
4224 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4225 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4226 }
4227
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004228 /**
4229 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004230 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004231 * specified in its ClipData. When applying to an Intent's ClipData,
4232 * all URIs as well as recursive traversals through data or other ClipData
4233 * in Intent items will be granted; only the grant flags of the top-level
4234 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004235 */
4236 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4237 /**
4238 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004239 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004240 * specified in its ClipData. When applying to an Intent's ClipData,
4241 * all URIs as well as recursive traversals through data or other ClipData
4242 * in Intent items will be granted; only the grant flags of the top-level
4243 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004244 */
4245 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4246 /**
4247 * Can be set by the caller to indicate that this Intent is coming from
4248 * a background operation, not from direct user interaction.
4249 */
4250 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4251 /**
4252 * A flag you can enable for debugging: when set, log messages will be
4253 * printed during the resolution of this intent to show you what has
4254 * been found to create the final resolved list.
4255 */
4256 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004257 /**
4258 * If set, this intent will not match any components in packages that
4259 * are currently stopped. If this is not set, then the default behavior
4260 * is to include such applications in the result.
4261 */
4262 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4263 /**
4264 * If set, this intent will always match any components in packages that
4265 * are currently stopped. This is the default behavior when
4266 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4267 * flags are set, this one wins (it allows overriding of exclude for
4268 * places where the framework may automatically set the exclude flag).
4269 */
4270 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004271
4272 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004273 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004274 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004275 * persisted across device reboots until explicitly revoked with
4276 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4277 * grant for possible persisting; the receiving application must call
4278 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4279 * actually persist.
4280 *
4281 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4282 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4283 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004284 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004285 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004286 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004287
4288 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004289 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4290 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4291 * applies to any URI that is a prefix match against the original granted
4292 * URI. (Without this flag, the URI must match exactly for access to be
4293 * granted.) Another URI is considered a prefix match only when scheme,
4294 * authority, and all path segments defined by the prefix are an exact
4295 * match.
4296 */
4297 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4298
4299 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004300 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004301 * homework and verified that they correctly handle packages and components
4302 * that come and go over time. In particular:
4303 * <ul>
4304 * <li>Apps installed on external storage, which will appear to be
4305 * uninstalled while the the device is ejected.
4306 * <li>Apps with encryption unaware components, which will appear to not
4307 * exist while the device is locked.
4308 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004309 *
4310 * @hide
4311 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004312 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004313
4314 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004315 * If set, the new activity is not kept in the history stack. As soon as
4316 * the user navigates away from it, the activity is finished. This may also
4317 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4318 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004319 *
4320 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4321 * is never invoked when the current activity starts a new activity which
4322 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004323 */
4324 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4325 /**
4326 * If set, the activity will not be launched if it is already running
4327 * at the top of the history stack.
4328 */
4329 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4330 /**
4331 * If set, this activity will become the start of a new task on this
4332 * history stack. A task (from the activity that started it to the
4333 * next task activity) defines an atomic group of activities that the
4334 * user can move to. Tasks can be moved to the foreground and background;
4335 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004336 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004337 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4338 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004339 *
4340 * <p>This flag is generally used by activities that want
4341 * to present a "launcher" style behavior: they give the user a list of
4342 * separate things that can be done, which otherwise run completely
4343 * independently of the activity launching them.
4344 *
4345 * <p>When using this flag, if a task is already running for the activity
4346 * you are now starting, then a new activity will not be started; instead,
4347 * the current task will simply be brought to the front of the screen with
4348 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4349 * to disable this behavior.
4350 *
4351 * <p>This flag can not be used when the caller is requesting a result from
4352 * the activity being launched.
4353 */
4354 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4355 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004356 * This flag is used to create a new task and launch an activity into it.
4357 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4358 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4359 * search through existing tasks for ones matching this Intent. Only if no such
4360 * task is found would a new task be created. When paired with
4361 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4362 * the search for a matching task and unconditionally start a new task.
4363 *
4364 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4365 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004366 * top-level application launcher.</strong> Used in conjunction with
4367 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4368 * behavior of bringing an existing task to the foreground. When set,
4369 * a new task is <em>always</em> started to host the Activity for the
4370 * Intent, regardless of whether there is already an existing task running
4371 * the same thing.
4372 *
4373 * <p><strong>Because the default system does not include graphical task management,
4374 * you should not use this flag unless you provide some way for a user to
4375 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004376 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004377 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4378 * creating new document tasks.
4379 *
4380 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004381 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004382 *
Scott Main7aee61f2011-02-08 11:25:01 -08004383 * <p>See
4384 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4385 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004386 *
4387 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4388 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004389 */
4390 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4391 /**
4392 * If set, and the activity being launched is already running in the
4393 * current task, then instead of launching a new instance of that activity,
4394 * all of the other activities on top of it will be closed and this Intent
4395 * will be delivered to the (now on top) old activity as a new Intent.
4396 *
4397 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4398 * If D calls startActivity() with an Intent that resolves to the component
4399 * of activity B, then C and D will be finished and B receive the given
4400 * Intent, resulting in the stack now being: A, B.
4401 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004402 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004403 * either receive the new intent you are starting here in its
4404 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004405 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004406 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4407 * the same intent, then it will be finished and re-created; for all other
4408 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4409 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004410 *
4411 * <p>This launch mode can also be used to good effect in conjunction with
4412 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4413 * of a task, it will bring any currently running instance of that task
4414 * to the foreground, and then clear it to its root state. This is
4415 * especially useful, for example, when launching an activity from the
4416 * notification manager.
4417 *
Scott Main7aee61f2011-02-08 11:25:01 -08004418 * <p>See
4419 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4420 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004421 */
4422 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4423 /**
4424 * If set and this intent is being used to launch a new activity from an
4425 * existing one, then the reply target of the existing activity will be
4426 * transfered to the new activity. This way the new activity can call
4427 * {@link android.app.Activity#setResult} and have that result sent back to
4428 * the reply target of the original activity.
4429 */
4430 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4431 /**
4432 * If set and this intent is being used to launch a new activity from an
4433 * existing one, the current activity will not be counted as the top
4434 * activity for deciding whether the new intent should be delivered to
4435 * the top instead of starting a new one. The previous activity will
4436 * be used as the top, with the assumption being that the current activity
4437 * will finish itself immediately.
4438 */
4439 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4440 /**
4441 * If set, the new activity is not kept in the list of recently launched
4442 * activities.
4443 */
4444 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4445 /**
4446 * This flag is not normally set by application code, but set for you by
4447 * the system as described in the
4448 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4449 * launchMode} documentation for the singleTask mode.
4450 */
4451 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4452 /**
4453 * If set, and this activity is either being started in a new task or
4454 * bringing to the top an existing task, then it will be launched as
4455 * the front door of the task. This will result in the application of
4456 * any affinities needed to have that task in the proper state (either
4457 * moving activities to or from it), or simply resetting that task to
4458 * its initial state if needed.
4459 */
4460 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4461 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004462 * This flag is not normally set by application code, but set for you by
4463 * the system if this activity is being launched from history
4464 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004465 */
4466 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004467 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004468 * @deprecated As of API 21 this performs identically to
4469 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004470 */
4471 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004472 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004473 * This flag is used to open a document into a new task rooted at the activity launched
4474 * by this Intent. Through the use of this flag, or its equivalent attribute,
4475 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004476 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004477 *
Craig Mautner026596b2014-05-21 15:35:44 -07004478 * <p>The use of the activity attribute form of this,
4479 * {@link android.R.attr#documentLaunchMode}, is
4480 * preferred over the Intent flag described here. The attribute form allows the
4481 * Activity to specify multiple document behavior for all launchers of the Activity
4482 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004483 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004484 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4485 * it is kept after the activity is finished is different than the use of
4486 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4487 * this flag is being used to create a new recents entry, then by default that entry
4488 * will be removed once the activity is finished. You can modify this behavior with
4489 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4490 *
Craig Mautner026596b2014-05-21 15:35:44 -07004491 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4492 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4493 * equivalent of the Activity manifest specifying {@link
4494 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4495 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4496 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004497 *
Craig Mautner026596b2014-05-21 15:35:44 -07004498 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004499 *
Craig Mautner026596b2014-05-21 15:35:44 -07004500 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004501 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4502 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004503 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004504 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004505 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004506 * callback from occurring on the current frontmost activity before it is
4507 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004508 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004509 * <p>Typically, an activity can rely on that callback to indicate that an
4510 * explicit user action has caused their activity to be moved out of the
4511 * foreground. The callback marks an appropriate point in the activity's
4512 * lifecycle for it to dismiss any notifications that it intends to display
4513 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004514 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004515 * <p>If an activity is ever started via any non-user-driven events such as
4516 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4517 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004518 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004519 */
4520 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004521 /**
4522 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4523 * this flag will cause the launched activity to be brought to the front of its
4524 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004525 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004526 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4527 * If D calls startActivity() with an Intent that resolves to the component
4528 * of activity B, then B will be brought to the front of the history stack,
4529 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004530 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004531 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004532 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004533 */
4534 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004535 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004536 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4537 * this flag will prevent the system from applying an activity transition
4538 * animation to go to the next activity state. This doesn't mean an
4539 * animation will never run -- if another activity change happens that doesn't
4540 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004541 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004542 * when you are going to do a series of activity operations but the
4543 * animation seen by the user shouldn't be driven by the first activity
4544 * change but rather a later one.
4545 */
4546 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4547 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004548 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4549 * this flag will cause any existing task that would be associated with the
4550 * activity to be cleared before the activity is started. That is, the activity
4551 * becomes the new root of an otherwise empty task, and any old activities
4552 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4553 */
4554 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4555 /**
4556 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4557 * this flag will cause a newly launching task to be placed on top of the current
4558 * home activity task (if there is one). That is, pressing back from the task
4559 * will always return the user to home even if that was not the last activity they
4560 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4561 */
4562 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4563 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004564 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4565 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004566 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004567 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004568 * this flag. When set and the task's activity is finished, the recents
4569 * entry will remain in the interface for the user to re-launch it, like a
4570 * recents entry for a top-level application.
4571 * <p>
4572 * The receiving activity can override this request with
4573 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4574 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004575 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004576 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004577 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004578
4579 /**
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004580 * This flag is only used in the multi-window mode. The new activity will be displayed on
4581 * the other side than the one that is launching it. This can only be used in conjunction with
4582 * {@link #FLAG_ACTIVITY_NEW_TASK}.
4583 */
4584 public static final int FLAG_ACTIVITY_LAUNCH_TO_SIDE = 0x00001000;
4585
4586 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004587 * If set, when sending a broadcast only registered receivers will be
4588 * called -- no BroadcastReceiver components will be launched.
4589 */
4590 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004591 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004592 * If set, when sending a broadcast the new broadcast will replace
4593 * any existing pending broadcast that matches it. Matching is defined
4594 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4595 * true for the intents of the two broadcasts. When a match is found,
4596 * the new broadcast (and receivers associated with it) will replace the
4597 * existing one in the pending broadcast list, remaining at the same
4598 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004599 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004600 * <p>This flag is most typically used with sticky broadcasts, which
4601 * only care about delivering the most recent values of the broadcast
4602 * to their receivers.
4603 */
4604 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4605 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004606 * If set, when sending a broadcast the recipient is allowed to run at
4607 * foreground priority, with a shorter timeout interval. During normal
4608 * broadcasts the receivers are not automatically hoisted out of the
4609 * background priority class.
4610 */
4611 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4612 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004613 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4614 * They can still propagate results through to later receivers, but they can not prevent
4615 * later receivers from seeing the broadcast.
4616 */
4617 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4618 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004619 * If set, when sending a broadcast <i>before boot has completed</i> only
4620 * registered receivers will be called -- no BroadcastReceiver components
4621 * will be launched. Sticky intent state will be recorded properly even
4622 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4623 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004624 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004625 * <p>This flag is only for use by system sevices as a convenience to
4626 * avoid having to implement a more complex mechanism around detection
4627 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004628 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004629 * @hide
4630 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004631 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004632 /**
4633 * Set when this broadcast is for a boot upgrade, a special mode that
4634 * allows the broadcast to be sent before the system is ready and launches
4635 * the app process with no providers running in it.
4636 * @hide
4637 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004638 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004639 /**
4640 * If set, the broadcast will always go to manifest receivers in background (cached
4641 * or not running) apps, regardless of whether that would be done by default. By
4642 * default they will only receive broadcasts if the broadcast has specified an
4643 * explicit component or package name.
4644 * @hide
4645 */
4646 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4647 /**
4648 * If set, the broadcast will never go to manifest receivers in background (cached
4649 * or not running) apps, regardless of whether that would be done by default. By
4650 * default they will receive broadcasts if the broadcast has specified an
4651 * explicit component or package name.
4652 * @hide
4653 */
4654 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004655
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004656 /**
4657 * @hide Flags that can't be changed with PendingIntent.
4658 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004659 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4660 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4661 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004662
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004663 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004664 // ---------------------------------------------------------------------
4665 // toUri() and parseUri() options.
4666
4667 /**
4668 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4669 * always has the "intent:" scheme. This syntax can be used when you want
4670 * to later disambiguate between URIs that are intended to describe an
4671 * Intent vs. all others that should be treated as raw URIs. When used
4672 * with {@link #parseUri}, any other scheme will result in a generic
4673 * VIEW action for that raw URI.
4674 */
4675 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004676
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004677 /**
4678 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4679 * always has the "android-app:" scheme. This is a variation of
4680 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4681 * http/https URI being delivered to a specific package name. The format
4682 * is:
4683 *
4684 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004685 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004686 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004687 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4688 * you must also include a scheme; including a path also requires both a host and a scheme.
4689 * The final #Intent; fragment can be used without a scheme, host, or path.
4690 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004691 * used with intents that have a {@link #setSelector}, since the base intent
4692 * will always have an explicit package name.</p>
4693 *
4694 * <p>Some examples of how this scheme maps to Intent objects:</p>
4695 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4696 * <colgroup align="left" />
4697 * <colgroup align="left" />
4698 * <thead>
4699 * <tr><th>URI</th> <th>Intent</th></tr>
4700 * </thead>
4701 *
4702 * <tbody>
4703 * <tr><td><code>android-app://com.example.app</code></td>
4704 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4705 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4706 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4707 * </table></td>
4708 * </tr>
4709 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4710 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4711 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4712 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4713 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4714 * </table></td>
4715 * </tr>
4716 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4717 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4718 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4719 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4720 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4721 * </table></td>
4722 * </tr>
4723 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4724 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4725 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4726 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4727 * </table></td>
4728 * </tr>
4729 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4730 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4731 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4732 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4733 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4734 * </table></td>
4735 * </tr>
4736 * <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>
4737 * <td><table border="" style="margin:0" >
4738 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4739 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4740 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4741 * </table></td>
4742 * </tr>
4743 * </tbody>
4744 * </table>
4745 */
4746 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4747
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004748 /**
4749 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4750 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4751 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4752 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4753 * generated Intent can not cause unexpected data access to happen.
4754 *
4755 * <p>If you do not trust the source of the URI being parsed, you should still do further
4756 * processing to protect yourself from it. In particular, when using it to start an
4757 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4758 * that can handle it.</p>
4759 */
4760 public static final int URI_ALLOW_UNSAFE = 1<<2;
4761
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004762 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004763
4764 private String mAction;
4765 private Uri mData;
4766 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004767 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004768 private ComponentName mComponent;
4769 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004770 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004771 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004772 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004773 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004774 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004775 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004776
4777 // ---------------------------------------------------------------------
4778
4779 /**
4780 * Create an empty intent.
4781 */
4782 public Intent() {
4783 }
4784
4785 /**
4786 * Copy constructor.
4787 */
4788 public Intent(Intent o) {
4789 this.mAction = o.mAction;
4790 this.mData = o.mData;
4791 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004792 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004793 this.mComponent = o.mComponent;
4794 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004795 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004796 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004797 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004798 }
4799 if (o.mExtras != null) {
4800 this.mExtras = new Bundle(o.mExtras);
4801 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004802 if (o.mSourceBounds != null) {
4803 this.mSourceBounds = new Rect(o.mSourceBounds);
4804 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004805 if (o.mSelector != null) {
4806 this.mSelector = new Intent(o.mSelector);
4807 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004808 if (o.mClipData != null) {
4809 this.mClipData = new ClipData(o.mClipData);
4810 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004811 }
4812
4813 @Override
4814 public Object clone() {
4815 return new Intent(this);
4816 }
4817
4818 private Intent(Intent o, boolean all) {
4819 this.mAction = o.mAction;
4820 this.mData = o.mData;
4821 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004822 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004823 this.mComponent = o.mComponent;
4824 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004825 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004826 }
4827 }
4828
4829 /**
4830 * Make a clone of only the parts of the Intent that are relevant for
4831 * filter matching: the action, data, type, component, and categories.
4832 */
4833 public Intent cloneFilter() {
4834 return new Intent(this, false);
4835 }
4836
4837 /**
4838 * Create an intent with a given action. All other fields (data, type,
4839 * class) are null. Note that the action <em>must</em> be in a
4840 * namespace because Intents are used globally in the system -- for
4841 * example the system VIEW action is android.intent.action.VIEW; an
4842 * application's custom action would be something like
4843 * com.google.app.myapp.CUSTOM_ACTION.
4844 *
4845 * @param action The Intent action, such as ACTION_VIEW.
4846 */
4847 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004848 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004849 }
4850
4851 /**
4852 * Create an intent with a given action and for a given data url. Note
4853 * that the action <em>must</em> be in a namespace because Intents are
4854 * used globally in the system -- for example the system VIEW action is
4855 * android.intent.action.VIEW; an application's custom action would be
4856 * something like com.google.app.myapp.CUSTOM_ACTION.
4857 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004858 * <p><em>Note: scheme and host name matching in the Android framework is
4859 * case-sensitive, unlike the formal RFC. As a result,
4860 * you should always ensure that you write your Uri with these elements
4861 * using lower case letters, and normalize any Uris you receive from
4862 * outside of Android to ensure the scheme and host is lower case.</em></p>
4863 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004864 * @param action The Intent action, such as ACTION_VIEW.
4865 * @param uri The Intent data URI.
4866 */
4867 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004868 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004869 mData = uri;
4870 }
4871
4872 /**
4873 * Create an intent for a specific component. All other fields (action, data,
4874 * type, class) are null, though they can be modified later with explicit
4875 * calls. This provides a convenient way to create an intent that is
4876 * intended to execute a hard-coded class name, rather than relying on the
4877 * system to find an appropriate class for you; see {@link #setComponent}
4878 * for more information on the repercussions of this.
4879 *
4880 * @param packageContext A Context of the application package implementing
4881 * this class.
4882 * @param cls The component class that is to be used for the intent.
4883 *
4884 * @see #setClass
4885 * @see #setComponent
4886 * @see #Intent(String, android.net.Uri , Context, Class)
4887 */
4888 public Intent(Context packageContext, Class<?> cls) {
4889 mComponent = new ComponentName(packageContext, cls);
4890 }
4891
4892 /**
4893 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004894 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004895 * construct the Intent and then calling {@link #setClass} to set its
4896 * class.
4897 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004898 * <p><em>Note: scheme and host name matching in the Android framework is
4899 * case-sensitive, unlike the formal RFC. As a result,
4900 * you should always ensure that you write your Uri with these elements
4901 * using lower case letters, and normalize any Uris you receive from
4902 * outside of Android to ensure the scheme and host is lower case.</em></p>
4903 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004904 * @param action The Intent action, such as ACTION_VIEW.
4905 * @param uri The Intent data URI.
4906 * @param packageContext A Context of the application package implementing
4907 * this class.
4908 * @param cls The component class that is to be used for the intent.
4909 *
4910 * @see #Intent(String, android.net.Uri)
4911 * @see #Intent(Context, Class)
4912 * @see #setClass
4913 * @see #setComponent
4914 */
4915 public Intent(String action, Uri uri,
4916 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004917 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004918 mData = uri;
4919 mComponent = new ComponentName(packageContext, cls);
4920 }
4921
4922 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004923 * Create an intent to launch the main (root) activity of a task. This
4924 * is the Intent that is started when the application's is launched from
4925 * Home. For anything else that wants to launch an application in the
4926 * same way, it is important that they use an Intent structured the same
4927 * way, and can use this function to ensure this is the case.
4928 *
4929 * <p>The returned Intent has the given Activity component as its explicit
4930 * component, {@link #ACTION_MAIN} as its action, and includes the
4931 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4932 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4933 * to do that through {@link #addFlags(int)} on the returned Intent.
4934 *
4935 * @param mainActivity The main activity component that this Intent will
4936 * launch.
4937 * @return Returns a newly created Intent that can be used to launch the
4938 * activity as a main application entry.
4939 *
4940 * @see #setClass
4941 * @see #setComponent
4942 */
4943 public static Intent makeMainActivity(ComponentName mainActivity) {
4944 Intent intent = new Intent(ACTION_MAIN);
4945 intent.setComponent(mainActivity);
4946 intent.addCategory(CATEGORY_LAUNCHER);
4947 return intent;
4948 }
4949
4950 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004951 * Make an Intent for the main activity of an application, without
4952 * specifying a specific activity to run but giving a selector to find
4953 * the activity. This results in a final Intent that is structured
4954 * the same as when the application is launched from
4955 * Home. For anything else that wants to launch an application in the
4956 * same way, it is important that they use an Intent structured the same
4957 * way, and can use this function to ensure this is the case.
4958 *
4959 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4960 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4961 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4962 * to do that through {@link #addFlags(int)} on the returned Intent.
4963 *
4964 * @param selectorAction The action name of the Intent's selector.
4965 * @param selectorCategory The name of a category to add to the Intent's
4966 * selector.
4967 * @return Returns a newly created Intent that can be used to launch the
4968 * activity as a main application entry.
4969 *
4970 * @see #setSelector(Intent)
4971 */
4972 public static Intent makeMainSelectorActivity(String selectorAction,
4973 String selectorCategory) {
4974 Intent intent = new Intent(ACTION_MAIN);
4975 intent.addCategory(CATEGORY_LAUNCHER);
4976 Intent selector = new Intent();
4977 selector.setAction(selectorAction);
4978 selector.addCategory(selectorCategory);
4979 intent.setSelector(selector);
4980 return intent;
4981 }
4982
4983 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004984 * Make an Intent that can be used to re-launch an application's task
4985 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4986 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4987 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4988 *
4989 * @param mainActivity The activity component that is the root of the
4990 * task; this is the activity that has been published in the application's
4991 * manifest as the main launcher icon.
4992 *
4993 * @return Returns a newly created Intent that can be used to relaunch the
4994 * activity's task in its root state.
4995 */
4996 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4997 Intent intent = makeMainActivity(mainActivity);
4998 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4999 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5000 return intent;
5001 }
5002
5003 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005004 * Call {@link #parseUri} with 0 flags.
5005 * @deprecated Use {@link #parseUri} instead.
5006 */
5007 @Deprecated
5008 public static Intent getIntent(String uri) throws URISyntaxException {
5009 return parseUri(uri, 0);
5010 }
Tom Taylord4a47292009-12-21 13:59:18 -08005011
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005012 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005013 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005014 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005015 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005016 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005017 *
5018 * <p>The URI given here must not be relative -- that is, it must include
5019 * the scheme and full path.
5020 *
5021 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005022 * @param flags Additional processing flags. Either 0,
5023 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005024 *
5025 * @return Intent The newly created Intent object.
5026 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005027 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5028 * it bad (as parsed by the Uri class) or the Intent data within the
5029 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005030 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005031 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005032 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005033 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005034 int i = 0;
5035 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005036 final boolean androidApp = uri.startsWith("android-app:");
5037
5038 // Validate intent scheme if requested.
5039 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5040 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005041 Intent intent = new Intent(ACTION_VIEW);
5042 try {
5043 intent.setData(Uri.parse(uri));
5044 } catch (IllegalArgumentException e) {
5045 throw new URISyntaxException(uri, e.getMessage());
5046 }
5047 return intent;
5048 }
5049 }
Tom Taylord4a47292009-12-21 13:59:18 -08005050
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005051 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005052 // simple case
5053 if (i == -1) {
5054 if (!androidApp) {
5055 return new Intent(ACTION_VIEW, Uri.parse(uri));
5056 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005057
5058 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005059 } else if (!uri.startsWith("#Intent;", i)) {
5060 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005061 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005062 } else {
5063 i = -1;
5064 }
5065 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005066
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005067 // new format
5068 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005069 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005070 boolean explicitAction = false;
5071 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005072
5073 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005074 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005075 String data;
5076 if (i >= 0) {
5077 data = uri.substring(0, i);
5078 i += 8; // length of "#Intent;"
5079 } else {
5080 data = uri;
5081 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005082
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005083 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005084 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005085 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005086 if (eq < 0) eq = i-1;
5087 int semi = uri.indexOf(';', i);
5088 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005089
5090 // action
5091 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005092 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005093 if (!inSelector) {
5094 explicitAction = true;
5095 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005096 }
5097
5098 // categories
5099 else if (uri.startsWith("category=", i)) {
5100 intent.addCategory(value);
5101 }
5102
5103 // type
5104 else if (uri.startsWith("type=", i)) {
5105 intent.mType = value;
5106 }
5107
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005108 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005109 else if (uri.startsWith("launchFlags=", i)) {
5110 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005111 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5112 intent.mFlags &= ~IMMUTABLE_FLAGS;
5113 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005114 }
5115
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005116 // package
5117 else if (uri.startsWith("package=", i)) {
5118 intent.mPackage = value;
5119 }
5120
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005121 // component
5122 else if (uri.startsWith("component=", i)) {
5123 intent.mComponent = ComponentName.unflattenFromString(value);
5124 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005125
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005126 // scheme
5127 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005128 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005129 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005130 } else {
5131 scheme = value;
5132 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005133 }
5134
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005135 // source bounds
5136 else if (uri.startsWith("sourceBounds=", i)) {
5137 intent.mSourceBounds = Rect.unflattenFromString(value);
5138 }
5139
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005140 // selector
5141 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5142 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005143 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005144 }
5145
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005146 // extra
5147 else {
5148 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005149 // create Bundle if it doesn't already exist
5150 if (intent.mExtras == null) intent.mExtras = new Bundle();
5151 Bundle b = intent.mExtras;
5152 // add EXTRA
5153 if (uri.startsWith("S.", i)) b.putString(key, value);
5154 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5155 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5156 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5157 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5158 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5159 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5160 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5161 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5162 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5163 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005164
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005165 // move to the next item
5166 i = semi + 1;
5167 }
5168
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005169 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005170 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005171 if (baseIntent.mPackage == null) {
5172 baseIntent.setSelector(intent);
5173 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005174 intent = baseIntent;
5175 }
5176
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005177 if (data != null) {
5178 if (data.startsWith("intent:")) {
5179 data = data.substring(7);
5180 if (scheme != null) {
5181 data = scheme + ':' + data;
5182 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005183 } else if (data.startsWith("android-app:")) {
5184 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5185 // Correctly formed android-app, first part is package name.
5186 int end = data.indexOf('/', 14);
5187 if (end < 0) {
5188 // All we have is a package name.
5189 intent.mPackage = data.substring(14);
5190 if (!explicitAction) {
5191 intent.setAction(ACTION_MAIN);
5192 }
5193 data = "";
5194 } else {
5195 // Target the Intent at the given package name always.
5196 String authority = null;
5197 intent.mPackage = data.substring(14, end);
5198 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005199 if ((end+1) < data.length()) {
5200 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5201 // Found a scheme, remember it.
5202 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005203 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005204 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5205 // Found a authority, remember it.
5206 authority = data.substring(end+1, newEnd);
5207 end = newEnd;
5208 }
5209 } else {
5210 // All we have is a scheme.
5211 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005212 }
5213 }
5214 if (scheme == null) {
5215 // If there was no scheme, then this just targets the package.
5216 if (!explicitAction) {
5217 intent.setAction(ACTION_MAIN);
5218 }
5219 data = "";
5220 } else if (authority == null) {
5221 data = scheme + ":";
5222 } else {
5223 data = scheme + "://" + authority + data.substring(end);
5224 }
5225 }
5226 } else {
5227 data = "";
5228 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005229 }
Tom Taylord4a47292009-12-21 13:59:18 -08005230
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005231 if (data.length() > 0) {
5232 try {
5233 intent.mData = Uri.parse(data);
5234 } catch (IllegalArgumentException e) {
5235 throw new URISyntaxException(uri, e.getMessage());
5236 }
5237 }
5238 }
Tom Taylord4a47292009-12-21 13:59:18 -08005239
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005240 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005241
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005242 } catch (IndexOutOfBoundsException e) {
5243 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5244 }
5245 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005246
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005247 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005248 return getIntentOld(uri, 0);
5249 }
5250
5251 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005252 Intent intent;
5253
5254 int i = uri.lastIndexOf('#');
5255 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005256 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005257 final int intentFragmentStart = i;
5258 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005259
5260 i++;
5261
5262 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005263 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005264 i += 7;
5265 int j = uri.indexOf(')', i);
5266 action = uri.substring(i, j);
5267 i = j + 1;
5268 }
5269
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005270 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005271
5272 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005273 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005274 i += 11;
5275 int j = uri.indexOf(')', i);
5276 while (i < j) {
5277 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005278 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005279 if (i < sep) {
5280 intent.addCategory(uri.substring(i, sep));
5281 }
5282 i = sep + 1;
5283 }
5284 i = j + 1;
5285 }
5286
5287 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005288 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005289 i += 5;
5290 int j = uri.indexOf(')', i);
5291 intent.mType = uri.substring(i, j);
5292 i = j + 1;
5293 }
5294
5295 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005296 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005297 i += 12;
5298 int j = uri.indexOf(')', i);
5299 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005300 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5301 intent.mFlags &= ~IMMUTABLE_FLAGS;
5302 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005303 i = j + 1;
5304 }
5305
5306 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005307 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005308 i += 10;
5309 int j = uri.indexOf(')', i);
5310 int sep = uri.indexOf('!', i);
5311 if (sep >= 0 && sep < j) {
5312 String pkg = uri.substring(i, sep);
5313 String cls = uri.substring(sep + 1, j);
5314 intent.mComponent = new ComponentName(pkg, cls);
5315 }
5316 i = j + 1;
5317 }
5318
5319 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005320 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005321 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005322
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005323 final int closeParen = uri.indexOf(')', i);
5324 if (closeParen == -1) throw new URISyntaxException(uri,
5325 "EXTRA missing trailing ')'", i);
5326
5327 while (i < closeParen) {
5328 // fetch the key value
5329 int j = uri.indexOf('=', i);
5330 if (j <= i + 1 || i >= closeParen) {
5331 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5332 }
5333 char type = uri.charAt(i);
5334 i++;
5335 String key = uri.substring(i, j);
5336 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005337
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005338 // get type-value
5339 j = uri.indexOf('!', i);
5340 if (j == -1 || j >= closeParen) j = closeParen;
5341 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5342 String value = uri.substring(i, j);
5343 i = j;
5344
5345 // create Bundle if it doesn't already exist
5346 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005347
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005348 // add item to bundle
5349 try {
5350 switch (type) {
5351 case 'S':
5352 intent.mExtras.putString(key, Uri.decode(value));
5353 break;
5354 case 'B':
5355 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5356 break;
5357 case 'b':
5358 intent.mExtras.putByte(key, Byte.parseByte(value));
5359 break;
5360 case 'c':
5361 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5362 break;
5363 case 'd':
5364 intent.mExtras.putDouble(key, Double.parseDouble(value));
5365 break;
5366 case 'f':
5367 intent.mExtras.putFloat(key, Float.parseFloat(value));
5368 break;
5369 case 'i':
5370 intent.mExtras.putInt(key, Integer.parseInt(value));
5371 break;
5372 case 'l':
5373 intent.mExtras.putLong(key, Long.parseLong(value));
5374 break;
5375 case 's':
5376 intent.mExtras.putShort(key, Short.parseShort(value));
5377 break;
5378 default:
5379 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5380 }
5381 } catch (NumberFormatException e) {
5382 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5383 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005384
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005385 char ch = uri.charAt(i);
5386 if (ch == ')') break;
5387 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5388 i++;
5389 }
5390 }
5391
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005392 if (isIntentFragment) {
5393 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5394 } else {
5395 intent.mData = Uri.parse(uri);
5396 }
Tom Taylord4a47292009-12-21 13:59:18 -08005397
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005398 if (intent.mAction == null) {
5399 // By default, if no action is specified, then use VIEW.
5400 intent.mAction = ACTION_VIEW;
5401 }
5402
5403 } else {
5404 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5405 }
5406
5407 return intent;
5408 }
5409
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005410 /** @hide */
5411 public interface CommandOptionHandler {
5412 boolean handleOption(String opt, ShellCommand cmd);
5413 }
5414
5415 /** @hide */
5416 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5417 throws URISyntaxException {
5418 Intent intent = new Intent();
5419 Intent baseIntent = intent;
5420 boolean hasIntentInfo = false;
5421
5422 Uri data = null;
5423 String type = null;
5424
5425 String opt;
5426 while ((opt=cmd.getNextOption()) != null) {
5427 switch (opt) {
5428 case "-a":
5429 intent.setAction(cmd.getNextArgRequired());
5430 if (intent == baseIntent) {
5431 hasIntentInfo = true;
5432 }
5433 break;
5434 case "-d":
5435 data = Uri.parse(cmd.getNextArgRequired());
5436 if (intent == baseIntent) {
5437 hasIntentInfo = true;
5438 }
5439 break;
5440 case "-t":
5441 type = cmd.getNextArgRequired();
5442 if (intent == baseIntent) {
5443 hasIntentInfo = true;
5444 }
5445 break;
5446 case "-c":
5447 intent.addCategory(cmd.getNextArgRequired());
5448 if (intent == baseIntent) {
5449 hasIntentInfo = true;
5450 }
5451 break;
5452 case "-e":
5453 case "--es": {
5454 String key = cmd.getNextArgRequired();
5455 String value = cmd.getNextArgRequired();
5456 intent.putExtra(key, value);
5457 }
5458 break;
5459 case "--esn": {
5460 String key = cmd.getNextArgRequired();
5461 intent.putExtra(key, (String) null);
5462 }
5463 break;
5464 case "--ei": {
5465 String key = cmd.getNextArgRequired();
5466 String value = cmd.getNextArgRequired();
5467 intent.putExtra(key, Integer.decode(value));
5468 }
5469 break;
5470 case "--eu": {
5471 String key = cmd.getNextArgRequired();
5472 String value = cmd.getNextArgRequired();
5473 intent.putExtra(key, Uri.parse(value));
5474 }
5475 break;
5476 case "--ecn": {
5477 String key = cmd.getNextArgRequired();
5478 String value = cmd.getNextArgRequired();
5479 ComponentName cn = ComponentName.unflattenFromString(value);
5480 if (cn == null)
5481 throw new IllegalArgumentException("Bad component name: " + value);
5482 intent.putExtra(key, cn);
5483 }
5484 break;
5485 case "--eia": {
5486 String key = cmd.getNextArgRequired();
5487 String value = cmd.getNextArgRequired();
5488 String[] strings = value.split(",");
5489 int[] list = new int[strings.length];
5490 for (int i = 0; i < strings.length; i++) {
5491 list[i] = Integer.decode(strings[i]);
5492 }
5493 intent.putExtra(key, list);
5494 }
5495 break;
5496 case "--eial": {
5497 String key = cmd.getNextArgRequired();
5498 String value = cmd.getNextArgRequired();
5499 String[] strings = value.split(",");
5500 ArrayList<Integer> list = new ArrayList<>(strings.length);
5501 for (int i = 0; i < strings.length; i++) {
5502 list.add(Integer.decode(strings[i]));
5503 }
5504 intent.putExtra(key, list);
5505 }
5506 break;
5507 case "--el": {
5508 String key = cmd.getNextArgRequired();
5509 String value = cmd.getNextArgRequired();
5510 intent.putExtra(key, Long.valueOf(value));
5511 }
5512 break;
5513 case "--ela": {
5514 String key = cmd.getNextArgRequired();
5515 String value = cmd.getNextArgRequired();
5516 String[] strings = value.split(",");
5517 long[] list = new long[strings.length];
5518 for (int i = 0; i < strings.length; i++) {
5519 list[i] = Long.valueOf(strings[i]);
5520 }
5521 intent.putExtra(key, list);
5522 hasIntentInfo = true;
5523 }
5524 break;
5525 case "--elal": {
5526 String key = cmd.getNextArgRequired();
5527 String value = cmd.getNextArgRequired();
5528 String[] strings = value.split(",");
5529 ArrayList<Long> list = new ArrayList<>(strings.length);
5530 for (int i = 0; i < strings.length; i++) {
5531 list.add(Long.valueOf(strings[i]));
5532 }
5533 intent.putExtra(key, list);
5534 hasIntentInfo = true;
5535 }
5536 break;
5537 case "--ef": {
5538 String key = cmd.getNextArgRequired();
5539 String value = cmd.getNextArgRequired();
5540 intent.putExtra(key, Float.valueOf(value));
5541 hasIntentInfo = true;
5542 }
5543 break;
5544 case "--efa": {
5545 String key = cmd.getNextArgRequired();
5546 String value = cmd.getNextArgRequired();
5547 String[] strings = value.split(",");
5548 float[] list = new float[strings.length];
5549 for (int i = 0; i < strings.length; i++) {
5550 list[i] = Float.valueOf(strings[i]);
5551 }
5552 intent.putExtra(key, list);
5553 hasIntentInfo = true;
5554 }
5555 break;
5556 case "--efal": {
5557 String key = cmd.getNextArgRequired();
5558 String value = cmd.getNextArgRequired();
5559 String[] strings = value.split(",");
5560 ArrayList<Float> list = new ArrayList<>(strings.length);
5561 for (int i = 0; i < strings.length; i++) {
5562 list.add(Float.valueOf(strings[i]));
5563 }
5564 intent.putExtra(key, list);
5565 hasIntentInfo = true;
5566 }
5567 break;
5568 case "--esa": {
5569 String key = cmd.getNextArgRequired();
5570 String value = cmd.getNextArgRequired();
5571 // Split on commas unless they are preceeded by an escape.
5572 // The escape character must be escaped for the string and
5573 // again for the regex, thus four escape characters become one.
5574 String[] strings = value.split("(?<!\\\\),");
5575 intent.putExtra(key, strings);
5576 hasIntentInfo = true;
5577 }
5578 break;
5579 case "--esal": {
5580 String key = cmd.getNextArgRequired();
5581 String value = cmd.getNextArgRequired();
5582 // Split on commas unless they are preceeded by an escape.
5583 // The escape character must be escaped for the string and
5584 // again for the regex, thus four escape characters become one.
5585 String[] strings = value.split("(?<!\\\\),");
5586 ArrayList<String> list = new ArrayList<>(strings.length);
5587 for (int i = 0; i < strings.length; i++) {
5588 list.add(strings[i]);
5589 }
5590 intent.putExtra(key, list);
5591 hasIntentInfo = true;
5592 }
5593 break;
5594 case "--ez": {
5595 String key = cmd.getNextArgRequired();
5596 String value = cmd.getNextArgRequired().toLowerCase();
5597 // Boolean.valueOf() results in false for anything that is not "true", which is
5598 // error-prone in shell commands
5599 boolean arg;
5600 if ("true".equals(value) || "t".equals(value)) {
5601 arg = true;
5602 } else if ("false".equals(value) || "f".equals(value)) {
5603 arg = false;
5604 } else {
5605 try {
5606 arg = Integer.decode(value) != 0;
5607 } catch (NumberFormatException ex) {
5608 throw new IllegalArgumentException("Invalid boolean value: " + value);
5609 }
5610 }
5611
5612 intent.putExtra(key, arg);
5613 }
5614 break;
5615 case "-n": {
5616 String str = cmd.getNextArgRequired();
5617 ComponentName cn = ComponentName.unflattenFromString(str);
5618 if (cn == null)
5619 throw new IllegalArgumentException("Bad component name: " + str);
5620 intent.setComponent(cn);
5621 if (intent == baseIntent) {
5622 hasIntentInfo = true;
5623 }
5624 }
5625 break;
5626 case "-p": {
5627 String str = cmd.getNextArgRequired();
5628 intent.setPackage(str);
5629 if (intent == baseIntent) {
5630 hasIntentInfo = true;
5631 }
5632 }
5633 break;
5634 case "-f":
5635 String str = cmd.getNextArgRequired();
5636 intent.setFlags(Integer.decode(str).intValue());
5637 break;
5638 case "--grant-read-uri-permission":
5639 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5640 break;
5641 case "--grant-write-uri-permission":
5642 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5643 break;
5644 case "--grant-persistable-uri-permission":
5645 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5646 break;
5647 case "--grant-prefix-uri-permission":
5648 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5649 break;
5650 case "--exclude-stopped-packages":
5651 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5652 break;
5653 case "--include-stopped-packages":
5654 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5655 break;
5656 case "--debug-log-resolution":
5657 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5658 break;
5659 case "--activity-brought-to-front":
5660 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5661 break;
5662 case "--activity-clear-top":
5663 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5664 break;
5665 case "--activity-clear-when-task-reset":
5666 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5667 break;
5668 case "--activity-exclude-from-recents":
5669 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5670 break;
5671 case "--activity-launched-from-history":
5672 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5673 break;
5674 case "--activity-multiple-task":
5675 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5676 break;
5677 case "--activity-no-animation":
5678 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5679 break;
5680 case "--activity-no-history":
5681 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5682 break;
5683 case "--activity-no-user-action":
5684 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5685 break;
5686 case "--activity-previous-is-top":
5687 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5688 break;
5689 case "--activity-reorder-to-front":
5690 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5691 break;
5692 case "--activity-reset-task-if-needed":
5693 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5694 break;
5695 case "--activity-single-top":
5696 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5697 break;
5698 case "--activity-clear-task":
5699 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5700 break;
5701 case "--activity-task-on-home":
5702 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5703 break;
5704 case "--receiver-registered-only":
5705 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5706 break;
5707 case "--receiver-replace-pending":
5708 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5709 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005710 case "--receiver-foreground":
5711 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
5712 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005713 case "--selector":
5714 intent.setDataAndType(data, type);
5715 intent = new Intent();
5716 break;
5717 default:
5718 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5719 // Okay, caller handled this option.
5720 } else {
5721 throw new IllegalArgumentException("Unknown option: " + opt);
5722 }
5723 break;
5724 }
5725 }
5726 intent.setDataAndType(data, type);
5727
5728 final boolean hasSelector = intent != baseIntent;
5729 if (hasSelector) {
5730 // A selector was specified; fix up.
5731 baseIntent.setSelector(intent);
5732 intent = baseIntent;
5733 }
5734
5735 String arg = cmd.getNextArg();
5736 baseIntent = null;
5737 if (arg == null) {
5738 if (hasSelector) {
5739 // If a selector has been specified, and no arguments
5740 // have been supplied for the main Intent, then we can
5741 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5742 // need to have a component name specified yet, the
5743 // selector will take care of that.
5744 baseIntent = new Intent(Intent.ACTION_MAIN);
5745 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5746 }
5747 } else if (arg.indexOf(':') >= 0) {
5748 // The argument is a URI. Fully parse it, and use that result
5749 // to fill in any data not specified so far.
5750 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5751 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5752 } else if (arg.indexOf('/') >= 0) {
5753 // The argument is a component name. Build an Intent to launch
5754 // it.
5755 baseIntent = new Intent(Intent.ACTION_MAIN);
5756 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5757 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5758 } else {
5759 // Assume the argument is a package name.
5760 baseIntent = new Intent(Intent.ACTION_MAIN);
5761 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5762 baseIntent.setPackage(arg);
5763 }
5764 if (baseIntent != null) {
5765 Bundle extras = intent.getExtras();
5766 intent.replaceExtras((Bundle)null);
5767 Bundle uriExtras = baseIntent.getExtras();
5768 baseIntent.replaceExtras((Bundle)null);
5769 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5770 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5771 for (String c : cats) {
5772 baseIntent.removeCategory(c);
5773 }
5774 }
5775 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5776 if (extras == null) {
5777 extras = uriExtras;
5778 } else if (uriExtras != null) {
5779 uriExtras.putAll(extras);
5780 extras = uriExtras;
5781 }
5782 intent.replaceExtras(extras);
5783 hasIntentInfo = true;
5784 }
5785
5786 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5787 return intent;
5788 }
5789
5790 /** @hide */
5791 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5792 final String[] lines = new String[] {
5793 "<INTENT> specifications include these flags and arguments:",
5794 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5795 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5796 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5797 " [--esn <EXTRA_KEY> ...]",
5798 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5799 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5800 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5801 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5802 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5803 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5804 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5805 " (mutiple extras passed as Integer[])",
5806 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5807 " (mutiple extras passed as List<Integer>)",
5808 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5809 " (mutiple extras passed as Long[])",
5810 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5811 " (mutiple extras passed as List<Long>)",
5812 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5813 " (mutiple extras passed as Float[])",
5814 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5815 " (mutiple extras passed as List<Float>)",
5816 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5817 " (mutiple extras passed as String[]; to embed a comma into a string,",
5818 " escape it using \"\\,\")",
5819 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5820 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5821 " escape it using \"\\,\")",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005822 " [--f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005823 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5824 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5825 " [--debug-log-resolution] [--exclude-stopped-packages]",
5826 " [--include-stopped-packages]",
5827 " [--activity-brought-to-front] [--activity-clear-top]",
5828 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5829 " [--activity-launched-from-history] [--activity-multiple-task]",
5830 " [--activity-no-animation] [--activity-no-history]",
5831 " [--activity-no-user-action] [--activity-previous-is-top]",
5832 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5833 " [--activity-single-top] [--activity-clear-task]",
5834 " [--activity-task-on-home]",
5835 " [--receiver-registered-only] [--receiver-replace-pending]",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005836 " [--receiver-foreground]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005837 " [--selector]",
5838 " [<URI> | <PACKAGE> | <COMPONENT>]"
5839 };
5840 for (String line : lines) {
5841 pw.print(prefix);
5842 pw.println(line);
5843 }
5844 }
5845
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005846 /**
5847 * Retrieve the general action to be performed, such as
5848 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5849 * the information in the intent should be interpreted -- most importantly,
5850 * what to do with the data returned by {@link #getData}.
5851 *
5852 * @return The action of this intent or null if none is specified.
5853 *
5854 * @see #setAction
5855 */
5856 public String getAction() {
5857 return mAction;
5858 }
5859
5860 /**
5861 * Retrieve data this intent is operating on. This URI specifies the name
5862 * of the data; often it uses the content: scheme, specifying data in a
5863 * content provider. Other schemes may be handled by specific activities,
5864 * such as http: by the web browser.
5865 *
5866 * @return The URI of the data this intent is targeting or null.
5867 *
5868 * @see #getScheme
5869 * @see #setData
5870 */
5871 public Uri getData() {
5872 return mData;
5873 }
5874
5875 /**
5876 * The same as {@link #getData()}, but returns the URI as an encoded
5877 * String.
5878 */
5879 public String getDataString() {
5880 return mData != null ? mData.toString() : null;
5881 }
5882
5883 /**
5884 * Return the scheme portion of the intent's data. If the data is null or
5885 * does not include a scheme, null is returned. Otherwise, the scheme
5886 * prefix without the final ':' is returned, i.e. "http".
5887 *
5888 * <p>This is the same as calling getData().getScheme() (and checking for
5889 * null data).
5890 *
5891 * @return The scheme of this intent.
5892 *
5893 * @see #getData
5894 */
5895 public String getScheme() {
5896 return mData != null ? mData.getScheme() : null;
5897 }
5898
5899 /**
5900 * Retrieve any explicit MIME type included in the intent. This is usually
5901 * null, as the type is determined by the intent data.
5902 *
5903 * @return If a type was manually set, it is returned; else null is
5904 * returned.
5905 *
5906 * @see #resolveType(ContentResolver)
5907 * @see #setType
5908 */
5909 public String getType() {
5910 return mType;
5911 }
5912
5913 /**
5914 * Return the MIME data type of this intent. If the type field is
5915 * explicitly set, that is simply returned. Otherwise, if the data is set,
5916 * the type of that data is returned. If neither fields are set, a null is
5917 * returned.
5918 *
5919 * @return The MIME type of this intent.
5920 *
5921 * @see #getType
5922 * @see #resolveType(ContentResolver)
5923 */
5924 public String resolveType(Context context) {
5925 return resolveType(context.getContentResolver());
5926 }
5927
5928 /**
5929 * Return the MIME data type of this intent. If the type field is
5930 * explicitly set, that is simply returned. Otherwise, if the data is set,
5931 * the type of that data is returned. If neither fields are set, a null is
5932 * returned.
5933 *
5934 * @param resolver A ContentResolver that can be used to determine the MIME
5935 * type of the intent's data.
5936 *
5937 * @return The MIME type of this intent.
5938 *
5939 * @see #getType
5940 * @see #resolveType(Context)
5941 */
5942 public String resolveType(ContentResolver resolver) {
5943 if (mType != null) {
5944 return mType;
5945 }
5946 if (mData != null) {
5947 if ("content".equals(mData.getScheme())) {
5948 return resolver.getType(mData);
5949 }
5950 }
5951 return null;
5952 }
5953
5954 /**
5955 * Return the MIME data type of this intent, only if it will be needed for
5956 * intent resolution. This is not generally useful for application code;
5957 * it is used by the frameworks for communicating with back-end system
5958 * services.
5959 *
5960 * @param resolver A ContentResolver that can be used to determine the MIME
5961 * type of the intent's data.
5962 *
5963 * @return The MIME type of this intent, or null if it is unknown or not
5964 * needed.
5965 */
5966 public String resolveTypeIfNeeded(ContentResolver resolver) {
5967 if (mComponent != null) {
5968 return mType;
5969 }
5970 return resolveType(resolver);
5971 }
5972
5973 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005974 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005975 *
5976 * @param category The category to check.
5977 *
5978 * @return boolean True if the intent contains the category, else false.
5979 *
5980 * @see #getCategories
5981 * @see #addCategory
5982 */
5983 public boolean hasCategory(String category) {
5984 return mCategories != null && mCategories.contains(category);
5985 }
5986
5987 /**
5988 * Return the set of all categories in the intent. If there are no categories,
5989 * returns NULL.
5990 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005991 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005992 *
5993 * @see #hasCategory
5994 * @see #addCategory
5995 */
5996 public Set<String> getCategories() {
5997 return mCategories;
5998 }
5999
6000 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006001 * Return the specific selector associated with this Intent. If there is
6002 * none, returns null. See {@link #setSelector} for more information.
6003 *
6004 * @see #setSelector
6005 */
6006 public Intent getSelector() {
6007 return mSelector;
6008 }
6009
6010 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006011 * Return the {@link ClipData} associated with this Intent. If there is
6012 * none, returns null. See {@link #setClipData} for more information.
6013 *
John Spurlock125d1332013-11-25 11:58:37 -05006014 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006015 */
6016 public ClipData getClipData() {
6017 return mClipData;
6018 }
6019
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006020 /** @hide */
6021 public int getContentUserHint() {
6022 return mContentUserHint;
6023 }
6024
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006025 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006026 * Sets the ClassLoader that will be used when unmarshalling
6027 * any Parcelable values from the extras of this Intent.
6028 *
6029 * @param loader a ClassLoader, or null to use the default loader
6030 * at the time of unmarshalling.
6031 */
6032 public void setExtrasClassLoader(ClassLoader loader) {
6033 if (mExtras != null) {
6034 mExtras.setClassLoader(loader);
6035 }
6036 }
6037
6038 /**
6039 * Returns true if an extra value is associated with the given name.
6040 * @param name the extra's name
6041 * @return true if the given extra is present.
6042 */
6043 public boolean hasExtra(String name) {
6044 return mExtras != null && mExtras.containsKey(name);
6045 }
6046
6047 /**
6048 * Returns true if the Intent's extras contain a parcelled file descriptor.
6049 * @return true if the Intent contains a parcelled file descriptor.
6050 */
6051 public boolean hasFileDescriptors() {
6052 return mExtras != null && mExtras.hasFileDescriptors();
6053 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006054
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006055 /** @hide */
6056 public void setAllowFds(boolean allowFds) {
6057 if (mExtras != null) {
6058 mExtras.setAllowFds(allowFds);
6059 }
6060 }
6061
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006062 /**
6063 * Retrieve extended data from the intent.
6064 *
6065 * @param name The name of the desired item.
6066 *
6067 * @return the value of an item that previously added with putExtra()
6068 * or null if none was found.
6069 *
6070 * @deprecated
6071 * @hide
6072 */
6073 @Deprecated
6074 public Object getExtra(String name) {
6075 return getExtra(name, null);
6076 }
6077
6078 /**
6079 * Retrieve extended data from the intent.
6080 *
6081 * @param name The name of the desired item.
6082 * @param defaultValue the value to be returned if no value of the desired
6083 * type is stored with the given name.
6084 *
6085 * @return the value of an item that previously added with putExtra()
6086 * or the default value if none was found.
6087 *
6088 * @see #putExtra(String, boolean)
6089 */
6090 public boolean getBooleanExtra(String name, boolean defaultValue) {
6091 return mExtras == null ? defaultValue :
6092 mExtras.getBoolean(name, defaultValue);
6093 }
6094
6095 /**
6096 * Retrieve extended data from the intent.
6097 *
6098 * @param name The name of the desired item.
6099 * @param defaultValue the value to be returned if no value of the desired
6100 * type is stored with the given name.
6101 *
6102 * @return the value of an item that previously added with putExtra()
6103 * or the default value if none was found.
6104 *
6105 * @see #putExtra(String, byte)
6106 */
6107 public byte getByteExtra(String name, byte defaultValue) {
6108 return mExtras == null ? defaultValue :
6109 mExtras.getByte(name, defaultValue);
6110 }
6111
6112 /**
6113 * Retrieve extended data from the intent.
6114 *
6115 * @param name The name of the desired item.
6116 * @param defaultValue the value to be returned if no value of the desired
6117 * type is stored with the given name.
6118 *
6119 * @return the value of an item that previously added with putExtra()
6120 * or the default value if none was found.
6121 *
6122 * @see #putExtra(String, short)
6123 */
6124 public short getShortExtra(String name, short defaultValue) {
6125 return mExtras == null ? defaultValue :
6126 mExtras.getShort(name, defaultValue);
6127 }
6128
6129 /**
6130 * Retrieve extended data from the intent.
6131 *
6132 * @param name The name of the desired item.
6133 * @param defaultValue the value to be returned if no value of the desired
6134 * type is stored with the given name.
6135 *
6136 * @return the value of an item that previously added with putExtra()
6137 * or the default value if none was found.
6138 *
6139 * @see #putExtra(String, char)
6140 */
6141 public char getCharExtra(String name, char defaultValue) {
6142 return mExtras == null ? defaultValue :
6143 mExtras.getChar(name, defaultValue);
6144 }
6145
6146 /**
6147 * Retrieve extended data from the intent.
6148 *
6149 * @param name The name of the desired item.
6150 * @param defaultValue the value to be returned if no value of the desired
6151 * type is stored with the given name.
6152 *
6153 * @return the value of an item that previously added with putExtra()
6154 * or the default value if none was found.
6155 *
6156 * @see #putExtra(String, int)
6157 */
6158 public int getIntExtra(String name, int defaultValue) {
6159 return mExtras == null ? defaultValue :
6160 mExtras.getInt(name, defaultValue);
6161 }
6162
6163 /**
6164 * Retrieve extended data from the intent.
6165 *
6166 * @param name The name of the desired item.
6167 * @param defaultValue the value to be returned if no value of the desired
6168 * type is stored with the given name.
6169 *
6170 * @return the value of an item that previously added with putExtra()
6171 * or the default value if none was found.
6172 *
6173 * @see #putExtra(String, long)
6174 */
6175 public long getLongExtra(String name, long defaultValue) {
6176 return mExtras == null ? defaultValue :
6177 mExtras.getLong(name, defaultValue);
6178 }
6179
6180 /**
6181 * Retrieve extended data from the intent.
6182 *
6183 * @param name The name of the desired item.
6184 * @param defaultValue the value to be returned if no value of the desired
6185 * type is stored with the given name.
6186 *
6187 * @return the value of an item that previously added with putExtra(),
6188 * or the default value if no such item is present
6189 *
6190 * @see #putExtra(String, float)
6191 */
6192 public float getFloatExtra(String name, float defaultValue) {
6193 return mExtras == null ? defaultValue :
6194 mExtras.getFloat(name, defaultValue);
6195 }
6196
6197 /**
6198 * Retrieve extended data from the intent.
6199 *
6200 * @param name The name of the desired item.
6201 * @param defaultValue the value to be returned if no value of the desired
6202 * type is stored with the given name.
6203 *
6204 * @return the value of an item that previously added with putExtra()
6205 * or the default value if none was found.
6206 *
6207 * @see #putExtra(String, double)
6208 */
6209 public double getDoubleExtra(String name, double defaultValue) {
6210 return mExtras == null ? defaultValue :
6211 mExtras.getDouble(name, defaultValue);
6212 }
6213
6214 /**
6215 * Retrieve extended data from the intent.
6216 *
6217 * @param name The name of the desired item.
6218 *
6219 * @return the value of an item that previously added with putExtra()
6220 * or null if no String value was found.
6221 *
6222 * @see #putExtra(String, String)
6223 */
6224 public String getStringExtra(String name) {
6225 return mExtras == null ? null : mExtras.getString(name);
6226 }
6227
6228 /**
6229 * Retrieve extended data from the intent.
6230 *
6231 * @param name The name of the desired item.
6232 *
6233 * @return the value of an item that previously added with putExtra()
6234 * or null if no CharSequence value was found.
6235 *
6236 * @see #putExtra(String, CharSequence)
6237 */
6238 public CharSequence getCharSequenceExtra(String name) {
6239 return mExtras == null ? null : mExtras.getCharSequence(name);
6240 }
6241
6242 /**
6243 * Retrieve extended data from the intent.
6244 *
6245 * @param name The name of the desired item.
6246 *
6247 * @return the value of an item that previously added with putExtra()
6248 * or null if no Parcelable value was found.
6249 *
6250 * @see #putExtra(String, Parcelable)
6251 */
6252 public <T extends Parcelable> T getParcelableExtra(String name) {
6253 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6254 }
6255
6256 /**
6257 * Retrieve extended data from the intent.
6258 *
6259 * @param name The name of the desired item.
6260 *
6261 * @return the value of an item that previously added with putExtra()
6262 * or null if no Parcelable[] value was found.
6263 *
6264 * @see #putExtra(String, Parcelable[])
6265 */
6266 public Parcelable[] getParcelableArrayExtra(String name) {
6267 return mExtras == null ? null : mExtras.getParcelableArray(name);
6268 }
6269
6270 /**
6271 * Retrieve extended data from the intent.
6272 *
6273 * @param name The name of the desired item.
6274 *
6275 * @return the value of an item that previously added with putExtra()
6276 * or null if no ArrayList<Parcelable> value was found.
6277 *
6278 * @see #putParcelableArrayListExtra(String, ArrayList)
6279 */
6280 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6281 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6282 }
6283
6284 /**
6285 * Retrieve extended data from the intent.
6286 *
6287 * @param name The name of the desired item.
6288 *
6289 * @return the value of an item that previously added with putExtra()
6290 * or null if no Serializable value was found.
6291 *
6292 * @see #putExtra(String, Serializable)
6293 */
6294 public Serializable getSerializableExtra(String name) {
6295 return mExtras == null ? null : mExtras.getSerializable(name);
6296 }
6297
6298 /**
6299 * Retrieve extended data from the intent.
6300 *
6301 * @param name The name of the desired item.
6302 *
6303 * @return the value of an item that previously added with putExtra()
6304 * or null if no ArrayList<Integer> value was found.
6305 *
6306 * @see #putIntegerArrayListExtra(String, ArrayList)
6307 */
6308 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6309 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6310 }
6311
6312 /**
6313 * Retrieve extended data from the intent.
6314 *
6315 * @param name The name of the desired item.
6316 *
6317 * @return the value of an item that previously added with putExtra()
6318 * or null if no ArrayList<String> value was found.
6319 *
6320 * @see #putStringArrayListExtra(String, ArrayList)
6321 */
6322 public ArrayList<String> getStringArrayListExtra(String name) {
6323 return mExtras == null ? null : mExtras.getStringArrayList(name);
6324 }
6325
6326 /**
6327 * Retrieve extended data from the intent.
6328 *
6329 * @param name The name of the desired item.
6330 *
6331 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006332 * or null if no ArrayList<CharSequence> value was found.
6333 *
6334 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6335 */
6336 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6337 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6338 }
6339
6340 /**
6341 * Retrieve extended data from the intent.
6342 *
6343 * @param name The name of the desired item.
6344 *
6345 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006346 * or null if no boolean array value was found.
6347 *
6348 * @see #putExtra(String, boolean[])
6349 */
6350 public boolean[] getBooleanArrayExtra(String name) {
6351 return mExtras == null ? null : mExtras.getBooleanArray(name);
6352 }
6353
6354 /**
6355 * Retrieve extended data from the intent.
6356 *
6357 * @param name The name of the desired item.
6358 *
6359 * @return the value of an item that previously added with putExtra()
6360 * or null if no byte array value was found.
6361 *
6362 * @see #putExtra(String, byte[])
6363 */
6364 public byte[] getByteArrayExtra(String name) {
6365 return mExtras == null ? null : mExtras.getByteArray(name);
6366 }
6367
6368 /**
6369 * Retrieve extended data from the intent.
6370 *
6371 * @param name The name of the desired item.
6372 *
6373 * @return the value of an item that previously added with putExtra()
6374 * or null if no short array value was found.
6375 *
6376 * @see #putExtra(String, short[])
6377 */
6378 public short[] getShortArrayExtra(String name) {
6379 return mExtras == null ? null : mExtras.getShortArray(name);
6380 }
6381
6382 /**
6383 * Retrieve extended data from the intent.
6384 *
6385 * @param name The name of the desired item.
6386 *
6387 * @return the value of an item that previously added with putExtra()
6388 * or null if no char array value was found.
6389 *
6390 * @see #putExtra(String, char[])
6391 */
6392 public char[] getCharArrayExtra(String name) {
6393 return mExtras == null ? null : mExtras.getCharArray(name);
6394 }
6395
6396 /**
6397 * Retrieve extended data from the intent.
6398 *
6399 * @param name The name of the desired item.
6400 *
6401 * @return the value of an item that previously added with putExtra()
6402 * or null if no int array value was found.
6403 *
6404 * @see #putExtra(String, int[])
6405 */
6406 public int[] getIntArrayExtra(String name) {
6407 return mExtras == null ? null : mExtras.getIntArray(name);
6408 }
6409
6410 /**
6411 * Retrieve extended data from the intent.
6412 *
6413 * @param name The name of the desired item.
6414 *
6415 * @return the value of an item that previously added with putExtra()
6416 * or null if no long array value was found.
6417 *
6418 * @see #putExtra(String, long[])
6419 */
6420 public long[] getLongArrayExtra(String name) {
6421 return mExtras == null ? null : mExtras.getLongArray(name);
6422 }
6423
6424 /**
6425 * Retrieve extended data from the intent.
6426 *
6427 * @param name The name of the desired item.
6428 *
6429 * @return the value of an item that previously added with putExtra()
6430 * or null if no float array value was found.
6431 *
6432 * @see #putExtra(String, float[])
6433 */
6434 public float[] getFloatArrayExtra(String name) {
6435 return mExtras == null ? null : mExtras.getFloatArray(name);
6436 }
6437
6438 /**
6439 * Retrieve extended data from the intent.
6440 *
6441 * @param name The name of the desired item.
6442 *
6443 * @return the value of an item that previously added with putExtra()
6444 * or null if no double array value was found.
6445 *
6446 * @see #putExtra(String, double[])
6447 */
6448 public double[] getDoubleArrayExtra(String name) {
6449 return mExtras == null ? null : mExtras.getDoubleArray(name);
6450 }
6451
6452 /**
6453 * Retrieve extended data from the intent.
6454 *
6455 * @param name The name of the desired item.
6456 *
6457 * @return the value of an item that previously added with putExtra()
6458 * or null if no String array value was found.
6459 *
6460 * @see #putExtra(String, String[])
6461 */
6462 public String[] getStringArrayExtra(String name) {
6463 return mExtras == null ? null : mExtras.getStringArray(name);
6464 }
6465
6466 /**
6467 * Retrieve extended data from the intent.
6468 *
6469 * @param name The name of the desired item.
6470 *
6471 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006472 * or null if no CharSequence array value was found.
6473 *
6474 * @see #putExtra(String, CharSequence[])
6475 */
6476 public CharSequence[] getCharSequenceArrayExtra(String name) {
6477 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6478 }
6479
6480 /**
6481 * Retrieve extended data from the intent.
6482 *
6483 * @param name The name of the desired item.
6484 *
6485 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006486 * or null if no Bundle value was found.
6487 *
6488 * @see #putExtra(String, Bundle)
6489 */
6490 public Bundle getBundleExtra(String name) {
6491 return mExtras == null ? null : mExtras.getBundle(name);
6492 }
6493
6494 /**
6495 * Retrieve extended data from the intent.
6496 *
6497 * @param name The name of the desired item.
6498 *
6499 * @return the value of an item that previously added with putExtra()
6500 * or null if no IBinder value was found.
6501 *
6502 * @see #putExtra(String, IBinder)
6503 *
6504 * @deprecated
6505 * @hide
6506 */
6507 @Deprecated
6508 public IBinder getIBinderExtra(String name) {
6509 return mExtras == null ? null : mExtras.getIBinder(name);
6510 }
6511
6512 /**
6513 * Retrieve extended data from the intent.
6514 *
6515 * @param name The name of the desired item.
6516 * @param defaultValue The default value to return in case no item is
6517 * associated with the key 'name'
6518 *
6519 * @return the value of an item that previously added with putExtra()
6520 * or defaultValue if none was found.
6521 *
6522 * @see #putExtra
6523 *
6524 * @deprecated
6525 * @hide
6526 */
6527 @Deprecated
6528 public Object getExtra(String name, Object defaultValue) {
6529 Object result = defaultValue;
6530 if (mExtras != null) {
6531 Object result2 = mExtras.get(name);
6532 if (result2 != null) {
6533 result = result2;
6534 }
6535 }
6536
6537 return result;
6538 }
6539
6540 /**
6541 * Retrieves a map of extended data from the intent.
6542 *
6543 * @return the map of all extras previously added with putExtra(),
6544 * or null if none have been added.
6545 */
6546 public Bundle getExtras() {
6547 return (mExtras != null)
6548 ? new Bundle(mExtras)
6549 : null;
6550 }
6551
6552 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006553 * Filter extras to only basic types.
6554 * @hide
6555 */
6556 public void removeUnsafeExtras() {
6557 if (mExtras != null) {
6558 mExtras.filterValues();
6559 }
6560 }
6561
6562 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006563 * Retrieve any special flags associated with this intent. You will
6564 * normally just set them with {@link #setFlags} and let the system
6565 * take the appropriate action with them.
6566 *
6567 * @return int The currently set flags.
6568 *
6569 * @see #setFlags
6570 */
6571 public int getFlags() {
6572 return mFlags;
6573 }
6574
Dianne Hackborne7f97212011-02-24 14:40:20 -08006575 /** @hide */
6576 public boolean isExcludingStopped() {
6577 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6578 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6579 }
6580
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006581 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006582 * Retrieve the application package name this Intent is limited to. When
6583 * resolving an Intent, if non-null this limits the resolution to only
6584 * components in the given application package.
6585 *
6586 * @return The name of the application package for the Intent.
6587 *
6588 * @see #resolveActivity
6589 * @see #setPackage
6590 */
6591 public String getPackage() {
6592 return mPackage;
6593 }
6594
6595 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006596 * Retrieve the concrete component associated with the intent. When receiving
6597 * an intent, this is the component that was found to best handle it (that is,
6598 * yourself) and will always be non-null; in all other cases it will be
6599 * null unless explicitly set.
6600 *
6601 * @return The name of the application component to handle the intent.
6602 *
6603 * @see #resolveActivity
6604 * @see #setComponent
6605 */
6606 public ComponentName getComponent() {
6607 return mComponent;
6608 }
6609
6610 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006611 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6612 * used as a hint to the receiver for animations and the like. Null means that there
6613 * is no source bounds.
6614 */
6615 public Rect getSourceBounds() {
6616 return mSourceBounds;
6617 }
6618
6619 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006620 * Return the Activity component that should be used to handle this intent.
6621 * The appropriate component is determined based on the information in the
6622 * intent, evaluated as follows:
6623 *
6624 * <p>If {@link #getComponent} returns an explicit class, that is returned
6625 * without any further consideration.
6626 *
6627 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6628 * category to be considered.
6629 *
6630 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6631 * action.
6632 *
6633 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6634 * this type.
6635 *
6636 * <p>If {@link #addCategory} has added any categories, the activity must
6637 * handle ALL of the categories specified.
6638 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006639 * <p>If {@link #getPackage} is non-NULL, only activity components in
6640 * that application package will be considered.
6641 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006642 * <p>If there are no activities that satisfy all of these conditions, a
6643 * null string is returned.
6644 *
6645 * <p>If multiple activities are found to satisfy the intent, the one with
6646 * the highest priority will be used. If there are multiple activities
6647 * with the same priority, the system will either pick the best activity
6648 * based on user preference, or resolve to a system class that will allow
6649 * the user to pick an activity and forward from there.
6650 *
6651 * <p>This method is implemented simply by calling
6652 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6653 * true.</p>
6654 * <p> This API is called for you as part of starting an activity from an
6655 * intent. You do not normally need to call it yourself.</p>
6656 *
6657 * @param pm The package manager with which to resolve the Intent.
6658 *
6659 * @return Name of the component implementing an activity that can
6660 * display the intent.
6661 *
6662 * @see #setComponent
6663 * @see #getComponent
6664 * @see #resolveActivityInfo
6665 */
6666 public ComponentName resolveActivity(PackageManager pm) {
6667 if (mComponent != null) {
6668 return mComponent;
6669 }
6670
6671 ResolveInfo info = pm.resolveActivity(
6672 this, PackageManager.MATCH_DEFAULT_ONLY);
6673 if (info != null) {
6674 return new ComponentName(
6675 info.activityInfo.applicationInfo.packageName,
6676 info.activityInfo.name);
6677 }
6678
6679 return null;
6680 }
6681
6682 /**
6683 * Resolve the Intent into an {@link ActivityInfo}
6684 * describing the activity that should execute the intent. Resolution
6685 * follows the same rules as described for {@link #resolveActivity}, but
6686 * you get back the completely information about the resolved activity
6687 * instead of just its class name.
6688 *
6689 * @param pm The package manager with which to resolve the Intent.
6690 * @param flags Addition information to retrieve as per
6691 * {@link PackageManager#getActivityInfo(ComponentName, int)
6692 * PackageManager.getActivityInfo()}.
6693 *
6694 * @return PackageManager.ActivityInfo
6695 *
6696 * @see #resolveActivity
6697 */
6698 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6699 ActivityInfo ai = null;
6700 if (mComponent != null) {
6701 try {
6702 ai = pm.getActivityInfo(mComponent, flags);
6703 } catch (PackageManager.NameNotFoundException e) {
6704 // ignore
6705 }
6706 } else {
6707 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006708 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006709 if (info != null) {
6710 ai = info.activityInfo;
6711 }
6712 }
6713
6714 return ai;
6715 }
6716
6717 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006718 * Special function for use by the system to resolve service
6719 * intents to system apps. Throws an exception if there are
6720 * multiple potential matches to the Intent. Returns null if
6721 * there are no matches.
6722 * @hide
6723 */
6724 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6725 if (mComponent != null) {
6726 return mComponent;
6727 }
6728
6729 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6730 if (results == null) {
6731 return null;
6732 }
6733 ComponentName comp = null;
6734 for (int i=0; i<results.size(); i++) {
6735 ResolveInfo ri = results.get(i);
6736 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6737 continue;
6738 }
6739 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6740 ri.serviceInfo.name);
6741 if (comp != null) {
6742 throw new IllegalStateException("Multiple system services handle " + this
6743 + ": " + comp + ", " + foundComp);
6744 }
6745 comp = foundComp;
6746 }
6747 return comp;
6748 }
6749
6750 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006751 * Set the general action to be performed.
6752 *
6753 * @param action An action name, such as ACTION_VIEW. Application-specific
6754 * actions should be prefixed with the vendor's package name.
6755 *
6756 * @return Returns the same Intent object, for chaining multiple calls
6757 * into a single statement.
6758 *
6759 * @see #getAction
6760 */
6761 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006762 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006763 return this;
6764 }
6765
6766 /**
6767 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006768 * clears any type that was previously set by {@link #setType} or
6769 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006770 *
Nick Pellyccae4122012-01-09 14:12:58 -08006771 * <p><em>Note: scheme matching in the Android framework is
6772 * case-sensitive, unlike the formal RFC. As a result,
6773 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006774 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006775 * {@link #setDataAndNormalize}
6776 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006777 *
Nick Pellyccae4122012-01-09 14:12:58 -08006778 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006779 *
6780 * @return Returns the same Intent object, for chaining multiple calls
6781 * into a single statement.
6782 *
6783 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006784 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006785 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006786 */
6787 public Intent setData(Uri data) {
6788 mData = data;
6789 mType = null;
6790 return this;
6791 }
6792
6793 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006794 * Normalize and set the data this intent is operating on.
6795 *
6796 * <p>This method automatically clears any type that was
6797 * previously set (for example, by {@link #setType}).
6798 *
6799 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006800 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006801 * so really this is just a convenience method for
6802 * <pre>
6803 * setData(data.normalize())
6804 * </pre>
6805 *
6806 * @param data The Uri of the data this intent is now targeting.
6807 *
6808 * @return Returns the same Intent object, for chaining multiple calls
6809 * into a single statement.
6810 *
6811 * @see #getData
6812 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006813 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006814 */
6815 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006816 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006817 }
6818
6819 /**
6820 * Set an explicit MIME data type.
6821 *
6822 * <p>This is used to create intents that only specify a type and not data,
6823 * for example to indicate the type of data to return.
6824 *
6825 * <p>This method automatically clears any data that was
6826 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006827 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006828 * <p><em>Note: MIME type matching in the Android framework is
6829 * case-sensitive, unlike formal RFC MIME types. As a result,
6830 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006831 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6832 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006833 *
6834 * @param type The MIME type of the data being handled by this intent.
6835 *
6836 * @return Returns the same Intent object, for chaining multiple calls
6837 * into a single statement.
6838 *
6839 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006840 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006841 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006842 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006843 */
6844 public Intent setType(String type) {
6845 mData = null;
6846 mType = type;
6847 return this;
6848 }
6849
6850 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006851 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006852 *
Nick Pellyccae4122012-01-09 14:12:58 -08006853 * <p>This is used to create intents that only specify a type and not data,
6854 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006855 *
Nick Pellyccae4122012-01-09 14:12:58 -08006856 * <p>This method automatically clears any data that was
6857 * previously set (for example by {@link #setData}).
6858 *
6859 * <p>The MIME type is normalized using
6860 * {@link #normalizeMimeType} before it is set,
6861 * so really this is just a convenience method for
6862 * <pre>
6863 * setType(Intent.normalizeMimeType(type))
6864 * </pre>
6865 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006866 * @param type The MIME type of the data being handled by this intent.
6867 *
6868 * @return Returns the same Intent object, for chaining multiple calls
6869 * into a single statement.
6870 *
Nick Pellyccae4122012-01-09 14:12:58 -08006871 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006872 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006873 * @see #normalizeMimeType
6874 */
6875 public Intent setTypeAndNormalize(String type) {
6876 return setType(normalizeMimeType(type));
6877 }
6878
6879 /**
6880 * (Usually optional) Set the data for the intent along with an explicit
6881 * MIME data type. This method should very rarely be used -- it allows you
6882 * to override the MIME type that would ordinarily be inferred from the
6883 * data with your own type given here.
6884 *
6885 * <p><em>Note: MIME type and Uri scheme matching in the
6886 * Android framework is case-sensitive, unlike the formal RFC definitions.
6887 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006888 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006889 * {@link #setDataAndTypeAndNormalize}
6890 * to ensure that they are converted to lower case.</em>
6891 *
6892 * @param data The Uri of the data this intent is now targeting.
6893 * @param type The MIME type of the data being handled by this intent.
6894 *
6895 * @return Returns the same Intent object, for chaining multiple calls
6896 * into a single statement.
6897 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006898 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006899 * @see #setData
6900 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006901 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006902 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006903 */
6904 public Intent setDataAndType(Uri data, String type) {
6905 mData = data;
6906 mType = type;
6907 return this;
6908 }
6909
6910 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006911 * (Usually optional) Normalize and set both the data Uri and an explicit
6912 * MIME data type. This method should very rarely be used -- it allows you
6913 * to override the MIME type that would ordinarily be inferred from the
6914 * data with your own type given here.
6915 *
6916 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006917 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006918 * before they are set, so really this is just a convenience method for
6919 * <pre>
6920 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6921 * </pre>
6922 *
6923 * @param data The Uri of the data this intent is now targeting.
6924 * @param type The MIME type of the data being handled by this intent.
6925 *
6926 * @return Returns the same Intent object, for chaining multiple calls
6927 * into a single statement.
6928 *
6929 * @see #setType
6930 * @see #setData
6931 * @see #setDataAndType
6932 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006933 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006934 */
6935 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006936 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006937 }
6938
6939 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006940 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006941 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006942 * activities that provide <em>all</em> of the requested categories will be
6943 * used.
6944 *
6945 * @param category The desired category. This can be either one of the
6946 * predefined Intent categories, or a custom category in your own
6947 * namespace.
6948 *
6949 * @return Returns the same Intent object, for chaining multiple calls
6950 * into a single statement.
6951 *
6952 * @see #hasCategory
6953 * @see #removeCategory
6954 */
6955 public Intent addCategory(String category) {
6956 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006957 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006958 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006959 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006960 return this;
6961 }
6962
6963 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006964 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006965 *
6966 * @param category The category to remove.
6967 *
6968 * @see #addCategory
6969 */
6970 public void removeCategory(String category) {
6971 if (mCategories != null) {
6972 mCategories.remove(category);
6973 if (mCategories.size() == 0) {
6974 mCategories = null;
6975 }
6976 }
6977 }
6978
6979 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006980 * Set a selector for this Intent. This is a modification to the kinds of
6981 * things the Intent will match. If the selector is set, it will be used
6982 * when trying to find entities that can handle the Intent, instead of the
6983 * main contents of the Intent. This allows you build an Intent containing
6984 * a generic protocol while targeting it more specifically.
6985 *
6986 * <p>An example of where this may be used is with things like
6987 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6988 * Intent that will launch the Browser application. However, the correct
6989 * main entry point of an application is actually {@link #ACTION_MAIN}
6990 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6991 * used to specify the actual Activity to launch. If you launch the browser
6992 * with something different, undesired behavior may happen if the user has
6993 * previously or later launches it the normal way, since they do not match.
6994 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6995 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6996 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6997 *
6998 * <p>Setting a selector does not impact the behavior of
6999 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7000 * desired behavior of a selector -- it does not impact the base meaning
7001 * of the Intent, just what kinds of things will be matched against it
7002 * when determining who can handle it.</p>
7003 *
7004 * <p>You can not use both a selector and {@link #setPackage(String)} on
7005 * the same base Intent.</p>
7006 *
7007 * @param selector The desired selector Intent; set to null to not use
7008 * a special selector.
7009 */
7010 public void setSelector(Intent selector) {
7011 if (selector == this) {
7012 throw new IllegalArgumentException(
7013 "Intent being set as a selector of itself");
7014 }
7015 if (selector != null && mPackage != null) {
7016 throw new IllegalArgumentException(
7017 "Can't set selector when package name is already set");
7018 }
7019 mSelector = selector;
7020 }
7021
7022 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007023 * Set a {@link ClipData} associated with this Intent. This replaces any
7024 * previously set ClipData.
7025 *
7026 * <p>The ClipData in an intent is not used for Intent matching or other
7027 * such operations. Semantically it is like extras, used to transmit
7028 * additional data with the Intent. The main feature of using this over
7029 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7030 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7031 * items included in the clip data. This is useful, in particular, if
7032 * you want to transmit an Intent containing multiple <code>content:</code>
7033 * URIs for which the recipient may not have global permission to access the
7034 * content provider.
7035 *
7036 * <p>If the ClipData contains items that are themselves Intents, any
7037 * grant flags in those Intents will be ignored. Only the top-level flags
7038 * of the main Intent are respected, and will be applied to all Uri or
7039 * Intent items in the clip (or sub-items of the clip).
7040 *
7041 * <p>The MIME type, label, and icon in the ClipData object are not
7042 * directly used by Intent. Applications should generally rely on the
7043 * MIME type of the Intent itself, not what it may find in the ClipData.
7044 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007045 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007046 *
7047 * @param clip The new clip to set. May be null to clear the current clip.
7048 */
7049 public void setClipData(ClipData clip) {
7050 mClipData = clip;
7051 }
7052
7053 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007054 * This is NOT a secure mechanism to identify the user who sent the intent.
7055 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7056 * who sent the intent.
7057 * @hide
7058 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007059 public void prepareToLeaveUser(int userId) {
7060 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7061 // We want mContentUserHint to refer to the original user, so don't do anything.
7062 if (mContentUserHint == UserHandle.USER_CURRENT) {
7063 mContentUserHint = userId;
7064 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007065 }
7066
7067 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007068 * Add extended data to the intent. The name must include a package
7069 * prefix, for example the app com.android.contacts would use names
7070 * like "com.android.contacts.ShowAll".
7071 *
7072 * @param name The name of the extra data, with package prefix.
7073 * @param value The boolean data value.
7074 *
7075 * @return Returns the same Intent object, for chaining multiple calls
7076 * into a single statement.
7077 *
7078 * @see #putExtras
7079 * @see #removeExtra
7080 * @see #getBooleanExtra(String, boolean)
7081 */
7082 public Intent putExtra(String name, boolean value) {
7083 if (mExtras == null) {
7084 mExtras = new Bundle();
7085 }
7086 mExtras.putBoolean(name, value);
7087 return this;
7088 }
7089
7090 /**
7091 * Add extended data to the intent. The name must include a package
7092 * prefix, for example the app com.android.contacts would use names
7093 * like "com.android.contacts.ShowAll".
7094 *
7095 * @param name The name of the extra data, with package prefix.
7096 * @param value The byte data value.
7097 *
7098 * @return Returns the same Intent object, for chaining multiple calls
7099 * into a single statement.
7100 *
7101 * @see #putExtras
7102 * @see #removeExtra
7103 * @see #getByteExtra(String, byte)
7104 */
7105 public Intent putExtra(String name, byte value) {
7106 if (mExtras == null) {
7107 mExtras = new Bundle();
7108 }
7109 mExtras.putByte(name, value);
7110 return this;
7111 }
7112
7113 /**
7114 * Add extended data to the intent. The name must include a package
7115 * prefix, for example the app com.android.contacts would use names
7116 * like "com.android.contacts.ShowAll".
7117 *
7118 * @param name The name of the extra data, with package prefix.
7119 * @param value The char data value.
7120 *
7121 * @return Returns the same Intent object, for chaining multiple calls
7122 * into a single statement.
7123 *
7124 * @see #putExtras
7125 * @see #removeExtra
7126 * @see #getCharExtra(String, char)
7127 */
7128 public Intent putExtra(String name, char value) {
7129 if (mExtras == null) {
7130 mExtras = new Bundle();
7131 }
7132 mExtras.putChar(name, value);
7133 return this;
7134 }
7135
7136 /**
7137 * Add extended data to the intent. The name must include a package
7138 * prefix, for example the app com.android.contacts would use names
7139 * like "com.android.contacts.ShowAll".
7140 *
7141 * @param name The name of the extra data, with package prefix.
7142 * @param value The short data value.
7143 *
7144 * @return Returns the same Intent object, for chaining multiple calls
7145 * into a single statement.
7146 *
7147 * @see #putExtras
7148 * @see #removeExtra
7149 * @see #getShortExtra(String, short)
7150 */
7151 public Intent putExtra(String name, short value) {
7152 if (mExtras == null) {
7153 mExtras = new Bundle();
7154 }
7155 mExtras.putShort(name, value);
7156 return this;
7157 }
7158
7159 /**
7160 * Add extended data to the intent. The name must include a package
7161 * prefix, for example the app com.android.contacts would use names
7162 * like "com.android.contacts.ShowAll".
7163 *
7164 * @param name The name of the extra data, with package prefix.
7165 * @param value The integer data value.
7166 *
7167 * @return Returns the same Intent object, for chaining multiple calls
7168 * into a single statement.
7169 *
7170 * @see #putExtras
7171 * @see #removeExtra
7172 * @see #getIntExtra(String, int)
7173 */
7174 public Intent putExtra(String name, int value) {
7175 if (mExtras == null) {
7176 mExtras = new Bundle();
7177 }
7178 mExtras.putInt(name, value);
7179 return this;
7180 }
7181
7182 /**
7183 * Add extended data to the intent. The name must include a package
7184 * prefix, for example the app com.android.contacts would use names
7185 * like "com.android.contacts.ShowAll".
7186 *
7187 * @param name The name of the extra data, with package prefix.
7188 * @param value The long data value.
7189 *
7190 * @return Returns the same Intent object, for chaining multiple calls
7191 * into a single statement.
7192 *
7193 * @see #putExtras
7194 * @see #removeExtra
7195 * @see #getLongExtra(String, long)
7196 */
7197 public Intent putExtra(String name, long value) {
7198 if (mExtras == null) {
7199 mExtras = new Bundle();
7200 }
7201 mExtras.putLong(name, value);
7202 return this;
7203 }
7204
7205 /**
7206 * Add extended data to the intent. The name must include a package
7207 * prefix, for example the app com.android.contacts would use names
7208 * like "com.android.contacts.ShowAll".
7209 *
7210 * @param name The name of the extra data, with package prefix.
7211 * @param value The float data value.
7212 *
7213 * @return Returns the same Intent object, for chaining multiple calls
7214 * into a single statement.
7215 *
7216 * @see #putExtras
7217 * @see #removeExtra
7218 * @see #getFloatExtra(String, float)
7219 */
7220 public Intent putExtra(String name, float value) {
7221 if (mExtras == null) {
7222 mExtras = new Bundle();
7223 }
7224 mExtras.putFloat(name, value);
7225 return this;
7226 }
7227
7228 /**
7229 * Add extended data to the intent. The name must include a package
7230 * prefix, for example the app com.android.contacts would use names
7231 * like "com.android.contacts.ShowAll".
7232 *
7233 * @param name The name of the extra data, with package prefix.
7234 * @param value The double data value.
7235 *
7236 * @return Returns the same Intent object, for chaining multiple calls
7237 * into a single statement.
7238 *
7239 * @see #putExtras
7240 * @see #removeExtra
7241 * @see #getDoubleExtra(String, double)
7242 */
7243 public Intent putExtra(String name, double value) {
7244 if (mExtras == null) {
7245 mExtras = new Bundle();
7246 }
7247 mExtras.putDouble(name, value);
7248 return this;
7249 }
7250
7251 /**
7252 * Add extended data to the intent. The name must include a package
7253 * prefix, for example the app com.android.contacts would use names
7254 * like "com.android.contacts.ShowAll".
7255 *
7256 * @param name The name of the extra data, with package prefix.
7257 * @param value The String data value.
7258 *
7259 * @return Returns the same Intent object, for chaining multiple calls
7260 * into a single statement.
7261 *
7262 * @see #putExtras
7263 * @see #removeExtra
7264 * @see #getStringExtra(String)
7265 */
7266 public Intent putExtra(String name, String value) {
7267 if (mExtras == null) {
7268 mExtras = new Bundle();
7269 }
7270 mExtras.putString(name, value);
7271 return this;
7272 }
7273
7274 /**
7275 * Add extended data to the intent. The name must include a package
7276 * prefix, for example the app com.android.contacts would use names
7277 * like "com.android.contacts.ShowAll".
7278 *
7279 * @param name The name of the extra data, with package prefix.
7280 * @param value The CharSequence data value.
7281 *
7282 * @return Returns the same Intent object, for chaining multiple calls
7283 * into a single statement.
7284 *
7285 * @see #putExtras
7286 * @see #removeExtra
7287 * @see #getCharSequenceExtra(String)
7288 */
7289 public Intent putExtra(String name, CharSequence value) {
7290 if (mExtras == null) {
7291 mExtras = new Bundle();
7292 }
7293 mExtras.putCharSequence(name, value);
7294 return this;
7295 }
7296
7297 /**
7298 * Add extended data to the intent. The name must include a package
7299 * prefix, for example the app com.android.contacts would use names
7300 * like "com.android.contacts.ShowAll".
7301 *
7302 * @param name The name of the extra data, with package prefix.
7303 * @param value The Parcelable data value.
7304 *
7305 * @return Returns the same Intent object, for chaining multiple calls
7306 * into a single statement.
7307 *
7308 * @see #putExtras
7309 * @see #removeExtra
7310 * @see #getParcelableExtra(String)
7311 */
7312 public Intent putExtra(String name, Parcelable value) {
7313 if (mExtras == null) {
7314 mExtras = new Bundle();
7315 }
7316 mExtras.putParcelable(name, value);
7317 return this;
7318 }
7319
7320 /**
7321 * Add extended data to the intent. The name must include a package
7322 * prefix, for example the app com.android.contacts would use names
7323 * like "com.android.contacts.ShowAll".
7324 *
7325 * @param name The name of the extra data, with package prefix.
7326 * @param value The Parcelable[] data value.
7327 *
7328 * @return Returns the same Intent object, for chaining multiple calls
7329 * into a single statement.
7330 *
7331 * @see #putExtras
7332 * @see #removeExtra
7333 * @see #getParcelableArrayExtra(String)
7334 */
7335 public Intent putExtra(String name, Parcelable[] value) {
7336 if (mExtras == null) {
7337 mExtras = new Bundle();
7338 }
7339 mExtras.putParcelableArray(name, value);
7340 return this;
7341 }
7342
7343 /**
7344 * Add extended data to the intent. The name must include a package
7345 * prefix, for example the app com.android.contacts would use names
7346 * like "com.android.contacts.ShowAll".
7347 *
7348 * @param name The name of the extra data, with package prefix.
7349 * @param value The ArrayList<Parcelable> data value.
7350 *
7351 * @return Returns the same Intent object, for chaining multiple calls
7352 * into a single statement.
7353 *
7354 * @see #putExtras
7355 * @see #removeExtra
7356 * @see #getParcelableArrayListExtra(String)
7357 */
7358 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7359 if (mExtras == null) {
7360 mExtras = new Bundle();
7361 }
7362 mExtras.putParcelableArrayList(name, value);
7363 return this;
7364 }
7365
7366 /**
7367 * Add extended data to the intent. The name must include a package
7368 * prefix, for example the app com.android.contacts would use names
7369 * like "com.android.contacts.ShowAll".
7370 *
7371 * @param name The name of the extra data, with package prefix.
7372 * @param value The ArrayList<Integer> data value.
7373 *
7374 * @return Returns the same Intent object, for chaining multiple calls
7375 * into a single statement.
7376 *
7377 * @see #putExtras
7378 * @see #removeExtra
7379 * @see #getIntegerArrayListExtra(String)
7380 */
7381 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7382 if (mExtras == null) {
7383 mExtras = new Bundle();
7384 }
7385 mExtras.putIntegerArrayList(name, value);
7386 return this;
7387 }
7388
7389 /**
7390 * Add extended data to the intent. The name must include a package
7391 * prefix, for example the app com.android.contacts would use names
7392 * like "com.android.contacts.ShowAll".
7393 *
7394 * @param name The name of the extra data, with package prefix.
7395 * @param value The ArrayList<String> data value.
7396 *
7397 * @return Returns the same Intent object, for chaining multiple calls
7398 * into a single statement.
7399 *
7400 * @see #putExtras
7401 * @see #removeExtra
7402 * @see #getStringArrayListExtra(String)
7403 */
7404 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7405 if (mExtras == null) {
7406 mExtras = new Bundle();
7407 }
7408 mExtras.putStringArrayList(name, value);
7409 return this;
7410 }
7411
7412 /**
7413 * Add extended data to the intent. The name must include a package
7414 * prefix, for example the app com.android.contacts would use names
7415 * like "com.android.contacts.ShowAll".
7416 *
7417 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007418 * @param value The ArrayList<CharSequence> data value.
7419 *
7420 * @return Returns the same Intent object, for chaining multiple calls
7421 * into a single statement.
7422 *
7423 * @see #putExtras
7424 * @see #removeExtra
7425 * @see #getCharSequenceArrayListExtra(String)
7426 */
7427 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7428 if (mExtras == null) {
7429 mExtras = new Bundle();
7430 }
7431 mExtras.putCharSequenceArrayList(name, value);
7432 return this;
7433 }
7434
7435 /**
7436 * Add extended data to the intent. The name must include a package
7437 * prefix, for example the app com.android.contacts would use names
7438 * like "com.android.contacts.ShowAll".
7439 *
7440 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007441 * @param value The Serializable data value.
7442 *
7443 * @return Returns the same Intent object, for chaining multiple calls
7444 * into a single statement.
7445 *
7446 * @see #putExtras
7447 * @see #removeExtra
7448 * @see #getSerializableExtra(String)
7449 */
7450 public Intent putExtra(String name, Serializable value) {
7451 if (mExtras == null) {
7452 mExtras = new Bundle();
7453 }
7454 mExtras.putSerializable(name, value);
7455 return this;
7456 }
7457
7458 /**
7459 * Add extended data to the intent. The name must include a package
7460 * prefix, for example the app com.android.contacts would use names
7461 * like "com.android.contacts.ShowAll".
7462 *
7463 * @param name The name of the extra data, with package prefix.
7464 * @param value The boolean array data value.
7465 *
7466 * @return Returns the same Intent object, for chaining multiple calls
7467 * into a single statement.
7468 *
7469 * @see #putExtras
7470 * @see #removeExtra
7471 * @see #getBooleanArrayExtra(String)
7472 */
7473 public Intent putExtra(String name, boolean[] value) {
7474 if (mExtras == null) {
7475 mExtras = new Bundle();
7476 }
7477 mExtras.putBooleanArray(name, value);
7478 return this;
7479 }
7480
7481 /**
7482 * Add extended data to the intent. The name must include a package
7483 * prefix, for example the app com.android.contacts would use names
7484 * like "com.android.contacts.ShowAll".
7485 *
7486 * @param name The name of the extra data, with package prefix.
7487 * @param value The byte array data value.
7488 *
7489 * @return Returns the same Intent object, for chaining multiple calls
7490 * into a single statement.
7491 *
7492 * @see #putExtras
7493 * @see #removeExtra
7494 * @see #getByteArrayExtra(String)
7495 */
7496 public Intent putExtra(String name, byte[] value) {
7497 if (mExtras == null) {
7498 mExtras = new Bundle();
7499 }
7500 mExtras.putByteArray(name, value);
7501 return this;
7502 }
7503
7504 /**
7505 * Add extended data to the intent. The name must include a package
7506 * prefix, for example the app com.android.contacts would use names
7507 * like "com.android.contacts.ShowAll".
7508 *
7509 * @param name The name of the extra data, with package prefix.
7510 * @param value The short array data value.
7511 *
7512 * @return Returns the same Intent object, for chaining multiple calls
7513 * into a single statement.
7514 *
7515 * @see #putExtras
7516 * @see #removeExtra
7517 * @see #getShortArrayExtra(String)
7518 */
7519 public Intent putExtra(String name, short[] value) {
7520 if (mExtras == null) {
7521 mExtras = new Bundle();
7522 }
7523 mExtras.putShortArray(name, value);
7524 return this;
7525 }
7526
7527 /**
7528 * Add extended data to the intent. The name must include a package
7529 * prefix, for example the app com.android.contacts would use names
7530 * like "com.android.contacts.ShowAll".
7531 *
7532 * @param name The name of the extra data, with package prefix.
7533 * @param value The char array data value.
7534 *
7535 * @return Returns the same Intent object, for chaining multiple calls
7536 * into a single statement.
7537 *
7538 * @see #putExtras
7539 * @see #removeExtra
7540 * @see #getCharArrayExtra(String)
7541 */
7542 public Intent putExtra(String name, char[] value) {
7543 if (mExtras == null) {
7544 mExtras = new Bundle();
7545 }
7546 mExtras.putCharArray(name, value);
7547 return this;
7548 }
7549
7550 /**
7551 * Add extended data to the intent. The name must include a package
7552 * prefix, for example the app com.android.contacts would use names
7553 * like "com.android.contacts.ShowAll".
7554 *
7555 * @param name The name of the extra data, with package prefix.
7556 * @param value The int array data value.
7557 *
7558 * @return Returns the same Intent object, for chaining multiple calls
7559 * into a single statement.
7560 *
7561 * @see #putExtras
7562 * @see #removeExtra
7563 * @see #getIntArrayExtra(String)
7564 */
7565 public Intent putExtra(String name, int[] value) {
7566 if (mExtras == null) {
7567 mExtras = new Bundle();
7568 }
7569 mExtras.putIntArray(name, value);
7570 return this;
7571 }
7572
7573 /**
7574 * Add extended data to the intent. The name must include a package
7575 * prefix, for example the app com.android.contacts would use names
7576 * like "com.android.contacts.ShowAll".
7577 *
7578 * @param name The name of the extra data, with package prefix.
7579 * @param value The byte array data value.
7580 *
7581 * @return Returns the same Intent object, for chaining multiple calls
7582 * into a single statement.
7583 *
7584 * @see #putExtras
7585 * @see #removeExtra
7586 * @see #getLongArrayExtra(String)
7587 */
7588 public Intent putExtra(String name, long[] value) {
7589 if (mExtras == null) {
7590 mExtras = new Bundle();
7591 }
7592 mExtras.putLongArray(name, value);
7593 return this;
7594 }
7595
7596 /**
7597 * Add extended data to the intent. The name must include a package
7598 * prefix, for example the app com.android.contacts would use names
7599 * like "com.android.contacts.ShowAll".
7600 *
7601 * @param name The name of the extra data, with package prefix.
7602 * @param value The float array data value.
7603 *
7604 * @return Returns the same Intent object, for chaining multiple calls
7605 * into a single statement.
7606 *
7607 * @see #putExtras
7608 * @see #removeExtra
7609 * @see #getFloatArrayExtra(String)
7610 */
7611 public Intent putExtra(String name, float[] value) {
7612 if (mExtras == null) {
7613 mExtras = new Bundle();
7614 }
7615 mExtras.putFloatArray(name, value);
7616 return this;
7617 }
7618
7619 /**
7620 * Add extended data to the intent. The name must include a package
7621 * prefix, for example the app com.android.contacts would use names
7622 * like "com.android.contacts.ShowAll".
7623 *
7624 * @param name The name of the extra data, with package prefix.
7625 * @param value The double array data value.
7626 *
7627 * @return Returns the same Intent object, for chaining multiple calls
7628 * into a single statement.
7629 *
7630 * @see #putExtras
7631 * @see #removeExtra
7632 * @see #getDoubleArrayExtra(String)
7633 */
7634 public Intent putExtra(String name, double[] value) {
7635 if (mExtras == null) {
7636 mExtras = new Bundle();
7637 }
7638 mExtras.putDoubleArray(name, value);
7639 return this;
7640 }
7641
7642 /**
7643 * Add extended data to the intent. The name must include a package
7644 * prefix, for example the app com.android.contacts would use names
7645 * like "com.android.contacts.ShowAll".
7646 *
7647 * @param name The name of the extra data, with package prefix.
7648 * @param value The String array data value.
7649 *
7650 * @return Returns the same Intent object, for chaining multiple calls
7651 * into a single statement.
7652 *
7653 * @see #putExtras
7654 * @see #removeExtra
7655 * @see #getStringArrayExtra(String)
7656 */
7657 public Intent putExtra(String name, String[] value) {
7658 if (mExtras == null) {
7659 mExtras = new Bundle();
7660 }
7661 mExtras.putStringArray(name, value);
7662 return this;
7663 }
7664
7665 /**
7666 * Add extended data to the intent. The name must include a package
7667 * prefix, for example the app com.android.contacts would use names
7668 * like "com.android.contacts.ShowAll".
7669 *
7670 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007671 * @param value The CharSequence array data value.
7672 *
7673 * @return Returns the same Intent object, for chaining multiple calls
7674 * into a single statement.
7675 *
7676 * @see #putExtras
7677 * @see #removeExtra
7678 * @see #getCharSequenceArrayExtra(String)
7679 */
7680 public Intent putExtra(String name, CharSequence[] value) {
7681 if (mExtras == null) {
7682 mExtras = new Bundle();
7683 }
7684 mExtras.putCharSequenceArray(name, value);
7685 return this;
7686 }
7687
7688 /**
7689 * Add extended data to the intent. The name must include a package
7690 * prefix, for example the app com.android.contacts would use names
7691 * like "com.android.contacts.ShowAll".
7692 *
7693 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007694 * @param value The Bundle data value.
7695 *
7696 * @return Returns the same Intent object, for chaining multiple calls
7697 * into a single statement.
7698 *
7699 * @see #putExtras
7700 * @see #removeExtra
7701 * @see #getBundleExtra(String)
7702 */
7703 public Intent putExtra(String name, Bundle value) {
7704 if (mExtras == null) {
7705 mExtras = new Bundle();
7706 }
7707 mExtras.putBundle(name, value);
7708 return this;
7709 }
7710
7711 /**
7712 * Add extended data to the intent. The name must include a package
7713 * prefix, for example the app com.android.contacts would use names
7714 * like "com.android.contacts.ShowAll".
7715 *
7716 * @param name The name of the extra data, with package prefix.
7717 * @param value The IBinder data value.
7718 *
7719 * @return Returns the same Intent object, for chaining multiple calls
7720 * into a single statement.
7721 *
7722 * @see #putExtras
7723 * @see #removeExtra
7724 * @see #getIBinderExtra(String)
7725 *
7726 * @deprecated
7727 * @hide
7728 */
7729 @Deprecated
7730 public Intent putExtra(String name, IBinder value) {
7731 if (mExtras == null) {
7732 mExtras = new Bundle();
7733 }
7734 mExtras.putIBinder(name, value);
7735 return this;
7736 }
7737
7738 /**
7739 * Copy all extras in 'src' in to this intent.
7740 *
7741 * @param src Contains the extras to copy.
7742 *
7743 * @see #putExtra
7744 */
7745 public Intent putExtras(Intent src) {
7746 if (src.mExtras != null) {
7747 if (mExtras == null) {
7748 mExtras = new Bundle(src.mExtras);
7749 } else {
7750 mExtras.putAll(src.mExtras);
7751 }
7752 }
7753 return this;
7754 }
7755
7756 /**
7757 * Add a set of extended data to the intent. The keys must include a package
7758 * prefix, for example the app com.android.contacts would use names
7759 * like "com.android.contacts.ShowAll".
7760 *
7761 * @param extras The Bundle of extras to add to this intent.
7762 *
7763 * @see #putExtra
7764 * @see #removeExtra
7765 */
7766 public Intent putExtras(Bundle extras) {
7767 if (mExtras == null) {
7768 mExtras = new Bundle();
7769 }
7770 mExtras.putAll(extras);
7771 return this;
7772 }
7773
7774 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007775 * Completely replace the extras in the Intent with the extras in the
7776 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007777 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007778 * @param src The exact extras contained in this Intent are copied
7779 * into the target intent, replacing any that were previously there.
7780 */
7781 public Intent replaceExtras(Intent src) {
7782 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7783 return this;
7784 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007785
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007786 /**
7787 * Completely replace the extras in the Intent with the given Bundle of
7788 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007789 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007790 * @param extras The new set of extras in the Intent, or null to erase
7791 * all extras.
7792 */
7793 public Intent replaceExtras(Bundle extras) {
7794 mExtras = extras != null ? new Bundle(extras) : null;
7795 return this;
7796 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007797
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007798 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007799 * Remove extended data from the intent.
7800 *
7801 * @see #putExtra
7802 */
7803 public void removeExtra(String name) {
7804 if (mExtras != null) {
7805 mExtras.remove(name);
7806 if (mExtras.size() == 0) {
7807 mExtras = null;
7808 }
7809 }
7810 }
7811
7812 /**
7813 * Set special flags controlling how this intent is handled. Most values
7814 * here depend on the type of component being executed by the Intent,
7815 * specifically the FLAG_ACTIVITY_* flags are all for use with
7816 * {@link Context#startActivity Context.startActivity()} and the
7817 * FLAG_RECEIVER_* flags are all for use with
7818 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7819 *
Scott Main7aee61f2011-02-08 11:25:01 -08007820 * <p>See the
7821 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7822 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007823 * the behavior of your application.
7824 *
7825 * @param flags The desired flags.
7826 *
7827 * @return Returns the same Intent object, for chaining multiple calls
7828 * into a single statement.
7829 *
7830 * @see #getFlags
7831 * @see #addFlags
7832 *
7833 * @see #FLAG_GRANT_READ_URI_PERMISSION
7834 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007835 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7836 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007837 * @see #FLAG_DEBUG_LOG_RESOLUTION
7838 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007839 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007840 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007841 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007842 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007843 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7844 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007845 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007846 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007847 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007848 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007849 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007850 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007851 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007852 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7853 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007854 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007855 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007856 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007857 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7858 */
7859 public Intent setFlags(int flags) {
7860 mFlags = flags;
7861 return this;
7862 }
7863
7864 /**
7865 * Add additional flags to the intent (or with existing flags
7866 * value).
7867 *
7868 * @param flags The new flags to set.
7869 *
7870 * @return Returns the same Intent object, for chaining multiple calls
7871 * into a single statement.
7872 *
7873 * @see #setFlags
7874 */
7875 public Intent addFlags(int flags) {
7876 mFlags |= flags;
7877 return this;
7878 }
7879
7880 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007881 * (Usually optional) Set an explicit application package name that limits
7882 * the components this Intent will resolve to. If left to the default
7883 * value of null, all components in all applications will considered.
7884 * If non-null, the Intent can only match the components in the given
7885 * application package.
7886 *
7887 * @param packageName The name of the application package to handle the
7888 * intent, or null to allow any application package.
7889 *
7890 * @return Returns the same Intent object, for chaining multiple calls
7891 * into a single statement.
7892 *
7893 * @see #getPackage
7894 * @see #resolveActivity
7895 */
7896 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007897 if (packageName != null && mSelector != null) {
7898 throw new IllegalArgumentException(
7899 "Can't set package name when selector is already set");
7900 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007901 mPackage = packageName;
7902 return this;
7903 }
7904
7905 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007906 * (Usually optional) Explicitly set the component to handle the intent.
7907 * If left with the default value of null, the system will determine the
7908 * appropriate class to use based on the other fields (action, data,
7909 * type, categories) in the Intent. If this class is defined, the
7910 * specified class will always be used regardless of the other fields. You
7911 * should only set this value when you know you absolutely want a specific
7912 * class to be used; otherwise it is better to let the system find the
7913 * appropriate class so that you will respect the installed applications
7914 * and user preferences.
7915 *
7916 * @param component The name of the application component to handle the
7917 * intent, or null to let the system find one for you.
7918 *
7919 * @return Returns the same Intent object, for chaining multiple calls
7920 * into a single statement.
7921 *
7922 * @see #setClass
7923 * @see #setClassName(Context, String)
7924 * @see #setClassName(String, String)
7925 * @see #getComponent
7926 * @see #resolveActivity
7927 */
7928 public Intent setComponent(ComponentName component) {
7929 mComponent = component;
7930 return this;
7931 }
7932
7933 /**
7934 * Convenience for calling {@link #setComponent} with an
7935 * explicit class name.
7936 *
7937 * @param packageContext A Context of the application package implementing
7938 * this class.
7939 * @param className The name of a class inside of the application package
7940 * that will be used as the component for this Intent.
7941 *
7942 * @return Returns the same Intent object, for chaining multiple calls
7943 * into a single statement.
7944 *
7945 * @see #setComponent
7946 * @see #setClass
7947 */
7948 public Intent setClassName(Context packageContext, String className) {
7949 mComponent = new ComponentName(packageContext, className);
7950 return this;
7951 }
7952
7953 /**
7954 * Convenience for calling {@link #setComponent} with an
7955 * explicit application package name and class name.
7956 *
7957 * @param packageName The name of the package implementing the desired
7958 * component.
7959 * @param className The name of a class inside of the application package
7960 * that will be used as the component for this Intent.
7961 *
7962 * @return Returns the same Intent object, for chaining multiple calls
7963 * into a single statement.
7964 *
7965 * @see #setComponent
7966 * @see #setClass
7967 */
7968 public Intent setClassName(String packageName, String className) {
7969 mComponent = new ComponentName(packageName, className);
7970 return this;
7971 }
7972
7973 /**
7974 * Convenience for calling {@link #setComponent(ComponentName)} with the
7975 * name returned by a {@link Class} object.
7976 *
7977 * @param packageContext A Context of the application package implementing
7978 * this class.
7979 * @param cls The class name to set, equivalent to
7980 * <code>setClassName(context, cls.getName())</code>.
7981 *
7982 * @return Returns the same Intent object, for chaining multiple calls
7983 * into a single statement.
7984 *
7985 * @see #setComponent
7986 */
7987 public Intent setClass(Context packageContext, Class<?> cls) {
7988 mComponent = new ComponentName(packageContext, cls);
7989 return this;
7990 }
7991
7992 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007993 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7994 * used as a hint to the receiver for animations and the like. Null means that there
7995 * is no source bounds.
7996 */
7997 public void setSourceBounds(Rect r) {
7998 if (r != null) {
7999 mSourceBounds = new Rect(r);
8000 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008001 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008002 }
8003 }
8004
Tor Norbyed9273d62013-05-30 15:59:53 -07008005 /** @hide */
8006 @IntDef(flag = true,
8007 value = {
8008 FILL_IN_ACTION,
8009 FILL_IN_DATA,
8010 FILL_IN_CATEGORIES,
8011 FILL_IN_COMPONENT,
8012 FILL_IN_PACKAGE,
8013 FILL_IN_SOURCE_BOUNDS,
8014 FILL_IN_SELECTOR,
8015 FILL_IN_CLIP_DATA
8016 })
8017 @Retention(RetentionPolicy.SOURCE)
8018 public @interface FillInFlags {}
8019
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008020 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008021 * Use with {@link #fillIn} to allow the current action value to be
8022 * overwritten, even if it is already set.
8023 */
8024 public static final int FILL_IN_ACTION = 1<<0;
8025
8026 /**
8027 * Use with {@link #fillIn} to allow the current data or type value
8028 * overwritten, even if it is already set.
8029 */
8030 public static final int FILL_IN_DATA = 1<<1;
8031
8032 /**
8033 * Use with {@link #fillIn} to allow the current categories to be
8034 * overwritten, even if they are already set.
8035 */
8036 public static final int FILL_IN_CATEGORIES = 1<<2;
8037
8038 /**
8039 * Use with {@link #fillIn} to allow the current component value to be
8040 * overwritten, even if it is already set.
8041 */
8042 public static final int FILL_IN_COMPONENT = 1<<3;
8043
8044 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008045 * Use with {@link #fillIn} to allow the current package value to be
8046 * overwritten, even if it is already set.
8047 */
8048 public static final int FILL_IN_PACKAGE = 1<<4;
8049
8050 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008051 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008052 * overwritten, even if it is already set.
8053 */
8054 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8055
8056 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008057 * Use with {@link #fillIn} to allow the current selector to be
8058 * overwritten, even if it is already set.
8059 */
8060 public static final int FILL_IN_SELECTOR = 1<<6;
8061
8062 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008063 * Use with {@link #fillIn} to allow the current ClipData to be
8064 * overwritten, even if it is already set.
8065 */
8066 public static final int FILL_IN_CLIP_DATA = 1<<7;
8067
8068 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008069 * Copy the contents of <var>other</var> in to this object, but only
8070 * where fields are not defined by this object. For purposes of a field
8071 * being defined, the following pieces of data in the Intent are
8072 * considered to be separate fields:
8073 *
8074 * <ul>
8075 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008076 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008077 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8078 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008079 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008080 * <li> component, as set by {@link #setComponent(ComponentName)} or
8081 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008082 * <li> source bounds, as set by {@link #setSourceBounds}.
8083 * <li> selector, as set by {@link #setSelector(Intent)}.
8084 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008085 * <li> each top-level name in the associated extras.
8086 * </ul>
8087 *
8088 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008089 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008090 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8091 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8092 * the restriction where the corresponding field will not be replaced if
8093 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008094 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008095 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8096 * is explicitly specified. The selector will only be copied if
8097 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008098 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008099 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8100 * and Intent B with {action="gotit", data-type="some/thing",
8101 * categories="one","two"}.
8102 *
8103 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8104 * containing: {action="gotit", data-type="some/thing",
8105 * categories="bar"}.
8106 *
8107 * @param other Another Intent whose values are to be used to fill in
8108 * the current one.
8109 * @param flags Options to control which fields can be filled in.
8110 *
8111 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008112 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008113 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8114 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8115 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008116 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008117 @FillInFlags
8118 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008119 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008120 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008121 if (other.mAction != null
8122 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008123 mAction = other.mAction;
8124 changes |= FILL_IN_ACTION;
8125 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008126 if ((other.mData != null || other.mType != null)
8127 && ((mData == null && mType == null)
8128 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008129 mData = other.mData;
8130 mType = other.mType;
8131 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008132 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008133 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008134 if (other.mCategories != null
8135 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008136 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008137 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008138 }
8139 changes |= FILL_IN_CATEGORIES;
8140 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008141 if (other.mPackage != null
8142 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008143 // Only do this if mSelector is not set.
8144 if (mSelector == null) {
8145 mPackage = other.mPackage;
8146 changes |= FILL_IN_PACKAGE;
8147 }
8148 }
8149 // Selector is special: it can only be set if explicitly allowed,
8150 // for the same reason as the component name.
8151 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8152 if (mPackage == null) {
8153 mSelector = new Intent(other.mSelector);
8154 mPackage = null;
8155 changes |= FILL_IN_SELECTOR;
8156 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008157 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008158 if (other.mClipData != null
8159 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8160 mClipData = other.mClipData;
8161 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008162 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008163 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008164 // Component is special: it can -only- be set if explicitly allowed,
8165 // since otherwise the sender could force the intent somewhere the
8166 // originator didn't intend.
8167 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008168 mComponent = other.mComponent;
8169 changes |= FILL_IN_COMPONENT;
8170 }
8171 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008172 if (other.mSourceBounds != null
8173 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8174 mSourceBounds = new Rect(other.mSourceBounds);
8175 changes |= FILL_IN_SOURCE_BOUNDS;
8176 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008177 if (mExtras == null) {
8178 if (other.mExtras != null) {
8179 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008180 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008181 }
8182 } else if (other.mExtras != null) {
8183 try {
8184 Bundle newb = new Bundle(other.mExtras);
8185 newb.putAll(mExtras);
8186 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008187 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 } catch (RuntimeException e) {
8189 // Modifying the extras can cause us to unparcel the contents
8190 // of the bundle, and if we do this in the system process that
8191 // may fail. We really should handle this (i.e., the Bundle
8192 // impl shouldn't be on top of a plain map), but for now just
8193 // ignore it and keep the original contents. :(
8194 Log.w("Intent", "Failure filling in extras", e);
8195 }
8196 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008197 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8198 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8199 mContentUserHint = other.mContentUserHint;
8200 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008201 return changes;
8202 }
8203
8204 /**
8205 * Wrapper class holding an Intent and implementing comparisons on it for
8206 * the purpose of filtering. The class implements its
8207 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8208 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8209 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8210 * on the wrapped Intent.
8211 */
8212 public static final class FilterComparison {
8213 private final Intent mIntent;
8214 private final int mHashCode;
8215
8216 public FilterComparison(Intent intent) {
8217 mIntent = intent;
8218 mHashCode = intent.filterHashCode();
8219 }
8220
8221 /**
8222 * Return the Intent that this FilterComparison represents.
8223 * @return Returns the Intent held by the FilterComparison. Do
8224 * not modify!
8225 */
8226 public Intent getIntent() {
8227 return mIntent;
8228 }
8229
8230 @Override
8231 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008232 if (obj instanceof FilterComparison) {
8233 Intent other = ((FilterComparison)obj).mIntent;
8234 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008235 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008236 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008237 }
8238
8239 @Override
8240 public int hashCode() {
8241 return mHashCode;
8242 }
8243 }
8244
8245 /**
8246 * Determine if two intents are the same for the purposes of intent
8247 * resolution (filtering). That is, if their action, data, type,
8248 * class, and categories are the same. This does <em>not</em> compare
8249 * any extra data included in the intents.
8250 *
8251 * @param other The other Intent to compare against.
8252 *
8253 * @return Returns true if action, data, type, class, and categories
8254 * are the same.
8255 */
8256 public boolean filterEquals(Intent other) {
8257 if (other == null) {
8258 return false;
8259 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008260 if (!Objects.equals(this.mAction, other.mAction)) return false;
8261 if (!Objects.equals(this.mData, other.mData)) return false;
8262 if (!Objects.equals(this.mType, other.mType)) return false;
8263 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8264 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8265 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008266
8267 return true;
8268 }
8269
8270 /**
8271 * Generate hash code that matches semantics of filterEquals().
8272 *
8273 * @return Returns the hash value of the action, data, type, class, and
8274 * categories.
8275 *
8276 * @see #filterEquals
8277 */
8278 public int filterHashCode() {
8279 int code = 0;
8280 if (mAction != null) {
8281 code += mAction.hashCode();
8282 }
8283 if (mData != null) {
8284 code += mData.hashCode();
8285 }
8286 if (mType != null) {
8287 code += mType.hashCode();
8288 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008289 if (mPackage != null) {
8290 code += mPackage.hashCode();
8291 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008292 if (mComponent != null) {
8293 code += mComponent.hashCode();
8294 }
8295 if (mCategories != null) {
8296 code += mCategories.hashCode();
8297 }
8298 return code;
8299 }
8300
8301 @Override
8302 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008303 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008304
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008305 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008306 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008307 b.append(" }");
8308
8309 return b.toString();
8310 }
8311
8312 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008313 public String toInsecureString() {
8314 StringBuilder b = new StringBuilder(128);
8315
8316 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008317 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008318 b.append(" }");
8319
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008320 return b.toString();
8321 }
Romain Guy4969af72009-06-17 10:53:19 -07008322
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008323 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008324 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008325 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008326
8327 b.append("Intent { ");
8328 toShortString(b, false, true, true, true);
8329 b.append(" }");
8330
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008331 return b.toString();
8332 }
8333
8334 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008335 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8336 StringBuilder b = new StringBuilder(128);
8337 toShortString(b, secure, comp, extras, clip);
8338 return b.toString();
8339 }
8340
8341 /** @hide */
8342 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8343 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008344 boolean first = true;
8345 if (mAction != null) {
8346 b.append("act=").append(mAction);
8347 first = false;
8348 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008349 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008350 if (!first) {
8351 b.append(' ');
8352 }
8353 first = false;
8354 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008355 for (int i=0; i<mCategories.size(); i++) {
8356 if (i > 0) b.append(',');
8357 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008358 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008359 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008360 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008361 if (mData != null) {
8362 if (!first) {
8363 b.append(' ');
8364 }
8365 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008366 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008367 if (secure) {
8368 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008369 } else {
8370 b.append(mData);
8371 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008372 }
8373 if (mType != null) {
8374 if (!first) {
8375 b.append(' ');
8376 }
8377 first = false;
8378 b.append("typ=").append(mType);
8379 }
8380 if (mFlags != 0) {
8381 if (!first) {
8382 b.append(' ');
8383 }
8384 first = false;
8385 b.append("flg=0x").append(Integer.toHexString(mFlags));
8386 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008387 if (mPackage != null) {
8388 if (!first) {
8389 b.append(' ');
8390 }
8391 first = false;
8392 b.append("pkg=").append(mPackage);
8393 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008394 if (comp && mComponent != null) {
8395 if (!first) {
8396 b.append(' ');
8397 }
8398 first = false;
8399 b.append("cmp=").append(mComponent.flattenToShortString());
8400 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008401 if (mSourceBounds != null) {
8402 if (!first) {
8403 b.append(' ');
8404 }
8405 first = false;
8406 b.append("bnds=").append(mSourceBounds.toShortString());
8407 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008408 if (mClipData != null) {
8409 if (!first) {
8410 b.append(' ');
8411 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008412 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008413 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008414 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008415 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008416 if (mClipData.getDescription() != null) {
8417 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8418 } else {
8419 first = true;
8420 }
8421 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008422 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008423 first = false;
8424 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008425 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008426 if (extras && mExtras != null) {
8427 if (!first) {
8428 b.append(' ');
8429 }
8430 first = false;
8431 b.append("(has extras)");
8432 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008433 if (mContentUserHint != UserHandle.USER_CURRENT) {
8434 if (!first) {
8435 b.append(' ');
8436 }
8437 first = false;
8438 b.append("u=").append(mContentUserHint);
8439 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008440 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008441 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008442 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008443 b.append("}");
8444 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008445 }
8446
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008447 /**
8448 * Call {@link #toUri} with 0 flags.
8449 * @deprecated Use {@link #toUri} instead.
8450 */
8451 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008452 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008453 return toUri(0);
8454 }
8455
8456 /**
8457 * Convert this Intent into a String holding a URI representation of it.
8458 * The returned URI string has been properly URI encoded, so it can be
8459 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8460 * Intent's data as the base URI, with an additional fragment describing
8461 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008462 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008463 * <p>You can convert the returned string back to an Intent with
8464 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008465 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008466 * @param flags Additional operating flags. Either 0,
8467 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008468 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008469 * @return Returns a URI encoding URI string describing the entire contents
8470 * of the Intent.
8471 */
8472 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008473 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008474 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8475 if (mPackage == null) {
8476 throw new IllegalArgumentException(
8477 "Intent must include an explicit package name to build an android-app: "
8478 + this);
8479 }
8480 uri.append("android-app://");
8481 uri.append(mPackage);
8482 String scheme = null;
8483 if (mData != null) {
8484 scheme = mData.getScheme();
8485 if (scheme != null) {
8486 uri.append('/');
8487 uri.append(scheme);
8488 String authority = mData.getEncodedAuthority();
8489 if (authority != null) {
8490 uri.append('/');
8491 uri.append(authority);
8492 String path = mData.getEncodedPath();
8493 if (path != null) {
8494 uri.append(path);
8495 }
8496 String queryParams = mData.getEncodedQuery();
8497 if (queryParams != null) {
8498 uri.append('?');
8499 uri.append(queryParams);
8500 }
8501 String fragment = mData.getEncodedFragment();
8502 if (fragment != null) {
8503 uri.append('#');
8504 uri.append(fragment);
8505 }
8506 }
8507 }
8508 }
8509 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8510 mPackage, flags);
8511 return uri.toString();
8512 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008513 String scheme = null;
8514 if (mData != null) {
8515 String data = mData.toString();
8516 if ((flags&URI_INTENT_SCHEME) != 0) {
8517 final int N = data.length();
8518 for (int i=0; i<N; i++) {
8519 char c = data.charAt(i);
8520 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8521 || c == '.' || c == '-') {
8522 continue;
8523 }
8524 if (c == ':' && i > 0) {
8525 // Valid scheme.
8526 scheme = data.substring(0, i);
8527 uri.append("intent:");
8528 data = data.substring(i+1);
8529 break;
8530 }
Tom Taylord4a47292009-12-21 13:59:18 -08008531
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008532 // No scheme.
8533 break;
8534 }
8535 }
8536 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008537
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008538 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8539 uri.append("intent:");
8540 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008541
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008542 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008543
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008544 return uri.toString();
8545 }
8546
8547 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8548 String defPackage, int flags) {
8549 StringBuilder frag = new StringBuilder(128);
8550
8551 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008552 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008553 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008554 // Note that for now we are not going to try to handle the
8555 // data part; not clear how to represent this as a URI, and
8556 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008557 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8558 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008559 }
8560
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008561 if (frag.length() > 0) {
8562 uri.append("#Intent;");
8563 uri.append(frag);
8564 uri.append("end");
8565 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008566 }
8567
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008568 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8569 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008570 if (scheme != null) {
8571 uri.append("scheme=").append(scheme).append(';');
8572 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008573 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008574 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 }
8576 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008577 for (int i=0; i<mCategories.size(); i++) {
8578 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008579 }
8580 }
8581 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008582 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 }
8584 if (mFlags != 0) {
8585 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8586 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008587 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008588 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8589 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008590 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008591 uri.append("component=").append(Uri.encode(
8592 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008593 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008594 if (mSourceBounds != null) {
8595 uri.append("sourceBounds=")
8596 .append(Uri.encode(mSourceBounds.flattenToString()))
8597 .append(';');
8598 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008599 if (mExtras != null) {
8600 for (String key : mExtras.keySet()) {
8601 final Object value = mExtras.get(key);
8602 char entryType =
8603 value instanceof String ? 'S' :
8604 value instanceof Boolean ? 'B' :
8605 value instanceof Byte ? 'b' :
8606 value instanceof Character ? 'c' :
8607 value instanceof Double ? 'd' :
8608 value instanceof Float ? 'f' :
8609 value instanceof Integer ? 'i' :
8610 value instanceof Long ? 'l' :
8611 value instanceof Short ? 's' :
8612 '\0';
8613
8614 if (entryType != '\0') {
8615 uri.append(entryType);
8616 uri.append('.');
8617 uri.append(Uri.encode(key));
8618 uri.append('=');
8619 uri.append(Uri.encode(value.toString()));
8620 uri.append(';');
8621 }
8622 }
8623 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008624 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008625
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008626 public int describeContents() {
8627 return (mExtras != null) ? mExtras.describeContents() : 0;
8628 }
8629
8630 public void writeToParcel(Parcel out, int flags) {
8631 out.writeString(mAction);
8632 Uri.writeToParcel(out, mData);
8633 out.writeString(mType);
8634 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008635 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008636 ComponentName.writeToParcel(mComponent, out);
8637
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008638 if (mSourceBounds != null) {
8639 out.writeInt(1);
8640 mSourceBounds.writeToParcel(out, flags);
8641 } else {
8642 out.writeInt(0);
8643 }
8644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008645 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008646 final int N = mCategories.size();
8647 out.writeInt(N);
8648 for (int i=0; i<N; i++) {
8649 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008650 }
8651 } else {
8652 out.writeInt(0);
8653 }
8654
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008655 if (mSelector != null) {
8656 out.writeInt(1);
8657 mSelector.writeToParcel(out, flags);
8658 } else {
8659 out.writeInt(0);
8660 }
8661
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008662 if (mClipData != null) {
8663 out.writeInt(1);
8664 mClipData.writeToParcel(out, flags);
8665 } else {
8666 out.writeInt(0);
8667 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008668 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008669 out.writeBundle(mExtras);
8670 }
8671
8672 public static final Parcelable.Creator<Intent> CREATOR
8673 = new Parcelable.Creator<Intent>() {
8674 public Intent createFromParcel(Parcel in) {
8675 return new Intent(in);
8676 }
8677 public Intent[] newArray(int size) {
8678 return new Intent[size];
8679 }
8680 };
8681
Dianne Hackborneb034652009-09-07 00:49:58 -07008682 /** @hide */
8683 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008684 readFromParcel(in);
8685 }
8686
8687 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008688 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008689 mData = Uri.CREATOR.createFromParcel(in);
8690 mType = in.readString();
8691 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008692 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008693 mComponent = ComponentName.readFromParcel(in);
8694
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008695 if (in.readInt() != 0) {
8696 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8697 }
8698
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008699 int N = in.readInt();
8700 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008701 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008702 int i;
8703 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008704 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008705 }
8706 } else {
8707 mCategories = null;
8708 }
8709
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008710 if (in.readInt() != 0) {
8711 mSelector = new Intent(in);
8712 }
8713
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008714 if (in.readInt() != 0) {
8715 mClipData = new ClipData(in);
8716 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008717 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008718 mExtras = in.readBundle();
8719 }
8720
8721 /**
8722 * Parses the "intent" element (and its children) from XML and instantiates
8723 * an Intent object. The given XML parser should be located at the tag
8724 * where parsing should start (often named "intent"), from which the
8725 * basic action, data, type, and package and class name will be
8726 * retrieved. The function will then parse in to any child elements,
8727 * looking for <category android:name="xxx"> tags to add categories and
8728 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8729 * to the intent.
8730 *
8731 * @param resources The Resources to use when inflating resources.
8732 * @param parser The XML parser pointing at an "intent" tag.
8733 * @param attrs The AttributeSet interface for retrieving extended
8734 * attribute data at the current <var>parser</var> location.
8735 * @return An Intent object matching the XML data.
8736 * @throws XmlPullParserException If there was an XML parsing error.
8737 * @throws IOException If there was an I/O error.
8738 */
8739 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8740 throws XmlPullParserException, IOException {
8741 Intent intent = new Intent();
8742
8743 TypedArray sa = resources.obtainAttributes(attrs,
8744 com.android.internal.R.styleable.Intent);
8745
8746 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8747
8748 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8749 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8750 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8751
8752 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8753 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8754 if (packageName != null && className != null) {
8755 intent.setComponent(new ComponentName(packageName, className));
8756 }
8757
8758 sa.recycle();
8759
8760 int outerDepth = parser.getDepth();
8761 int type;
8762 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8763 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8764 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8765 continue;
8766 }
8767
8768 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008769 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008770 sa = resources.obtainAttributes(attrs,
8771 com.android.internal.R.styleable.IntentCategory);
8772 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8773 sa.recycle();
8774
8775 if (cat != null) {
8776 intent.addCategory(cat);
8777 }
8778 XmlUtils.skipCurrentTag(parser);
8779
Craig Mautner21d24a22014-04-23 11:45:37 -07008780 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008781 if (intent.mExtras == null) {
8782 intent.mExtras = new Bundle();
8783 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008784 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008785 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008786
8787 } else {
8788 XmlUtils.skipCurrentTag(parser);
8789 }
8790 }
8791
8792 return intent;
8793 }
Nick Pellyccae4122012-01-09 14:12:58 -08008794
Craig Mautner21d24a22014-04-23 11:45:37 -07008795 /** @hide */
8796 public void saveToXml(XmlSerializer out) throws IOException {
8797 if (mAction != null) {
8798 out.attribute(null, ATTR_ACTION, mAction);
8799 }
8800 if (mData != null) {
8801 out.attribute(null, ATTR_DATA, mData.toString());
8802 }
8803 if (mType != null) {
8804 out.attribute(null, ATTR_TYPE, mType);
8805 }
8806 if (mComponent != null) {
8807 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8808 }
8809 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8810
8811 if (mCategories != null) {
8812 out.startTag(null, TAG_CATEGORIES);
8813 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8814 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8815 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008816 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008817 }
8818 }
8819
8820 /** @hide */
8821 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8822 XmlPullParserException {
8823 Intent intent = new Intent();
8824 final int outerDepth = in.getDepth();
8825
8826 int attrCount = in.getAttributeCount();
8827 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8828 final String attrName = in.getAttributeName(attrNdx);
8829 final String attrValue = in.getAttributeValue(attrNdx);
8830 if (ATTR_ACTION.equals(attrName)) {
8831 intent.setAction(attrValue);
8832 } else if (ATTR_DATA.equals(attrName)) {
8833 intent.setData(Uri.parse(attrValue));
8834 } else if (ATTR_TYPE.equals(attrName)) {
8835 intent.setType(attrValue);
8836 } else if (ATTR_COMPONENT.equals(attrName)) {
8837 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8838 } else if (ATTR_FLAGS.equals(attrName)) {
8839 intent.setFlags(Integer.valueOf(attrValue, 16));
8840 } else {
8841 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8842 }
8843 }
8844
8845 int event;
8846 String name;
8847 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8848 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8849 if (event == XmlPullParser.START_TAG) {
8850 name = in.getName();
8851 if (TAG_CATEGORIES.equals(name)) {
8852 attrCount = in.getAttributeCount();
8853 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8854 intent.addCategory(in.getAttributeValue(attrNdx));
8855 }
8856 } else {
8857 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8858 XmlUtils.skipCurrentTag(in);
8859 }
8860 }
8861 }
8862
8863 return intent;
8864 }
8865
Nick Pellyccae4122012-01-09 14:12:58 -08008866 /**
8867 * Normalize a MIME data type.
8868 *
8869 * <p>A normalized MIME type has white-space trimmed,
8870 * content-type parameters removed, and is lower-case.
8871 * This aligns the type with Android best practices for
8872 * intent filtering.
8873 *
8874 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8875 * "text/x-vCard" becomes "text/x-vcard".
8876 *
8877 * <p>All MIME types received from outside Android (such as user input,
8878 * or external sources like Bluetooth, NFC, or the Internet) should
8879 * be normalized before they are used to create an Intent.
8880 *
8881 * @param type MIME data type to normalize
8882 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008883 * @see #setType
8884 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008885 */
8886 public static String normalizeMimeType(String type) {
8887 if (type == null) {
8888 return null;
8889 }
8890
Elliott Hughescb64d432013-08-02 10:00:44 -07008891 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008892
8893 final int semicolonIndex = type.indexOf(';');
8894 if (semicolonIndex != -1) {
8895 type = type.substring(0, semicolonIndex);
8896 }
8897 return type;
8898 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008899
8900 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008901 * Prepare this {@link Intent} to leave an app process.
8902 *
8903 * @hide
8904 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07008905 public void prepareToLeaveProcess(Context context) {
8906 final boolean leavingPackage = (mComponent == null)
8907 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
8908 prepareToLeaveProcess(leavingPackage);
8909 }
8910
8911 /**
8912 * Prepare this {@link Intent} to leave an app process.
8913 *
8914 * @hide
8915 */
8916 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008917 setAllowFds(false);
8918
8919 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008920 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008921 }
8922 if (mClipData != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008923 mClipData.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008924 }
8925
Jeff Sharkeya8b42782016-01-30 17:58:09 -07008926 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
8927 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008928 switch (mAction) {
8929 case ACTION_MEDIA_REMOVED:
8930 case ACTION_MEDIA_UNMOUNTED:
8931 case ACTION_MEDIA_CHECKING:
8932 case ACTION_MEDIA_NOFS:
8933 case ACTION_MEDIA_MOUNTED:
8934 case ACTION_MEDIA_SHARED:
8935 case ACTION_MEDIA_UNSHARED:
8936 case ACTION_MEDIA_BAD_REMOVAL:
8937 case ACTION_MEDIA_UNMOUNTABLE:
8938 case ACTION_MEDIA_EJECT:
8939 case ACTION_MEDIA_SCANNER_STARTED:
8940 case ACTION_MEDIA_SCANNER_FINISHED:
8941 case ACTION_MEDIA_SCANNER_SCAN_FILE:
8942 // Ignore legacy actions
8943 break;
8944 default:
8945 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008946 }
8947 }
8948 }
8949
8950 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008951 * @hide
8952 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008953 public void prepareToEnterProcess() {
8954 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008955 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8956 fixUris(mContentUserHint);
8957 mContentUserHint = UserHandle.USER_CURRENT;
8958 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008959 }
8960 }
8961
8962 /**
8963 * @hide
8964 */
8965 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008966 Uri data = getData();
8967 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008968 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008969 }
8970 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008971 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008972 }
8973 String action = getAction();
8974 if (ACTION_SEND.equals(action)) {
8975 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8976 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008977 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008978 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008979 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008980 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8981 if (streams != null) {
8982 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8983 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008984 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008985 }
8986 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8987 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008988 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8989 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8990 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8991 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8992 if (output != null) {
8993 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8994 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008995 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008996 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008997
8998 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008999 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009000 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9001 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009002 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009003 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009004 * @hide
9005 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009006 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009007 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009008 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009009
9010 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009011 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009012
9013 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009014 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009015 // Inspect contained intents to see if we need to migrate extras. We
9016 // don't promote ClipData to the parent, since ChooserActivity will
9017 // already start the picked item as the caller, and we can't combine
9018 // the flags in a safe way.
9019
9020 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009021 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009022 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9023 if (intent != null) {
9024 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009025 }
9026 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009027 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009028 try {
9029 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9030 if (intents != null) {
9031 for (int i = 0; i < intents.length; i++) {
9032 final Intent intent = (Intent) intents[i];
9033 if (intent != null) {
9034 migrated |= intent.migrateExtraStreamToClipData();
9035 }
9036 }
9037 }
9038 } catch (ClassCastException e) {
9039 }
9040 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009041
9042 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009043 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009044 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9045 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9046 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9047 if (stream != null || text != null || htmlText != null) {
9048 final ClipData clipData = new ClipData(
9049 null, new String[] { getType() },
9050 new ClipData.Item(text, htmlText, null, stream));
9051 setClipData(clipData);
9052 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009053 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009054 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009055 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009056 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009057
9058 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009059 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009060 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9061 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9062 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9063 int num = -1;
9064 if (streams != null) {
9065 num = streams.size();
9066 }
9067 if (texts != null) {
9068 if (num >= 0 && num != texts.size()) {
9069 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009070 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009071 }
9072 num = texts.size();
9073 }
9074 if (htmlTexts != null) {
9075 if (num >= 0 && num != htmlTexts.size()) {
9076 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009077 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009078 }
9079 num = htmlTexts.size();
9080 }
9081 if (num > 0) {
9082 final ClipData clipData = new ClipData(
9083 null, new String[] { getType() },
9084 makeClipItem(streams, texts, htmlTexts, 0));
9085
9086 for (int i = 1; i < num; i++) {
9087 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9088 }
9089
9090 setClipData(clipData);
9091 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009092 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009093 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009094 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009095 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009096 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9097 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9098 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9099 final Uri output;
9100 try {
9101 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9102 } catch (ClassCastException e) {
9103 return false;
9104 }
9105 if (output != null) {
9106 setClipData(ClipData.newRawUri("", output));
9107 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9108 return true;
9109 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009110 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009111
9112 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009113 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009114
9115 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9116 ArrayList<String> htmlTexts, int which) {
9117 Uri uri = streams != null ? streams.get(which) : null;
9118 CharSequence text = texts != null ? texts.get(which) : null;
9119 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9120 return new ClipData.Item(text, htmlText, null, uri);
9121 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009122
9123 /** @hide */
9124 public boolean isDocument() {
9125 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9126 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009127}