blob: c95f19b9bd15d509b9719c56f522d4b342e2b6e7 [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;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010020import android.provider.MediaStore;
Dianne Hackbornadd005c2013-07-17 18:43:12 -070021import android.util.ArraySet;
Jeff Sharkey846318a2014-04-04 12:12:41 -070022
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070023import org.xmlpull.v1.XmlPullParser;
24import org.xmlpull.v1.XmlPullParserException;
25
Tor Norbye7b9c9122013-05-30 16:48:33 -070026import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070027import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070028import android.annotation.SdkConstant;
Jose Lima73915cf2014-07-29 17:16:31 -070029import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.annotation.SdkConstant.SdkConstantType;
31import android.content.pm.ActivityInfo;
Jose Lima73915cf2014-07-29 17:16:31 -070032
Nicolas Prevotd85fc722014-04-16 19:52:08 +010033import static android.content.ContentProvider.maybeAddUserId;
Jose Lima73915cf2014-07-29 17:16:31 -070034
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070035import android.content.pm.PackageManager;
36import android.content.pm.ResolveInfo;
37import android.content.res.Resources;
38import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080039import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070040import android.net.Uri;
41import android.os.Bundle;
42import android.os.IBinder;
43import android.os.Parcel;
44import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000045import android.os.Process;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070046import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010047import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070048import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070049import android.provider.DocumentsProvider;
50import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070051import android.util.AttributeSet;
52import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080053
54import com.android.internal.util.XmlUtils;
Jose Lima73915cf2014-07-29 17:16:31 -070055
Craig Mautner21d24a22014-04-23 11:45:37 -070056import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070057
58import java.io.IOException;
59import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070060import java.lang.annotation.Retention;
61import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.net.URISyntaxException;
63import java.util.ArrayList;
Dianne Hackborn221ea892013-08-04 16:50:16 -070064import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080065import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070066import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070067import java.util.Set;
68
69/**
70 * An intent is an abstract description of an operation to be performed. It
71 * can be used with {@link Context#startActivity(Intent) startActivity} to
72 * launch an {@link android.app.Activity},
73 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
74 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
75 * and {@link android.content.Context#startService} or
76 * {@link android.content.Context#bindService} to communicate with a
77 * background {@link android.app.Service}.
78 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070079 * <p>An Intent provides a facility for performing late runtime binding between the code in
80 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070081 * can be thought of as the glue between activities. It is basically a passive data structure
82 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070083 *
84 * <div class="special reference">
85 * <h3>Developer Guides</h3>
86 * <p>For information about how to create and resolve intents, read the
87 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
88 * developer guide.</p>
89 * </div>
90 *
91 * <a name="IntentStructure"></a>
92 * <h3>Intent Structure</h3>
93 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070094 *
95 * <ul>
96 * <li> <p><b>action</b> -- The general action to be performed, such as
97 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
98 * etc.</p>
99 * </li>
100 * <li> <p><b>data</b> -- The data to operate on, such as a person record
101 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
102 * </li>
103 * </ul>
104 *
105 *
106 * <p>Some examples of action/data pairs are:</p>
107 *
108 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700109 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700110 * information about the person whose identifier is "1".</p>
111 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700112 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700113 * the phone dialer with the person filled in.</p>
114 * </li>
115 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
116 * the phone dialer with the given number filled in. Note how the
117 * VIEW action does what what is considered the most reasonable thing for
118 * a particular URI.</p>
119 * </li>
120 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
121 * the phone dialer with the given number filled in.</p>
122 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700123 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700124 * information about the person whose identifier is "1".</p>
125 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700126 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700127 * a list of people, which the user can browse through. This example is a
128 * typical top-level entry into the Contacts application, showing you the
129 * list of people. Selecting a particular person to view would result in a
130 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
131 * being used to start an activity to display that person.</p>
132 * </li>
133 * </ul>
134 *
135 * <p>In addition to these primary attributes, there are a number of secondary
136 * attributes that you can also include with an intent:</p>
137 *
138 * <ul>
139 * <li> <p><b>category</b> -- Gives additional information about the action
140 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
141 * appear in the Launcher as a top-level application, while
142 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
143 * of alternative actions the user can perform on a piece of data.</p>
144 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
145 * intent data. Normally the type is inferred from the data itself.
146 * By setting this attribute, you disable that evaluation and force
147 * an explicit type.</p>
148 * <li> <p><b>component</b> -- Specifies an explicit name of a component
149 * class to use for the intent. Normally this is determined by looking
150 * at the other information in the intent (the action, data/type, and
151 * categories) and matching that with a component that can handle it.
152 * If this attribute is set then none of the evaluation is performed,
153 * and this component is used exactly as is. By specifying this attribute,
154 * all of the other Intent attributes become optional.</p>
155 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
156 * This can be used to provide extended information to the component.
157 * For example, if we have a action to send an e-mail message, we could
158 * also include extra pieces of data here to supply a subject, body,
159 * etc.</p>
160 * </ul>
161 *
162 * <p>Here are some examples of other operations you can specify as intents
163 * using these additional parameters:</p>
164 *
165 * <ul>
166 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
167 * Launch the home screen.</p>
168 * </li>
169 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
170 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
171 * vnd.android.cursor.item/phone}</i></b>
172 * -- Display the list of people's phone numbers, allowing the user to
173 * browse through them and pick one and return it to the parent activity.</p>
174 * </li>
175 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
176 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
177 * -- Display all pickers for data that can be opened with
178 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
179 * allowing the user to pick one of them and then some data inside of it
180 * and returning the resulting URI to the caller. This can be used,
181 * for example, in an e-mail application to allow the user to pick some
182 * data to include as an attachment.</p>
183 * </li>
184 * </ul>
185 *
186 * <p>There are a variety of standard Intent action and category constants
187 * defined in the Intent class, but applications can also define their own.
188 * These strings use java style scoping, to ensure they are unique -- for
189 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700190 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700191 *
192 * <p>Put together, the set of actions, data types, categories, and extra data
193 * defines a language for the system allowing for the expression of phrases
194 * such as "call john smith's cell". As applications are added to the system,
195 * they can extend this language by adding new actions, types, and categories, or
196 * they can modify the behavior of existing phrases by supplying their own
197 * activities that handle them.</p>
198 *
199 * <a name="IntentResolution"></a>
200 * <h3>Intent Resolution</h3>
201 *
202 * <p>There are two primary forms of intents you will use.
203 *
204 * <ul>
205 * <li> <p><b>Explicit Intents</b> have specified a component (via
206 * {@link #setComponent} or {@link #setClass}), which provides the exact
207 * class to be run. Often these will not include any other information,
208 * simply being a way for an application to launch various internal
209 * activities it has as the user interacts with the application.
210 *
211 * <li> <p><b>Implicit Intents</b> have not specified a component;
212 * instead, they must include enough information for the system to
213 * determine which of the available components is best to run for that
214 * intent.
215 * </ul>
216 *
217 * <p>When using implicit intents, given such an arbitrary intent we need to
218 * know what to do with it. This is handled by the process of <em>Intent
219 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
220 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
221 * more activities/receivers) that can handle it.</p>
222 *
223 * <p>The intent resolution mechanism basically revolves around matching an
224 * Intent against all of the &lt;intent-filter&gt; descriptions in the
225 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
226 * objects explicitly registered with {@link Context#registerReceiver}.) More
227 * details on this can be found in the documentation on the {@link
228 * IntentFilter} class.</p>
229 *
230 * <p>There are three pieces of information in the Intent that are used for
231 * resolution: the action, type, and category. Using this information, a query
232 * is done on the {@link PackageManager} for a component that can handle the
233 * intent. The appropriate component is determined based on the intent
234 * information supplied in the <code>AndroidManifest.xml</code> file as
235 * follows:</p>
236 *
237 * <ul>
238 * <li> <p>The <b>action</b>, if given, must be listed by the component as
239 * one it handles.</p>
240 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
241 * already supplied in the Intent. Like the action, if a type is
242 * included in the intent (either explicitly or implicitly in its
243 * data), then this must be listed by the component as one it handles.</p>
244 * <li> For data that is not a <code>content:</code> URI and where no explicit
245 * type is included in the Intent, instead the <b>scheme</b> of the
246 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
247 * considered. Again like the action, if we are matching a scheme it
248 * must be listed by the component as one it can handle.
249 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
250 * by the activity as categories it handles. That is, if you include
251 * the categories {@link #CATEGORY_LAUNCHER} and
252 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
253 * with an intent that lists <em>both</em> of those categories.
254 * Activities will very often need to support the
255 * {@link #CATEGORY_DEFAULT} so that they can be found by
256 * {@link Context#startActivity Context.startActivity()}.</p>
257 * </ul>
258 *
259 * <p>For example, consider the Note Pad sample application that
260 * allows user to browse through a list of notes data and view details about
261 * individual items. Text in italics indicate places were you would replace a
262 * name with one specific to your own package.</p>
263 *
264 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
265 * package="<i>com.android.notepad</i>"&gt;
266 * &lt;application android:icon="@drawable/app_notes"
267 * android:label="@string/app_name"&gt;
268 *
269 * &lt;provider class=".NotePadProvider"
270 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
271 *
272 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
273 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700274 * &lt;action android:name="android.intent.action.MAIN" /&gt;
275 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700276 * &lt;/intent-filter&gt;
277 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700278 * &lt;action android:name="android.intent.action.VIEW" /&gt;
279 * &lt;action android:name="android.intent.action.EDIT" /&gt;
280 * &lt;action android:name="android.intent.action.PICK" /&gt;
281 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
282 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700283 * &lt;/intent-filter&gt;
284 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700285 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
286 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
287 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700288 * &lt;/intent-filter&gt;
289 * &lt;/activity&gt;
290 *
291 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
292 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700293 * &lt;action android:name="android.intent.action.VIEW" /&gt;
294 * &lt;action android:name="android.intent.action.EDIT" /&gt;
295 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
296 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700297 * &lt;/intent-filter&gt;
298 *
299 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700300 * &lt;action android:name="android.intent.action.INSERT" /&gt;
301 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
302 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700303 * &lt;/intent-filter&gt;
304 *
305 * &lt;/activity&gt;
306 *
307 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
308 * android:theme="@android:style/Theme.Dialog"&gt;
309 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700310 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
311 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
312 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
313 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
314 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700315 * &lt;/intent-filter&gt;
316 * &lt;/activity&gt;
317 *
318 * &lt;/application&gt;
319 * &lt;/manifest&gt;</pre>
320 *
321 * <p>The first activity,
322 * <code>com.android.notepad.NotesList</code>, serves as our main
323 * entry into the app. It can do three things as described by its three intent
324 * templates:
325 * <ol>
326 * <li><pre>
327 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700328 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
329 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700330 * &lt;/intent-filter&gt;</pre>
331 * <p>This provides a top-level entry into the NotePad application: the standard
332 * MAIN action is a main entry point (not requiring any other information in
333 * the Intent), and the LAUNCHER category says that this entry point should be
334 * listed in the application launcher.</p>
335 * <li><pre>
336 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700337 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
338 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
339 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
340 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
341 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700342 * &lt;/intent-filter&gt;</pre>
343 * <p>This declares the things that the activity can do on a directory of
344 * notes. The type being supported is given with the &lt;type&gt; tag, where
345 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
346 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
347 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
348 * The activity allows the user to view or edit the directory of data (via
349 * the VIEW and EDIT actions), or to pick a particular note and return it
350 * to the caller (via the PICK action). Note also the DEFAULT category
351 * supplied here: this is <em>required</em> for the
352 * {@link Context#startActivity Context.startActivity} method to resolve your
353 * activity when its component name is not explicitly specified.</p>
354 * <li><pre>
355 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700356 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
357 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
358 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700359 * &lt;/intent-filter&gt;</pre>
360 * <p>This filter describes the ability return to the caller a note selected by
361 * the user without needing to know where it came from. The data type
362 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
363 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
364 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
365 * The GET_CONTENT action is similar to the PICK action, where the activity
366 * will return to its caller a piece of data selected by the user. Here,
367 * however, the caller specifies the type of data they desire instead of
368 * the type of data the user will be picking from.</p>
369 * </ol>
370 *
371 * <p>Given these capabilities, the following intents will resolve to the
372 * NotesList activity:</p>
373 *
374 * <ul>
375 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
376 * activities that can be used as top-level entry points into an
377 * application.</p>
378 * <li> <p><b>{ action=android.app.action.MAIN,
379 * category=android.app.category.LAUNCHER }</b> is the actual intent
380 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700381 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700382 * data=content://com.google.provider.NotePad/notes }</b>
383 * displays a list of all the notes under
384 * "content://com.google.provider.NotePad/notes", which
385 * the user can browse through and see the details on.</p>
386 * <li> <p><b>{ action=android.app.action.PICK
387 * data=content://com.google.provider.NotePad/notes }</b>
388 * provides a list of the notes under
389 * "content://com.google.provider.NotePad/notes", from which
390 * the user can pick a note whose data URL is returned back to the caller.</p>
391 * <li> <p><b>{ action=android.app.action.GET_CONTENT
392 * type=vnd.android.cursor.item/vnd.google.note }</b>
393 * is similar to the pick action, but allows the caller to specify the
394 * kind of data they want back so that the system can find the appropriate
395 * activity to pick something of that data type.</p>
396 * </ul>
397 *
398 * <p>The second activity,
399 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
400 * note entry and allows them to edit it. It can do two things as described
401 * by its two intent templates:
402 * <ol>
403 * <li><pre>
404 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700405 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
406 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
407 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
408 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700409 * &lt;/intent-filter&gt;</pre>
410 * <p>The first, primary, purpose of this activity is to let the user interact
411 * with a single note, as decribed by the MIME type
412 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
413 * either VIEW a note or allow the user to EDIT it. Again we support the
414 * DEFAULT category to allow the activity to be launched without explicitly
415 * specifying its component.</p>
416 * <li><pre>
417 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700418 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
419 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
420 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700421 * &lt;/intent-filter&gt;</pre>
422 * <p>The secondary use of this activity is to insert a new note entry into
423 * an existing directory of notes. This is used when the user creates a new
424 * note: the INSERT action is executed on the directory of notes, causing
425 * this activity to run and have the user create the new note data which
426 * it then adds to the content provider.</p>
427 * </ol>
428 *
429 * <p>Given these capabilities, the following intents will resolve to the
430 * NoteEditor activity:</p>
431 *
432 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700433 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700434 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
435 * shows the user the content of note <var>{ID}</var>.</p>
436 * <li> <p><b>{ action=android.app.action.EDIT
437 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
438 * allows the user to edit the content of note <var>{ID}</var>.</p>
439 * <li> <p><b>{ action=android.app.action.INSERT
440 * data=content://com.google.provider.NotePad/notes }</b>
441 * creates a new, empty note in the notes list at
442 * "content://com.google.provider.NotePad/notes"
443 * and allows the user to edit it. If they keep their changes, the URI
444 * of the newly created note is returned to the caller.</p>
445 * </ul>
446 *
447 * <p>The last activity,
448 * <code>com.android.notepad.TitleEditor</code>, allows the user to
449 * edit the title of a note. This could be implemented as a class that the
450 * application directly invokes (by explicitly setting its component in
451 * the Intent), but here we show a way you can publish alternative
452 * operations on existing data:</p>
453 *
454 * <pre>
455 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700456 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
457 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
458 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
459 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
460 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700461 * &lt;/intent-filter&gt;</pre>
462 *
463 * <p>In the single intent template here, we
464 * have created our own private action called
465 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
466 * edit the title of a note. It must be invoked on a specific note
467 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
468 * view and edit actions, but here displays and edits the title contained
469 * in the note data.
470 *
471 * <p>In addition to supporting the default category as usual, our title editor
472 * also supports two other standard categories: ALTERNATIVE and
473 * SELECTED_ALTERNATIVE. Implementing
474 * these categories allows others to find the special action it provides
475 * without directly knowing about it, through the
476 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
477 * more often to build dynamic menu items with
478 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
479 * template here was also supply an explicit name for the template
480 * (via <code>android:label="@string/resolve_title"</code>) to better control
481 * what the user sees when presented with this activity as an alternative
482 * action to the data they are viewing.
483 *
484 * <p>Given these capabilities, the following intent will resolve to the
485 * TitleEditor activity:</p>
486 *
487 * <ul>
488 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
489 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
490 * displays and allows the user to edit the title associated
491 * with note <var>{ID}</var>.</p>
492 * </ul>
493 *
494 * <h3>Standard Activity Actions</h3>
495 *
496 * <p>These are the current standard actions that Intent defines for launching
497 * activities (usually through {@link Context#startActivity}. The most
498 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
499 * {@link #ACTION_EDIT}.
500 *
501 * <ul>
502 * <li> {@link #ACTION_MAIN}
503 * <li> {@link #ACTION_VIEW}
504 * <li> {@link #ACTION_ATTACH_DATA}
505 * <li> {@link #ACTION_EDIT}
506 * <li> {@link #ACTION_PICK}
507 * <li> {@link #ACTION_CHOOSER}
508 * <li> {@link #ACTION_GET_CONTENT}
509 * <li> {@link #ACTION_DIAL}
510 * <li> {@link #ACTION_CALL}
511 * <li> {@link #ACTION_SEND}
512 * <li> {@link #ACTION_SENDTO}
513 * <li> {@link #ACTION_ANSWER}
514 * <li> {@link #ACTION_INSERT}
515 * <li> {@link #ACTION_DELETE}
516 * <li> {@link #ACTION_RUN}
517 * <li> {@link #ACTION_SYNC}
518 * <li> {@link #ACTION_PICK_ACTIVITY}
519 * <li> {@link #ACTION_SEARCH}
520 * <li> {@link #ACTION_WEB_SEARCH}
521 * <li> {@link #ACTION_FACTORY_TEST}
522 * </ul>
523 *
524 * <h3>Standard Broadcast Actions</h3>
525 *
526 * <p>These are the current standard actions that Intent defines for receiving
527 * broadcasts (usually through {@link Context#registerReceiver} or a
528 * &lt;receiver&gt; tag in a manifest).
529 *
530 * <ul>
531 * <li> {@link #ACTION_TIME_TICK}
532 * <li> {@link #ACTION_TIME_CHANGED}
533 * <li> {@link #ACTION_TIMEZONE_CHANGED}
534 * <li> {@link #ACTION_BOOT_COMPLETED}
535 * <li> {@link #ACTION_PACKAGE_ADDED}
536 * <li> {@link #ACTION_PACKAGE_CHANGED}
537 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800538 * <li> {@link #ACTION_PACKAGE_RESTARTED}
539 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700540 * <li> {@link #ACTION_UID_REMOVED}
541 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700542 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700543 * <li> {@link #ACTION_POWER_DISCONNECTED}
544 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700545 * </ul>
546 *
547 * <h3>Standard Categories</h3>
548 *
549 * <p>These are the current standard categories that can be used to further
550 * clarify an Intent via {@link #addCategory}.
551 *
552 * <ul>
553 * <li> {@link #CATEGORY_DEFAULT}
554 * <li> {@link #CATEGORY_BROWSABLE}
555 * <li> {@link #CATEGORY_TAB}
556 * <li> {@link #CATEGORY_ALTERNATIVE}
557 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
558 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800559 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700560 * <li> {@link #CATEGORY_HOME}
561 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700562 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400563 * <li> {@link #CATEGORY_CAR_DOCK}
564 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500565 * <li> {@link #CATEGORY_LE_DESK_DOCK}
566 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200567 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700568 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700569 * </ul>
570 *
571 * <h3>Standard Extra Data</h3>
572 *
573 * <p>These are the current standard fields that can be used as extra data via
574 * {@link #putExtra}.
575 *
576 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800577 * <li> {@link #EXTRA_ALARM_COUNT}
578 * <li> {@link #EXTRA_BCC}
579 * <li> {@link #EXTRA_CC}
580 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
581 * <li> {@link #EXTRA_DATA_REMOVED}
582 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500583 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
584 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800585 * <li> {@link #EXTRA_DOCK_STATE_CAR}
586 * <li> {@link #EXTRA_DOCK_STATE_DESK}
587 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
588 * <li> {@link #EXTRA_DONT_KILL_APP}
589 * <li> {@link #EXTRA_EMAIL}
590 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700591 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800592 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700593 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800594 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700595 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800596 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
597 * <li> {@link #EXTRA_REPLACING}
598 * <li> {@link #EXTRA_SHORTCUT_ICON}
599 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
600 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700601 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_SHORTCUT_NAME}
603 * <li> {@link #EXTRA_SUBJECT}
604 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700605 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_TITLE}
607 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 * </ul>
609 *
610 * <h3>Flags</h3>
611 *
612 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800613 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
614 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800616public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700617 private static final String ATTR_ACTION = "action";
618 private static final String TAG_CATEGORIES = "categories";
619 private static final String ATTR_CATEGORY = "category";
620 private static final String TAG_EXTRA = "extra";
621 private static final String ATTR_TYPE = "type";
622 private static final String ATTR_COMPONENT = "component";
623 private static final String ATTR_DATA = "data";
624 private static final String ATTR_FLAGS = "flags";
625
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700626 // ---------------------------------------------------------------------
627 // ---------------------------------------------------------------------
628 // Standard intent activity actions (see action variable).
629
630 /**
631 * Activity Action: Start as a main entry point, does not expect to
632 * receive data.
633 * <p>Input: nothing
634 * <p>Output: nothing
635 */
636 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
637 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800638
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700639 /**
640 * Activity Action: Display the data to the user. This is the most common
641 * action performed on data -- it is the generic action you can use on
642 * a piece of data to get the most reasonable thing to occur. For example,
643 * when used on a contacts entry it will view the entry; when used on a
644 * mailto: URI it will bring up a compose window filled with the information
645 * supplied by the URI; when used with a tel: URI it will invoke the
646 * dialer.
647 * <p>Input: {@link #getData} is URI from which to retrieve data.
648 * <p>Output: nothing.
649 */
650 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
651 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800652
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700653 /**
654 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
655 * performed on a piece of data.
656 */
657 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 /**
660 * Used to indicate that some piece of data should be attached to some other
661 * place. For example, image data could be attached to a contact. It is up
662 * to the recipient to decide where the data should be attached; the intent
663 * does not specify the ultimate destination.
664 * <p>Input: {@link #getData} is URI of data to be attached.
665 * <p>Output: nothing.
666 */
667 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
668 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800669
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700670 /**
671 * Activity Action: Provide explicit editable access to the given data.
672 * <p>Input: {@link #getData} is URI of data to be edited.
673 * <p>Output: nothing.
674 */
675 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
676 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800677
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700678 /**
679 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
680 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
681 * The extras can contain type specific data to pass through to the editing/creating
682 * activity.
683 * <p>Output: The URI of the item that was picked. This must be a content:
684 * URI so that any receiver can access it.
685 */
686 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
687 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
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: Pick an item from the data, returning what was selected.
691 * <p>Input: {@link #getData} is URI containing a directory of data
692 * (vnd.android.cursor.dir/*) from which to pick an item.
693 * <p>Output: The URI of the item that was picked.
694 */
695 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
696 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800697
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700698 /**
699 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800700 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700701 * <p>Output: An Intent representing the shortcut. The intent must contain three
702 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
703 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800704 * (value: ShortcutIconResource).</p>
705 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700706 * @see #EXTRA_SHORTCUT_INTENT
707 * @see #EXTRA_SHORTCUT_NAME
708 * @see #EXTRA_SHORTCUT_ICON
709 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
710 * @see android.content.Intent.ShortcutIconResource
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
714
715 /**
716 * The name of the extra used to define the Intent of a shortcut.
717 *
718 * @see #ACTION_CREATE_SHORTCUT
719 */
720 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
721 /**
722 * The name of the extra used to define the name of a shortcut.
723 *
724 * @see #ACTION_CREATE_SHORTCUT
725 */
726 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
727 /**
728 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
729 *
730 * @see #ACTION_CREATE_SHORTCUT
731 */
732 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
733 /**
734 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
735 *
736 * @see #ACTION_CREATE_SHORTCUT
737 * @see android.content.Intent.ShortcutIconResource
738 */
739 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
740 "android.intent.extra.shortcut.ICON_RESOURCE";
741
742 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800743 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700744 *
745 * @see Intent#ACTION_CREATE_SHORTCUT
746 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800747 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
748 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700749 */
750 public static class ShortcutIconResource implements Parcelable {
751 /**
752 * The package name of the application containing the icon.
753 */
754 public String packageName;
755
756 /**
757 * The resource name of the icon, including package, name and type.
758 */
759 public String resourceName;
760
761 /**
762 * Creates a new ShortcutIconResource for the specified context and resource
763 * identifier.
764 *
765 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700766 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700768 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700769 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700770 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700771 ShortcutIconResource icon = new ShortcutIconResource();
772 icon.packageName = context.getPackageName();
773 icon.resourceName = context.getResources().getResourceName(resourceId);
774 return icon;
775 }
776
777 /**
778 * Used to read a ShortcutIconResource from a Parcel.
779 */
780 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
781 new Parcelable.Creator<ShortcutIconResource>() {
782
783 public ShortcutIconResource createFromParcel(Parcel source) {
784 ShortcutIconResource icon = new ShortcutIconResource();
785 icon.packageName = source.readString();
786 icon.resourceName = source.readString();
787 return icon;
788 }
789
790 public ShortcutIconResource[] newArray(int size) {
791 return new ShortcutIconResource[size];
792 }
793 };
794
795 /**
796 * No special parcel contents.
797 */
798 public int describeContents() {
799 return 0;
800 }
801
802 public void writeToParcel(Parcel dest, int flags) {
803 dest.writeString(packageName);
804 dest.writeString(resourceName);
805 }
806
807 @Override
808 public String toString() {
809 return resourceName;
810 }
811 }
812
813 /**
814 * Activity Action: Display an activity chooser, allowing the user to pick
815 * what they want to before proceeding. This can be used as an alternative
816 * to the standard activity picker that is displayed by the system when
817 * you try to start an activity with multiple possible matches, with these
818 * differences in behavior:
819 * <ul>
820 * <li>You can specify the title that will appear in the activity chooser.
821 * <li>The user does not have the option to make one of the matching
822 * activities a preferred activity, and all possible activities will
823 * always be shown even if one of them is currently marked as the
824 * preferred activity.
825 * </ul>
826 * <p>
827 * This action should be used when the user will naturally expect to
828 * select an activity in order to proceed. An example if when not to use
829 * it is when the user clicks on a "mailto:" link. They would naturally
830 * expect to go directly to their mail app, so startActivity() should be
831 * called directly: it will
832 * either launch the current preferred app, or put up a dialog allowing the
833 * user to pick an app to use and optionally marking that as preferred.
834 * <p>
835 * In contrast, if the user is selecting a menu item to send a picture
836 * they are viewing to someone else, there are many different things they
837 * may want to do at this point: send it through e-mail, upload it to a
838 * web service, etc. In this case the CHOOSER action should be used, to
839 * always present to the user a list of the things they can do, with a
840 * nice title given by the caller such as "Send this photo with:".
841 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700842 * If you need to grant URI permissions through a chooser, you must specify
843 * the permissions to be granted on the ACTION_CHOOSER Intent
844 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
845 * {@link #setClipData} to specify the URIs to be granted as well as
846 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
847 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
848 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700849 * As a convenience, an Intent of this form can be created with the
850 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700851 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700852 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700853 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
854 * and can optionally have a {@link #EXTRA_TITLE} field containing the
855 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700856 * <p>
857 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700858 */
859 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
860 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
861
862 /**
863 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
864 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700865 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
866 * target intent, also optionally supplying a title. If the target
867 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
868 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
869 * set in the returned chooser intent, with its ClipData set appropriately:
870 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500871 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700872 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700873 * @param target The Intent that the user will be selecting an activity
874 * to perform.
875 * @param title Optional title that will be displayed in the chooser.
876 * @return Return a new Intent object that you can hand to
877 * {@link Context#startActivity(Intent) Context.startActivity()} and
878 * related methods.
879 */
880 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700881 return createChooser(target, title, null);
882 }
883
884 /**
885 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
886 *
887 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
888 * target intent, also optionally supplying a title. If the target
889 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
890 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
891 * set in the returned chooser intent, with its ClipData set appropriately:
892 * either a direct reflection of {@link #getClipData()} if that is non-null,
893 * or a new ClipData built from {@link #getData()}.</p>
894 *
895 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
896 * when the user makes a choice. This can be useful if the calling application wants
897 * to remember the last chosen target and surface it as a more prominent or one-touch
898 * affordance elsewhere in the UI for next time.</p>
899 *
900 * @param target The Intent that the user will be selecting an activity
901 * to perform.
902 * @param title Optional title that will be displayed in the chooser.
903 * @param sender Optional IntentSender to be called when a choice is made.
904 * @return Return a new Intent object that you can hand to
905 * {@link Context#startActivity(Intent) Context.startActivity()} and
906 * related methods.
907 */
908 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700909 Intent intent = new Intent(ACTION_CHOOSER);
910 intent.putExtra(EXTRA_INTENT, target);
911 if (title != null) {
912 intent.putExtra(EXTRA_TITLE, title);
913 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700914
Adam Powell0b3c1122014-10-09 12:50:14 -0700915 if (sender != null) {
916 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
917 }
918
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700919 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700920 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
921 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
922 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700923 if (permFlags != 0) {
924 ClipData targetClipData = target.getClipData();
925 if (targetClipData == null && target.getData() != null) {
926 ClipData.Item item = new ClipData.Item(target.getData());
927 String[] mimeTypes;
928 if (target.getType() != null) {
929 mimeTypes = new String[] { target.getType() };
930 } else {
931 mimeTypes = new String[] { };
932 }
933 targetClipData = new ClipData(null, mimeTypes, item);
934 }
935 if (targetClipData != null) {
936 intent.setClipData(targetClipData);
937 intent.addFlags(permFlags);
938 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700939 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700940
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700941 return intent;
942 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700943
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700944 /**
945 * Activity Action: Allow the user to select a particular kind of data and
946 * return it. This is different than {@link #ACTION_PICK} in that here we
947 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800948 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700949 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900950 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700951 * etc.
952 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900953 * 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 -0700954 * of data, such as a person contact, you set the MIME type to the kind of
955 * data you want and launch it with {@link Context#startActivity(Intent)}.
956 * The system will then launch the best application to select that kind
957 * of data for you.
958 * <p>
959 * You may also be interested in any of a set of types of content the user
960 * can pick. For example, an e-mail application that wants to allow the
961 * user to add an attachment to an e-mail message can use this action to
962 * bring up a list of all of the types of content the user can attach.
963 * <p>
964 * In this case, you should wrap the GET_CONTENT intent with a chooser
965 * (through {@link #createChooser}), which will give the proper interface
966 * for the user to pick how to send your data and allow you to specify
967 * a prompt indicating what they are doing. You will usually specify a
968 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
969 * broad range of content types the user can select from.
970 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900971 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700972 * only pick from data that can be represented as a stream. This is
973 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
974 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800975 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900976 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800977 * is locally available on the device. For example, if this extra is set
978 * to true then an image picker should not show any pictures that are available
979 * from a remote server but not already on the local device (thus requiring
980 * they be downloaded when opened).
981 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800982 * If the caller can handle multiple returned items (the user performing
983 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
984 * to indicate this.
985 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700986 * Input: {@link #getType} is the desired MIME type to retrieve. Note
987 * that no URI is supplied in the intent, as there are no constraints on
988 * where the returned data originally comes from. You may also include the
989 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800990 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800991 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
992 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700993 * <p>
994 * Output: The URI of the item that was picked. This must be a content:
995 * URI so that any receiver can access it.
996 */
997 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
998 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
999 /**
1000 * Activity Action: Dial a number as specified by the data. This shows a
1001 * UI with the number being dialed, allowing the user to explicitly
1002 * initiate the call.
1003 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1004 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1005 * number.
1006 * <p>Output: nothing.
1007 */
1008 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1009 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1010 /**
1011 * Activity Action: Perform a call to someone specified by the data.
1012 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1013 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1014 * number.
1015 * <p>Output: nothing.
1016 *
1017 * <p>Note: there will be restrictions on which applications can initiate a
1018 * call; most applications should use the {@link #ACTION_DIAL}.
1019 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1020 * numbers. Applications can <strong>dial</strong> emergency numbers using
1021 * {@link #ACTION_DIAL}, however.
1022 */
1023 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1024 public static final String ACTION_CALL = "android.intent.action.CALL";
1025 /**
1026 * Activity Action: Perform a call to an emergency number specified by the
1027 * data.
1028 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1029 * tel: URI of an explicit phone number.
1030 * <p>Output: nothing.
1031 * @hide
1032 */
1033 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1034 /**
1035 * Activity action: Perform a call to any number (emergency or not)
1036 * specified by the data.
1037 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1038 * tel: URI of an explicit phone number.
1039 * <p>Output: nothing.
1040 * @hide
1041 */
1042 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1043 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001044 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1045 * sending this intent is a no-op.
1046 * <p>Input: No data should be specified. get*Extra may have an optional
1047 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1048 * send the activation result.
1049 * <p>Output: nothing.
1050 * @hide
1051 */
1052 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1053 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1054 "android.intent.action.SIM_ACTIVATION_REQUEST";
1055 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001056 * Activity Action: Send a message to someone specified by the data.
1057 * <p>Input: {@link #getData} is URI describing the target.
1058 * <p>Output: nothing.
1059 */
1060 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1061 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1062 /**
1063 * Activity Action: Deliver some data to someone else. Who the data is
1064 * being delivered to is not specified; it is up to the receiver of this
1065 * action to ask the user where the data should be sent.
1066 * <p>
1067 * When launching a SEND intent, you should usually wrap it in a chooser
1068 * (through {@link #createChooser}), which will give the proper interface
1069 * for the user to pick how to send your data and allow you to specify
1070 * a prompt indicating what they are doing.
1071 * <p>
1072 * Input: {@link #getType} is the MIME type of the data being sent.
1073 * get*Extra can have either a {@link #EXTRA_TEXT}
1074 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1075 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1076 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1077 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001078 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1079 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1080 * your text with HTML formatting.
1081 * <p>
1082 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1083 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1084 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1085 * content: URIs and other advanced features of {@link ClipData}. If
1086 * using this approach, you still must supply the same data through the
1087 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1088 * for compatibility with old applications. If you don't set a ClipData,
1089 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001090 * <p>
1091 * Optional standard extras, which may be interpreted by some recipients as
1092 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1093 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1094 * <p>
1095 * Output: nothing.
1096 */
1097 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1098 public static final String ACTION_SEND = "android.intent.action.SEND";
1099 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001100 * Activity Action: Deliver multiple data to someone else.
1101 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001102 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001103 * <p>
1104 * Input: {@link #getType} is the MIME type of the data being sent.
1105 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001106 * #EXTRA_STREAM} field, containing the data to be sent. If using
1107 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1108 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001109 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001110 * Multiple types are supported, and receivers should handle mixed types
1111 * whenever possible. The right way for the receiver to check them is to
1112 * use the content resolver on each URI. The intent sender should try to
1113 * put the most concrete mime type in the intent type, but it can fall
1114 * back to {@literal <type>/*} or {@literal *}/* as needed.
1115 * <p>
1116 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1117 * be image/jpg, but if you are sending image/jpg and image/png, then the
1118 * intent's type should be image/*.
1119 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001120 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1121 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1122 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1123 * content: URIs and other advanced features of {@link ClipData}. If
1124 * using this approach, you still must supply the same data through the
1125 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1126 * for compatibility with old applications. If you don't set a ClipData,
1127 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1128 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001129 * Optional standard extras, which may be interpreted by some recipients as
1130 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1131 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1132 * <p>
1133 * Output: nothing.
1134 */
1135 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1136 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1137 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001138 * Activity Action: Handle an incoming phone call.
1139 * <p>Input: nothing.
1140 * <p>Output: nothing.
1141 */
1142 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1143 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1144 /**
1145 * Activity Action: Insert an empty item into the given container.
1146 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1147 * in which to place the data.
1148 * <p>Output: URI of the new data that was created.
1149 */
1150 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1151 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1152 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001153 * Activity Action: Create a new item in the given container, initializing it
1154 * from the current contents of the clipboard.
1155 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1156 * in which to place the data.
1157 * <p>Output: URI of the new data that was created.
1158 */
1159 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1160 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1161 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001162 * Activity Action: Delete the given data from its container.
1163 * <p>Input: {@link #getData} is URI of data to be deleted.
1164 * <p>Output: nothing.
1165 */
1166 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1167 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1168 /**
1169 * Activity Action: Run the data, whatever that means.
1170 * <p>Input: ? (Note: this is currently specific to the test harness.)
1171 * <p>Output: nothing.
1172 */
1173 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1174 public static final String ACTION_RUN = "android.intent.action.RUN";
1175 /**
1176 * Activity Action: Perform a data synchronization.
1177 * <p>Input: ?
1178 * <p>Output: ?
1179 */
1180 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1181 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1182 /**
1183 * Activity Action: Pick an activity given an intent, returning the class
1184 * selected.
1185 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1186 * used with {@link PackageManager#queryIntentActivities} to determine the
1187 * set of activities from which to pick.
1188 * <p>Output: Class name of the activity that was selected.
1189 */
1190 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1191 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1192 /**
1193 * Activity Action: Perform a search.
1194 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1195 * is the text to search for. If empty, simply
1196 * enter your search results Activity with the search UI activated.
1197 * <p>Output: nothing.
1198 */
1199 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1200 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1201 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001202 * Activity Action: Start the platform-defined tutorial
1203 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1204 * is the text to search for. If empty, simply
1205 * enter your search results Activity with the search UI activated.
1206 * <p>Output: nothing.
1207 */
1208 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1209 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1210 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001211 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001212 * <p>
1213 * Input: {@link android.app.SearchManager#QUERY
1214 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1215 * a url starts with http or https, the site will be opened. If it is plain
1216 * text, Google search will be applied.
1217 * <p>
1218 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001219 */
1220 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1221 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001222
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001223 /**
Jim Miller07994402012-05-02 14:22:27 -07001224 * Activity Action: Perform assist action.
1225 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001226 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1227 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001228 * requested the assist.
Jim Miller07994402012-05-02 14:22:27 -07001229 * Output: nothing.
1230 */
1231 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1232 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001233
1234 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001235 * Activity Action: Perform voice assist action.
1236 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001237 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1238 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001239 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001240 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001241 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001242 */
1243 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1244 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1245
1246 /**
Adam Skory7140a252013-09-11 12:04:58 +01001247 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1248 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001249 */
1250 public static final String EXTRA_ASSIST_PACKAGE
1251 = "android.intent.extra.ASSIST_PACKAGE";
1252
1253 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001254 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1255 * application package at the time the assist was invoked.
1256 */
1257 public static final String EXTRA_ASSIST_UID
1258 = "android.intent.extra.ASSIST_UID";
1259
1260 /**
Adam Skory7140a252013-09-11 12:04:58 +01001261 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1262 * information supplied by the current foreground app at the time of the assist request.
1263 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001264 */
1265 public static final String EXTRA_ASSIST_CONTEXT
1266 = "android.intent.extra.ASSIST_CONTEXT";
1267
Jim Miller07994402012-05-02 14:22:27 -07001268 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001269 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1270 * keyboard as the primary input device for assistance.
1271 */
1272 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1273 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1274
1275 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001276 * Activity Action: List all available applications
1277 * <p>Input: Nothing.
1278 * <p>Output: nothing.
1279 */
1280 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1281 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1282 /**
1283 * Activity Action: Show settings for choosing wallpaper
1284 * <p>Input: Nothing.
1285 * <p>Output: Nothing.
1286 */
1287 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1289
1290 /**
1291 * Activity Action: Show activity for reporting a bug.
1292 * <p>Input: Nothing.
1293 * <p>Output: Nothing.
1294 */
1295 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1296 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1297
1298 /**
1299 * Activity Action: Main entry point for factory tests. Only used when
1300 * the device is booting in factory test node. The implementing package
1301 * must be installed in the system image.
1302 * <p>Input: nothing
1303 * <p>Output: nothing
1304 */
1305 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1306
1307 /**
1308 * Activity Action: The user pressed the "call" button to go to the dialer
1309 * or other appropriate UI for placing a call.
1310 * <p>Input: Nothing.
1311 * <p>Output: Nothing.
1312 */
1313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1314 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1315
1316 /**
1317 * Activity Action: Start Voice Command.
1318 * <p>Input: Nothing.
1319 * <p>Output: Nothing.
1320 */
1321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001323
1324 /**
1325 * Activity Action: Start action associated with long pressing on the
1326 * search key.
1327 * <p>Input: Nothing.
1328 * <p>Output: Nothing.
1329 */
1330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1331 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001332
Jacek Surazski86b6c532009-05-13 14:38:28 +02001333 /**
1334 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1335 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001336 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001337 * <p>Input: No data is specified. The bug report is passed in using
1338 * an {@link #EXTRA_BUG_REPORT} field.
1339 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001340 *
1341 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001342 */
1343 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1344 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001345
1346 /**
1347 * Activity Action: Show power usage information to the user.
1348 * <p>Input: Nothing.
1349 * <p>Output: Nothing.
1350 */
1351 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1352 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001353
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001354 /**
1355 * Activity Action: Setup wizard to launch after a platform update. This
1356 * activity should have a string meta-data field associated with it,
1357 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1358 * the platform for setup. The activity will be launched only if
1359 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1360 * same value.
1361 * <p>Input: Nothing.
1362 * <p>Output: Nothing.
1363 * @hide
1364 */
1365 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001367
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001368 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001369 * Activity Action: Show settings for managing network data usage of a
1370 * specific application. Applications should define an activity that offers
1371 * options to control data usage.
1372 */
1373 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1374 public static final String ACTION_MANAGE_NETWORK_USAGE =
1375 "android.intent.action.MANAGE_NETWORK_USAGE";
1376
1377 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001378 * Activity Action: Launch application installer.
1379 * <p>
1380 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001381 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1382 * you can also use "package:<package-name>" to install an application for the
1383 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001384 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1385 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1386 * <p>
1387 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1388 * succeeded.
1389 *
1390 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1391 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1392 * @see #EXTRA_RETURN_RESULT
1393 */
1394 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1395 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1396
1397 /**
1398 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1399 * package. Specifies the installer package name; this package will receive the
1400 * {@link #ACTION_APP_ERROR} intent.
1401 */
1402 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1403 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1404
1405 /**
1406 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1407 * package. Specifies that the application being installed should not be
1408 * treated as coming from an unknown source, but as coming from the app
1409 * invoking the Intent. For this to work you must start the installer with
1410 * startActivityForResult().
1411 */
1412 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1413 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1414
1415 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001416 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1417 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001418 * data field originated from.
1419 */
rich cannings706e8ba2012-08-20 13:20:14 -07001420 public static final String EXTRA_ORIGINATING_URI
1421 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001422
1423 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001424 * This extra can be used with any Intent used to launch an activity, supplying information
1425 * about who is launching that activity. This field contains a {@link android.net.Uri}
1426 * object, typically an http: or https: URI of the web site that the referral came from;
1427 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1428 * a native application that it came from.
1429 *
1430 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1431 * instead of directly retrieving the extra. It is also valid for applications to
1432 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1433 * a string, not a Uri; the field here, if supplied, will always take precedence,
1434 * however.</p>
1435 *
1436 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001437 */
1438 public static final String EXTRA_REFERRER
1439 = "android.intent.extra.REFERRER";
1440
1441 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001442 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1443 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1444 * not be created, in particular when Intent extras are supplied through the
1445 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1446 * schemes.
1447 *
1448 * @see #EXTRA_REFERRER
1449 */
1450 public static final String EXTRA_REFERRER_NAME
1451 = "android.intent.extra.REFERRER_NAME";
1452
1453 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001454 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1455 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1456 * @hide
1457 */
1458 public static final String EXTRA_ORIGINATING_UID
1459 = "android.intent.extra.ORIGINATING_UID";
1460
1461 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001462 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1463 * package. Tells the installer UI to skip the confirmation with the user
1464 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001465 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1466 * will no longer show an interstitial message about updating existing
1467 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001468 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001469 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001470 public static final String EXTRA_ALLOW_REPLACE
1471 = "android.intent.extra.ALLOW_REPLACE";
1472
1473 /**
1474 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1475 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1476 * return to the application the result code of the install/uninstall. The returned result
1477 * code will be {@link android.app.Activity#RESULT_OK} on success or
1478 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1479 */
1480 public static final String EXTRA_RETURN_RESULT
1481 = "android.intent.extra.RETURN_RESULT";
1482
1483 /**
1484 * Package manager install result code. @hide because result codes are not
1485 * yet ready to be exposed.
1486 */
1487 public static final String EXTRA_INSTALL_RESULT
1488 = "android.intent.extra.INSTALL_RESULT";
1489
1490 /**
1491 * Activity Action: Launch application uninstaller.
1492 * <p>
1493 * Input: The data must be a package: URI whose scheme specific part is
1494 * the package name of the current installed package to be uninstalled.
1495 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1496 * <p>
1497 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1498 * succeeded.
1499 */
1500 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1501 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1502
1503 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001504 * Specify whether the package should be uninstalled for all users.
1505 * @hide because these should not be part of normal application flow.
1506 */
1507 public static final String EXTRA_UNINSTALL_ALL_USERS
1508 = "android.intent.extra.UNINSTALL_ALL_USERS";
1509
1510 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001511 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1512 * describing the last run version of the platform that was setup.
1513 * @hide
1514 */
1515 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1516
Svet Ganov3695b8a2015-03-24 16:30:25 -07001517 /**
1518 * Activity action: Launch UI to manage the permissions of an app.
1519 * <p>
1520 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1521 * will be managed by the launched UI.
1522 * </p>
1523 * <p>
1524 * Output: Nothing.
1525 * </p>
1526 *
1527 * @see #EXTRA_PACKAGE_NAME
1528 *
1529 * @hide
1530 */
1531 @SystemApi
1532 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1533 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1534 "android.intent.action.MANAGE_APP_PERMISSIONS";
1535
1536 /**
1537 * Intent extra: An app package name.
1538 * <p>
1539 * Type: String
1540 * </p>S
1541 *
1542 * @hide
1543 */
1544 @SystemApi
1545 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1546
1547 /**
1548 * Activity action: Launch UI to manage which apps have a given permission.
1549 * <p>
1550 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1551 * to which will be managed by the launched UI.
1552 * </p>
1553 * <p>
1554 * Output: Nothing.
1555 * </p>
1556 *
1557 * @see #EXTRA_PERMISSION_NAME
1558 *
1559 * @hide
1560 */
1561 @SystemApi
1562 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1563 public static final String ACTION_MANAGE_PERMISSION_APPS =
1564 "android.intent.action.MANAGE_PERMISSION_APPS";
1565
1566 /**
1567 * Intent extra: The name of a permission.
1568 * <p>
1569 * Type: String
1570 * </p>
1571 *
1572 * @hide
1573 */
1574 @SystemApi
1575 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1576
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001577 // ---------------------------------------------------------------------
1578 // ---------------------------------------------------------------------
1579 // Standard intent broadcast actions (see action variable).
1580
1581 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001582 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1583 * <p>
1584 * For historical reasons, the name of this broadcast action refers to the power
1585 * state of the screen but it is actually sent in response to changes in the
1586 * overall interactive state of the device.
1587 * </p><p>
1588 * This broadcast is sent when the device becomes non-interactive which may have
1589 * nothing to do with the screen turning off. To determine the
1590 * actual state of the screen, use {@link android.view.Display#getState}.
1591 * </p><p>
1592 * See {@link android.os.PowerManager#isInteractive} for details.
1593 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001594 * You <em>cannot</em> receive this through components declared in
1595 * manifests, only by explicitly registering for it with
1596 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1597 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001598 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001599 * <p class="note">This is a protected intent that can only be sent
1600 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001601 */
1602 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1603 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001604
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001605 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001606 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1607 * <p>
1608 * For historical reasons, the name of this broadcast action refers to the power
1609 * state of the screen but it is actually sent in response to changes in the
1610 * overall interactive state of the device.
1611 * </p><p>
1612 * This broadcast is sent when the device becomes interactive which may have
1613 * nothing to do with the screen turning on. To determine the
1614 * actual state of the screen, use {@link android.view.Display#getState}.
1615 * </p><p>
1616 * See {@link android.os.PowerManager#isInteractive} for details.
1617 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001618 * You <em>cannot</em> receive this through components declared in
1619 * manifests, only by explicitly registering for it with
1620 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1621 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001622 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001623 * <p class="note">This is a protected intent that can only be sent
1624 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001625 */
1626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1627 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001628
1629 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001630 * Broadcast Action: Sent after the system stops dreaming.
1631 *
1632 * <p class="note">This is a protected intent that can only be sent by the system.
1633 * It is only sent to registered receivers.</p>
1634 */
1635 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1636 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1637
1638 /**
1639 * Broadcast Action: Sent after the system starts dreaming.
1640 *
1641 * <p class="note">This is a protected intent that can only be sent by the system.
1642 * It is only sent to registered receivers.</p>
1643 */
1644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1645 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1646
1647 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001648 * 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 -07001649 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001650 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001651 * <p class="note">This is a protected intent that can only be sent
1652 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001653 */
1654 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001655 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001656
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001657 /**
1658 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001659 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001660 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001661 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1662 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001663 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001664 * <p class="note">This is a protected intent that can only be sent
1665 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001666 */
1667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1668 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1669 /**
1670 * Broadcast Action: The time was set.
1671 */
1672 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1673 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1674 /**
1675 * Broadcast Action: The date has changed.
1676 */
1677 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1678 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1679 /**
1680 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1681 * <ul>
1682 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1683 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001684 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001685 * <p class="note">This is a protected intent that can only be sent
1686 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001687 */
1688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1689 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1690 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001691 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1692 * DNS entries should be tossed.
1693 * @hide
1694 */
1695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1696 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1697 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001698 * Alarm Changed Action: This is broadcast when the AlarmClock
1699 * application's alarm is set or unset. It is used by the
1700 * AlarmClock application and the StatusBar service.
1701 * @hide
1702 */
1703 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1704 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1705 /**
1706 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1707 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1708 * @hide
1709 */
1710 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1711 public static final String ACTION_SYNC_STATE_CHANGED
1712 = "android.intent.action.SYNC_STATE_CHANGED";
1713 /**
1714 * Broadcast Action: This is broadcast once, after the system has finished
1715 * booting. It can be used to perform application-specific initialization,
1716 * such as installing alarms. You must hold the
1717 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1718 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001719 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001720 * <p class="note">This is a protected intent that can only be sent
1721 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001722 */
1723 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1724 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1725 /**
1726 * Broadcast Action: This is broadcast when a user action should request a
1727 * temporary system dialog to dismiss. Some examples of temporary system
1728 * dialogs are the notification window-shade and the recent tasks dialog.
1729 */
1730 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1731 /**
1732 * Broadcast Action: Trigger the download and eventual installation
1733 * of a package.
1734 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001735 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001736 * <p class="note">This is a protected intent that can only be sent
1737 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001738 *
1739 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001740 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001741 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001742 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1743 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1744 /**
1745 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001746 * device. The data contains the name of the package. Note that the
1747 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001748 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001749 * <ul>
1750 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1751 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1752 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1753 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001754 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001755 * <p class="note">This is a protected intent that can only be sent
1756 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001757 */
1758 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1759 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1760 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001761 * Broadcast Action: A new version of an application package has been
1762 * installed, replacing an existing version that was previously installed.
1763 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001764 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001765 * <ul>
1766 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1767 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001768 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001769 * <p class="note">This is a protected intent that can only be sent
1770 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001771 */
1772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1773 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1774 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001775 * Broadcast Action: A new version of your application has been installed
1776 * over an existing one. This is only sent to the application that was
1777 * replaced. It does not contain any additional data; to receive it, just
1778 * use an intent filter for this action.
1779 *
1780 * <p class="note">This is a protected intent that can only be sent
1781 * by the system.
1782 */
1783 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1784 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1785 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001786 * Broadcast Action: An existing application package has been removed from
1787 * the device. The data contains the name of the package. The package
1788 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001789 * <ul>
1790 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1791 * to the package.
1792 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1793 * application -- data and code -- is being removed.
1794 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1795 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1796 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001797 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001798 * <p class="note">This is a protected intent that can only be sent
1799 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001800 */
1801 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1802 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1803 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001804 * Broadcast Action: An existing application package has been completely
1805 * removed from the device. The data contains the name of the package.
1806 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1807 * {@link #EXTRA_DATA_REMOVED} is true and
1808 * {@link #EXTRA_REPLACING} is false of that broadcast.
1809 *
1810 * <ul>
1811 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1812 * to the package.
1813 * </ul>
1814 *
1815 * <p class="note">This is a protected intent that can only be sent
1816 * by the system.
1817 */
1818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1819 public static final String ACTION_PACKAGE_FULLY_REMOVED
1820 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1821 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001822 * Broadcast Action: An existing application package has been changed (e.g.
1823 * a component has been enabled or disabled). The data contains the name of
1824 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001825 * <ul>
1826 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001827 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001828 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001829 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1830 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001831 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001832 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001833 * <p class="note">This is a protected intent that can only be sent
1834 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001835 */
1836 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1837 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1838 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001839 * @hide
1840 * Broadcast Action: Ask system services if there is any reason to
1841 * restart the given package. The data contains the name of the
1842 * package.
1843 * <ul>
1844 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1845 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1846 * </ul>
1847 *
1848 * <p class="note">This is a protected intent that can only be sent
1849 * by the system.
1850 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001851 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001852 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1853 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1854 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001855 * Broadcast Action: The user has restarted a package, and all of its
1856 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001857 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001858 * be removed. Note that the restarted package does <em>not</em>
1859 * receive this broadcast.
1860 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001861 * <ul>
1862 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1863 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001864 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001865 * <p class="note">This is a protected intent that can only be sent
1866 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001867 */
1868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1869 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1870 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001871 * Broadcast Action: The user has cleared the data of a package. This should
1872 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001873 * its persistent data is erased and this broadcast sent.
1874 * Note that the cleared package does <em>not</em>
1875 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001876 * <ul>
1877 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1878 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001879 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001880 * <p class="note">This is a protected intent that can only be sent
1881 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001882 */
1883 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1884 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1885 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001886 * Broadcast Action: A user ID has been removed from the system. The user
1887 * ID number is stored in the extra data under {@link #EXTRA_UID}.
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 Project54b6cfa2008-10-21 07:00:00 -07001891 */
1892 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1893 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001894
1895 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001896 * Broadcast Action: Sent to the installer package of an application
1897 * when that application is first launched (that is the first time it
1898 * is moved out of the stopped state). The data contains the name of the package.
1899 *
1900 * <p class="note">This is a protected intent that can only be sent
1901 * by the system.
1902 */
1903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1904 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1905
1906 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001907 * Broadcast Action: Sent to the system package verifier when a package
1908 * needs to be verified. The data contains the package URI.
1909 * <p class="note">
1910 * This is a protected intent that can only be sent by the system.
1911 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001912 */
1913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1914 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1915
1916 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001917 * Broadcast Action: Sent to the system package verifier when a package is
1918 * verified. The data contains the package URI.
1919 * <p class="note">
1920 * This is a protected intent that can only be sent by the system.
1921 */
1922 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1923 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1924
1925 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001926 * Broadcast Action: Resources for a set of packages (which were
1927 * previously unavailable) are currently
1928 * available since the media on which they exist is available.
1929 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1930 * list of packages whose availability changed.
1931 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1932 * list of uids of packages whose availability changed.
1933 * Note that the
1934 * packages in this list do <em>not</em> receive this broadcast.
1935 * The specified set of packages are now available on the system.
1936 * <p>Includes the following extras:
1937 * <ul>
1938 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1939 * whose resources(were previously unavailable) are currently available.
1940 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1941 * packages whose resources(were previously unavailable)
1942 * are currently available.
1943 * </ul>
1944 *
1945 * <p class="note">This is a protected intent that can only be sent
1946 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001947 */
1948 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001949 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1950 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001951
1952 /**
1953 * Broadcast Action: Resources for a set of packages are currently
1954 * unavailable since the media on which they exist is unavailable.
1955 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1956 * list of packages whose availability changed.
1957 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1958 * list of uids of packages whose availability changed.
1959 * The specified set of packages can no longer be
1960 * launched and are practically unavailable on the system.
1961 * <p>Inclues the following extras:
1962 * <ul>
1963 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1964 * whose resources are no longer available.
1965 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1966 * whose resources are no longer available.
1967 * </ul>
1968 *
1969 * <p class="note">This is a protected intent that can only be sent
1970 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001971 */
1972 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001973 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001974 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001976 /**
1977 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001978 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001979 * This should <em>only</em> be used to determine when the wallpaper
1980 * has changed to show the new wallpaper to the user. You should certainly
1981 * never, in response to this, change the wallpaper or other attributes of
1982 * it such as the suggested size. That would be crazy, right? You'd cause
1983 * all kinds of loops, especially if other apps are doing similar things,
1984 * right? Of course. So please don't do this.
1985 *
1986 * @deprecated Modern applications should use
1987 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
1988 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
1989 * shown behind their UI, rather than watching for this broadcast and
1990 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001992 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001993 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1994 /**
1995 * Broadcast Action: The current device {@link android.content.res.Configuration}
1996 * (orientation, locale, etc) has changed. When such a change happens, the
1997 * UIs (view hierarchy) will need to be rebuilt based on this new
1998 * information; for the most part, applications don't need to worry about
1999 * this, because the system will take care of stopping and restarting the
2000 * application to make sure it sees the new changes. Some system code that
2001 * can not be restarted will need to watch for this action and handle it
2002 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002003 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002004 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002005 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002006 * in manifests, only by explicitly registering for it with
2007 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2008 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002009 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002010 * <p class="note">This is a protected intent that can only be sent
2011 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002012 *
2013 * @see android.content.res.Configuration
2014 */
2015 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2016 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2017 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002018 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002019 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002020 * <p class="note">This is a protected intent that can only be sent
2021 * by the system.
2022 */
2023 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2024 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2025 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002026 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2027 * charging state, level, and other information about the battery.
2028 * See {@link android.os.BatteryManager} for documentation on the
2029 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002030 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002031 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002032 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002033 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002034 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002035 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2036 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2037 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2038 * broadcasts that are sent and can be received through manifest
2039 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002040 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002041 * <p class="note">This is a protected intent that can only be sent
2042 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002043 */
2044 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2045 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2046 /**
2047 * Broadcast Action: Indicates low battery condition on the device.
2048 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002049 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002050 * <p class="note">This is a protected intent that can only be sent
2051 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002052 */
2053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2054 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2055 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002056 * Broadcast Action: Indicates the battery is now okay after being low.
2057 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2058 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002059 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002060 * <p class="note">This is a protected intent that can only be sent
2061 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002062 */
2063 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2064 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2065 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002066 * Broadcast Action: External power has been connected to the device.
2067 * This is intended for applications that wish to register specifically to this notification.
2068 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2069 * stay active to receive this notification. This action can be used to implement actions
2070 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002071 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002072 * <p class="note">This is a protected intent that can only be sent
2073 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002074 */
2075 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002076 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002077 /**
2078 * Broadcast Action: External power has been removed from the device.
2079 * This is intended for applications that wish to register specifically to this notification.
2080 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2081 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002082 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002083 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002084 * <p class="note">This is a protected intent that can only be sent
2085 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002086 */
2087 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002088 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002089 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002090 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002091 * Broadcast Action: Device is shutting down.
2092 * This is broadcast when the device is being shut down (completely turned
2093 * off, not sleeping). Once the broadcast is complete, the final shutdown
2094 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002095 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002096 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002097 * <p class="note">This is a protected intent that can only be sent
2098 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002099 * <p>May include the following extras:
2100 * <ul>
2101 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2102 * shutdown is only for userspace processes. If not set, assumed to be false.
2103 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002104 */
2105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002106 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002107 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002108 * Activity Action: Start this activity to request system shutdown.
2109 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2110 * to request confirmation from the user before shutting down.
2111 *
2112 * <p class="note">This is a protected intent that can only be sent
2113 * by the system.
2114 *
2115 * {@hide}
2116 */
2117 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2118 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002119 * Broadcast Action: A sticky broadcast that indicates low memory
2120 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002121 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002122 * <p class="note">This is a protected intent that can only be sent
2123 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002124 */
2125 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2126 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2127 /**
2128 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002129 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002130 * <p class="note">This is a protected intent that can only be sent
2131 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002132 */
2133 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2134 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2135 /**
Jake Hambybb371632010-08-23 18:16:48 -07002136 * Broadcast Action: A sticky broadcast that indicates a memory full
2137 * condition on the device. This is intended for activities that want
2138 * to be able to fill the data partition completely, leaving only
2139 * enough free space to prevent system-wide SQLite failures.
2140 *
2141 * <p class="note">This is a protected intent that can only be sent
2142 * by the system.
2143 *
2144 * {@hide}
2145 */
2146 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2147 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2148 /**
2149 * Broadcast Action: Indicates memory full condition on the device
2150 * no longer exists.
2151 *
2152 * <p class="note">This is a protected intent that can only be sent
2153 * by the system.
2154 *
2155 * {@hide}
2156 */
2157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2158 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2159 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002160 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2161 * and package management should be started.
2162 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2163 * notification.
2164 */
2165 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2166 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2167 /**
2168 * Broadcast Action: The device has entered USB Mass Storage mode.
2169 * This is used mainly for the USB Settings panel.
2170 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2171 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002172 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002173 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002174 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002175 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2176
2177 /**
2178 * Broadcast Action: The device has exited USB Mass Storage mode.
2179 * This is used mainly for the USB Settings panel.
2180 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2181 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002182 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002183 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002184 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002185 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2186
2187 /**
2188 * Broadcast Action: External media has been removed.
2189 * The path to the mount point for the removed media is contained in the Intent.mData field.
2190 */
2191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2192 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2193
2194 /**
2195 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002196 * 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 -07002197 */
2198 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2199 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2200
2201 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002202 * Broadcast Action: External media is present, and being disk-checked
2203 * 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 -08002204 */
2205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2206 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2207
2208 /**
2209 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2210 * 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 -08002211 */
2212 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2213 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2214
2215 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002216 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002217 * 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 -07002218 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2219 * media was mounted read only.
2220 */
2221 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2222 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2223
2224 /**
2225 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002226 * 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 -07002227 */
2228 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2229 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2230
2231 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002232 * Broadcast Action: External media is no longer being shared via USB mass storage.
2233 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2234 *
2235 * @hide
2236 */
2237 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2238
2239 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002240 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2241 * The path to the mount point for the removed media is contained in the Intent.mData field.
2242 */
2243 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2244 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2245
2246 /**
2247 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002248 * 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 -07002249 */
2250 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2251 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2252
2253 /**
2254 * Broadcast Action: User has expressed the desire to remove the external storage media.
2255 * Applications should close all files they have open within the mount point when they receive this intent.
2256 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2259 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2260
2261 /**
2262 * Broadcast Action: The media scanner has started scanning a directory.
2263 * The path to the directory being scanned is contained in the Intent.mData field.
2264 */
2265 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2266 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2267
2268 /**
2269 * Broadcast Action: The media scanner has finished scanning a directory.
2270 * The path to the scanned directory is contained in the Intent.mData field.
2271 */
2272 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2273 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2274
2275 /**
2276 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2277 * The path to the file is contained in the Intent.mData field.
2278 */
2279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2280 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2281
2282 /**
2283 * Broadcast Action: The "Media Button" was pressed. Includes a single
2284 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2285 * caused the broadcast.
2286 */
2287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2288 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2289
2290 /**
2291 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2292 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2293 * caused the broadcast.
2294 */
2295 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2296 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2297
2298 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2299 // location; they are not general-purpose actions.
2300
2301 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002302 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002303 */
2304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2305 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2306 "android.intent.action.GTALK_CONNECTED";
2307
2308 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002309 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002310 */
2311 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2312 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2313 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002314
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002315 /**
2316 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002317 */
2318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2319 public static final String ACTION_INPUT_METHOD_CHANGED =
2320 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002321
2322 /**
2323 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2324 * more radios have been turned off or on. The intent will have the following extra value:</p>
2325 * <ul>
2326 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2327 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2328 * turned off</li>
2329 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002330 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002331 * <p class="note">This is a protected intent that can only be sent
2332 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002333 */
2334 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2335 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2336
2337 /**
2338 * Broadcast Action: Some content providers have parts of their namespace
2339 * where they publish new events or items that the user may be especially
2340 * interested in. For these things, they may broadcast this action when the
2341 * set of interesting items change.
2342 *
2343 * For example, GmailProvider sends this notification when the set of unread
2344 * mail in the inbox changes.
2345 *
2346 * <p>The data of the intent identifies which part of which provider
2347 * changed. When queried through the content resolver, the data URI will
2348 * return the data set in question.
2349 *
2350 * <p>The intent will have the following extra values:
2351 * <ul>
2352 * <li><em>count</em> - The number of items in the data set. This is the
2353 * same as the number of items in the cursor returned by querying the
2354 * data URI. </li>
2355 * </ul>
2356 *
2357 * This intent will be sent at boot (if the count is non-zero) and when the
2358 * data set changes. It is possible for the data set to change without the
2359 * count changing (for example, if a new unread message arrives in the same
2360 * sync operation in which a message is archived). The phone should still
2361 * ring/vibrate/etc as normal in this case.
2362 */
2363 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2364 public static final String ACTION_PROVIDER_CHANGED =
2365 "android.intent.action.PROVIDER_CHANGED";
2366
2367 /**
2368 * Broadcast Action: Wired Headset plugged in or unplugged.
2369 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002370 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2371 * and documentation.
2372 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002373 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002374 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002375 */
2376 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002377 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002378
2379 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002380 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2381 * <ul>
2382 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2383 * </ul>
2384 *
2385 * <p class="note">This is a protected intent that can only be sent
2386 * by the system.
2387 *
2388 * @hide
2389 */
2390 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2391 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2392 = "android.intent.action.ADVANCED_SETTINGS";
2393
2394 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002395 * Broadcast Action: Sent after application restrictions are changed.
2396 *
2397 * <p class="note">This is a protected intent that can only be sent
2398 * by the system.</p>
2399 */
2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2402 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2403
2404 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002405 * Broadcast Action: An outgoing call is about to be placed.
2406 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002407 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002408 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002409 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002410 * the phone number originally intended to be dialed.</li>
2411 * </ul>
2412 * <p>Once the broadcast is finished, the resultData is used as the actual
2413 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002414 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002415 * outgoing call in turn: for example, a parental control application
2416 * might verify that the user is authorized to place the call at that
2417 * time, then a number-rewriting application might add an area code if
2418 * one was not specified.</p>
2419 * <p>For consistency, any receiver whose purpose is to prohibit phone
2420 * calls should have a priority of 0, to ensure it will see the final
2421 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002422 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002423 * should have a positive priority.
2424 * Negative priorities are reserved for the system for this broadcast;
2425 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002426 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2427 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002428 * <p>Emergency calls cannot be intercepted using this mechanism, and
2429 * other calls cannot be modified to call emergency numbers using this
2430 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002431 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2432 * call to use their own service instead. Those apps should first prevent
2433 * the call from being placed by setting resultData to <code>null</code>
2434 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002435 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2437 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002438 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002439 * <p class="note">This is a protected intent that can only be sent
2440 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002441 */
2442 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2443 public static final String ACTION_NEW_OUTGOING_CALL =
2444 "android.intent.action.NEW_OUTGOING_CALL";
2445
2446 /**
2447 * Broadcast Action: Have the device reboot. This is only for use by
2448 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002449 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002450 * <p class="note">This is a protected intent that can only be sent
2451 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002452 */
2453 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2454 public static final String ACTION_REBOOT =
2455 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002456
Wei Huang97ecc9c2009-05-11 17:44:20 -07002457 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002458 * Broadcast Action: A sticky broadcast for changes in the physical
2459 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002460 *
2461 * <p>The intent will have the following extra values:
2462 * <ul>
2463 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002464 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002465 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002466 * <p>This is intended for monitoring the current physical dock state.
2467 * See {@link android.app.UiModeManager} for the normal API dealing with
2468 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002469 */
2470 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2471 public static final String ACTION_DOCK_EVENT =
2472 "android.intent.action.DOCK_EVENT";
2473
2474 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002475 * Broadcast Action: A broadcast when idle maintenance can be started.
2476 * This means that the user is not interacting with the device and is
2477 * not expected to do so soon. Typical use of the idle maintenance is
2478 * to perform somehow expensive tasks that can be postponed at a moment
2479 * when they will not degrade user experience.
2480 * <p>
2481 * <p class="note">In order to keep the device responsive in case of an
2482 * unexpected user interaction, implementations of a maintenance task
2483 * should be interruptible. In such a scenario a broadcast with action
2484 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2485 * should not do the maintenance work in
2486 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2487 * maintenance service by {@link Context#startService(Intent)}. Also
2488 * you should hold a wake lock while your maintenance service is running
2489 * to prevent the device going to sleep.
2490 * </p>
2491 * <p>
2492 * <p class="note">This is a protected intent that can only be sent by
2493 * the system.
2494 * </p>
2495 *
2496 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002497 *
2498 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002499 */
2500 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2501 public static final String ACTION_IDLE_MAINTENANCE_START =
2502 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2503
2504 /**
2505 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2506 * This means that the user was not interacting with the device as a result
2507 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2508 * was sent and now the user started interacting with the device. Typical
2509 * use of the idle maintenance is to perform somehow expensive tasks that
2510 * can be postponed at a moment when they will not degrade user experience.
2511 * <p>
2512 * <p class="note">In order to keep the device responsive in case of an
2513 * unexpected user interaction, implementations of a maintenance task
2514 * should be interruptible. Hence, on receiving a broadcast with this
2515 * action, the maintenance task should be interrupted as soon as possible.
2516 * In other words, you should not do the maintenance work in
2517 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2518 * maintenance service that was started on receiving of
2519 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2520 * lock you acquired when your maintenance service started.
2521 * </p>
2522 * <p class="note">This is a protected intent that can only be sent
2523 * by the system.
2524 *
2525 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002526 *
2527 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002528 */
2529 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2530 public static final String ACTION_IDLE_MAINTENANCE_END =
2531 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2532
2533 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002534 * Broadcast Action: a remote intent is to be broadcasted.
2535 *
2536 * A remote intent is used for remote RPC between devices. The remote intent
2537 * is serialized and sent from one device to another device. The receiving
2538 * device parses the remote intent and broadcasts it. Note that anyone can
2539 * broadcast a remote intent. However, if the intent receiver of the remote intent
2540 * does not trust intent broadcasts from arbitrary intent senders, it should require
2541 * the sender to hold certain permissions so only trusted sender's broadcast will be
2542 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002543 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002544 */
2545 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002546 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002547
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002548 /**
2549 * Broadcast Action: hook for permforming cleanup after a system update.
2550 *
2551 * The broadcast is sent when the system is booting, before the
2552 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2553 * image. A receiver for this should do its work and then disable itself
2554 * so that it does not get run again at the next boot.
2555 * @hide
2556 */
2557 public static final String ACTION_PRE_BOOT_COMPLETED =
2558 "android.intent.action.PRE_BOOT_COMPLETED";
2559
Amith Yamasani13593602012-03-22 16:16:17 -07002560 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002561 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002562 * on restricted users. The broadcast intent contains an extra
2563 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2564 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2565 * String[] depending on the restriction type.<p/>
2566 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002567 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2568 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2569 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002570 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2571 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002572 * @see RestrictionEntry
2573 */
2574 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2575 "android.intent.action.GET_RESTRICTION_ENTRIES";
2576
2577 /**
Amith Yamasanid304af62013-09-05 09:30:23 -07002578 * @hide
Amith Yamasani655d0e22013-06-12 14:19:10 -07002579 * Activity to challenge the user for a PIN that was configured when setting up
Amith Yamasanid304af62013-09-05 09:30:23 -07002580 * restrictions. Restrictions include blocking of apps and preventing certain user operations,
2581 * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle).
2582 * Launch the activity using
Amith Yamasani655d0e22013-06-12 14:19:10 -07002583 * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the
2584 * result is {@link android.app.Activity#RESULT_OK} for a successful response to the
2585 * challenge.<p/>
2586 * Before launching this activity, make sure that there is a PIN in effect, by calling
Amith Yamasanid304af62013-09-05 09:30:23 -07002587 * {@link android.os.UserManager#hasRestrictionsChallenge()}.
Amith Yamasani655d0e22013-06-12 14:19:10 -07002588 */
Amith Yamasanid304af62013-09-05 09:30:23 -07002589 public static final String ACTION_RESTRICTIONS_CHALLENGE =
2590 "android.intent.action.RESTRICTIONS_CHALLENGE";
Amith Yamasani655d0e22013-06-12 14:19:10 -07002591
2592 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002593 * Sent the first time a user is starting, to allow system apps to
2594 * perform one time initialization. (This will not be seen by third
2595 * party applications because a newly initialized user does not have any
2596 * third party applications installed for it.) This is sent early in
2597 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002598 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2599 * broadcast, since it is part of a visible user interaction; be as quick
2600 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002601 */
2602 public static final String ACTION_USER_INITIALIZE =
2603 "android.intent.action.USER_INITIALIZE";
2604
2605 /**
2606 * Sent when a user switch is happening, causing the process's user to be
2607 * brought to the foreground. This is only sent to receivers registered
2608 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2609 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002610 * foreground. This is sent as a foreground
2611 * broadcast, since it is part of a visible user interaction; be as quick
2612 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002613 */
2614 public static final String ACTION_USER_FOREGROUND =
2615 "android.intent.action.USER_FOREGROUND";
2616
2617 /**
2618 * Sent when a user switch is happening, causing the process's user to be
2619 * sent to the background. This is only sent to receivers registered
2620 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2621 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002622 * background. This is sent as a foreground
2623 * broadcast, since it is part of a visible user interaction; be as quick
2624 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002625 */
2626 public static final String ACTION_USER_BACKGROUND =
2627 "android.intent.action.USER_BACKGROUND";
2628
2629 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002630 * Broadcast sent to the system when a user is added. Carries an extra
2631 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2632 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002633 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002634 * @hide
2635 */
2636 public static final String ACTION_USER_ADDED =
2637 "android.intent.action.USER_ADDED";
2638
2639 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002640 * Broadcast sent by the system when a user is started. Carries an extra
2641 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002642 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002643 * that has been started. This is sent as a foreground
2644 * broadcast, since it is part of a visible user interaction; be as quick
2645 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002646 * @hide
2647 */
2648 public static final String ACTION_USER_STARTED =
2649 "android.intent.action.USER_STARTED";
2650
2651 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002652 * Broadcast sent when a user is in the process of starting. Carries an extra
2653 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2654 * sent to registered receivers, not manifest receivers. It is sent to all
2655 * users (including the one that is being started). You must hold
2656 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2657 * this broadcast. This is sent as a background broadcast, since
2658 * its result is not part of the primary UX flow; to safely keep track of
2659 * started/stopped state of a user you can use this in conjunction with
2660 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2661 * other user state broadcasts since those are foreground broadcasts so can
2662 * execute in a different order.
2663 * @hide
2664 */
2665 public static final String ACTION_USER_STARTING =
2666 "android.intent.action.USER_STARTING";
2667
2668 /**
2669 * Broadcast sent when a user is going to be stopped. Carries an extra
2670 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2671 * sent to registered receivers, not manifest receivers. It is sent to all
2672 * users (including the one that is being stopped). You must hold
2673 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2674 * this broadcast. The user will not stop until all receivers have
2675 * handled the broadcast. This is sent as a background broadcast, since
2676 * its result is not part of the primary UX flow; to safely keep track of
2677 * started/stopped state of a user you can use this in conjunction with
2678 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2679 * other user state broadcasts since those are foreground broadcasts so can
2680 * execute in a different order.
2681 * @hide
2682 */
2683 public static final String ACTION_USER_STOPPING =
2684 "android.intent.action.USER_STOPPING";
2685
2686 /**
2687 * Broadcast sent to the system when a user is stopped. Carries an extra
2688 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2689 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2690 * specific package. This is only sent to registered receivers, not manifest
2691 * receivers. It is sent to all running users <em>except</em> the one that
2692 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002693 * @hide
2694 */
2695 public static final String ACTION_USER_STOPPED =
2696 "android.intent.action.USER_STOPPED";
2697
2698 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002699 * 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 -07002700 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002701 * one that has been removed. The user will not be completely removed until all receivers have
2702 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002703 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002704 * @hide
2705 */
2706 public static final String ACTION_USER_REMOVED =
2707 "android.intent.action.USER_REMOVED";
2708
2709 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002710 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002711 * the userHandle of the user to become the current one. This is only sent to
2712 * registered receivers, not manifest receivers. It is sent to all running users.
2713 * You must hold
2714 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002715 * @hide
2716 */
2717 public static final String ACTION_USER_SWITCHED =
2718 "android.intent.action.USER_SWITCHED";
2719
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002720 /**
2721 * Broadcast sent to the system when a user's information changes. Carries an extra
2722 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002723 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002724 * @hide
2725 */
2726 public static final String ACTION_USER_INFO_CHANGED =
2727 "android.intent.action.USER_INFO_CHANGED";
2728
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002729 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002730 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2731 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002732 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2733 * that need to display merged content across both primary and managed profiles need to
2734 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002735 * not manifest receivers.
2736 */
2737 public static final String ACTION_MANAGED_PROFILE_ADDED =
2738 "android.intent.action.MANAGED_PROFILE_ADDED";
2739
2740 /**
2741 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002742 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2743 * Only applications (for example Launchers) that need to display merged content across both
2744 * primary and managed profiles need to worry about this broadcast. This is only sent to
2745 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002746 */
2747 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2748 "android.intent.action.MANAGED_PROFILE_REMOVED";
2749
2750 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002751 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2752 */
2753 public static final String ACTION_QUICK_CLOCK =
2754 "android.intent.action.QUICK_CLOCK";
2755
Michael Wright0087a142013-02-05 16:29:39 -08002756 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002757 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002758 * @hide
2759 */
2760 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2761 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2762
Justin Kohd378ad72013-04-01 12:18:26 -07002763 /**
2764 * Broadcast Action: A global button was pressed. Includes a single
2765 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2766 * caused the broadcast.
2767 * @hide
2768 */
2769 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2770
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002771 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002772 * Activity Action: Allow the user to select and return one or more existing
2773 * documents. When invoked, the system will display the various
2774 * {@link DocumentsProvider} instances installed on the device, letting the
2775 * user interactively navigate through them. These documents include local
2776 * media, such as photos and video, and documents provided by installed
2777 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002778 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002779 * Each document is represented as a {@code content://} URI backed by a
2780 * {@link DocumentsProvider}, which can be opened as a stream with
2781 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2782 * {@link android.provider.DocumentsContract.Document} metadata.
2783 * <p>
2784 * All selected documents are returned to the calling application with
2785 * persistable read and write permission grants. If you want to maintain
2786 * access to the documents across device reboots, you need to explicitly
2787 * take the persistable permissions using
2788 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2789 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002790 * Callers must indicate the acceptable document MIME types through
2791 * {@link #setType(String)}. For example, to select photos, use
2792 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2793 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2794 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002795 * <p>
2796 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002797 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2798 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002799 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002800 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2801 * returned URIs can be opened with
2802 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002803 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002804 * Output: The URI of the item that was picked, returned in
2805 * {@link #getData()}. This must be a {@code content://} URI so that any
2806 * receiver can access it. If multiple documents were selected, they are
2807 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002808 *
2809 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002810 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002811 * @see #ACTION_CREATE_DOCUMENT
2812 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002813 */
2814 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2815 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2816
2817 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002818 * Activity Action: Allow the user to create a new document. When invoked,
2819 * the system will display the various {@link DocumentsProvider} instances
2820 * installed on the device, letting the user navigate through them. The
2821 * returned document may be a newly created document with no content, or it
2822 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002823 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002824 * Each document is represented as a {@code content://} URI backed by a
2825 * {@link DocumentsProvider}, which can be opened as a stream with
2826 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2827 * {@link android.provider.DocumentsContract.Document} metadata.
2828 * <p>
2829 * Callers must indicate the concrete MIME type of the document being
2830 * created by setting {@link #setType(String)}. This MIME type cannot be
2831 * changed after the document is created.
2832 * <p>
2833 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2834 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002835 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002836 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2837 * returned URIs can be opened with
2838 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002839 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002840 * Output: The URI of the item that was created. This must be a
2841 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002842 *
2843 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002844 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002845 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002846 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002847 */
2848 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2849 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2850
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002851 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002852 * Activity Action: Allow the user to pick a directory subtree. When
2853 * invoked, the system will display the various {@link DocumentsProvider}
2854 * instances installed on the device, letting the user navigate through
2855 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002856 * <p>
2857 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002858 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2859 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2860 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002861 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002862 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002863 *
2864 * @see DocumentsContract
2865 */
2866 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002867 public static final String
2868 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002869
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002870 /** {@hide} */
2871 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2872
Christopher Tate6597e342015-02-17 12:15:25 -08002873 /**
2874 * Broadcast action: report that a settings element is being restored from backup. The intent
2875 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
2876 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
2877 * is the value of that settings entry prior to the restore operation. All of these values are
2878 * represented as strings.
2879 *
2880 * <p>This broadcast is sent only for settings provider entries known to require special handling
2881 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
2882 * the provider's backup agent implementation.
2883 *
2884 * @see #EXTRA_SETTING_NAME
2885 * @see #EXTRA_SETTING_PREVIOUS_VALUE
2886 * @see #EXTRA_SETTING_NEW_VALUE
2887 * {@hide}
2888 */
2889 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
2890
2891 /** {@hide} */
2892 public static final String EXTRA_SETTING_NAME = "setting_name";
2893 /** {@hide} */
2894 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
2895 /** {@hide} */
2896 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
2897
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002898 // ---------------------------------------------------------------------
2899 // ---------------------------------------------------------------------
2900 // Standard intent categories (see addCategory()).
2901
2902 /**
2903 * Set if the activity should be an option for the default action
2904 * (center press) to perform on a piece of data. Setting this will
2905 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002906 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002907 * Intent when initiating an action -- it is for use in intent filters
2908 * specified in packages.
2909 */
2910 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2911 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2912 /**
2913 * Activities that can be safely invoked from a browser must support this
2914 * category. For example, if the user is viewing a web page or an e-mail
2915 * and clicks on a link in the text, the Intent generated execute that
2916 * link will require the BROWSABLE category, so that only activities
2917 * supporting this category will be considered as possible actions. By
2918 * supporting this category, you are promising that there is nothing
2919 * damaging (without user intervention) that can happen by invoking any
2920 * matching Intent.
2921 */
2922 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2923 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2924 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002925 * Categories for activities that can participate in voice interaction.
2926 * An activity that supports this category must be prepared to run with
2927 * no UI shown at all (though in some case it may have a UI shown), and
2928 * rely on {@link android.app.VoiceInteractor} to interact with the user.
2929 */
2930 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2931 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
2932 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002933 * Set if the activity should be considered as an alternative action to
2934 * the data the user is currently viewing. See also
2935 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2936 * applies to the selection in a list of items.
2937 *
2938 * <p>Supporting this category means that you would like your activity to be
2939 * displayed in the set of alternative things the user can do, usually as
2940 * part of the current activity's options menu. You will usually want to
2941 * include a specific label in the &lt;intent-filter&gt; of this action
2942 * describing to the user what it does.
2943 *
2944 * <p>The action of IntentFilter with this category is important in that it
2945 * describes the specific action the target will perform. This generally
2946 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2947 * a specific name such as "com.android.camera.action.CROP. Only one
2948 * alternative of any particular action will be shown to the user, so using
2949 * a specific action like this makes sure that your alternative will be
2950 * displayed while also allowing other applications to provide their own
2951 * overrides of that particular action.
2952 */
2953 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2954 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2955 /**
2956 * Set if the activity should be considered as an alternative selection
2957 * action to the data the user has currently selected. This is like
2958 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2959 * of items from which the user can select, giving them alternatives to the
2960 * default action that will be performed on it.
2961 */
2962 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2963 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2964 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002965 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002966 */
2967 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2968 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2969 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002970 * Should be displayed in the top-level launcher.
2971 */
2972 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2973 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2974 /**
Jose Lima38b75b62014-03-11 10:41:39 -07002975 * Indicates an activity optimized for Leanback mode, and that should
2976 * be displayed in the Leanback launcher.
2977 */
2978 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2979 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
2980 /**
Jose Lima73915cf2014-07-29 17:16:31 -07002981 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
2982 * @hide
2983 */
2984 @SystemApi
2985 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
2986 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002987 * Provides information about the package it is in; typically used if
2988 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2989 * a front-door to the user without having to be shown in the all apps list.
2990 */
2991 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2992 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2993 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002994 * This is the home activity, that is the first activity that is displayed
2995 * when the device boots.
2996 */
2997 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2998 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2999 /**
3000 * This activity is a preference panel.
3001 */
3002 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3003 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3004 /**
3005 * This activity is a development preference panel.
3006 */
3007 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3008 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3009 /**
3010 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003011 */
3012 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3013 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3014 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003015 * This activity allows the user to browse and download new applications.
3016 */
3017 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3018 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3019 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003020 * This activity may be exercised by the monkey or other automated test tools.
3021 */
3022 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3023 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3024 /**
3025 * To be used as a test (not part of the normal user experience).
3026 */
3027 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3028 /**
3029 * To be used as a unit test (run through the Test Harness).
3030 */
3031 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3032 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003033 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003034 * experience).
3035 */
3036 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003037
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003038 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003039 * Used to indicate that an intent only wants URIs that can be opened with
3040 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3041 * must support at least the columns defined in {@link OpenableColumns} when
3042 * queried.
3043 *
3044 * @see #ACTION_GET_CONTENT
3045 * @see #ACTION_OPEN_DOCUMENT
3046 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003047 */
3048 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3049 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3050
3051 /**
3052 * To be used as code under test for framework instrumentation tests.
3053 */
3054 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3055 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003056 /**
3057 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003058 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3059 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003060 */
3061 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3062 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3063 /**
3064 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003065 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3066 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003067 */
3068 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3069 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003070 /**
3071 * An activity to run when device is inserted into a analog (low end) dock.
3072 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3073 * information, see {@link android.app.UiModeManager}.
3074 */
3075 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3076 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3077
3078 /**
3079 * An activity to run when device is inserted into a digital (high end) dock.
3080 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3081 * information, see {@link android.app.UiModeManager}.
3082 */
3083 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3084 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003085
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003086 /**
3087 * Used to indicate that the activity can be used in a car environment.
3088 */
3089 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3090 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3091
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003092 // ---------------------------------------------------------------------
3093 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003094 // Application launch intent categories (see addCategory()).
3095
3096 /**
3097 * Used with {@link #ACTION_MAIN} to launch the browser application.
3098 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003099 * <p>NOTE: This should not be used as the primary key of an Intent,
3100 * since it will not result in the app launching with the correct
3101 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003102 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003103 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003104 */
3105 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3106 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3107
3108 /**
3109 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3110 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003111 * <p>NOTE: This should not be used as the primary key of an Intent,
3112 * since it will not result in the app launching with the correct
3113 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003114 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003115 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003116 */
3117 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3118 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3119
3120 /**
3121 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3122 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003123 * <p>NOTE: This should not be used as the primary key of an Intent,
3124 * since it will not result in the app launching with the correct
3125 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003126 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003127 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003128 */
3129 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3130 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3131
3132 /**
3133 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3134 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003135 * <p>NOTE: This should not be used as the primary key of an Intent,
3136 * since it will not result in the app launching with the correct
3137 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003138 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003139 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003140 */
3141 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3142 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3143
3144 /**
3145 * Used with {@link #ACTION_MAIN} to launch the email application.
3146 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003147 * <p>NOTE: This should not be used as the primary key of an Intent,
3148 * since it will not result in the app launching with the correct
3149 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003150 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003151 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003152 */
3153 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3154 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3155
3156 /**
3157 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3158 * The activity should be able to view and manipulate image and video files
3159 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003160 * <p>NOTE: This should not be used as the primary key of an Intent,
3161 * since it will not result in the app launching with the correct
3162 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003163 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003164 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003165 */
3166 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3167 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3168
3169 /**
3170 * Used with {@link #ACTION_MAIN} to launch the maps application.
3171 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003172 * <p>NOTE: This should not be used as the primary key of an Intent,
3173 * since it will not result in the app launching with the correct
3174 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003175 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003176 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003177 */
3178 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3179 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3180
3181 /**
3182 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3183 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003184 * <p>NOTE: This should not be used as the primary key of an Intent,
3185 * since it will not result in the app launching with the correct
3186 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003187 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003188 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003189 */
3190 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3191 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3192
3193 /**
3194 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003195 * The activity should be able to play, browse, or manipulate music files
3196 * stored on the device.
3197 * <p>NOTE: This should not be used as the primary key of an Intent,
3198 * since it will not result in the app launching with the correct
3199 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003200 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003201 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003202 */
3203 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3204 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3205
3206 // ---------------------------------------------------------------------
3207 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003208 // Standard extra data keys.
3209
3210 /**
3211 * The initial data to place in a newly created record. Use with
3212 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3213 * fields as would be given to the underlying ContentProvider.insert()
3214 * call.
3215 */
3216 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3217
3218 /**
3219 * A constant CharSequence that is associated with the Intent, used with
3220 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3221 * this may be a styled CharSequence, so you must use
3222 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3223 * retrieve it.
3224 */
3225 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3226
3227 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003228 * A constant String that is associated with the Intent, used with
3229 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3230 * as HTML formatted text. Note that you <em>must</em> also supply
3231 * {@link #EXTRA_TEXT}.
3232 */
3233 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3234
3235 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003236 * A content: URI holding a stream of data associated with the Intent,
3237 * used with {@link #ACTION_SEND} to supply the data being sent.
3238 */
3239 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3240
3241 /**
3242 * A String[] holding e-mail addresses that should be delivered to.
3243 */
3244 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3245
3246 /**
3247 * A String[] holding e-mail addresses that should be carbon copied.
3248 */
3249 public static final String EXTRA_CC = "android.intent.extra.CC";
3250
3251 /**
3252 * A String[] holding e-mail addresses that should be blind carbon copied.
3253 */
3254 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3255
3256 /**
3257 * A constant string holding the desired subject line of a message.
3258 */
3259 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3260
3261 /**
3262 * An Intent describing the choices you would like shown with
3263 * {@link #ACTION_PICK_ACTIVITY}.
3264 */
3265 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3266
3267 /**
3268 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003269 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003270 */
3271 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3272
3273 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003274 * A Parcelable[] of {@link Intent} or
3275 * {@link android.content.pm.LabeledIntent} objects as set with
3276 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3277 * a the front of the list of choices, when shown to the user with a
3278 * {@link #ACTION_CHOOSER}.
3279 */
3280 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3281
3282 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003283 * A Bundle forming a mapping of potential target package names to different extras Bundles
3284 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3285 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3286 * be currently installed on the device.
3287 *
3288 * <p>An application may choose to provide alternate extras for the case where a user
3289 * selects an activity from a predetermined set of target packages. If the activity
3290 * the user selects from the chooser belongs to a package with its package name as
3291 * a key in this bundle, the corresponding extras for that package will be merged with
3292 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3293 * extra has the same key as an extra already present in the intent it will overwrite
3294 * the extra from the intent.</p>
3295 *
3296 * <p><em>Examples:</em>
3297 * <ul>
3298 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3299 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3300 * parameters for that target.</li>
3301 * <li>An application may offer additional metadata for known targets of a given intent
3302 * to pass along information only relevant to that target such as account or content
3303 * identifiers already known to that application.</li>
3304 * </ul></p>
3305 */
3306 public static final String EXTRA_REPLACEMENT_EXTRAS =
3307 "android.intent.extra.REPLACEMENT_EXTRAS";
3308
3309 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003310 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3311 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3312 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3313 * {@link ComponentName} of the chosen component.
3314 *
3315 * <p>In some situations this callback may never come, for example if the user abandons
3316 * the chooser, switches to another task or any number of other reasons. Apps should not
3317 * be written assuming that this callback will always occur.</p>
3318 */
3319 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3320 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3321
3322 /**
3323 * The {@link ComponentName} chosen by the user to complete an action.
3324 *
3325 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3326 */
3327 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3328
3329 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003330 * A {@link android.view.KeyEvent} object containing the event that
3331 * triggered the creation of the Intent it is in.
3332 */
3333 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3334
3335 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003336 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3337 * before shutting down.
3338 *
3339 * {@hide}
3340 */
3341 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3342
3343 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003344 * 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 -07003345 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3346 * of restarting the application.
3347 */
3348 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3349
3350 /**
3351 * A String holding the phone number originally entered in
3352 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3353 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3354 */
3355 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003356
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003357 /**
3358 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3359 * intents to supply the uid the package had been assigned. Also an optional
3360 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3361 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3362 * purpose.
3363 */
3364 public static final String EXTRA_UID = "android.intent.extra.UID";
3365
3366 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003367 * @hide String array of package names.
3368 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003369 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003370 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3371
3372 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003373 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3374 * intents to indicate whether this represents a full uninstall (removing
3375 * both the code and its data) or a partial uninstall (leaving its data,
3376 * implying that this is an update).
3377 */
3378 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003379
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003380 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003381 * @hide
3382 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3383 * intents to indicate that at this point the package has been removed for
3384 * all users on the device.
3385 */
3386 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3387 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3388
3389 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003390 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3391 * intents to indicate that this is a replacement of the package, so this
3392 * broadcast will immediately be followed by an add broadcast for a
3393 * different version of the same package.
3394 */
3395 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003396
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003397 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003398 * Used as an int extra field in {@link android.app.AlarmManager} intents
3399 * to tell the application being invoked how many pending alarms are being
3400 * delievered with the intent. For one-shot alarms this will always be 1.
3401 * For recurring alarms, this might be greater than 1 if the device was
3402 * asleep or powered off at the time an earlier alarm would have been
3403 * delivered.
3404 */
3405 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003406
Jacek Surazski86b6c532009-05-13 14:38:28 +02003407 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003408 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3409 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003410 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3411 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003412 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3413 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3414 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003415 */
3416 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3417
3418 /**
3419 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3420 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003421 */
3422 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3423
3424 /**
3425 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3426 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003427 */
3428 public static final int EXTRA_DOCK_STATE_DESK = 1;
3429
3430 /**
3431 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3432 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003433 */
3434 public static final int EXTRA_DOCK_STATE_CAR = 2;
3435
3436 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003437 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3438 * to represent that the phone is in a analog (low end) dock.
3439 */
3440 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3441
3442 /**
3443 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3444 * to represent that the phone is in a digital (high end) dock.
3445 */
3446 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3447
3448 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003449 * Boolean that can be supplied as meta-data with a dock activity, to
3450 * indicate that the dock should take over the home key when it is active.
3451 */
3452 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003453
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003454 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003455 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3456 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003457 */
3458 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3459
3460 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003461 * Used in the extra field in the remote intent. It's astring token passed with the
3462 * remote intent.
3463 */
3464 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3465 "android.intent.extra.remote_intent_token";
3466
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003467 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003468 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003469 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003470 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003471 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003472 "android.intent.extra.changed_component_name";
3473
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003474 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003475 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003476 * and contains a string array of all of the components that have changed. If
3477 * the state of the overall package has changed, then it will contain an entry
3478 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003479 */
3480 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3481 "android.intent.extra.changed_component_name_list";
3482
3483 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003484 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003485 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3486 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003487 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003488 */
3489 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3490 "android.intent.extra.changed_package_list";
3491
3492 /**
3493 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003494 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3495 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003496 * and contains an integer array of uids of all of the components
3497 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003498 */
3499 public static final String EXTRA_CHANGED_UID_LIST =
3500 "android.intent.extra.changed_uid_list";
3501
3502 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003503 * @hide
3504 * Magic extra system code can use when binding, to give a label for
3505 * who it is that has bound to a service. This is an integer giving
3506 * a framework string resource that can be displayed to the user.
3507 */
3508 public static final String EXTRA_CLIENT_LABEL =
3509 "android.intent.extra.client_label";
3510
3511 /**
3512 * @hide
3513 * Magic extra system code can use when binding, to give a PendingIntent object
3514 * that can be launched for the user to disable the system's use of this
3515 * service.
3516 */
3517 public static final String EXTRA_CLIENT_INTENT =
3518 "android.intent.extra.client_intent";
3519
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003520 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003521 * Extra used to indicate that an intent should only return data that is on
3522 * the local device. This is a boolean extra; the default is false. If true,
3523 * an implementation should only allow the user to select data that is
3524 * already on the device, not requiring it be downloaded from a remote
3525 * service when opened.
3526 *
3527 * @see #ACTION_GET_CONTENT
3528 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003529 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003530 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003531 */
3532 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003533 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003534
Amith Yamasani13593602012-03-22 16:16:17 -07003535 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003536 * Extra used to indicate that an intent can allow the user to select and
3537 * return multiple items. This is a boolean extra; the default is false. If
3538 * true, an implementation is allowed to present the user with a UI where
3539 * they can pick multiple items that are all returned to the caller. When
3540 * this happens, they should be returned as the {@link #getClipData()} part
3541 * of the result Intent.
3542 *
3543 * @see #ACTION_GET_CONTENT
3544 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003545 */
3546 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003547 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003548
3549 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003550 * The integer userHandle carried with broadcast intents related to addition, removal and
3551 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3552 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3553 *
Amith Yamasani13593602012-03-22 16:16:17 -07003554 * @hide
3555 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003556 public static final String EXTRA_USER_HANDLE =
3557 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003558
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003559 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003560 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3561 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3562 */
3563 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003564 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003565
3566 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003567 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003568 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3569 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003570 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003571 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3572
3573 /**
3574 * Extra sent in the intent to the BroadcastReceiver that handles
3575 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3576 * the restrictions as key/value pairs.
3577 */
3578 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3579 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003580
Amith Yamasani86118ba2013-03-28 14:33:16 -07003581 /**
3582 * Extra used in the response from a BroadcastReceiver that handles
3583 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3584 */
3585 public static final String EXTRA_RESTRICTIONS_INTENT =
3586 "android.intent.extra.restrictions_intent";
3587
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003588 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003589 * Extra used to communicate a set of acceptable MIME types. The type of the
3590 * extra is {@code String[]}. Values may be a combination of concrete MIME
3591 * types (such as "image/png") and/or partial MIME types (such as
3592 * "audio/*").
3593 *
3594 * @see #ACTION_GET_CONTENT
3595 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003596 */
3597 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3598
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003599 /**
3600 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3601 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003602 * When this is true, hardware devices can use this information to determine that
3603 * they shouldn't do a complete shutdown of their device since this is not a
3604 * complete shutdown down to the kernel, but only user space restarting.
3605 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003606 */
3607 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3608 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3609
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003610 /**
3611 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3612 * user has set their time format preferences to the 24 hour format.
3613 *
3614 * @hide for internal use only.
3615 */
3616 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3617 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3618
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003619 /** {@hide} */
3620 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3621
Santos Cordon15a13782015-03-31 18:32:31 -07003622 /**
3623 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3624 * activation request.
3625 * TODO: Add information about the structure and response data used with the pending intent.
3626 * @hide
3627 */
3628 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3629 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3630
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003631 // ---------------------------------------------------------------------
3632 // ---------------------------------------------------------------------
3633 // Intent flags (see mFlags variable).
3634
Tor Norbyed9273d62013-05-30 15:59:53 -07003635 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003636 @IntDef(flag = true, value = {
3637 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3638 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003639 @Retention(RetentionPolicy.SOURCE)
3640 public @interface GrantUriMode {}
3641
Jeff Sharkey846318a2014-04-04 12:12:41 -07003642 /** @hide */
3643 @IntDef(flag = true, value = {
3644 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3645 @Retention(RetentionPolicy.SOURCE)
3646 public @interface AccessUriMode {}
3647
3648 /**
3649 * Test if given mode flags specify an access mode, which must be at least
3650 * read and/or write.
3651 *
3652 * @hide
3653 */
3654 public static boolean isAccessUriMode(int modeFlags) {
3655 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3656 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3657 }
3658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003659 /**
3660 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003661 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003662 * specified in its ClipData. When applying to an Intent's ClipData,
3663 * all URIs as well as recursive traversals through data or other ClipData
3664 * in Intent items will be granted; only the grant flags of the top-level
3665 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003666 */
3667 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3668 /**
3669 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003670 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003671 * specified in its ClipData. When applying to an Intent's ClipData,
3672 * all URIs as well as recursive traversals through data or other ClipData
3673 * in Intent items will be granted; only the grant flags of the top-level
3674 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003675 */
3676 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3677 /**
3678 * Can be set by the caller to indicate that this Intent is coming from
3679 * a background operation, not from direct user interaction.
3680 */
3681 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3682 /**
3683 * A flag you can enable for debugging: when set, log messages will be
3684 * printed during the resolution of this intent to show you what has
3685 * been found to create the final resolved list.
3686 */
3687 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003688 /**
3689 * If set, this intent will not match any components in packages that
3690 * are currently stopped. If this is not set, then the default behavior
3691 * is to include such applications in the result.
3692 */
3693 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3694 /**
3695 * If set, this intent will always match any components in packages that
3696 * are currently stopped. This is the default behavior when
3697 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3698 * flags are set, this one wins (it allows overriding of exclude for
3699 * places where the framework may automatically set the exclude flag).
3700 */
3701 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003702
3703 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003704 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003705 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003706 * persisted across device reboots until explicitly revoked with
3707 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3708 * grant for possible persisting; the receiving application must call
3709 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3710 * actually persist.
3711 *
3712 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3713 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3714 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003715 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003716 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003717 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003718
3719 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003720 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3721 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3722 * applies to any URI that is a prefix match against the original granted
3723 * URI. (Without this flag, the URI must match exactly for access to be
3724 * granted.) Another URI is considered a prefix match only when scheme,
3725 * authority, and all path segments defined by the prefix are an exact
3726 * match.
3727 */
3728 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3729
3730 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003731 * If set, the new activity is not kept in the history stack. As soon as
3732 * the user navigates away from it, the activity is finished. This may also
3733 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3734 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003735 *
3736 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3737 * is never invoked when the current activity starts a new activity which
3738 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003739 */
3740 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3741 /**
3742 * If set, the activity will not be launched if it is already running
3743 * at the top of the history stack.
3744 */
3745 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3746 /**
3747 * If set, this activity will become the start of a new task on this
3748 * history stack. A task (from the activity that started it to the
3749 * next task activity) defines an atomic group of activities that the
3750 * user can move to. Tasks can be moved to the foreground and background;
3751 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003752 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003753 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3754 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003755 *
3756 * <p>This flag is generally used by activities that want
3757 * to present a "launcher" style behavior: they give the user a list of
3758 * separate things that can be done, which otherwise run completely
3759 * independently of the activity launching them.
3760 *
3761 * <p>When using this flag, if a task is already running for the activity
3762 * you are now starting, then a new activity will not be started; instead,
3763 * the current task will simply be brought to the front of the screen with
3764 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3765 * to disable this behavior.
3766 *
3767 * <p>This flag can not be used when the caller is requesting a result from
3768 * the activity being launched.
3769 */
3770 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3771 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003772 * This flag is used to create a new task and launch an activity into it.
3773 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3774 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3775 * search through existing tasks for ones matching this Intent. Only if no such
3776 * task is found would a new task be created. When paired with
3777 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3778 * the search for a matching task and unconditionally start a new task.
3779 *
3780 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3781 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003782 * top-level application launcher.</strong> Used in conjunction with
3783 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3784 * behavior of bringing an existing task to the foreground. When set,
3785 * a new task is <em>always</em> started to host the Activity for the
3786 * Intent, regardless of whether there is already an existing task running
3787 * the same thing.
3788 *
3789 * <p><strong>Because the default system does not include graphical task management,
3790 * you should not use this flag unless you provide some way for a user to
3791 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003792 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003793 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3794 * creating new document tasks.
3795 *
3796 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003797 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003798 *
Scott Main7aee61f2011-02-08 11:25:01 -08003799 * <p>See
3800 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3801 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003802 *
3803 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3804 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003805 */
3806 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3807 /**
3808 * If set, and the activity being launched is already running in the
3809 * current task, then instead of launching a new instance of that activity,
3810 * all of the other activities on top of it will be closed and this Intent
3811 * will be delivered to the (now on top) old activity as a new Intent.
3812 *
3813 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3814 * If D calls startActivity() with an Intent that resolves to the component
3815 * of activity B, then C and D will be finished and B receive the given
3816 * Intent, resulting in the stack now being: A, B.
3817 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003818 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003819 * either receive the new intent you are starting here in its
3820 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003821 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003822 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3823 * the same intent, then it will be finished and re-created; for all other
3824 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3825 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003826 *
3827 * <p>This launch mode can also be used to good effect in conjunction with
3828 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3829 * of a task, it will bring any currently running instance of that task
3830 * to the foreground, and then clear it to its root state. This is
3831 * especially useful, for example, when launching an activity from the
3832 * notification manager.
3833 *
Scott Main7aee61f2011-02-08 11:25:01 -08003834 * <p>See
3835 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3836 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003837 */
3838 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3839 /**
3840 * If set and this intent is being used to launch a new activity from an
3841 * existing one, then the reply target of the existing activity will be
3842 * transfered to the new activity. This way the new activity can call
3843 * {@link android.app.Activity#setResult} and have that result sent back to
3844 * the reply target of the original activity.
3845 */
3846 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3847 /**
3848 * If set and this intent is being used to launch a new activity from an
3849 * existing one, the current activity will not be counted as the top
3850 * activity for deciding whether the new intent should be delivered to
3851 * the top instead of starting a new one. The previous activity will
3852 * be used as the top, with the assumption being that the current activity
3853 * will finish itself immediately.
3854 */
3855 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3856 /**
3857 * If set, the new activity is not kept in the list of recently launched
3858 * activities.
3859 */
3860 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3861 /**
3862 * This flag is not normally set by application code, but set for you by
3863 * the system as described in the
3864 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3865 * launchMode} documentation for the singleTask mode.
3866 */
3867 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3868 /**
3869 * If set, and this activity is either being started in a new task or
3870 * bringing to the top an existing task, then it will be launched as
3871 * the front door of the task. This will result in the application of
3872 * any affinities needed to have that task in the proper state (either
3873 * moving activities to or from it), or simply resetting that task to
3874 * its initial state if needed.
3875 */
3876 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3877 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003878 * This flag is not normally set by application code, but set for you by
3879 * the system if this activity is being launched from history
3880 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003881 */
3882 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003883 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003884 * @deprecated As of API 21 this performs identically to
3885 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003886 */
3887 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003888 /**
Craig Mautner026596b2014-05-21 15:35:44 -07003889 * This flag is used to open a document into a new task rooted at the activity launched
3890 * by this Intent. Through the use of this flag, or its equivalent attribute,
3891 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00003892 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003893 *
Craig Mautner026596b2014-05-21 15:35:44 -07003894 * <p>The use of the activity attribute form of this,
3895 * {@link android.R.attr#documentLaunchMode}, is
3896 * preferred over the Intent flag described here. The attribute form allows the
3897 * Activity to specify multiple document behavior for all launchers of the Activity
3898 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003899 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07003900 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
3901 * it is kept after the activity is finished is different than the use of
3902 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
3903 * this flag is being used to create a new recents entry, then by default that entry
3904 * will be removed once the activity is finished. You can modify this behavior with
3905 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
3906 *
Craig Mautner026596b2014-05-21 15:35:44 -07003907 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
3908 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
3909 * equivalent of the Activity manifest specifying {@link
3910 * android.R.attr#documentLaunchMode}="intoExisting". When used with
3911 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
3912 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07003913 *
Craig Mautner026596b2014-05-21 15:35:44 -07003914 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003915 *
Craig Mautner026596b2014-05-21 15:35:44 -07003916 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07003917 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
3918 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003919 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07003920 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003921 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003922 * callback from occurring on the current frontmost activity before it is
3923 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07003924 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003925 * <p>Typically, an activity can rely on that callback to indicate that an
3926 * explicit user action has caused their activity to be moved out of the
3927 * foreground. The callback marks an appropriate point in the activity's
3928 * lifecycle for it to dismiss any notifications that it intends to display
3929 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07003930 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003931 * <p>If an activity is ever started via any non-user-driven events such as
3932 * phone-call receipt or an alarm handler, this flag should be passed to {@link
3933 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07003934 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003935 */
3936 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003937 /**
3938 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3939 * this flag will cause the launched activity to be brought to the front of its
3940 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07003941 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003942 * <p>For example, consider a task consisting of four activities: A, B, C, D.
3943 * If D calls startActivity() with an Intent that resolves to the component
3944 * of activity B, then B will be brought to the front of the history stack,
3945 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07003946 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003947 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07003948 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003949 */
3950 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003951 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003952 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3953 * this flag will prevent the system from applying an activity transition
3954 * animation to go to the next activity state. This doesn't mean an
3955 * animation will never run -- if another activity change happens that doesn't
3956 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003957 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003958 * when you are going to do a series of activity operations but the
3959 * animation seen by the user shouldn't be driven by the first activity
3960 * change but rather a later one.
3961 */
3962 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
3963 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003964 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3965 * this flag will cause any existing task that would be associated with the
3966 * activity to be cleared before the activity is started. That is, the activity
3967 * becomes the new root of an otherwise empty task, and any old activities
3968 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3969 */
3970 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
3971 /**
3972 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3973 * this flag will cause a newly launching task to be placed on top of the current
3974 * home activity task (if there is one). That is, pressing back from the task
3975 * will always return the user to home even if that was not the last activity they
3976 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3977 */
3978 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
3979 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07003980 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
3981 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07003982 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07003983 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07003984 * this flag. When set and the task's activity is finished, the recents
3985 * entry will remain in the interface for the user to re-launch it, like a
3986 * recents entry for a top-level application.
3987 * <p>
3988 * The receiving activity can override this request with
3989 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
3990 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07003991 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07003992 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07003993 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07003994
3995 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003996 * If set, when sending a broadcast only registered receivers will be
3997 * called -- no BroadcastReceiver components will be launched.
3998 */
3999 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004000 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004001 * If set, when sending a broadcast the new broadcast will replace
4002 * any existing pending broadcast that matches it. Matching is defined
4003 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4004 * true for the intents of the two broadcasts. When a match is found,
4005 * the new broadcast (and receivers associated with it) will replace the
4006 * existing one in the pending broadcast list, remaining at the same
4007 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004008 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004009 * <p>This flag is most typically used with sticky broadcasts, which
4010 * only care about delivering the most recent values of the broadcast
4011 * to their receivers.
4012 */
4013 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4014 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004015 * If set, when sending a broadcast the recipient is allowed to run at
4016 * foreground priority, with a shorter timeout interval. During normal
4017 * broadcasts the receivers are not automatically hoisted out of the
4018 * background priority class.
4019 */
4020 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4021 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004022 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4023 * They can still propagate results through to later receivers, but they can not prevent
4024 * later receivers from seeing the broadcast.
4025 */
4026 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4027 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004028 * If set, when sending a broadcast <i>before boot has completed</i> only
4029 * registered receivers will be called -- no BroadcastReceiver components
4030 * will be launched. Sticky intent state will be recorded properly even
4031 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4032 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004033 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004034 * <p>This flag is only for use by system sevices as a convenience to
4035 * avoid having to implement a more complex mechanism around detection
4036 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004037 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004038 * @hide
4039 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004040 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004041 /**
4042 * Set when this broadcast is for a boot upgrade, a special mode that
4043 * allows the broadcast to be sent before the system is ready and launches
4044 * the app process with no providers running in it.
4045 * @hide
4046 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004047 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004048
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004049 /**
4050 * @hide Flags that can't be changed with PendingIntent.
4051 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004052 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4053 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4054 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004055
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004056 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004057 // ---------------------------------------------------------------------
4058 // toUri() and parseUri() options.
4059
4060 /**
4061 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4062 * always has the "intent:" scheme. This syntax can be used when you want
4063 * to later disambiguate between URIs that are intended to describe an
4064 * Intent vs. all others that should be treated as raw URIs. When used
4065 * with {@link #parseUri}, any other scheme will result in a generic
4066 * VIEW action for that raw URI.
4067 */
4068 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004069
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004070 /**
4071 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4072 * always has the "android-app:" scheme. This is a variation of
4073 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4074 * http/https URI being delivered to a specific package name. The format
4075 * is:
4076 *
4077 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004078 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004079 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004080 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4081 * you must also include a scheme; including a path also requires both a host and a scheme.
4082 * The final #Intent; fragment can be used without a scheme, host, or path.
4083 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004084 * used with intents that have a {@link #setSelector}, since the base intent
4085 * will always have an explicit package name.</p>
4086 *
4087 * <p>Some examples of how this scheme maps to Intent objects:</p>
4088 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4089 * <colgroup align="left" />
4090 * <colgroup align="left" />
4091 * <thead>
4092 * <tr><th>URI</th> <th>Intent</th></tr>
4093 * </thead>
4094 *
4095 * <tbody>
4096 * <tr><td><code>android-app://com.example.app</code></td>
4097 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4098 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4099 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4100 * </table></td>
4101 * </tr>
4102 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4103 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4104 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4105 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4106 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4107 * </table></td>
4108 * </tr>
4109 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4110 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4111 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4112 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4113 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4114 * </table></td>
4115 * </tr>
4116 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4117 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4118 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4119 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4120 * </table></td>
4121 * </tr>
4122 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4123 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4124 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4125 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4126 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4127 * </table></td>
4128 * </tr>
4129 * <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>
4130 * <td><table border="" style="margin:0" >
4131 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4132 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4133 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4134 * </table></td>
4135 * </tr>
4136 * </tbody>
4137 * </table>
4138 */
4139 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4140
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004141 /**
4142 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4143 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4144 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4145 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4146 * generated Intent can not cause unexpected data access to happen.
4147 *
4148 * <p>If you do not trust the source of the URI being parsed, you should still do further
4149 * processing to protect yourself from it. In particular, when using it to start an
4150 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4151 * that can handle it.</p>
4152 */
4153 public static final int URI_ALLOW_UNSAFE = 1<<2;
4154
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004155 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004156
4157 private String mAction;
4158 private Uri mData;
4159 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004160 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004161 private ComponentName mComponent;
4162 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004163 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004164 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004165 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004166 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004167 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004168 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004169
4170 // ---------------------------------------------------------------------
4171
4172 /**
4173 * Create an empty intent.
4174 */
4175 public Intent() {
4176 }
4177
4178 /**
4179 * Copy constructor.
4180 */
4181 public Intent(Intent o) {
4182 this.mAction = o.mAction;
4183 this.mData = o.mData;
4184 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004185 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004186 this.mComponent = o.mComponent;
4187 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004188 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004189 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004190 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004191 }
4192 if (o.mExtras != null) {
4193 this.mExtras = new Bundle(o.mExtras);
4194 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004195 if (o.mSourceBounds != null) {
4196 this.mSourceBounds = new Rect(o.mSourceBounds);
4197 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004198 if (o.mSelector != null) {
4199 this.mSelector = new Intent(o.mSelector);
4200 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004201 if (o.mClipData != null) {
4202 this.mClipData = new ClipData(o.mClipData);
4203 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004204 }
4205
4206 @Override
4207 public Object clone() {
4208 return new Intent(this);
4209 }
4210
4211 private Intent(Intent o, boolean all) {
4212 this.mAction = o.mAction;
4213 this.mData = o.mData;
4214 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004215 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004216 this.mComponent = o.mComponent;
4217 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004218 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004219 }
4220 }
4221
4222 /**
4223 * Make a clone of only the parts of the Intent that are relevant for
4224 * filter matching: the action, data, type, component, and categories.
4225 */
4226 public Intent cloneFilter() {
4227 return new Intent(this, false);
4228 }
4229
4230 /**
4231 * Create an intent with a given action. All other fields (data, type,
4232 * class) are null. Note that the action <em>must</em> be in a
4233 * namespace because Intents are used globally in the system -- for
4234 * example the system VIEW action is android.intent.action.VIEW; an
4235 * application's custom action would be something like
4236 * com.google.app.myapp.CUSTOM_ACTION.
4237 *
4238 * @param action The Intent action, such as ACTION_VIEW.
4239 */
4240 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004241 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004242 }
4243
4244 /**
4245 * Create an intent with a given action and for a given data url. Note
4246 * that the action <em>must</em> be in a namespace because Intents are
4247 * used globally in the system -- for example the system VIEW action is
4248 * android.intent.action.VIEW; an application's custom action would be
4249 * something like com.google.app.myapp.CUSTOM_ACTION.
4250 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004251 * <p><em>Note: scheme and host name matching in the Android framework is
4252 * case-sensitive, unlike the formal RFC. As a result,
4253 * you should always ensure that you write your Uri with these elements
4254 * using lower case letters, and normalize any Uris you receive from
4255 * outside of Android to ensure the scheme and host is lower case.</em></p>
4256 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004257 * @param action The Intent action, such as ACTION_VIEW.
4258 * @param uri The Intent data URI.
4259 */
4260 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004261 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004262 mData = uri;
4263 }
4264
4265 /**
4266 * Create an intent for a specific component. All other fields (action, data,
4267 * type, class) are null, though they can be modified later with explicit
4268 * calls. This provides a convenient way to create an intent that is
4269 * intended to execute a hard-coded class name, rather than relying on the
4270 * system to find an appropriate class for you; see {@link #setComponent}
4271 * for more information on the repercussions of this.
4272 *
4273 * @param packageContext A Context of the application package implementing
4274 * this class.
4275 * @param cls The component class that is to be used for the intent.
4276 *
4277 * @see #setClass
4278 * @see #setComponent
4279 * @see #Intent(String, android.net.Uri , Context, Class)
4280 */
4281 public Intent(Context packageContext, Class<?> cls) {
4282 mComponent = new ComponentName(packageContext, cls);
4283 }
4284
4285 /**
4286 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004287 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004288 * construct the Intent and then calling {@link #setClass} to set its
4289 * class.
4290 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004291 * <p><em>Note: scheme and host name matching in the Android framework is
4292 * case-sensitive, unlike the formal RFC. As a result,
4293 * you should always ensure that you write your Uri with these elements
4294 * using lower case letters, and normalize any Uris you receive from
4295 * outside of Android to ensure the scheme and host is lower case.</em></p>
4296 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004297 * @param action The Intent action, such as ACTION_VIEW.
4298 * @param uri The Intent data URI.
4299 * @param packageContext A Context of the application package implementing
4300 * this class.
4301 * @param cls The component class that is to be used for the intent.
4302 *
4303 * @see #Intent(String, android.net.Uri)
4304 * @see #Intent(Context, Class)
4305 * @see #setClass
4306 * @see #setComponent
4307 */
4308 public Intent(String action, Uri uri,
4309 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004310 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004311 mData = uri;
4312 mComponent = new ComponentName(packageContext, cls);
4313 }
4314
4315 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004316 * Create an intent to launch the main (root) activity of a task. This
4317 * is the Intent that is started when the application's is launched from
4318 * Home. For anything else that wants to launch an application in the
4319 * same way, it is important that they use an Intent structured the same
4320 * way, and can use this function to ensure this is the case.
4321 *
4322 * <p>The returned Intent has the given Activity component as its explicit
4323 * component, {@link #ACTION_MAIN} as its action, and includes the
4324 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4325 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4326 * to do that through {@link #addFlags(int)} on the returned Intent.
4327 *
4328 * @param mainActivity The main activity component that this Intent will
4329 * launch.
4330 * @return Returns a newly created Intent that can be used to launch the
4331 * activity as a main application entry.
4332 *
4333 * @see #setClass
4334 * @see #setComponent
4335 */
4336 public static Intent makeMainActivity(ComponentName mainActivity) {
4337 Intent intent = new Intent(ACTION_MAIN);
4338 intent.setComponent(mainActivity);
4339 intent.addCategory(CATEGORY_LAUNCHER);
4340 return intent;
4341 }
4342
4343 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004344 * Make an Intent for the main activity of an application, without
4345 * specifying a specific activity to run but giving a selector to find
4346 * the activity. This results in a final Intent that is structured
4347 * the same as when the application is launched from
4348 * Home. For anything else that wants to launch an application in the
4349 * same way, it is important that they use an Intent structured the same
4350 * way, and can use this function to ensure this is the case.
4351 *
4352 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4353 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4354 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4355 * to do that through {@link #addFlags(int)} on the returned Intent.
4356 *
4357 * @param selectorAction The action name of the Intent's selector.
4358 * @param selectorCategory The name of a category to add to the Intent's
4359 * selector.
4360 * @return Returns a newly created Intent that can be used to launch the
4361 * activity as a main application entry.
4362 *
4363 * @see #setSelector(Intent)
4364 */
4365 public static Intent makeMainSelectorActivity(String selectorAction,
4366 String selectorCategory) {
4367 Intent intent = new Intent(ACTION_MAIN);
4368 intent.addCategory(CATEGORY_LAUNCHER);
4369 Intent selector = new Intent();
4370 selector.setAction(selectorAction);
4371 selector.addCategory(selectorCategory);
4372 intent.setSelector(selector);
4373 return intent;
4374 }
4375
4376 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004377 * Make an Intent that can be used to re-launch an application's task
4378 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4379 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4380 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4381 *
4382 * @param mainActivity The activity component that is the root of the
4383 * task; this is the activity that has been published in the application's
4384 * manifest as the main launcher icon.
4385 *
4386 * @return Returns a newly created Intent that can be used to relaunch the
4387 * activity's task in its root state.
4388 */
4389 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4390 Intent intent = makeMainActivity(mainActivity);
4391 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4392 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4393 return intent;
4394 }
4395
4396 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004397 * Call {@link #parseUri} with 0 flags.
4398 * @deprecated Use {@link #parseUri} instead.
4399 */
4400 @Deprecated
4401 public static Intent getIntent(String uri) throws URISyntaxException {
4402 return parseUri(uri, 0);
4403 }
Tom Taylord4a47292009-12-21 13:59:18 -08004404
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004405 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004406 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004407 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004408 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004409 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004410 *
4411 * <p>The URI given here must not be relative -- that is, it must include
4412 * the scheme and full path.
4413 *
4414 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004415 * @param flags Additional processing flags. Either 0,
4416 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004417 *
4418 * @return Intent The newly created Intent object.
4419 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004420 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4421 * it bad (as parsed by the Uri class) or the Intent data within the
4422 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004423 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004424 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004425 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004426 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004427 int i = 0;
4428 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004429 final boolean androidApp = uri.startsWith("android-app:");
4430
4431 // Validate intent scheme if requested.
4432 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4433 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004434 Intent intent = new Intent(ACTION_VIEW);
4435 try {
4436 intent.setData(Uri.parse(uri));
4437 } catch (IllegalArgumentException e) {
4438 throw new URISyntaxException(uri, e.getMessage());
4439 }
4440 return intent;
4441 }
4442 }
Tom Taylord4a47292009-12-21 13:59:18 -08004443
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004444 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004445 // simple case
4446 if (i == -1) {
4447 if (!androidApp) {
4448 return new Intent(ACTION_VIEW, Uri.parse(uri));
4449 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004450
4451 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004452 } else if (!uri.startsWith("#Intent;", i)) {
4453 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004454 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004455 } else {
4456 i = -1;
4457 }
4458 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004459
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004460 // new format
4461 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004462 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004463 boolean explicitAction = false;
4464 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004465
4466 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004467 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004468 String data;
4469 if (i >= 0) {
4470 data = uri.substring(0, i);
4471 i += 8; // length of "#Intent;"
4472 } else {
4473 data = uri;
4474 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004475
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004476 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004477 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004478 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004479 if (eq < 0) eq = i-1;
4480 int semi = uri.indexOf(';', i);
4481 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004482
4483 // action
4484 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004485 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004486 if (!inSelector) {
4487 explicitAction = true;
4488 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004489 }
4490
4491 // categories
4492 else if (uri.startsWith("category=", i)) {
4493 intent.addCategory(value);
4494 }
4495
4496 // type
4497 else if (uri.startsWith("type=", i)) {
4498 intent.mType = value;
4499 }
4500
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004501 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004502 else if (uri.startsWith("launchFlags=", i)) {
4503 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004504 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4505 intent.mFlags &= ~IMMUTABLE_FLAGS;
4506 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004507 }
4508
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004509 // package
4510 else if (uri.startsWith("package=", i)) {
4511 intent.mPackage = value;
4512 }
4513
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004514 // component
4515 else if (uri.startsWith("component=", i)) {
4516 intent.mComponent = ComponentName.unflattenFromString(value);
4517 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004518
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004519 // scheme
4520 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004521 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004522 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004523 } else {
4524 scheme = value;
4525 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004526 }
4527
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004528 // source bounds
4529 else if (uri.startsWith("sourceBounds=", i)) {
4530 intent.mSourceBounds = Rect.unflattenFromString(value);
4531 }
4532
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004533 // selector
4534 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4535 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004536 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004537 }
4538
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004539 // extra
4540 else {
4541 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004542 // create Bundle if it doesn't already exist
4543 if (intent.mExtras == null) intent.mExtras = new Bundle();
4544 Bundle b = intent.mExtras;
4545 // add EXTRA
4546 if (uri.startsWith("S.", i)) b.putString(key, value);
4547 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4548 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4549 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4550 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4551 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4552 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4553 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4554 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4555 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4556 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004557
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004558 // move to the next item
4559 i = semi + 1;
4560 }
4561
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004562 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004563 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004564 if (baseIntent.mPackage == null) {
4565 baseIntent.setSelector(intent);
4566 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004567 intent = baseIntent;
4568 }
4569
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004570 if (data != null) {
4571 if (data.startsWith("intent:")) {
4572 data = data.substring(7);
4573 if (scheme != null) {
4574 data = scheme + ':' + data;
4575 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004576 } else if (data.startsWith("android-app:")) {
4577 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4578 // Correctly formed android-app, first part is package name.
4579 int end = data.indexOf('/', 14);
4580 if (end < 0) {
4581 // All we have is a package name.
4582 intent.mPackage = data.substring(14);
4583 if (!explicitAction) {
4584 intent.setAction(ACTION_MAIN);
4585 }
4586 data = "";
4587 } else {
4588 // Target the Intent at the given package name always.
4589 String authority = null;
4590 intent.mPackage = data.substring(14, end);
4591 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004592 if ((end+1) < data.length()) {
4593 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4594 // Found a scheme, remember it.
4595 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004596 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004597 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4598 // Found a authority, remember it.
4599 authority = data.substring(end+1, newEnd);
4600 end = newEnd;
4601 }
4602 } else {
4603 // All we have is a scheme.
4604 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004605 }
4606 }
4607 if (scheme == null) {
4608 // If there was no scheme, then this just targets the package.
4609 if (!explicitAction) {
4610 intent.setAction(ACTION_MAIN);
4611 }
4612 data = "";
4613 } else if (authority == null) {
4614 data = scheme + ":";
4615 } else {
4616 data = scheme + "://" + authority + data.substring(end);
4617 }
4618 }
4619 } else {
4620 data = "";
4621 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004622 }
Tom Taylord4a47292009-12-21 13:59:18 -08004623
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004624 if (data.length() > 0) {
4625 try {
4626 intent.mData = Uri.parse(data);
4627 } catch (IllegalArgumentException e) {
4628 throw new URISyntaxException(uri, e.getMessage());
4629 }
4630 }
4631 }
Tom Taylord4a47292009-12-21 13:59:18 -08004632
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004633 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004634
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004635 } catch (IndexOutOfBoundsException e) {
4636 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4637 }
4638 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004640 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004641 return getIntentOld(uri, 0);
4642 }
4643
4644 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004645 Intent intent;
4646
4647 int i = uri.lastIndexOf('#');
4648 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004649 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004650 final int intentFragmentStart = i;
4651 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004652
4653 i++;
4654
4655 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004656 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004657 i += 7;
4658 int j = uri.indexOf(')', i);
4659 action = uri.substring(i, j);
4660 i = j + 1;
4661 }
4662
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004663 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004664
4665 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004666 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004667 i += 11;
4668 int j = uri.indexOf(')', i);
4669 while (i < j) {
4670 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004671 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004672 if (i < sep) {
4673 intent.addCategory(uri.substring(i, sep));
4674 }
4675 i = sep + 1;
4676 }
4677 i = j + 1;
4678 }
4679
4680 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004681 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004682 i += 5;
4683 int j = uri.indexOf(')', i);
4684 intent.mType = uri.substring(i, j);
4685 i = j + 1;
4686 }
4687
4688 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004689 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004690 i += 12;
4691 int j = uri.indexOf(')', i);
4692 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004693 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4694 intent.mFlags &= ~IMMUTABLE_FLAGS;
4695 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004696 i = j + 1;
4697 }
4698
4699 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004700 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004701 i += 10;
4702 int j = uri.indexOf(')', i);
4703 int sep = uri.indexOf('!', i);
4704 if (sep >= 0 && sep < j) {
4705 String pkg = uri.substring(i, sep);
4706 String cls = uri.substring(sep + 1, j);
4707 intent.mComponent = new ComponentName(pkg, cls);
4708 }
4709 i = j + 1;
4710 }
4711
4712 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004713 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004714 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004715
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004716 final int closeParen = uri.indexOf(')', i);
4717 if (closeParen == -1) throw new URISyntaxException(uri,
4718 "EXTRA missing trailing ')'", i);
4719
4720 while (i < closeParen) {
4721 // fetch the key value
4722 int j = uri.indexOf('=', i);
4723 if (j <= i + 1 || i >= closeParen) {
4724 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4725 }
4726 char type = uri.charAt(i);
4727 i++;
4728 String key = uri.substring(i, j);
4729 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004730
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004731 // get type-value
4732 j = uri.indexOf('!', i);
4733 if (j == -1 || j >= closeParen) j = closeParen;
4734 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4735 String value = uri.substring(i, j);
4736 i = j;
4737
4738 // create Bundle if it doesn't already exist
4739 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004740
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 // add item to bundle
4742 try {
4743 switch (type) {
4744 case 'S':
4745 intent.mExtras.putString(key, Uri.decode(value));
4746 break;
4747 case 'B':
4748 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4749 break;
4750 case 'b':
4751 intent.mExtras.putByte(key, Byte.parseByte(value));
4752 break;
4753 case 'c':
4754 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4755 break;
4756 case 'd':
4757 intent.mExtras.putDouble(key, Double.parseDouble(value));
4758 break;
4759 case 'f':
4760 intent.mExtras.putFloat(key, Float.parseFloat(value));
4761 break;
4762 case 'i':
4763 intent.mExtras.putInt(key, Integer.parseInt(value));
4764 break;
4765 case 'l':
4766 intent.mExtras.putLong(key, Long.parseLong(value));
4767 break;
4768 case 's':
4769 intent.mExtras.putShort(key, Short.parseShort(value));
4770 break;
4771 default:
4772 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4773 }
4774 } catch (NumberFormatException e) {
4775 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4776 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004777
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004778 char ch = uri.charAt(i);
4779 if (ch == ')') break;
4780 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4781 i++;
4782 }
4783 }
4784
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004785 if (isIntentFragment) {
4786 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4787 } else {
4788 intent.mData = Uri.parse(uri);
4789 }
Tom Taylord4a47292009-12-21 13:59:18 -08004790
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004791 if (intent.mAction == null) {
4792 // By default, if no action is specified, then use VIEW.
4793 intent.mAction = ACTION_VIEW;
4794 }
4795
4796 } else {
4797 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4798 }
4799
4800 return intent;
4801 }
4802
4803 /**
4804 * Retrieve the general action to be performed, such as
4805 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4806 * the information in the intent should be interpreted -- most importantly,
4807 * what to do with the data returned by {@link #getData}.
4808 *
4809 * @return The action of this intent or null if none is specified.
4810 *
4811 * @see #setAction
4812 */
4813 public String getAction() {
4814 return mAction;
4815 }
4816
4817 /**
4818 * Retrieve data this intent is operating on. This URI specifies the name
4819 * of the data; often it uses the content: scheme, specifying data in a
4820 * content provider. Other schemes may be handled by specific activities,
4821 * such as http: by the web browser.
4822 *
4823 * @return The URI of the data this intent is targeting or null.
4824 *
4825 * @see #getScheme
4826 * @see #setData
4827 */
4828 public Uri getData() {
4829 return mData;
4830 }
4831
4832 /**
4833 * The same as {@link #getData()}, but returns the URI as an encoded
4834 * String.
4835 */
4836 public String getDataString() {
4837 return mData != null ? mData.toString() : null;
4838 }
4839
4840 /**
4841 * Return the scheme portion of the intent's data. If the data is null or
4842 * does not include a scheme, null is returned. Otherwise, the scheme
4843 * prefix without the final ':' is returned, i.e. "http".
4844 *
4845 * <p>This is the same as calling getData().getScheme() (and checking for
4846 * null data).
4847 *
4848 * @return The scheme of this intent.
4849 *
4850 * @see #getData
4851 */
4852 public String getScheme() {
4853 return mData != null ? mData.getScheme() : null;
4854 }
4855
4856 /**
4857 * Retrieve any explicit MIME type included in the intent. This is usually
4858 * null, as the type is determined by the intent data.
4859 *
4860 * @return If a type was manually set, it is returned; else null is
4861 * returned.
4862 *
4863 * @see #resolveType(ContentResolver)
4864 * @see #setType
4865 */
4866 public String getType() {
4867 return mType;
4868 }
4869
4870 /**
4871 * Return the MIME data type of this intent. If the type field is
4872 * explicitly set, that is simply returned. Otherwise, if the data is set,
4873 * the type of that data is returned. If neither fields are set, a null is
4874 * returned.
4875 *
4876 * @return The MIME type of this intent.
4877 *
4878 * @see #getType
4879 * @see #resolveType(ContentResolver)
4880 */
4881 public String resolveType(Context context) {
4882 return resolveType(context.getContentResolver());
4883 }
4884
4885 /**
4886 * Return the MIME data type of this intent. If the type field is
4887 * explicitly set, that is simply returned. Otherwise, if the data is set,
4888 * the type of that data is returned. If neither fields are set, a null is
4889 * returned.
4890 *
4891 * @param resolver A ContentResolver that can be used to determine the MIME
4892 * type of the intent's data.
4893 *
4894 * @return The MIME type of this intent.
4895 *
4896 * @see #getType
4897 * @see #resolveType(Context)
4898 */
4899 public String resolveType(ContentResolver resolver) {
4900 if (mType != null) {
4901 return mType;
4902 }
4903 if (mData != null) {
4904 if ("content".equals(mData.getScheme())) {
4905 return resolver.getType(mData);
4906 }
4907 }
4908 return null;
4909 }
4910
4911 /**
4912 * Return the MIME data type of this intent, only if it will be needed for
4913 * intent resolution. This is not generally useful for application code;
4914 * it is used by the frameworks for communicating with back-end system
4915 * services.
4916 *
4917 * @param resolver A ContentResolver that can be used to determine the MIME
4918 * type of the intent's data.
4919 *
4920 * @return The MIME type of this intent, or null if it is unknown or not
4921 * needed.
4922 */
4923 public String resolveTypeIfNeeded(ContentResolver resolver) {
4924 if (mComponent != null) {
4925 return mType;
4926 }
4927 return resolveType(resolver);
4928 }
4929
4930 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004931 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004932 *
4933 * @param category The category to check.
4934 *
4935 * @return boolean True if the intent contains the category, else false.
4936 *
4937 * @see #getCategories
4938 * @see #addCategory
4939 */
4940 public boolean hasCategory(String category) {
4941 return mCategories != null && mCategories.contains(category);
4942 }
4943
4944 /**
4945 * Return the set of all categories in the intent. If there are no categories,
4946 * returns NULL.
4947 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004948 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004949 *
4950 * @see #hasCategory
4951 * @see #addCategory
4952 */
4953 public Set<String> getCategories() {
4954 return mCategories;
4955 }
4956
4957 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004958 * Return the specific selector associated with this Intent. If there is
4959 * none, returns null. See {@link #setSelector} for more information.
4960 *
4961 * @see #setSelector
4962 */
4963 public Intent getSelector() {
4964 return mSelector;
4965 }
4966
4967 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004968 * Return the {@link ClipData} associated with this Intent. If there is
4969 * none, returns null. See {@link #setClipData} for more information.
4970 *
John Spurlock125d1332013-11-25 11:58:37 -05004971 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004972 */
4973 public ClipData getClipData() {
4974 return mClipData;
4975 }
4976
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004977 /** @hide */
4978 public int getContentUserHint() {
4979 return mContentUserHint;
4980 }
4981
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004982 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004983 * Sets the ClassLoader that will be used when unmarshalling
4984 * any Parcelable values from the extras of this Intent.
4985 *
4986 * @param loader a ClassLoader, or null to use the default loader
4987 * at the time of unmarshalling.
4988 */
4989 public void setExtrasClassLoader(ClassLoader loader) {
4990 if (mExtras != null) {
4991 mExtras.setClassLoader(loader);
4992 }
4993 }
4994
4995 /**
4996 * Returns true if an extra value is associated with the given name.
4997 * @param name the extra's name
4998 * @return true if the given extra is present.
4999 */
5000 public boolean hasExtra(String name) {
5001 return mExtras != null && mExtras.containsKey(name);
5002 }
5003
5004 /**
5005 * Returns true if the Intent's extras contain a parcelled file descriptor.
5006 * @return true if the Intent contains a parcelled file descriptor.
5007 */
5008 public boolean hasFileDescriptors() {
5009 return mExtras != null && mExtras.hasFileDescriptors();
5010 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005011
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005012 /** @hide */
5013 public void setAllowFds(boolean allowFds) {
5014 if (mExtras != null) {
5015 mExtras.setAllowFds(allowFds);
5016 }
5017 }
5018
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005019 /**
5020 * Retrieve extended data from the intent.
5021 *
5022 * @param name The name of the desired item.
5023 *
5024 * @return the value of an item that previously added with putExtra()
5025 * or null if none was found.
5026 *
5027 * @deprecated
5028 * @hide
5029 */
5030 @Deprecated
5031 public Object getExtra(String name) {
5032 return getExtra(name, null);
5033 }
5034
5035 /**
5036 * Retrieve extended data from the intent.
5037 *
5038 * @param name The name of the desired item.
5039 * @param defaultValue the value to be returned if no value of the desired
5040 * type is stored with the given name.
5041 *
5042 * @return the value of an item that previously added with putExtra()
5043 * or the default value if none was found.
5044 *
5045 * @see #putExtra(String, boolean)
5046 */
5047 public boolean getBooleanExtra(String name, boolean defaultValue) {
5048 return mExtras == null ? defaultValue :
5049 mExtras.getBoolean(name, defaultValue);
5050 }
5051
5052 /**
5053 * Retrieve extended data from the intent.
5054 *
5055 * @param name The name of the desired item.
5056 * @param defaultValue the value to be returned if no value of the desired
5057 * type is stored with the given name.
5058 *
5059 * @return the value of an item that previously added with putExtra()
5060 * or the default value if none was found.
5061 *
5062 * @see #putExtra(String, byte)
5063 */
5064 public byte getByteExtra(String name, byte defaultValue) {
5065 return mExtras == null ? defaultValue :
5066 mExtras.getByte(name, defaultValue);
5067 }
5068
5069 /**
5070 * Retrieve extended data from the intent.
5071 *
5072 * @param name The name of the desired item.
5073 * @param defaultValue the value to be returned if no value of the desired
5074 * type is stored with the given name.
5075 *
5076 * @return the value of an item that previously added with putExtra()
5077 * or the default value if none was found.
5078 *
5079 * @see #putExtra(String, short)
5080 */
5081 public short getShortExtra(String name, short defaultValue) {
5082 return mExtras == null ? defaultValue :
5083 mExtras.getShort(name, defaultValue);
5084 }
5085
5086 /**
5087 * Retrieve extended data from the intent.
5088 *
5089 * @param name The name of the desired item.
5090 * @param defaultValue the value to be returned if no value of the desired
5091 * type is stored with the given name.
5092 *
5093 * @return the value of an item that previously added with putExtra()
5094 * or the default value if none was found.
5095 *
5096 * @see #putExtra(String, char)
5097 */
5098 public char getCharExtra(String name, char defaultValue) {
5099 return mExtras == null ? defaultValue :
5100 mExtras.getChar(name, defaultValue);
5101 }
5102
5103 /**
5104 * Retrieve extended data from the intent.
5105 *
5106 * @param name The name of the desired item.
5107 * @param defaultValue the value to be returned if no value of the desired
5108 * type is stored with the given name.
5109 *
5110 * @return the value of an item that previously added with putExtra()
5111 * or the default value if none was found.
5112 *
5113 * @see #putExtra(String, int)
5114 */
5115 public int getIntExtra(String name, int defaultValue) {
5116 return mExtras == null ? defaultValue :
5117 mExtras.getInt(name, defaultValue);
5118 }
5119
5120 /**
5121 * Retrieve extended data from the intent.
5122 *
5123 * @param name The name of the desired item.
5124 * @param defaultValue the value to be returned if no value of the desired
5125 * type is stored with the given name.
5126 *
5127 * @return the value of an item that previously added with putExtra()
5128 * or the default value if none was found.
5129 *
5130 * @see #putExtra(String, long)
5131 */
5132 public long getLongExtra(String name, long defaultValue) {
5133 return mExtras == null ? defaultValue :
5134 mExtras.getLong(name, defaultValue);
5135 }
5136
5137 /**
5138 * Retrieve extended data from the intent.
5139 *
5140 * @param name The name of the desired item.
5141 * @param defaultValue the value to be returned if no value of the desired
5142 * type is stored with the given name.
5143 *
5144 * @return the value of an item that previously added with putExtra(),
5145 * or the default value if no such item is present
5146 *
5147 * @see #putExtra(String, float)
5148 */
5149 public float getFloatExtra(String name, float defaultValue) {
5150 return mExtras == null ? defaultValue :
5151 mExtras.getFloat(name, defaultValue);
5152 }
5153
5154 /**
5155 * Retrieve extended data from the intent.
5156 *
5157 * @param name The name of the desired item.
5158 * @param defaultValue the value to be returned if no value of the desired
5159 * type is stored with the given name.
5160 *
5161 * @return the value of an item that previously added with putExtra()
5162 * or the default value if none was found.
5163 *
5164 * @see #putExtra(String, double)
5165 */
5166 public double getDoubleExtra(String name, double defaultValue) {
5167 return mExtras == null ? defaultValue :
5168 mExtras.getDouble(name, defaultValue);
5169 }
5170
5171 /**
5172 * Retrieve extended data from the intent.
5173 *
5174 * @param name The name of the desired item.
5175 *
5176 * @return the value of an item that previously added with putExtra()
5177 * or null if no String value was found.
5178 *
5179 * @see #putExtra(String, String)
5180 */
5181 public String getStringExtra(String name) {
5182 return mExtras == null ? null : mExtras.getString(name);
5183 }
5184
5185 /**
5186 * Retrieve extended data from the intent.
5187 *
5188 * @param name The name of the desired item.
5189 *
5190 * @return the value of an item that previously added with putExtra()
5191 * or null if no CharSequence value was found.
5192 *
5193 * @see #putExtra(String, CharSequence)
5194 */
5195 public CharSequence getCharSequenceExtra(String name) {
5196 return mExtras == null ? null : mExtras.getCharSequence(name);
5197 }
5198
5199 /**
5200 * Retrieve extended data from the intent.
5201 *
5202 * @param name The name of the desired item.
5203 *
5204 * @return the value of an item that previously added with putExtra()
5205 * or null if no Parcelable value was found.
5206 *
5207 * @see #putExtra(String, Parcelable)
5208 */
5209 public <T extends Parcelable> T getParcelableExtra(String name) {
5210 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5211 }
5212
5213 /**
5214 * Retrieve extended data from the intent.
5215 *
5216 * @param name The name of the desired item.
5217 *
5218 * @return the value of an item that previously added with putExtra()
5219 * or null if no Parcelable[] value was found.
5220 *
5221 * @see #putExtra(String, Parcelable[])
5222 */
5223 public Parcelable[] getParcelableArrayExtra(String name) {
5224 return mExtras == null ? null : mExtras.getParcelableArray(name);
5225 }
5226
5227 /**
5228 * Retrieve extended data from the intent.
5229 *
5230 * @param name The name of the desired item.
5231 *
5232 * @return the value of an item that previously added with putExtra()
5233 * or null if no ArrayList<Parcelable> value was found.
5234 *
5235 * @see #putParcelableArrayListExtra(String, ArrayList)
5236 */
5237 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5238 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5239 }
5240
5241 /**
5242 * Retrieve extended data from the intent.
5243 *
5244 * @param name The name of the desired item.
5245 *
5246 * @return the value of an item that previously added with putExtra()
5247 * or null if no Serializable value was found.
5248 *
5249 * @see #putExtra(String, Serializable)
5250 */
5251 public Serializable getSerializableExtra(String name) {
5252 return mExtras == null ? null : mExtras.getSerializable(name);
5253 }
5254
5255 /**
5256 * Retrieve extended data from the intent.
5257 *
5258 * @param name The name of the desired item.
5259 *
5260 * @return the value of an item that previously added with putExtra()
5261 * or null if no ArrayList<Integer> value was found.
5262 *
5263 * @see #putIntegerArrayListExtra(String, ArrayList)
5264 */
5265 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5266 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5267 }
5268
5269 /**
5270 * Retrieve extended data from the intent.
5271 *
5272 * @param name The name of the desired item.
5273 *
5274 * @return the value of an item that previously added with putExtra()
5275 * or null if no ArrayList<String> value was found.
5276 *
5277 * @see #putStringArrayListExtra(String, ArrayList)
5278 */
5279 public ArrayList<String> getStringArrayListExtra(String name) {
5280 return mExtras == null ? null : mExtras.getStringArrayList(name);
5281 }
5282
5283 /**
5284 * Retrieve extended data from the intent.
5285 *
5286 * @param name The name of the desired item.
5287 *
5288 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005289 * or null if no ArrayList<CharSequence> value was found.
5290 *
5291 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5292 */
5293 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5294 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5295 }
5296
5297 /**
5298 * Retrieve extended data from the intent.
5299 *
5300 * @param name The name of the desired item.
5301 *
5302 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005303 * or null if no boolean array value was found.
5304 *
5305 * @see #putExtra(String, boolean[])
5306 */
5307 public boolean[] getBooleanArrayExtra(String name) {
5308 return mExtras == null ? null : mExtras.getBooleanArray(name);
5309 }
5310
5311 /**
5312 * Retrieve extended data from the intent.
5313 *
5314 * @param name The name of the desired item.
5315 *
5316 * @return the value of an item that previously added with putExtra()
5317 * or null if no byte array value was found.
5318 *
5319 * @see #putExtra(String, byte[])
5320 */
5321 public byte[] getByteArrayExtra(String name) {
5322 return mExtras == null ? null : mExtras.getByteArray(name);
5323 }
5324
5325 /**
5326 * Retrieve extended data from the intent.
5327 *
5328 * @param name The name of the desired item.
5329 *
5330 * @return the value of an item that previously added with putExtra()
5331 * or null if no short array value was found.
5332 *
5333 * @see #putExtra(String, short[])
5334 */
5335 public short[] getShortArrayExtra(String name) {
5336 return mExtras == null ? null : mExtras.getShortArray(name);
5337 }
5338
5339 /**
5340 * Retrieve extended data from the intent.
5341 *
5342 * @param name The name of the desired item.
5343 *
5344 * @return the value of an item that previously added with putExtra()
5345 * or null if no char array value was found.
5346 *
5347 * @see #putExtra(String, char[])
5348 */
5349 public char[] getCharArrayExtra(String name) {
5350 return mExtras == null ? null : mExtras.getCharArray(name);
5351 }
5352
5353 /**
5354 * Retrieve extended data from the intent.
5355 *
5356 * @param name The name of the desired item.
5357 *
5358 * @return the value of an item that previously added with putExtra()
5359 * or null if no int array value was found.
5360 *
5361 * @see #putExtra(String, int[])
5362 */
5363 public int[] getIntArrayExtra(String name) {
5364 return mExtras == null ? null : mExtras.getIntArray(name);
5365 }
5366
5367 /**
5368 * Retrieve extended data from the intent.
5369 *
5370 * @param name The name of the desired item.
5371 *
5372 * @return the value of an item that previously added with putExtra()
5373 * or null if no long array value was found.
5374 *
5375 * @see #putExtra(String, long[])
5376 */
5377 public long[] getLongArrayExtra(String name) {
5378 return mExtras == null ? null : mExtras.getLongArray(name);
5379 }
5380
5381 /**
5382 * Retrieve extended data from the intent.
5383 *
5384 * @param name The name of the desired item.
5385 *
5386 * @return the value of an item that previously added with putExtra()
5387 * or null if no float array value was found.
5388 *
5389 * @see #putExtra(String, float[])
5390 */
5391 public float[] getFloatArrayExtra(String name) {
5392 return mExtras == null ? null : mExtras.getFloatArray(name);
5393 }
5394
5395 /**
5396 * Retrieve extended data from the intent.
5397 *
5398 * @param name The name of the desired item.
5399 *
5400 * @return the value of an item that previously added with putExtra()
5401 * or null if no double array value was found.
5402 *
5403 * @see #putExtra(String, double[])
5404 */
5405 public double[] getDoubleArrayExtra(String name) {
5406 return mExtras == null ? null : mExtras.getDoubleArray(name);
5407 }
5408
5409 /**
5410 * Retrieve extended data from the intent.
5411 *
5412 * @param name The name of the desired item.
5413 *
5414 * @return the value of an item that previously added with putExtra()
5415 * or null if no String array value was found.
5416 *
5417 * @see #putExtra(String, String[])
5418 */
5419 public String[] getStringArrayExtra(String name) {
5420 return mExtras == null ? null : mExtras.getStringArray(name);
5421 }
5422
5423 /**
5424 * Retrieve extended data from the intent.
5425 *
5426 * @param name The name of the desired item.
5427 *
5428 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005429 * or null if no CharSequence array value was found.
5430 *
5431 * @see #putExtra(String, CharSequence[])
5432 */
5433 public CharSequence[] getCharSequenceArrayExtra(String name) {
5434 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5435 }
5436
5437 /**
5438 * Retrieve extended data from the intent.
5439 *
5440 * @param name The name of the desired item.
5441 *
5442 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005443 * or null if no Bundle value was found.
5444 *
5445 * @see #putExtra(String, Bundle)
5446 */
5447 public Bundle getBundleExtra(String name) {
5448 return mExtras == null ? null : mExtras.getBundle(name);
5449 }
5450
5451 /**
5452 * Retrieve extended data from the intent.
5453 *
5454 * @param name The name of the desired item.
5455 *
5456 * @return the value of an item that previously added with putExtra()
5457 * or null if no IBinder value was found.
5458 *
5459 * @see #putExtra(String, IBinder)
5460 *
5461 * @deprecated
5462 * @hide
5463 */
5464 @Deprecated
5465 public IBinder getIBinderExtra(String name) {
5466 return mExtras == null ? null : mExtras.getIBinder(name);
5467 }
5468
5469 /**
5470 * Retrieve extended data from the intent.
5471 *
5472 * @param name The name of the desired item.
5473 * @param defaultValue The default value to return in case no item is
5474 * associated with the key 'name'
5475 *
5476 * @return the value of an item that previously added with putExtra()
5477 * or defaultValue if none was found.
5478 *
5479 * @see #putExtra
5480 *
5481 * @deprecated
5482 * @hide
5483 */
5484 @Deprecated
5485 public Object getExtra(String name, Object defaultValue) {
5486 Object result = defaultValue;
5487 if (mExtras != null) {
5488 Object result2 = mExtras.get(name);
5489 if (result2 != null) {
5490 result = result2;
5491 }
5492 }
5493
5494 return result;
5495 }
5496
5497 /**
5498 * Retrieves a map of extended data from the intent.
5499 *
5500 * @return the map of all extras previously added with putExtra(),
5501 * or null if none have been added.
5502 */
5503 public Bundle getExtras() {
5504 return (mExtras != null)
5505 ? new Bundle(mExtras)
5506 : null;
5507 }
5508
5509 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005510 * Filter extras to only basic types.
5511 * @hide
5512 */
5513 public void removeUnsafeExtras() {
5514 if (mExtras != null) {
5515 mExtras.filterValues();
5516 }
5517 }
5518
5519 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005520 * Retrieve any special flags associated with this intent. You will
5521 * normally just set them with {@link #setFlags} and let the system
5522 * take the appropriate action with them.
5523 *
5524 * @return int The currently set flags.
5525 *
5526 * @see #setFlags
5527 */
5528 public int getFlags() {
5529 return mFlags;
5530 }
5531
Dianne Hackborne7f97212011-02-24 14:40:20 -08005532 /** @hide */
5533 public boolean isExcludingStopped() {
5534 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5535 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5536 }
5537
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005538 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005539 * Retrieve the application package name this Intent is limited to. When
5540 * resolving an Intent, if non-null this limits the resolution to only
5541 * components in the given application package.
5542 *
5543 * @return The name of the application package for the Intent.
5544 *
5545 * @see #resolveActivity
5546 * @see #setPackage
5547 */
5548 public String getPackage() {
5549 return mPackage;
5550 }
5551
5552 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005553 * Retrieve the concrete component associated with the intent. When receiving
5554 * an intent, this is the component that was found to best handle it (that is,
5555 * yourself) and will always be non-null; in all other cases it will be
5556 * null unless explicitly set.
5557 *
5558 * @return The name of the application component to handle the intent.
5559 *
5560 * @see #resolveActivity
5561 * @see #setComponent
5562 */
5563 public ComponentName getComponent() {
5564 return mComponent;
5565 }
5566
5567 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005568 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5569 * used as a hint to the receiver for animations and the like. Null means that there
5570 * is no source bounds.
5571 */
5572 public Rect getSourceBounds() {
5573 return mSourceBounds;
5574 }
5575
5576 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005577 * Return the Activity component that should be used to handle this intent.
5578 * The appropriate component is determined based on the information in the
5579 * intent, evaluated as follows:
5580 *
5581 * <p>If {@link #getComponent} returns an explicit class, that is returned
5582 * without any further consideration.
5583 *
5584 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5585 * category to be considered.
5586 *
5587 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5588 * action.
5589 *
5590 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5591 * this type.
5592 *
5593 * <p>If {@link #addCategory} has added any categories, the activity must
5594 * handle ALL of the categories specified.
5595 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005596 * <p>If {@link #getPackage} is non-NULL, only activity components in
5597 * that application package will be considered.
5598 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005599 * <p>If there are no activities that satisfy all of these conditions, a
5600 * null string is returned.
5601 *
5602 * <p>If multiple activities are found to satisfy the intent, the one with
5603 * the highest priority will be used. If there are multiple activities
5604 * with the same priority, the system will either pick the best activity
5605 * based on user preference, or resolve to a system class that will allow
5606 * the user to pick an activity and forward from there.
5607 *
5608 * <p>This method is implemented simply by calling
5609 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5610 * true.</p>
5611 * <p> This API is called for you as part of starting an activity from an
5612 * intent. You do not normally need to call it yourself.</p>
5613 *
5614 * @param pm The package manager with which to resolve the Intent.
5615 *
5616 * @return Name of the component implementing an activity that can
5617 * display the intent.
5618 *
5619 * @see #setComponent
5620 * @see #getComponent
5621 * @see #resolveActivityInfo
5622 */
5623 public ComponentName resolveActivity(PackageManager pm) {
5624 if (mComponent != null) {
5625 return mComponent;
5626 }
5627
5628 ResolveInfo info = pm.resolveActivity(
5629 this, PackageManager.MATCH_DEFAULT_ONLY);
5630 if (info != null) {
5631 return new ComponentName(
5632 info.activityInfo.applicationInfo.packageName,
5633 info.activityInfo.name);
5634 }
5635
5636 return null;
5637 }
5638
5639 /**
5640 * Resolve the Intent into an {@link ActivityInfo}
5641 * describing the activity that should execute the intent. Resolution
5642 * follows the same rules as described for {@link #resolveActivity}, but
5643 * you get back the completely information about the resolved activity
5644 * instead of just its class name.
5645 *
5646 * @param pm The package manager with which to resolve the Intent.
5647 * @param flags Addition information to retrieve as per
5648 * {@link PackageManager#getActivityInfo(ComponentName, int)
5649 * PackageManager.getActivityInfo()}.
5650 *
5651 * @return PackageManager.ActivityInfo
5652 *
5653 * @see #resolveActivity
5654 */
5655 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5656 ActivityInfo ai = null;
5657 if (mComponent != null) {
5658 try {
5659 ai = pm.getActivityInfo(mComponent, flags);
5660 } catch (PackageManager.NameNotFoundException e) {
5661 // ignore
5662 }
5663 } else {
5664 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005665 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005666 if (info != null) {
5667 ai = info.activityInfo;
5668 }
5669 }
5670
5671 return ai;
5672 }
5673
5674 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005675 * Special function for use by the system to resolve service
5676 * intents to system apps. Throws an exception if there are
5677 * multiple potential matches to the Intent. Returns null if
5678 * there are no matches.
5679 * @hide
5680 */
5681 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5682 if (mComponent != null) {
5683 return mComponent;
5684 }
5685
5686 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5687 if (results == null) {
5688 return null;
5689 }
5690 ComponentName comp = null;
5691 for (int i=0; i<results.size(); i++) {
5692 ResolveInfo ri = results.get(i);
5693 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5694 continue;
5695 }
5696 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5697 ri.serviceInfo.name);
5698 if (comp != null) {
5699 throw new IllegalStateException("Multiple system services handle " + this
5700 + ": " + comp + ", " + foundComp);
5701 }
5702 comp = foundComp;
5703 }
5704 return comp;
5705 }
5706
5707 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005708 * Set the general action to be performed.
5709 *
5710 * @param action An action name, such as ACTION_VIEW. Application-specific
5711 * actions should be prefixed with the vendor's package name.
5712 *
5713 * @return Returns the same Intent object, for chaining multiple calls
5714 * into a single statement.
5715 *
5716 * @see #getAction
5717 */
5718 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005719 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005720 return this;
5721 }
5722
5723 /**
5724 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005725 * clears any type that was previously set by {@link #setType} or
5726 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005727 *
Nick Pellyccae4122012-01-09 14:12:58 -08005728 * <p><em>Note: scheme matching in the Android framework is
5729 * case-sensitive, unlike the formal RFC. As a result,
5730 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005731 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005732 * {@link #setDataAndNormalize}
5733 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005734 *
Nick Pellyccae4122012-01-09 14:12:58 -08005735 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005736 *
5737 * @return Returns the same Intent object, for chaining multiple calls
5738 * into a single statement.
5739 *
5740 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005741 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005742 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005743 */
5744 public Intent setData(Uri data) {
5745 mData = data;
5746 mType = null;
5747 return this;
5748 }
5749
5750 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005751 * Normalize and set the data this intent is operating on.
5752 *
5753 * <p>This method automatically clears any type that was
5754 * previously set (for example, by {@link #setType}).
5755 *
5756 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005757 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005758 * so really this is just a convenience method for
5759 * <pre>
5760 * setData(data.normalize())
5761 * </pre>
5762 *
5763 * @param data The Uri of the data this intent is now targeting.
5764 *
5765 * @return Returns the same Intent object, for chaining multiple calls
5766 * into a single statement.
5767 *
5768 * @see #getData
5769 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005770 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005771 */
5772 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005773 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005774 }
5775
5776 /**
5777 * Set an explicit MIME data type.
5778 *
5779 * <p>This is used to create intents that only specify a type and not data,
5780 * for example to indicate the type of data to return.
5781 *
5782 * <p>This method automatically clears any data that was
5783 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005784 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005785 * <p><em>Note: MIME type matching in the Android framework is
5786 * case-sensitive, unlike formal RFC MIME types. As a result,
5787 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005788 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5789 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005790 *
5791 * @param type The MIME type of the data being handled by this intent.
5792 *
5793 * @return Returns the same Intent object, for chaining multiple calls
5794 * into a single statement.
5795 *
5796 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005797 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005798 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005799 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005800 */
5801 public Intent setType(String type) {
5802 mData = null;
5803 mType = type;
5804 return this;
5805 }
5806
5807 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005808 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005809 *
Nick Pellyccae4122012-01-09 14:12:58 -08005810 * <p>This is used to create intents that only specify a type and not data,
5811 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005812 *
Nick Pellyccae4122012-01-09 14:12:58 -08005813 * <p>This method automatically clears any data that was
5814 * previously set (for example by {@link #setData}).
5815 *
5816 * <p>The MIME type is normalized using
5817 * {@link #normalizeMimeType} before it is set,
5818 * so really this is just a convenience method for
5819 * <pre>
5820 * setType(Intent.normalizeMimeType(type))
5821 * </pre>
5822 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005823 * @param type The MIME type of the data being handled by this intent.
5824 *
5825 * @return Returns the same Intent object, for chaining multiple calls
5826 * into a single statement.
5827 *
Nick Pellyccae4122012-01-09 14:12:58 -08005828 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005829 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005830 * @see #normalizeMimeType
5831 */
5832 public Intent setTypeAndNormalize(String type) {
5833 return setType(normalizeMimeType(type));
5834 }
5835
5836 /**
5837 * (Usually optional) Set the data for the intent along with an explicit
5838 * MIME data type. This method should very rarely be used -- it allows you
5839 * to override the MIME type that would ordinarily be inferred from the
5840 * data with your own type given here.
5841 *
5842 * <p><em>Note: MIME type and Uri scheme matching in the
5843 * Android framework is case-sensitive, unlike the formal RFC definitions.
5844 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005845 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005846 * {@link #setDataAndTypeAndNormalize}
5847 * to ensure that they are converted to lower case.</em>
5848 *
5849 * @param data The Uri of the data this intent is now targeting.
5850 * @param type The MIME type of the data being handled by this intent.
5851 *
5852 * @return Returns the same Intent object, for chaining multiple calls
5853 * into a single statement.
5854 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005855 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08005856 * @see #setData
5857 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005858 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005859 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005860 */
5861 public Intent setDataAndType(Uri data, String type) {
5862 mData = data;
5863 mType = type;
5864 return this;
5865 }
5866
5867 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005868 * (Usually optional) Normalize and set both the data Uri and an explicit
5869 * MIME data type. This method should very rarely be used -- it allows you
5870 * to override the MIME type that would ordinarily be inferred from the
5871 * data with your own type given here.
5872 *
5873 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005874 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08005875 * before they are set, so really this is just a convenience method for
5876 * <pre>
5877 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
5878 * </pre>
5879 *
5880 * @param data The Uri of the data this intent is now targeting.
5881 * @param type The MIME type of the data being handled by this intent.
5882 *
5883 * @return Returns the same Intent object, for chaining multiple calls
5884 * into a single statement.
5885 *
5886 * @see #setType
5887 * @see #setData
5888 * @see #setDataAndType
5889 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005890 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005891 */
5892 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005893 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08005894 }
5895
5896 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005897 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005898 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005899 * activities that provide <em>all</em> of the requested categories will be
5900 * used.
5901 *
5902 * @param category The desired category. This can be either one of the
5903 * predefined Intent categories, or a custom category in your own
5904 * namespace.
5905 *
5906 * @return Returns the same Intent object, for chaining multiple calls
5907 * into a single statement.
5908 *
5909 * @see #hasCategory
5910 * @see #removeCategory
5911 */
5912 public Intent addCategory(String category) {
5913 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005914 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005915 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08005916 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005917 return this;
5918 }
5919
5920 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005921 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005922 *
5923 * @param category The category to remove.
5924 *
5925 * @see #addCategory
5926 */
5927 public void removeCategory(String category) {
5928 if (mCategories != null) {
5929 mCategories.remove(category);
5930 if (mCategories.size() == 0) {
5931 mCategories = null;
5932 }
5933 }
5934 }
5935
5936 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005937 * Set a selector for this Intent. This is a modification to the kinds of
5938 * things the Intent will match. If the selector is set, it will be used
5939 * when trying to find entities that can handle the Intent, instead of the
5940 * main contents of the Intent. This allows you build an Intent containing
5941 * a generic protocol while targeting it more specifically.
5942 *
5943 * <p>An example of where this may be used is with things like
5944 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
5945 * Intent that will launch the Browser application. However, the correct
5946 * main entry point of an application is actually {@link #ACTION_MAIN}
5947 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
5948 * used to specify the actual Activity to launch. If you launch the browser
5949 * with something different, undesired behavior may happen if the user has
5950 * previously or later launches it the normal way, since they do not match.
5951 * Instead, you can build an Intent with the MAIN action (but no ComponentName
5952 * yet specified) and set a selector with {@link #ACTION_MAIN} and
5953 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
5954 *
5955 * <p>Setting a selector does not impact the behavior of
5956 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
5957 * desired behavior of a selector -- it does not impact the base meaning
5958 * of the Intent, just what kinds of things will be matched against it
5959 * when determining who can handle it.</p>
5960 *
5961 * <p>You can not use both a selector and {@link #setPackage(String)} on
5962 * the same base Intent.</p>
5963 *
5964 * @param selector The desired selector Intent; set to null to not use
5965 * a special selector.
5966 */
5967 public void setSelector(Intent selector) {
5968 if (selector == this) {
5969 throw new IllegalArgumentException(
5970 "Intent being set as a selector of itself");
5971 }
5972 if (selector != null && mPackage != null) {
5973 throw new IllegalArgumentException(
5974 "Can't set selector when package name is already set");
5975 }
5976 mSelector = selector;
5977 }
5978
5979 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005980 * Set a {@link ClipData} associated with this Intent. This replaces any
5981 * previously set ClipData.
5982 *
5983 * <p>The ClipData in an intent is not used for Intent matching or other
5984 * such operations. Semantically it is like extras, used to transmit
5985 * additional data with the Intent. The main feature of using this over
5986 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
5987 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
5988 * items included in the clip data. This is useful, in particular, if
5989 * you want to transmit an Intent containing multiple <code>content:</code>
5990 * URIs for which the recipient may not have global permission to access the
5991 * content provider.
5992 *
5993 * <p>If the ClipData contains items that are themselves Intents, any
5994 * grant flags in those Intents will be ignored. Only the top-level flags
5995 * of the main Intent are respected, and will be applied to all Uri or
5996 * Intent items in the clip (or sub-items of the clip).
5997 *
5998 * <p>The MIME type, label, and icon in the ClipData object are not
5999 * directly used by Intent. Applications should generally rely on the
6000 * MIME type of the Intent itself, not what it may find in the ClipData.
6001 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006002 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006003 *
6004 * @param clip The new clip to set. May be null to clear the current clip.
6005 */
6006 public void setClipData(ClipData clip) {
6007 mClipData = clip;
6008 }
6009
6010 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006011 * This is NOT a secure mechanism to identify the user who sent the intent.
6012 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6013 * who sent the intent.
6014 * @hide
6015 */
6016 public void setContentUserHint(int contentUserHint) {
6017 mContentUserHint = contentUserHint;
6018 }
6019
6020 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006021 * Add extended data to the intent. The name must include a package
6022 * prefix, for example the app com.android.contacts would use names
6023 * like "com.android.contacts.ShowAll".
6024 *
6025 * @param name The name of the extra data, with package prefix.
6026 * @param value The boolean data value.
6027 *
6028 * @return Returns the same Intent object, for chaining multiple calls
6029 * into a single statement.
6030 *
6031 * @see #putExtras
6032 * @see #removeExtra
6033 * @see #getBooleanExtra(String, boolean)
6034 */
6035 public Intent putExtra(String name, boolean value) {
6036 if (mExtras == null) {
6037 mExtras = new Bundle();
6038 }
6039 mExtras.putBoolean(name, value);
6040 return this;
6041 }
6042
6043 /**
6044 * Add extended data to the intent. The name must include a package
6045 * prefix, for example the app com.android.contacts would use names
6046 * like "com.android.contacts.ShowAll".
6047 *
6048 * @param name The name of the extra data, with package prefix.
6049 * @param value The byte data value.
6050 *
6051 * @return Returns the same Intent object, for chaining multiple calls
6052 * into a single statement.
6053 *
6054 * @see #putExtras
6055 * @see #removeExtra
6056 * @see #getByteExtra(String, byte)
6057 */
6058 public Intent putExtra(String name, byte value) {
6059 if (mExtras == null) {
6060 mExtras = new Bundle();
6061 }
6062 mExtras.putByte(name, value);
6063 return this;
6064 }
6065
6066 /**
6067 * Add extended data to the intent. The name must include a package
6068 * prefix, for example the app com.android.contacts would use names
6069 * like "com.android.contacts.ShowAll".
6070 *
6071 * @param name The name of the extra data, with package prefix.
6072 * @param value The char data value.
6073 *
6074 * @return Returns the same Intent object, for chaining multiple calls
6075 * into a single statement.
6076 *
6077 * @see #putExtras
6078 * @see #removeExtra
6079 * @see #getCharExtra(String, char)
6080 */
6081 public Intent putExtra(String name, char value) {
6082 if (mExtras == null) {
6083 mExtras = new Bundle();
6084 }
6085 mExtras.putChar(name, value);
6086 return this;
6087 }
6088
6089 /**
6090 * Add extended data to the intent. The name must include a package
6091 * prefix, for example the app com.android.contacts would use names
6092 * like "com.android.contacts.ShowAll".
6093 *
6094 * @param name The name of the extra data, with package prefix.
6095 * @param value The short data value.
6096 *
6097 * @return Returns the same Intent object, for chaining multiple calls
6098 * into a single statement.
6099 *
6100 * @see #putExtras
6101 * @see #removeExtra
6102 * @see #getShortExtra(String, short)
6103 */
6104 public Intent putExtra(String name, short value) {
6105 if (mExtras == null) {
6106 mExtras = new Bundle();
6107 }
6108 mExtras.putShort(name, value);
6109 return this;
6110 }
6111
6112 /**
6113 * Add extended data to the intent. The name must include a package
6114 * prefix, for example the app com.android.contacts would use names
6115 * like "com.android.contacts.ShowAll".
6116 *
6117 * @param name The name of the extra data, with package prefix.
6118 * @param value The integer data value.
6119 *
6120 * @return Returns the same Intent object, for chaining multiple calls
6121 * into a single statement.
6122 *
6123 * @see #putExtras
6124 * @see #removeExtra
6125 * @see #getIntExtra(String, int)
6126 */
6127 public Intent putExtra(String name, int value) {
6128 if (mExtras == null) {
6129 mExtras = new Bundle();
6130 }
6131 mExtras.putInt(name, value);
6132 return this;
6133 }
6134
6135 /**
6136 * Add extended data to the intent. The name must include a package
6137 * prefix, for example the app com.android.contacts would use names
6138 * like "com.android.contacts.ShowAll".
6139 *
6140 * @param name The name of the extra data, with package prefix.
6141 * @param value The long data value.
6142 *
6143 * @return Returns the same Intent object, for chaining multiple calls
6144 * into a single statement.
6145 *
6146 * @see #putExtras
6147 * @see #removeExtra
6148 * @see #getLongExtra(String, long)
6149 */
6150 public Intent putExtra(String name, long value) {
6151 if (mExtras == null) {
6152 mExtras = new Bundle();
6153 }
6154 mExtras.putLong(name, value);
6155 return this;
6156 }
6157
6158 /**
6159 * Add extended data to the intent. The name must include a package
6160 * prefix, for example the app com.android.contacts would use names
6161 * like "com.android.contacts.ShowAll".
6162 *
6163 * @param name The name of the extra data, with package prefix.
6164 * @param value The float data value.
6165 *
6166 * @return Returns the same Intent object, for chaining multiple calls
6167 * into a single statement.
6168 *
6169 * @see #putExtras
6170 * @see #removeExtra
6171 * @see #getFloatExtra(String, float)
6172 */
6173 public Intent putExtra(String name, float value) {
6174 if (mExtras == null) {
6175 mExtras = new Bundle();
6176 }
6177 mExtras.putFloat(name, value);
6178 return this;
6179 }
6180
6181 /**
6182 * Add extended data to the intent. The name must include a package
6183 * prefix, for example the app com.android.contacts would use names
6184 * like "com.android.contacts.ShowAll".
6185 *
6186 * @param name The name of the extra data, with package prefix.
6187 * @param value The double data value.
6188 *
6189 * @return Returns the same Intent object, for chaining multiple calls
6190 * into a single statement.
6191 *
6192 * @see #putExtras
6193 * @see #removeExtra
6194 * @see #getDoubleExtra(String, double)
6195 */
6196 public Intent putExtra(String name, double value) {
6197 if (mExtras == null) {
6198 mExtras = new Bundle();
6199 }
6200 mExtras.putDouble(name, value);
6201 return this;
6202 }
6203
6204 /**
6205 * Add extended data to the intent. The name must include a package
6206 * prefix, for example the app com.android.contacts would use names
6207 * like "com.android.contacts.ShowAll".
6208 *
6209 * @param name The name of the extra data, with package prefix.
6210 * @param value The String data value.
6211 *
6212 * @return Returns the same Intent object, for chaining multiple calls
6213 * into a single statement.
6214 *
6215 * @see #putExtras
6216 * @see #removeExtra
6217 * @see #getStringExtra(String)
6218 */
6219 public Intent putExtra(String name, String value) {
6220 if (mExtras == null) {
6221 mExtras = new Bundle();
6222 }
6223 mExtras.putString(name, value);
6224 return this;
6225 }
6226
6227 /**
6228 * Add extended data to the intent. The name must include a package
6229 * prefix, for example the app com.android.contacts would use names
6230 * like "com.android.contacts.ShowAll".
6231 *
6232 * @param name The name of the extra data, with package prefix.
6233 * @param value The CharSequence data value.
6234 *
6235 * @return Returns the same Intent object, for chaining multiple calls
6236 * into a single statement.
6237 *
6238 * @see #putExtras
6239 * @see #removeExtra
6240 * @see #getCharSequenceExtra(String)
6241 */
6242 public Intent putExtra(String name, CharSequence value) {
6243 if (mExtras == null) {
6244 mExtras = new Bundle();
6245 }
6246 mExtras.putCharSequence(name, value);
6247 return this;
6248 }
6249
6250 /**
6251 * Add extended data to the intent. The name must include a package
6252 * prefix, for example the app com.android.contacts would use names
6253 * like "com.android.contacts.ShowAll".
6254 *
6255 * @param name The name of the extra data, with package prefix.
6256 * @param value The Parcelable data value.
6257 *
6258 * @return Returns the same Intent object, for chaining multiple calls
6259 * into a single statement.
6260 *
6261 * @see #putExtras
6262 * @see #removeExtra
6263 * @see #getParcelableExtra(String)
6264 */
6265 public Intent putExtra(String name, Parcelable value) {
6266 if (mExtras == null) {
6267 mExtras = new Bundle();
6268 }
6269 mExtras.putParcelable(name, value);
6270 return this;
6271 }
6272
6273 /**
6274 * Add extended data to the intent. The name must include a package
6275 * prefix, for example the app com.android.contacts would use names
6276 * like "com.android.contacts.ShowAll".
6277 *
6278 * @param name The name of the extra data, with package prefix.
6279 * @param value The Parcelable[] data value.
6280 *
6281 * @return Returns the same Intent object, for chaining multiple calls
6282 * into a single statement.
6283 *
6284 * @see #putExtras
6285 * @see #removeExtra
6286 * @see #getParcelableArrayExtra(String)
6287 */
6288 public Intent putExtra(String name, Parcelable[] value) {
6289 if (mExtras == null) {
6290 mExtras = new Bundle();
6291 }
6292 mExtras.putParcelableArray(name, value);
6293 return this;
6294 }
6295
6296 /**
6297 * Add extended data to the intent. The name must include a package
6298 * prefix, for example the app com.android.contacts would use names
6299 * like "com.android.contacts.ShowAll".
6300 *
6301 * @param name The name of the extra data, with package prefix.
6302 * @param value The ArrayList<Parcelable> data value.
6303 *
6304 * @return Returns the same Intent object, for chaining multiple calls
6305 * into a single statement.
6306 *
6307 * @see #putExtras
6308 * @see #removeExtra
6309 * @see #getParcelableArrayListExtra(String)
6310 */
6311 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6312 if (mExtras == null) {
6313 mExtras = new Bundle();
6314 }
6315 mExtras.putParcelableArrayList(name, value);
6316 return this;
6317 }
6318
6319 /**
6320 * Add extended data to the intent. The name must include a package
6321 * prefix, for example the app com.android.contacts would use names
6322 * like "com.android.contacts.ShowAll".
6323 *
6324 * @param name The name of the extra data, with package prefix.
6325 * @param value The ArrayList<Integer> data value.
6326 *
6327 * @return Returns the same Intent object, for chaining multiple calls
6328 * into a single statement.
6329 *
6330 * @see #putExtras
6331 * @see #removeExtra
6332 * @see #getIntegerArrayListExtra(String)
6333 */
6334 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6335 if (mExtras == null) {
6336 mExtras = new Bundle();
6337 }
6338 mExtras.putIntegerArrayList(name, value);
6339 return this;
6340 }
6341
6342 /**
6343 * Add extended data to the intent. The name must include a package
6344 * prefix, for example the app com.android.contacts would use names
6345 * like "com.android.contacts.ShowAll".
6346 *
6347 * @param name The name of the extra data, with package prefix.
6348 * @param value The ArrayList<String> data value.
6349 *
6350 * @return Returns the same Intent object, for chaining multiple calls
6351 * into a single statement.
6352 *
6353 * @see #putExtras
6354 * @see #removeExtra
6355 * @see #getStringArrayListExtra(String)
6356 */
6357 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6358 if (mExtras == null) {
6359 mExtras = new Bundle();
6360 }
6361 mExtras.putStringArrayList(name, value);
6362 return this;
6363 }
6364
6365 /**
6366 * Add extended data to the intent. The name must include a package
6367 * prefix, for example the app com.android.contacts would use names
6368 * like "com.android.contacts.ShowAll".
6369 *
6370 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006371 * @param value The ArrayList<CharSequence> data value.
6372 *
6373 * @return Returns the same Intent object, for chaining multiple calls
6374 * into a single statement.
6375 *
6376 * @see #putExtras
6377 * @see #removeExtra
6378 * @see #getCharSequenceArrayListExtra(String)
6379 */
6380 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6381 if (mExtras == null) {
6382 mExtras = new Bundle();
6383 }
6384 mExtras.putCharSequenceArrayList(name, value);
6385 return this;
6386 }
6387
6388 /**
6389 * Add extended data to the intent. The name must include a package
6390 * prefix, for example the app com.android.contacts would use names
6391 * like "com.android.contacts.ShowAll".
6392 *
6393 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006394 * @param value The Serializable data value.
6395 *
6396 * @return Returns the same Intent object, for chaining multiple calls
6397 * into a single statement.
6398 *
6399 * @see #putExtras
6400 * @see #removeExtra
6401 * @see #getSerializableExtra(String)
6402 */
6403 public Intent putExtra(String name, Serializable value) {
6404 if (mExtras == null) {
6405 mExtras = new Bundle();
6406 }
6407 mExtras.putSerializable(name, value);
6408 return this;
6409 }
6410
6411 /**
6412 * Add extended data to the intent. The name must include a package
6413 * prefix, for example the app com.android.contacts would use names
6414 * like "com.android.contacts.ShowAll".
6415 *
6416 * @param name The name of the extra data, with package prefix.
6417 * @param value The boolean array data value.
6418 *
6419 * @return Returns the same Intent object, for chaining multiple calls
6420 * into a single statement.
6421 *
6422 * @see #putExtras
6423 * @see #removeExtra
6424 * @see #getBooleanArrayExtra(String)
6425 */
6426 public Intent putExtra(String name, boolean[] value) {
6427 if (mExtras == null) {
6428 mExtras = new Bundle();
6429 }
6430 mExtras.putBooleanArray(name, value);
6431 return this;
6432 }
6433
6434 /**
6435 * Add extended data to the intent. The name must include a package
6436 * prefix, for example the app com.android.contacts would use names
6437 * like "com.android.contacts.ShowAll".
6438 *
6439 * @param name The name of the extra data, with package prefix.
6440 * @param value The byte array data value.
6441 *
6442 * @return Returns the same Intent object, for chaining multiple calls
6443 * into a single statement.
6444 *
6445 * @see #putExtras
6446 * @see #removeExtra
6447 * @see #getByteArrayExtra(String)
6448 */
6449 public Intent putExtra(String name, byte[] value) {
6450 if (mExtras == null) {
6451 mExtras = new Bundle();
6452 }
6453 mExtras.putByteArray(name, value);
6454 return this;
6455 }
6456
6457 /**
6458 * Add extended data to the intent. The name must include a package
6459 * prefix, for example the app com.android.contacts would use names
6460 * like "com.android.contacts.ShowAll".
6461 *
6462 * @param name The name of the extra data, with package prefix.
6463 * @param value The short array data value.
6464 *
6465 * @return Returns the same Intent object, for chaining multiple calls
6466 * into a single statement.
6467 *
6468 * @see #putExtras
6469 * @see #removeExtra
6470 * @see #getShortArrayExtra(String)
6471 */
6472 public Intent putExtra(String name, short[] value) {
6473 if (mExtras == null) {
6474 mExtras = new Bundle();
6475 }
6476 mExtras.putShortArray(name, value);
6477 return this;
6478 }
6479
6480 /**
6481 * Add extended data to the intent. The name must include a package
6482 * prefix, for example the app com.android.contacts would use names
6483 * like "com.android.contacts.ShowAll".
6484 *
6485 * @param name The name of the extra data, with package prefix.
6486 * @param value The char array data value.
6487 *
6488 * @return Returns the same Intent object, for chaining multiple calls
6489 * into a single statement.
6490 *
6491 * @see #putExtras
6492 * @see #removeExtra
6493 * @see #getCharArrayExtra(String)
6494 */
6495 public Intent putExtra(String name, char[] value) {
6496 if (mExtras == null) {
6497 mExtras = new Bundle();
6498 }
6499 mExtras.putCharArray(name, value);
6500 return this;
6501 }
6502
6503 /**
6504 * Add extended data to the intent. The name must include a package
6505 * prefix, for example the app com.android.contacts would use names
6506 * like "com.android.contacts.ShowAll".
6507 *
6508 * @param name The name of the extra data, with package prefix.
6509 * @param value The int array data value.
6510 *
6511 * @return Returns the same Intent object, for chaining multiple calls
6512 * into a single statement.
6513 *
6514 * @see #putExtras
6515 * @see #removeExtra
6516 * @see #getIntArrayExtra(String)
6517 */
6518 public Intent putExtra(String name, int[] value) {
6519 if (mExtras == null) {
6520 mExtras = new Bundle();
6521 }
6522 mExtras.putIntArray(name, value);
6523 return this;
6524 }
6525
6526 /**
6527 * Add extended data to the intent. The name must include a package
6528 * prefix, for example the app com.android.contacts would use names
6529 * like "com.android.contacts.ShowAll".
6530 *
6531 * @param name The name of the extra data, with package prefix.
6532 * @param value The byte array data value.
6533 *
6534 * @return Returns the same Intent object, for chaining multiple calls
6535 * into a single statement.
6536 *
6537 * @see #putExtras
6538 * @see #removeExtra
6539 * @see #getLongArrayExtra(String)
6540 */
6541 public Intent putExtra(String name, long[] value) {
6542 if (mExtras == null) {
6543 mExtras = new Bundle();
6544 }
6545 mExtras.putLongArray(name, value);
6546 return this;
6547 }
6548
6549 /**
6550 * Add extended data to the intent. The name must include a package
6551 * prefix, for example the app com.android.contacts would use names
6552 * like "com.android.contacts.ShowAll".
6553 *
6554 * @param name The name of the extra data, with package prefix.
6555 * @param value The float array data value.
6556 *
6557 * @return Returns the same Intent object, for chaining multiple calls
6558 * into a single statement.
6559 *
6560 * @see #putExtras
6561 * @see #removeExtra
6562 * @see #getFloatArrayExtra(String)
6563 */
6564 public Intent putExtra(String name, float[] value) {
6565 if (mExtras == null) {
6566 mExtras = new Bundle();
6567 }
6568 mExtras.putFloatArray(name, value);
6569 return this;
6570 }
6571
6572 /**
6573 * Add extended data to the intent. The name must include a package
6574 * prefix, for example the app com.android.contacts would use names
6575 * like "com.android.contacts.ShowAll".
6576 *
6577 * @param name The name of the extra data, with package prefix.
6578 * @param value The double array data value.
6579 *
6580 * @return Returns the same Intent object, for chaining multiple calls
6581 * into a single statement.
6582 *
6583 * @see #putExtras
6584 * @see #removeExtra
6585 * @see #getDoubleArrayExtra(String)
6586 */
6587 public Intent putExtra(String name, double[] value) {
6588 if (mExtras == null) {
6589 mExtras = new Bundle();
6590 }
6591 mExtras.putDoubleArray(name, value);
6592 return this;
6593 }
6594
6595 /**
6596 * Add extended data to the intent. The name must include a package
6597 * prefix, for example the app com.android.contacts would use names
6598 * like "com.android.contacts.ShowAll".
6599 *
6600 * @param name The name of the extra data, with package prefix.
6601 * @param value The String array data value.
6602 *
6603 * @return Returns the same Intent object, for chaining multiple calls
6604 * into a single statement.
6605 *
6606 * @see #putExtras
6607 * @see #removeExtra
6608 * @see #getStringArrayExtra(String)
6609 */
6610 public Intent putExtra(String name, String[] value) {
6611 if (mExtras == null) {
6612 mExtras = new Bundle();
6613 }
6614 mExtras.putStringArray(name, value);
6615 return this;
6616 }
6617
6618 /**
6619 * Add extended data to the intent. The name must include a package
6620 * prefix, for example the app com.android.contacts would use names
6621 * like "com.android.contacts.ShowAll".
6622 *
6623 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006624 * @param value The CharSequence array data value.
6625 *
6626 * @return Returns the same Intent object, for chaining multiple calls
6627 * into a single statement.
6628 *
6629 * @see #putExtras
6630 * @see #removeExtra
6631 * @see #getCharSequenceArrayExtra(String)
6632 */
6633 public Intent putExtra(String name, CharSequence[] value) {
6634 if (mExtras == null) {
6635 mExtras = new Bundle();
6636 }
6637 mExtras.putCharSequenceArray(name, value);
6638 return this;
6639 }
6640
6641 /**
6642 * Add extended data to the intent. The name must include a package
6643 * prefix, for example the app com.android.contacts would use names
6644 * like "com.android.contacts.ShowAll".
6645 *
6646 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006647 * @param value The Bundle data value.
6648 *
6649 * @return Returns the same Intent object, for chaining multiple calls
6650 * into a single statement.
6651 *
6652 * @see #putExtras
6653 * @see #removeExtra
6654 * @see #getBundleExtra(String)
6655 */
6656 public Intent putExtra(String name, Bundle value) {
6657 if (mExtras == null) {
6658 mExtras = new Bundle();
6659 }
6660 mExtras.putBundle(name, value);
6661 return this;
6662 }
6663
6664 /**
6665 * Add extended data to the intent. The name must include a package
6666 * prefix, for example the app com.android.contacts would use names
6667 * like "com.android.contacts.ShowAll".
6668 *
6669 * @param name The name of the extra data, with package prefix.
6670 * @param value The IBinder data value.
6671 *
6672 * @return Returns the same Intent object, for chaining multiple calls
6673 * into a single statement.
6674 *
6675 * @see #putExtras
6676 * @see #removeExtra
6677 * @see #getIBinderExtra(String)
6678 *
6679 * @deprecated
6680 * @hide
6681 */
6682 @Deprecated
6683 public Intent putExtra(String name, IBinder value) {
6684 if (mExtras == null) {
6685 mExtras = new Bundle();
6686 }
6687 mExtras.putIBinder(name, value);
6688 return this;
6689 }
6690
6691 /**
6692 * Copy all extras in 'src' in to this intent.
6693 *
6694 * @param src Contains the extras to copy.
6695 *
6696 * @see #putExtra
6697 */
6698 public Intent putExtras(Intent src) {
6699 if (src.mExtras != null) {
6700 if (mExtras == null) {
6701 mExtras = new Bundle(src.mExtras);
6702 } else {
6703 mExtras.putAll(src.mExtras);
6704 }
6705 }
6706 return this;
6707 }
6708
6709 /**
6710 * Add a set of extended data to the intent. The keys must include a package
6711 * prefix, for example the app com.android.contacts would use names
6712 * like "com.android.contacts.ShowAll".
6713 *
6714 * @param extras The Bundle of extras to add to this intent.
6715 *
6716 * @see #putExtra
6717 * @see #removeExtra
6718 */
6719 public Intent putExtras(Bundle extras) {
6720 if (mExtras == null) {
6721 mExtras = new Bundle();
6722 }
6723 mExtras.putAll(extras);
6724 return this;
6725 }
6726
6727 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006728 * Completely replace the extras in the Intent with the extras in the
6729 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006730 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006731 * @param src The exact extras contained in this Intent are copied
6732 * into the target intent, replacing any that were previously there.
6733 */
6734 public Intent replaceExtras(Intent src) {
6735 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6736 return this;
6737 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006738
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006739 /**
6740 * Completely replace the extras in the Intent with the given Bundle of
6741 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006742 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006743 * @param extras The new set of extras in the Intent, or null to erase
6744 * all extras.
6745 */
6746 public Intent replaceExtras(Bundle extras) {
6747 mExtras = extras != null ? new Bundle(extras) : null;
6748 return this;
6749 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006750
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006751 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006752 * Remove extended data from the intent.
6753 *
6754 * @see #putExtra
6755 */
6756 public void removeExtra(String name) {
6757 if (mExtras != null) {
6758 mExtras.remove(name);
6759 if (mExtras.size() == 0) {
6760 mExtras = null;
6761 }
6762 }
6763 }
6764
6765 /**
6766 * Set special flags controlling how this intent is handled. Most values
6767 * here depend on the type of component being executed by the Intent,
6768 * specifically the FLAG_ACTIVITY_* flags are all for use with
6769 * {@link Context#startActivity Context.startActivity()} and the
6770 * FLAG_RECEIVER_* flags are all for use with
6771 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6772 *
Scott Main7aee61f2011-02-08 11:25:01 -08006773 * <p>See the
6774 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6775 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006776 * the behavior of your application.
6777 *
6778 * @param flags The desired flags.
6779 *
6780 * @return Returns the same Intent object, for chaining multiple calls
6781 * into a single statement.
6782 *
6783 * @see #getFlags
6784 * @see #addFlags
6785 *
6786 * @see #FLAG_GRANT_READ_URI_PERMISSION
6787 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006788 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6789 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006790 * @see #FLAG_DEBUG_LOG_RESOLUTION
6791 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006792 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006793 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006794 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006795 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006796 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6797 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006798 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006799 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006800 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006801 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006802 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006803 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006804 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006805 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6806 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006807 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006808 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006809 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006810 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6811 */
6812 public Intent setFlags(int flags) {
6813 mFlags = flags;
6814 return this;
6815 }
6816
6817 /**
6818 * Add additional flags to the intent (or with existing flags
6819 * value).
6820 *
6821 * @param flags The new flags to set.
6822 *
6823 * @return Returns the same Intent object, for chaining multiple calls
6824 * into a single statement.
6825 *
6826 * @see #setFlags
6827 */
6828 public Intent addFlags(int flags) {
6829 mFlags |= flags;
6830 return this;
6831 }
6832
6833 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006834 * (Usually optional) Set an explicit application package name that limits
6835 * the components this Intent will resolve to. If left to the default
6836 * value of null, all components in all applications will considered.
6837 * If non-null, the Intent can only match the components in the given
6838 * application package.
6839 *
6840 * @param packageName The name of the application package to handle the
6841 * intent, or null to allow any application package.
6842 *
6843 * @return Returns the same Intent object, for chaining multiple calls
6844 * into a single statement.
6845 *
6846 * @see #getPackage
6847 * @see #resolveActivity
6848 */
6849 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006850 if (packageName != null && mSelector != null) {
6851 throw new IllegalArgumentException(
6852 "Can't set package name when selector is already set");
6853 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006854 mPackage = packageName;
6855 return this;
6856 }
6857
6858 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006859 * (Usually optional) Explicitly set the component to handle the intent.
6860 * If left with the default value of null, the system will determine the
6861 * appropriate class to use based on the other fields (action, data,
6862 * type, categories) in the Intent. If this class is defined, the
6863 * specified class will always be used regardless of the other fields. You
6864 * should only set this value when you know you absolutely want a specific
6865 * class to be used; otherwise it is better to let the system find the
6866 * appropriate class so that you will respect the installed applications
6867 * and user preferences.
6868 *
6869 * @param component The name of the application component to handle the
6870 * intent, or null to let the system find one for you.
6871 *
6872 * @return Returns the same Intent object, for chaining multiple calls
6873 * into a single statement.
6874 *
6875 * @see #setClass
6876 * @see #setClassName(Context, String)
6877 * @see #setClassName(String, String)
6878 * @see #getComponent
6879 * @see #resolveActivity
6880 */
6881 public Intent setComponent(ComponentName component) {
6882 mComponent = component;
6883 return this;
6884 }
6885
6886 /**
6887 * Convenience for calling {@link #setComponent} with an
6888 * explicit class name.
6889 *
6890 * @param packageContext A Context of the application package implementing
6891 * this class.
6892 * @param className The name of a class inside of the application package
6893 * that will be used as the component for this Intent.
6894 *
6895 * @return Returns the same Intent object, for chaining multiple calls
6896 * into a single statement.
6897 *
6898 * @see #setComponent
6899 * @see #setClass
6900 */
6901 public Intent setClassName(Context packageContext, String className) {
6902 mComponent = new ComponentName(packageContext, className);
6903 return this;
6904 }
6905
6906 /**
6907 * Convenience for calling {@link #setComponent} with an
6908 * explicit application package name and class name.
6909 *
6910 * @param packageName The name of the package implementing the desired
6911 * component.
6912 * @param className The name of a class inside of the application package
6913 * that will be used as the component for this Intent.
6914 *
6915 * @return Returns the same Intent object, for chaining multiple calls
6916 * into a single statement.
6917 *
6918 * @see #setComponent
6919 * @see #setClass
6920 */
6921 public Intent setClassName(String packageName, String className) {
6922 mComponent = new ComponentName(packageName, className);
6923 return this;
6924 }
6925
6926 /**
6927 * Convenience for calling {@link #setComponent(ComponentName)} with the
6928 * name returned by a {@link Class} object.
6929 *
6930 * @param packageContext A Context of the application package implementing
6931 * this class.
6932 * @param cls The class name to set, equivalent to
6933 * <code>setClassName(context, cls.getName())</code>.
6934 *
6935 * @return Returns the same Intent object, for chaining multiple calls
6936 * into a single statement.
6937 *
6938 * @see #setComponent
6939 */
6940 public Intent setClass(Context packageContext, Class<?> cls) {
6941 mComponent = new ComponentName(packageContext, cls);
6942 return this;
6943 }
6944
6945 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006946 * Set the bounds of the sender of this intent, in screen coordinates. This can be
6947 * used as a hint to the receiver for animations and the like. Null means that there
6948 * is no source bounds.
6949 */
6950 public void setSourceBounds(Rect r) {
6951 if (r != null) {
6952 mSourceBounds = new Rect(r);
6953 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07006954 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006955 }
6956 }
6957
Tor Norbyed9273d62013-05-30 15:59:53 -07006958 /** @hide */
6959 @IntDef(flag = true,
6960 value = {
6961 FILL_IN_ACTION,
6962 FILL_IN_DATA,
6963 FILL_IN_CATEGORIES,
6964 FILL_IN_COMPONENT,
6965 FILL_IN_PACKAGE,
6966 FILL_IN_SOURCE_BOUNDS,
6967 FILL_IN_SELECTOR,
6968 FILL_IN_CLIP_DATA
6969 })
6970 @Retention(RetentionPolicy.SOURCE)
6971 public @interface FillInFlags {}
6972
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006973 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006974 * Use with {@link #fillIn} to allow the current action value to be
6975 * overwritten, even if it is already set.
6976 */
6977 public static final int FILL_IN_ACTION = 1<<0;
6978
6979 /**
6980 * Use with {@link #fillIn} to allow the current data or type value
6981 * overwritten, even if it is already set.
6982 */
6983 public static final int FILL_IN_DATA = 1<<1;
6984
6985 /**
6986 * Use with {@link #fillIn} to allow the current categories to be
6987 * overwritten, even if they are already set.
6988 */
6989 public static final int FILL_IN_CATEGORIES = 1<<2;
6990
6991 /**
6992 * Use with {@link #fillIn} to allow the current component value to be
6993 * overwritten, even if it is already set.
6994 */
6995 public static final int FILL_IN_COMPONENT = 1<<3;
6996
6997 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006998 * Use with {@link #fillIn} to allow the current package value to be
6999 * overwritten, even if it is already set.
7000 */
7001 public static final int FILL_IN_PACKAGE = 1<<4;
7002
7003 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007004 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007005 * overwritten, even if it is already set.
7006 */
7007 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7008
7009 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007010 * Use with {@link #fillIn} to allow the current selector to be
7011 * overwritten, even if it is already set.
7012 */
7013 public static final int FILL_IN_SELECTOR = 1<<6;
7014
7015 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007016 * Use with {@link #fillIn} to allow the current ClipData to be
7017 * overwritten, even if it is already set.
7018 */
7019 public static final int FILL_IN_CLIP_DATA = 1<<7;
7020
7021 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007022 * Copy the contents of <var>other</var> in to this object, but only
7023 * where fields are not defined by this object. For purposes of a field
7024 * being defined, the following pieces of data in the Intent are
7025 * considered to be separate fields:
7026 *
7027 * <ul>
7028 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007029 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007030 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7031 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007032 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007033 * <li> component, as set by {@link #setComponent(ComponentName)} or
7034 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007035 * <li> source bounds, as set by {@link #setSourceBounds}.
7036 * <li> selector, as set by {@link #setSelector(Intent)}.
7037 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007038 * <li> each top-level name in the associated extras.
7039 * </ul>
7040 *
7041 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007042 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007043 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7044 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7045 * the restriction where the corresponding field will not be replaced if
7046 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007047 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007048 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7049 * is explicitly specified. The selector will only be copied if
7050 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007051 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007052 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7053 * and Intent B with {action="gotit", data-type="some/thing",
7054 * categories="one","two"}.
7055 *
7056 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7057 * containing: {action="gotit", data-type="some/thing",
7058 * categories="bar"}.
7059 *
7060 * @param other Another Intent whose values are to be used to fill in
7061 * the current one.
7062 * @param flags Options to control which fields can be filled in.
7063 *
7064 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007065 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007066 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7067 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7068 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007069 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007070 @FillInFlags
7071 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007072 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007073 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007074 if (other.mAction != null
7075 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007076 mAction = other.mAction;
7077 changes |= FILL_IN_ACTION;
7078 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007079 if ((other.mData != null || other.mType != null)
7080 && ((mData == null && mType == null)
7081 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007082 mData = other.mData;
7083 mType = other.mType;
7084 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007085 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007086 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007087 if (other.mCategories != null
7088 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007089 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007090 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007091 }
7092 changes |= FILL_IN_CATEGORIES;
7093 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007094 if (other.mPackage != null
7095 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007096 // Only do this if mSelector is not set.
7097 if (mSelector == null) {
7098 mPackage = other.mPackage;
7099 changes |= FILL_IN_PACKAGE;
7100 }
7101 }
7102 // Selector is special: it can only be set if explicitly allowed,
7103 // for the same reason as the component name.
7104 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7105 if (mPackage == null) {
7106 mSelector = new Intent(other.mSelector);
7107 mPackage = null;
7108 changes |= FILL_IN_SELECTOR;
7109 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007110 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007111 if (other.mClipData != null
7112 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7113 mClipData = other.mClipData;
7114 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007115 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007116 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007117 // Component is special: it can -only- be set if explicitly allowed,
7118 // since otherwise the sender could force the intent somewhere the
7119 // originator didn't intend.
7120 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007121 mComponent = other.mComponent;
7122 changes |= FILL_IN_COMPONENT;
7123 }
7124 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007125 if (other.mSourceBounds != null
7126 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7127 mSourceBounds = new Rect(other.mSourceBounds);
7128 changes |= FILL_IN_SOURCE_BOUNDS;
7129 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007130 if (mExtras == null) {
7131 if (other.mExtras != null) {
7132 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007133 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007134 }
7135 } else if (other.mExtras != null) {
7136 try {
7137 Bundle newb = new Bundle(other.mExtras);
7138 newb.putAll(mExtras);
7139 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007140 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007141 } catch (RuntimeException e) {
7142 // Modifying the extras can cause us to unparcel the contents
7143 // of the bundle, and if we do this in the system process that
7144 // may fail. We really should handle this (i.e., the Bundle
7145 // impl shouldn't be on top of a plain map), but for now just
7146 // ignore it and keep the original contents. :(
7147 Log.w("Intent", "Failure filling in extras", e);
7148 }
7149 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007150 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7151 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7152 mContentUserHint = other.mContentUserHint;
7153 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007154 return changes;
7155 }
7156
7157 /**
7158 * Wrapper class holding an Intent and implementing comparisons on it for
7159 * the purpose of filtering. The class implements its
7160 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7161 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7162 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7163 * on the wrapped Intent.
7164 */
7165 public static final class FilterComparison {
7166 private final Intent mIntent;
7167 private final int mHashCode;
7168
7169 public FilterComparison(Intent intent) {
7170 mIntent = intent;
7171 mHashCode = intent.filterHashCode();
7172 }
7173
7174 /**
7175 * Return the Intent that this FilterComparison represents.
7176 * @return Returns the Intent held by the FilterComparison. Do
7177 * not modify!
7178 */
7179 public Intent getIntent() {
7180 return mIntent;
7181 }
7182
7183 @Override
7184 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007185 if (obj instanceof FilterComparison) {
7186 Intent other = ((FilterComparison)obj).mIntent;
7187 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007188 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007189 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007190 }
7191
7192 @Override
7193 public int hashCode() {
7194 return mHashCode;
7195 }
7196 }
7197
7198 /**
7199 * Determine if two intents are the same for the purposes of intent
7200 * resolution (filtering). That is, if their action, data, type,
7201 * class, and categories are the same. This does <em>not</em> compare
7202 * any extra data included in the intents.
7203 *
7204 * @param other The other Intent to compare against.
7205 *
7206 * @return Returns true if action, data, type, class, and categories
7207 * are the same.
7208 */
7209 public boolean filterEquals(Intent other) {
7210 if (other == null) {
7211 return false;
7212 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007213 if (!Objects.equals(this.mAction, other.mAction)) return false;
7214 if (!Objects.equals(this.mData, other.mData)) return false;
7215 if (!Objects.equals(this.mType, other.mType)) return false;
7216 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7217 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7218 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007219
7220 return true;
7221 }
7222
7223 /**
7224 * Generate hash code that matches semantics of filterEquals().
7225 *
7226 * @return Returns the hash value of the action, data, type, class, and
7227 * categories.
7228 *
7229 * @see #filterEquals
7230 */
7231 public int filterHashCode() {
7232 int code = 0;
7233 if (mAction != null) {
7234 code += mAction.hashCode();
7235 }
7236 if (mData != null) {
7237 code += mData.hashCode();
7238 }
7239 if (mType != null) {
7240 code += mType.hashCode();
7241 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007242 if (mPackage != null) {
7243 code += mPackage.hashCode();
7244 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007245 if (mComponent != null) {
7246 code += mComponent.hashCode();
7247 }
7248 if (mCategories != null) {
7249 code += mCategories.hashCode();
7250 }
7251 return code;
7252 }
7253
7254 @Override
7255 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007256 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007257
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007258 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007259 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007260 b.append(" }");
7261
7262 return b.toString();
7263 }
7264
7265 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007266 public String toInsecureString() {
7267 StringBuilder b = new StringBuilder(128);
7268
7269 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007270 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007271 b.append(" }");
7272
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007273 return b.toString();
7274 }
Romain Guy4969af72009-06-17 10:53:19 -07007275
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007276 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007277 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007278 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007279
7280 b.append("Intent { ");
7281 toShortString(b, false, true, true, true);
7282 b.append(" }");
7283
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007284 return b.toString();
7285 }
7286
7287 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007288 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7289 StringBuilder b = new StringBuilder(128);
7290 toShortString(b, secure, comp, extras, clip);
7291 return b.toString();
7292 }
7293
7294 /** @hide */
7295 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7296 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007297 boolean first = true;
7298 if (mAction != null) {
7299 b.append("act=").append(mAction);
7300 first = false;
7301 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007302 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007303 if (!first) {
7304 b.append(' ');
7305 }
7306 first = false;
7307 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007308 for (int i=0; i<mCategories.size(); i++) {
7309 if (i > 0) b.append(',');
7310 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007311 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007312 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007313 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007314 if (mData != null) {
7315 if (!first) {
7316 b.append(' ');
7317 }
7318 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007319 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007320 if (secure) {
7321 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007322 } else {
7323 b.append(mData);
7324 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007325 }
7326 if (mType != null) {
7327 if (!first) {
7328 b.append(' ');
7329 }
7330 first = false;
7331 b.append("typ=").append(mType);
7332 }
7333 if (mFlags != 0) {
7334 if (!first) {
7335 b.append(' ');
7336 }
7337 first = false;
7338 b.append("flg=0x").append(Integer.toHexString(mFlags));
7339 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007340 if (mPackage != null) {
7341 if (!first) {
7342 b.append(' ');
7343 }
7344 first = false;
7345 b.append("pkg=").append(mPackage);
7346 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007347 if (comp && mComponent != null) {
7348 if (!first) {
7349 b.append(' ');
7350 }
7351 first = false;
7352 b.append("cmp=").append(mComponent.flattenToShortString());
7353 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007354 if (mSourceBounds != null) {
7355 if (!first) {
7356 b.append(' ');
7357 }
7358 first = false;
7359 b.append("bnds=").append(mSourceBounds.toShortString());
7360 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007361 if (mClipData != null) {
7362 if (!first) {
7363 b.append(' ');
7364 }
7365 first = false;
7366 if (clip) {
7367 b.append("clip={");
7368 mClipData.toShortString(b);
7369 b.append('}');
7370 } else {
7371 b.append("(has clip)");
7372 }
7373 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007374 if (extras && mExtras != null) {
7375 if (!first) {
7376 b.append(' ');
7377 }
7378 first = false;
7379 b.append("(has extras)");
7380 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007381 if (mContentUserHint != UserHandle.USER_CURRENT) {
7382 if (!first) {
7383 b.append(' ');
7384 }
7385 first = false;
7386 b.append("u=").append(mContentUserHint);
7387 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007388 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007389 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007390 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007391 b.append("}");
7392 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007393 }
7394
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007395 /**
7396 * Call {@link #toUri} with 0 flags.
7397 * @deprecated Use {@link #toUri} instead.
7398 */
7399 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007400 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007401 return toUri(0);
7402 }
7403
7404 /**
7405 * Convert this Intent into a String holding a URI representation of it.
7406 * The returned URI string has been properly URI encoded, so it can be
7407 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7408 * Intent's data as the base URI, with an additional fragment describing
7409 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007410 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007411 * <p>You can convert the returned string back to an Intent with
7412 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007413 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007414 * @param flags Additional operating flags. Either 0,
7415 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007416 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007417 * @return Returns a URI encoding URI string describing the entire contents
7418 * of the Intent.
7419 */
7420 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007421 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007422 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7423 if (mPackage == null) {
7424 throw new IllegalArgumentException(
7425 "Intent must include an explicit package name to build an android-app: "
7426 + this);
7427 }
7428 uri.append("android-app://");
7429 uri.append(mPackage);
7430 String scheme = null;
7431 if (mData != null) {
7432 scheme = mData.getScheme();
7433 if (scheme != null) {
7434 uri.append('/');
7435 uri.append(scheme);
7436 String authority = mData.getEncodedAuthority();
7437 if (authority != null) {
7438 uri.append('/');
7439 uri.append(authority);
7440 String path = mData.getEncodedPath();
7441 if (path != null) {
7442 uri.append(path);
7443 }
7444 String queryParams = mData.getEncodedQuery();
7445 if (queryParams != null) {
7446 uri.append('?');
7447 uri.append(queryParams);
7448 }
7449 String fragment = mData.getEncodedFragment();
7450 if (fragment != null) {
7451 uri.append('#');
7452 uri.append(fragment);
7453 }
7454 }
7455 }
7456 }
7457 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7458 mPackage, flags);
7459 return uri.toString();
7460 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007461 String scheme = null;
7462 if (mData != null) {
7463 String data = mData.toString();
7464 if ((flags&URI_INTENT_SCHEME) != 0) {
7465 final int N = data.length();
7466 for (int i=0; i<N; i++) {
7467 char c = data.charAt(i);
7468 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7469 || c == '.' || c == '-') {
7470 continue;
7471 }
7472 if (c == ':' && i > 0) {
7473 // Valid scheme.
7474 scheme = data.substring(0, i);
7475 uri.append("intent:");
7476 data = data.substring(i+1);
7477 break;
7478 }
Tom Taylord4a47292009-12-21 13:59:18 -08007479
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007480 // No scheme.
7481 break;
7482 }
7483 }
7484 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007485
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007486 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7487 uri.append("intent:");
7488 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007489
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007490 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007491
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007492 return uri.toString();
7493 }
7494
7495 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7496 String defPackage, int flags) {
7497 StringBuilder frag = new StringBuilder(128);
7498
7499 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007500 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007501 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007502 // Note that for now we are not going to try to handle the
7503 // data part; not clear how to represent this as a URI, and
7504 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007505 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7506 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007507 }
7508
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007509 if (frag.length() > 0) {
7510 uri.append("#Intent;");
7511 uri.append(frag);
7512 uri.append("end");
7513 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007514 }
7515
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007516 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7517 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007518 if (scheme != null) {
7519 uri.append("scheme=").append(scheme).append(';');
7520 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007521 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007522 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007523 }
7524 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007525 for (int i=0; i<mCategories.size(); i++) {
7526 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007527 }
7528 }
7529 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007530 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007531 }
7532 if (mFlags != 0) {
7533 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7534 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007535 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007536 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7537 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007538 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007539 uri.append("component=").append(Uri.encode(
7540 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007541 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007542 if (mSourceBounds != null) {
7543 uri.append("sourceBounds=")
7544 .append(Uri.encode(mSourceBounds.flattenToString()))
7545 .append(';');
7546 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007547 if (mExtras != null) {
7548 for (String key : mExtras.keySet()) {
7549 final Object value = mExtras.get(key);
7550 char entryType =
7551 value instanceof String ? 'S' :
7552 value instanceof Boolean ? 'B' :
7553 value instanceof Byte ? 'b' :
7554 value instanceof Character ? 'c' :
7555 value instanceof Double ? 'd' :
7556 value instanceof Float ? 'f' :
7557 value instanceof Integer ? 'i' :
7558 value instanceof Long ? 'l' :
7559 value instanceof Short ? 's' :
7560 '\0';
7561
7562 if (entryType != '\0') {
7563 uri.append(entryType);
7564 uri.append('.');
7565 uri.append(Uri.encode(key));
7566 uri.append('=');
7567 uri.append(Uri.encode(value.toString()));
7568 uri.append(';');
7569 }
7570 }
7571 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007572 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007573
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007574 public int describeContents() {
7575 return (mExtras != null) ? mExtras.describeContents() : 0;
7576 }
7577
7578 public void writeToParcel(Parcel out, int flags) {
7579 out.writeString(mAction);
7580 Uri.writeToParcel(out, mData);
7581 out.writeString(mType);
7582 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007583 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007584 ComponentName.writeToParcel(mComponent, out);
7585
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007586 if (mSourceBounds != null) {
7587 out.writeInt(1);
7588 mSourceBounds.writeToParcel(out, flags);
7589 } else {
7590 out.writeInt(0);
7591 }
7592
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007593 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007594 final int N = mCategories.size();
7595 out.writeInt(N);
7596 for (int i=0; i<N; i++) {
7597 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007598 }
7599 } else {
7600 out.writeInt(0);
7601 }
7602
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007603 if (mSelector != null) {
7604 out.writeInt(1);
7605 mSelector.writeToParcel(out, flags);
7606 } else {
7607 out.writeInt(0);
7608 }
7609
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007610 if (mClipData != null) {
7611 out.writeInt(1);
7612 mClipData.writeToParcel(out, flags);
7613 } else {
7614 out.writeInt(0);
7615 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007616 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007617 out.writeBundle(mExtras);
7618 }
7619
7620 public static final Parcelable.Creator<Intent> CREATOR
7621 = new Parcelable.Creator<Intent>() {
7622 public Intent createFromParcel(Parcel in) {
7623 return new Intent(in);
7624 }
7625 public Intent[] newArray(int size) {
7626 return new Intent[size];
7627 }
7628 };
7629
Dianne Hackborneb034652009-09-07 00:49:58 -07007630 /** @hide */
7631 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007632 readFromParcel(in);
7633 }
7634
7635 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007636 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007637 mData = Uri.CREATOR.createFromParcel(in);
7638 mType = in.readString();
7639 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007640 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007641 mComponent = ComponentName.readFromParcel(in);
7642
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007643 if (in.readInt() != 0) {
7644 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7645 }
7646
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007647 int N = in.readInt();
7648 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007649 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007650 int i;
7651 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007652 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007653 }
7654 } else {
7655 mCategories = null;
7656 }
7657
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007658 if (in.readInt() != 0) {
7659 mSelector = new Intent(in);
7660 }
7661
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007662 if (in.readInt() != 0) {
7663 mClipData = new ClipData(in);
7664 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007665 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007666 mExtras = in.readBundle();
7667 }
7668
7669 /**
7670 * Parses the "intent" element (and its children) from XML and instantiates
7671 * an Intent object. The given XML parser should be located at the tag
7672 * where parsing should start (often named "intent"), from which the
7673 * basic action, data, type, and package and class name will be
7674 * retrieved. The function will then parse in to any child elements,
7675 * looking for <category android:name="xxx"> tags to add categories and
7676 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7677 * to the intent.
7678 *
7679 * @param resources The Resources to use when inflating resources.
7680 * @param parser The XML parser pointing at an "intent" tag.
7681 * @param attrs The AttributeSet interface for retrieving extended
7682 * attribute data at the current <var>parser</var> location.
7683 * @return An Intent object matching the XML data.
7684 * @throws XmlPullParserException If there was an XML parsing error.
7685 * @throws IOException If there was an I/O error.
7686 */
7687 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7688 throws XmlPullParserException, IOException {
7689 Intent intent = new Intent();
7690
7691 TypedArray sa = resources.obtainAttributes(attrs,
7692 com.android.internal.R.styleable.Intent);
7693
7694 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7695
7696 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7697 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7698 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7699
7700 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7701 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7702 if (packageName != null && className != null) {
7703 intent.setComponent(new ComponentName(packageName, className));
7704 }
7705
7706 sa.recycle();
7707
7708 int outerDepth = parser.getDepth();
7709 int type;
7710 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7711 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7712 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7713 continue;
7714 }
7715
7716 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007717 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007718 sa = resources.obtainAttributes(attrs,
7719 com.android.internal.R.styleable.IntentCategory);
7720 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7721 sa.recycle();
7722
7723 if (cat != null) {
7724 intent.addCategory(cat);
7725 }
7726 XmlUtils.skipCurrentTag(parser);
7727
Craig Mautner21d24a22014-04-23 11:45:37 -07007728 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007729 if (intent.mExtras == null) {
7730 intent.mExtras = new Bundle();
7731 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007732 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007733 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007734
7735 } else {
7736 XmlUtils.skipCurrentTag(parser);
7737 }
7738 }
7739
7740 return intent;
7741 }
Nick Pellyccae4122012-01-09 14:12:58 -08007742
Craig Mautner21d24a22014-04-23 11:45:37 -07007743 /** @hide */
7744 public void saveToXml(XmlSerializer out) throws IOException {
7745 if (mAction != null) {
7746 out.attribute(null, ATTR_ACTION, mAction);
7747 }
7748 if (mData != null) {
7749 out.attribute(null, ATTR_DATA, mData.toString());
7750 }
7751 if (mType != null) {
7752 out.attribute(null, ATTR_TYPE, mType);
7753 }
7754 if (mComponent != null) {
7755 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7756 }
7757 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7758
7759 if (mCategories != null) {
7760 out.startTag(null, TAG_CATEGORIES);
7761 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7762 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7763 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007764 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007765 }
7766 }
7767
7768 /** @hide */
7769 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7770 XmlPullParserException {
7771 Intent intent = new Intent();
7772 final int outerDepth = in.getDepth();
7773
7774 int attrCount = in.getAttributeCount();
7775 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7776 final String attrName = in.getAttributeName(attrNdx);
7777 final String attrValue = in.getAttributeValue(attrNdx);
7778 if (ATTR_ACTION.equals(attrName)) {
7779 intent.setAction(attrValue);
7780 } else if (ATTR_DATA.equals(attrName)) {
7781 intent.setData(Uri.parse(attrValue));
7782 } else if (ATTR_TYPE.equals(attrName)) {
7783 intent.setType(attrValue);
7784 } else if (ATTR_COMPONENT.equals(attrName)) {
7785 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7786 } else if (ATTR_FLAGS.equals(attrName)) {
7787 intent.setFlags(Integer.valueOf(attrValue, 16));
7788 } else {
7789 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7790 }
7791 }
7792
7793 int event;
7794 String name;
7795 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7796 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7797 if (event == XmlPullParser.START_TAG) {
7798 name = in.getName();
7799 if (TAG_CATEGORIES.equals(name)) {
7800 attrCount = in.getAttributeCount();
7801 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7802 intent.addCategory(in.getAttributeValue(attrNdx));
7803 }
7804 } else {
7805 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7806 XmlUtils.skipCurrentTag(in);
7807 }
7808 }
7809 }
7810
7811 return intent;
7812 }
7813
Nick Pellyccae4122012-01-09 14:12:58 -08007814 /**
7815 * Normalize a MIME data type.
7816 *
7817 * <p>A normalized MIME type has white-space trimmed,
7818 * content-type parameters removed, and is lower-case.
7819 * This aligns the type with Android best practices for
7820 * intent filtering.
7821 *
7822 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7823 * "text/x-vCard" becomes "text/x-vcard".
7824 *
7825 * <p>All MIME types received from outside Android (such as user input,
7826 * or external sources like Bluetooth, NFC, or the Internet) should
7827 * be normalized before they are used to create an Intent.
7828 *
7829 * @param type MIME data type to normalize
7830 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007831 * @see #setType
7832 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007833 */
7834 public static String normalizeMimeType(String type) {
7835 if (type == null) {
7836 return null;
7837 }
7838
Elliott Hughescb64d432013-08-02 10:00:44 -07007839 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007840
7841 final int semicolonIndex = type.indexOf(';');
7842 if (semicolonIndex != -1) {
7843 type = type.substring(0, semicolonIndex);
7844 }
7845 return type;
7846 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007847
7848 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007849 * Prepare this {@link Intent} to leave an app process.
7850 *
7851 * @hide
7852 */
7853 public void prepareToLeaveProcess() {
7854 setAllowFds(false);
7855
7856 if (mSelector != null) {
7857 mSelector.prepareToLeaveProcess();
7858 }
7859 if (mClipData != null) {
7860 mClipData.prepareToLeaveProcess();
7861 }
7862
7863 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
7864 // There are several ACTION_MEDIA_* broadcasts that send file://
7865 // Uris, so only check common actions.
7866 if (ACTION_VIEW.equals(mAction) ||
7867 ACTION_EDIT.equals(mAction) ||
7868 ACTION_ATTACH_DATA.equals(mAction)) {
7869 mData.checkFileUriExposed("Intent.getData()");
7870 }
7871 }
7872 }
7873
7874 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007875 * @hide
7876 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007877 public void prepareToEnterProcess() {
7878 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00007879 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
7880 fixUris(mContentUserHint);
7881 mContentUserHint = UserHandle.USER_CURRENT;
7882 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007883 }
7884 }
7885
7886 /**
7887 * @hide
7888 */
7889 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007890 Uri data = getData();
7891 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007892 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007893 }
7894 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007895 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007896 }
7897 String action = getAction();
7898 if (ACTION_SEND.equals(action)) {
7899 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7900 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007901 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007902 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007903 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007904 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7905 if (streams != null) {
7906 ArrayList<Uri> newStreams = new ArrayList<Uri>();
7907 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007908 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007909 }
7910 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
7911 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007912 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
7913 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
7914 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
7915 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
7916 if (output != null) {
7917 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
7918 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007919 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007920 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007921
7922 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007923 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007924 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
7925 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007926 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007927 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007928 * @hide
7929 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007930 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007931 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007932 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007933
7934 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007935 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007936
7937 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007938 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007939 // Inspect contained intents to see if we need to migrate extras. We
7940 // don't promote ClipData to the parent, since ChooserActivity will
7941 // already start the picked item as the caller, and we can't combine
7942 // the flags in a safe way.
7943
7944 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07007945 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007946 final Intent intent = getParcelableExtra(EXTRA_INTENT);
7947 if (intent != null) {
7948 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07007949 }
7950 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007951 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007952 try {
7953 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
7954 if (intents != null) {
7955 for (int i = 0; i < intents.length; i++) {
7956 final Intent intent = (Intent) intents[i];
7957 if (intent != null) {
7958 migrated |= intent.migrateExtraStreamToClipData();
7959 }
7960 }
7961 }
7962 } catch (ClassCastException e) {
7963 }
7964 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007965
7966 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007967 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007968 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7969 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
7970 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
7971 if (stream != null || text != null || htmlText != null) {
7972 final ClipData clipData = new ClipData(
7973 null, new String[] { getType() },
7974 new ClipData.Item(text, htmlText, null, stream));
7975 setClipData(clipData);
7976 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007977 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007978 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007979 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007980 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007981
7982 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007983 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007984 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7985 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
7986 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
7987 int num = -1;
7988 if (streams != null) {
7989 num = streams.size();
7990 }
7991 if (texts != null) {
7992 if (num >= 0 && num != texts.size()) {
7993 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007994 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007995 }
7996 num = texts.size();
7997 }
7998 if (htmlTexts != null) {
7999 if (num >= 0 && num != htmlTexts.size()) {
8000 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008001 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008002 }
8003 num = htmlTexts.size();
8004 }
8005 if (num > 0) {
8006 final ClipData clipData = new ClipData(
8007 null, new String[] { getType() },
8008 makeClipItem(streams, texts, htmlTexts, 0));
8009
8010 for (int i = 1; i < num; i++) {
8011 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8012 }
8013
8014 setClipData(clipData);
8015 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008016 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008017 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008018 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008019 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008020 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8021 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8022 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8023 final Uri output;
8024 try {
8025 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8026 } catch (ClassCastException e) {
8027 return false;
8028 }
8029 if (output != null) {
8030 setClipData(ClipData.newRawUri("", output));
8031 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8032 return true;
8033 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008034 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008035
8036 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008037 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008038
8039 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8040 ArrayList<String> htmlTexts, int which) {
8041 Uri uri = streams != null ? streams.get(which) : null;
8042 CharSequence text = texts != null ? texts.get(which) : null;
8043 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8044 return new ClipData.Item(text, htmlText, null, uri);
8045 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008046
8047 /** @hide */
8048 public boolean isDocument() {
8049 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8050 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008051}