blob: 2ed8c44ddc2f562b27d240dabdf489b53c7f1c6a [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 /**
1044 * Activity Action: Send a message to someone specified by the data.
1045 * <p>Input: {@link #getData} is URI describing the target.
1046 * <p>Output: nothing.
1047 */
1048 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1049 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1050 /**
1051 * Activity Action: Deliver some data to someone else. Who the data is
1052 * being delivered to is not specified; it is up to the receiver of this
1053 * action to ask the user where the data should be sent.
1054 * <p>
1055 * When launching a SEND intent, you should usually wrap it in a chooser
1056 * (through {@link #createChooser}), which will give the proper interface
1057 * for the user to pick how to send your data and allow you to specify
1058 * a prompt indicating what they are doing.
1059 * <p>
1060 * Input: {@link #getType} is the MIME type of the data being sent.
1061 * get*Extra can have either a {@link #EXTRA_TEXT}
1062 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1063 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1064 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1065 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001066 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1067 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1068 * your text with HTML formatting.
1069 * <p>
1070 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1071 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1072 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1073 * content: URIs and other advanced features of {@link ClipData}. If
1074 * using this approach, you still must supply the same data through the
1075 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1076 * for compatibility with old applications. If you don't set a ClipData,
1077 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001078 * <p>
1079 * Optional standard extras, which may be interpreted by some recipients as
1080 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1081 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1082 * <p>
1083 * Output: nothing.
1084 */
1085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086 public static final String ACTION_SEND = "android.intent.action.SEND";
1087 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001088 * Activity Action: Deliver multiple data to someone else.
1089 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001090 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001091 * <p>
1092 * Input: {@link #getType} is the MIME type of the data being sent.
1093 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001094 * #EXTRA_STREAM} field, containing the data to be sent. If using
1095 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1096 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001097 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001098 * Multiple types are supported, and receivers should handle mixed types
1099 * whenever possible. The right way for the receiver to check them is to
1100 * use the content resolver on each URI. The intent sender should try to
1101 * put the most concrete mime type in the intent type, but it can fall
1102 * back to {@literal <type>/*} or {@literal *}/* as needed.
1103 * <p>
1104 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1105 * be image/jpg, but if you are sending image/jpg and image/png, then the
1106 * intent's type should be image/*.
1107 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001108 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1109 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1110 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1111 * content: URIs and other advanced features of {@link ClipData}. If
1112 * using this approach, you still must supply the same data through the
1113 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1114 * for compatibility with old applications. If you don't set a ClipData,
1115 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1116 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001117 * Optional standard extras, which may be interpreted by some recipients as
1118 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1119 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1120 * <p>
1121 * Output: nothing.
1122 */
1123 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1124 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1125 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001126 * Activity Action: Handle an incoming phone call.
1127 * <p>Input: nothing.
1128 * <p>Output: nothing.
1129 */
1130 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1131 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1132 /**
1133 * Activity Action: Insert an empty item into the given container.
1134 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1135 * in which to place the data.
1136 * <p>Output: URI of the new data that was created.
1137 */
1138 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1139 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1140 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001141 * Activity Action: Create a new item in the given container, initializing it
1142 * from the current contents of the clipboard.
1143 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1144 * in which to place the data.
1145 * <p>Output: URI of the new data that was created.
1146 */
1147 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1148 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1149 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001150 * Activity Action: Delete the given data from its container.
1151 * <p>Input: {@link #getData} is URI of data to be deleted.
1152 * <p>Output: nothing.
1153 */
1154 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1155 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1156 /**
1157 * Activity Action: Run the data, whatever that means.
1158 * <p>Input: ? (Note: this is currently specific to the test harness.)
1159 * <p>Output: nothing.
1160 */
1161 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1162 public static final String ACTION_RUN = "android.intent.action.RUN";
1163 /**
1164 * Activity Action: Perform a data synchronization.
1165 * <p>Input: ?
1166 * <p>Output: ?
1167 */
1168 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1169 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1170 /**
1171 * Activity Action: Pick an activity given an intent, returning the class
1172 * selected.
1173 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1174 * used with {@link PackageManager#queryIntentActivities} to determine the
1175 * set of activities from which to pick.
1176 * <p>Output: Class name of the activity that was selected.
1177 */
1178 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1179 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1180 /**
1181 * Activity Action: Perform a search.
1182 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1183 * is the text to search for. If empty, simply
1184 * enter your search results Activity with the search UI activated.
1185 * <p>Output: nothing.
1186 */
1187 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1188 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1189 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001190 * Activity Action: Start the platform-defined tutorial
1191 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1192 * is the text to search for. If empty, simply
1193 * enter your search results Activity with the search UI activated.
1194 * <p>Output: nothing.
1195 */
1196 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1197 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1198 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001199 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001200 * <p>
1201 * Input: {@link android.app.SearchManager#QUERY
1202 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1203 * a url starts with http or https, the site will be opened. If it is plain
1204 * text, Google search will be applied.
1205 * <p>
1206 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001207 */
1208 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1209 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001210
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001211 /**
Jim Miller07994402012-05-02 14:22:27 -07001212 * Activity Action: Perform assist action.
1213 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001214 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1215 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001216 * requested the assist.
Jim Miller07994402012-05-02 14:22:27 -07001217 * Output: nothing.
1218 */
1219 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1220 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001221
1222 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001223 * Activity Action: Perform voice assist action.
1224 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001225 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1226 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001227 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001228 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001229 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001230 */
1231 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1232 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1233
1234 /**
Adam Skory7140a252013-09-11 12:04:58 +01001235 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1236 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001237 */
1238 public static final String EXTRA_ASSIST_PACKAGE
1239 = "android.intent.extra.ASSIST_PACKAGE";
1240
1241 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001242 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1243 * application package at the time the assist was invoked.
1244 */
1245 public static final String EXTRA_ASSIST_UID
1246 = "android.intent.extra.ASSIST_UID";
1247
1248 /**
Adam Skory7140a252013-09-11 12:04:58 +01001249 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1250 * information supplied by the current foreground app at the time of the assist request.
1251 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001252 */
1253 public static final String EXTRA_ASSIST_CONTEXT
1254 = "android.intent.extra.ASSIST_CONTEXT";
1255
Jim Miller07994402012-05-02 14:22:27 -07001256 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001257 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1258 * keyboard as the primary input device for assistance.
1259 */
1260 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1261 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1262
1263 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001264 * Activity Action: List all available applications
1265 * <p>Input: Nothing.
1266 * <p>Output: nothing.
1267 */
1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1269 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1270 /**
1271 * Activity Action: Show settings for choosing wallpaper
1272 * <p>Input: Nothing.
1273 * <p>Output: Nothing.
1274 */
1275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1276 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1277
1278 /**
1279 * Activity Action: Show activity for reporting a bug.
1280 * <p>Input: Nothing.
1281 * <p>Output: Nothing.
1282 */
1283 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1284 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1285
1286 /**
1287 * Activity Action: Main entry point for factory tests. Only used when
1288 * the device is booting in factory test node. The implementing package
1289 * must be installed in the system image.
1290 * <p>Input: nothing
1291 * <p>Output: nothing
1292 */
1293 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1294
1295 /**
1296 * Activity Action: The user pressed the "call" button to go to the dialer
1297 * or other appropriate UI for placing a call.
1298 * <p>Input: Nothing.
1299 * <p>Output: Nothing.
1300 */
1301 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1302 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1303
1304 /**
1305 * Activity Action: Start Voice Command.
1306 * <p>Input: Nothing.
1307 * <p>Output: Nothing.
1308 */
1309 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1310 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001311
1312 /**
1313 * Activity Action: Start action associated with long pressing on the
1314 * search key.
1315 * <p>Input: Nothing.
1316 * <p>Output: Nothing.
1317 */
1318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001320
Jacek Surazski86b6c532009-05-13 14:38:28 +02001321 /**
1322 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1323 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001324 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001325 * <p>Input: No data is specified. The bug report is passed in using
1326 * an {@link #EXTRA_BUG_REPORT} field.
1327 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001328 *
1329 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001330 */
1331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1332 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001333
1334 /**
1335 * Activity Action: Show power usage information to the user.
1336 * <p>Input: Nothing.
1337 * <p>Output: Nothing.
1338 */
1339 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1340 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001341
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001342 /**
1343 * Activity Action: Setup wizard to launch after a platform update. This
1344 * activity should have a string meta-data field associated with it,
1345 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1346 * the platform for setup. The activity will be launched only if
1347 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1348 * same value.
1349 * <p>Input: Nothing.
1350 * <p>Output: Nothing.
1351 * @hide
1352 */
1353 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1354 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001355
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001356 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001357 * Activity Action: Show settings for managing network data usage of a
1358 * specific application. Applications should define an activity that offers
1359 * options to control data usage.
1360 */
1361 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1362 public static final String ACTION_MANAGE_NETWORK_USAGE =
1363 "android.intent.action.MANAGE_NETWORK_USAGE";
1364
1365 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001366 * Activity Action: Launch application installer.
1367 * <p>
1368 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001369 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1370 * you can also use "package:<package-name>" to install an application for the
1371 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001372 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1373 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1374 * <p>
1375 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1376 * succeeded.
1377 *
1378 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1379 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1380 * @see #EXTRA_RETURN_RESULT
1381 */
1382 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1383 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1384
1385 /**
1386 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1387 * package. Specifies the installer package name; this package will receive the
1388 * {@link #ACTION_APP_ERROR} intent.
1389 */
1390 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1391 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1392
1393 /**
1394 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1395 * package. Specifies that the application being installed should not be
1396 * treated as coming from an unknown source, but as coming from the app
1397 * invoking the Intent. For this to work you must start the installer with
1398 * startActivityForResult().
1399 */
1400 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1401 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1402
1403 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001404 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1405 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001406 * data field originated from.
1407 */
rich cannings706e8ba2012-08-20 13:20:14 -07001408 public static final String EXTRA_ORIGINATING_URI
1409 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001410
1411 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001412 * This extra can be used with any Intent used to launch an activity, supplying information
1413 * about who is launching that activity. This field contains a {@link android.net.Uri}
1414 * object, typically an http: or https: URI of the web site that the referral came from;
1415 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1416 * a native application that it came from.
1417 *
1418 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1419 * instead of directly retrieving the extra. It is also valid for applications to
1420 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1421 * a string, not a Uri; the field here, if supplied, will always take precedence,
1422 * however.</p>
1423 *
1424 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001425 */
1426 public static final String EXTRA_REFERRER
1427 = "android.intent.extra.REFERRER";
1428
1429 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001430 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1431 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1432 * not be created, in particular when Intent extras are supplied through the
1433 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1434 * schemes.
1435 *
1436 * @see #EXTRA_REFERRER
1437 */
1438 public static final String EXTRA_REFERRER_NAME
1439 = "android.intent.extra.REFERRER_NAME";
1440
1441 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001442 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1443 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1444 * @hide
1445 */
1446 public static final String EXTRA_ORIGINATING_UID
1447 = "android.intent.extra.ORIGINATING_UID";
1448
1449 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001450 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1451 * package. Tells the installer UI to skip the confirmation with the user
1452 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001453 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1454 * will no longer show an interstitial message about updating existing
1455 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001456 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001457 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001458 public static final String EXTRA_ALLOW_REPLACE
1459 = "android.intent.extra.ALLOW_REPLACE";
1460
1461 /**
1462 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1463 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1464 * return to the application the result code of the install/uninstall. The returned result
1465 * code will be {@link android.app.Activity#RESULT_OK} on success or
1466 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1467 */
1468 public static final String EXTRA_RETURN_RESULT
1469 = "android.intent.extra.RETURN_RESULT";
1470
1471 /**
1472 * Package manager install result code. @hide because result codes are not
1473 * yet ready to be exposed.
1474 */
1475 public static final String EXTRA_INSTALL_RESULT
1476 = "android.intent.extra.INSTALL_RESULT";
1477
1478 /**
1479 * Activity Action: Launch application uninstaller.
1480 * <p>
1481 * Input: The data must be a package: URI whose scheme specific part is
1482 * the package name of the current installed package to be uninstalled.
1483 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1484 * <p>
1485 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1486 * succeeded.
1487 */
1488 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1489 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1490
1491 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001492 * Specify whether the package should be uninstalled for all users.
1493 * @hide because these should not be part of normal application flow.
1494 */
1495 public static final String EXTRA_UNINSTALL_ALL_USERS
1496 = "android.intent.extra.UNINSTALL_ALL_USERS";
1497
1498 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001499 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1500 * describing the last run version of the platform that was setup.
1501 * @hide
1502 */
1503 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1504
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001505 // ---------------------------------------------------------------------
1506 // ---------------------------------------------------------------------
1507 // Standard intent broadcast actions (see action variable).
1508
1509 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001510 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1511 * <p>
1512 * For historical reasons, the name of this broadcast action refers to the power
1513 * state of the screen but it is actually sent in response to changes in the
1514 * overall interactive state of the device.
1515 * </p><p>
1516 * This broadcast is sent when the device becomes non-interactive which may have
1517 * nothing to do with the screen turning off. To determine the
1518 * actual state of the screen, use {@link android.view.Display#getState}.
1519 * </p><p>
1520 * See {@link android.os.PowerManager#isInteractive} for details.
1521 * </p>
Tom Taylord4a47292009-12-21 13:59:18 -08001522 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001523 * <p class="note">This is a protected intent that can only be sent
1524 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001525 */
1526 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1527 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001528
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001529 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001530 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1531 * <p>
1532 * For historical reasons, the name of this broadcast action refers to the power
1533 * state of the screen but it is actually sent in response to changes in the
1534 * overall interactive state of the device.
1535 * </p><p>
1536 * This broadcast is sent when the device becomes interactive which may have
1537 * nothing to do with the screen turning on. To determine the
1538 * actual state of the screen, use {@link android.view.Display#getState}.
1539 * </p><p>
1540 * See {@link android.os.PowerManager#isInteractive} for details.
1541 * </p>
Tom Taylord4a47292009-12-21 13:59:18 -08001542 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001543 * <p class="note">This is a protected intent that can only be sent
1544 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001545 */
1546 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1547 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001548
1549 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001550 * Broadcast Action: Sent after the system stops dreaming.
1551 *
1552 * <p class="note">This is a protected intent that can only be sent by the system.
1553 * It is only sent to registered receivers.</p>
1554 */
1555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1556 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1557
1558 /**
1559 * Broadcast Action: Sent after the system starts dreaming.
1560 *
1561 * <p class="note">This is a protected intent that can only be sent by the system.
1562 * It is only sent to registered receivers.</p>
1563 */
1564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1565 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1566
1567 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001568 * 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 -07001569 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001570 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001571 * <p class="note">This is a protected intent that can only be sent
1572 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001573 */
1574 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001575 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001576
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001577 /**
1578 * Broadcast Action: The current time has changed. Sent every
1579 * minute. You can <em>not</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001580 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001581 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1582 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001583 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001584 * <p class="note">This is a protected intent that can only be sent
1585 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001586 */
1587 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1588 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1589 /**
1590 * Broadcast Action: The time was set.
1591 */
1592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1593 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1594 /**
1595 * Broadcast Action: The date has changed.
1596 */
1597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1598 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1599 /**
1600 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1601 * <ul>
1602 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1603 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001604 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001605 * <p class="note">This is a protected intent that can only be sent
1606 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001607 */
1608 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1609 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1610 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001611 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1612 * DNS entries should be tossed.
1613 * @hide
1614 */
1615 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1616 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1617 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001618 * Alarm Changed Action: This is broadcast when the AlarmClock
1619 * application's alarm is set or unset. It is used by the
1620 * AlarmClock application and the StatusBar service.
1621 * @hide
1622 */
1623 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1624 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1625 /**
1626 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1627 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1628 * @hide
1629 */
1630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1631 public static final String ACTION_SYNC_STATE_CHANGED
1632 = "android.intent.action.SYNC_STATE_CHANGED";
1633 /**
1634 * Broadcast Action: This is broadcast once, after the system has finished
1635 * booting. It can be used to perform application-specific initialization,
1636 * such as installing alarms. You must hold the
1637 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1638 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001639 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001640 * <p class="note">This is a protected intent that can only be sent
1641 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001642 */
1643 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1644 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1645 /**
1646 * Broadcast Action: This is broadcast when a user action should request a
1647 * temporary system dialog to dismiss. Some examples of temporary system
1648 * dialogs are the notification window-shade and the recent tasks dialog.
1649 */
1650 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1651 /**
1652 * Broadcast Action: Trigger the download and eventual installation
1653 * of a package.
1654 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001655 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001656 * <p class="note">This is a protected intent that can only be sent
1657 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001658 *
1659 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001660 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001661 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1663 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1664 /**
1665 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001666 * device. The data contains the name of the package. Note that the
1667 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001668 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001669 * <ul>
1670 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1671 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1672 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1673 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001674 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001675 * <p class="note">This is a protected intent that can only be sent
1676 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001677 */
1678 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1679 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1680 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001681 * Broadcast Action: A new version of an application package has been
1682 * installed, replacing an existing version that was previously installed.
1683 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001684 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001685 * <ul>
1686 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1687 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001688 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001689 * <p class="note">This is a protected intent that can only be sent
1690 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001691 */
1692 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1693 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1694 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001695 * Broadcast Action: A new version of your application has been installed
1696 * over an existing one. This is only sent to the application that was
1697 * replaced. It does not contain any additional data; to receive it, just
1698 * use an intent filter for this action.
1699 *
1700 * <p class="note">This is a protected intent that can only be sent
1701 * by the system.
1702 */
1703 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1704 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1705 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001706 * Broadcast Action: An existing application package has been removed from
1707 * the device. The data contains the name of the package. The package
1708 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001709 * <ul>
1710 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1711 * to the package.
1712 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1713 * application -- data and code -- is being removed.
1714 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1715 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1716 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001717 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001718 * <p class="note">This is a protected intent that can only be sent
1719 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001720 */
1721 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1722 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1723 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001724 * Broadcast Action: An existing application package has been completely
1725 * removed from the device. The data contains the name of the package.
1726 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1727 * {@link #EXTRA_DATA_REMOVED} is true and
1728 * {@link #EXTRA_REPLACING} is false of that broadcast.
1729 *
1730 * <ul>
1731 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1732 * to the package.
1733 * </ul>
1734 *
1735 * <p class="note">This is a protected intent that can only be sent
1736 * by the system.
1737 */
1738 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1739 public static final String ACTION_PACKAGE_FULLY_REMOVED
1740 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1741 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001742 * Broadcast Action: An existing application package has been changed (e.g.
1743 * a component has been enabled or disabled). The data contains the name of
1744 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001745 * <ul>
1746 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001747 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001748 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001749 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1750 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001751 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001752 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001753 * <p class="note">This is a protected intent that can only be sent
1754 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001755 */
1756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1757 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1758 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001759 * @hide
1760 * Broadcast Action: Ask system services if there is any reason to
1761 * restart the given package. The data contains the name of the
1762 * package.
1763 * <ul>
1764 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1765 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1766 * </ul>
1767 *
1768 * <p class="note">This is a protected intent that can only be sent
1769 * by the system.
1770 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001771 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1773 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1774 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001775 * Broadcast Action: The user has restarted a package, and all of its
1776 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001777 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001778 * be removed. Note that the restarted package does <em>not</em>
1779 * receive this broadcast.
1780 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001781 * <ul>
1782 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1783 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001784 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001785 * <p class="note">This is a protected intent that can only be sent
1786 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001787 */
1788 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1789 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1790 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001791 * Broadcast Action: The user has cleared the data of a package. This should
1792 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001793 * its persistent data is erased and this broadcast sent.
1794 * Note that the cleared package does <em>not</em>
1795 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001796 * <ul>
1797 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1798 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001799 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001800 * <p class="note">This is a protected intent that can only be sent
1801 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001802 */
1803 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1804 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1805 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001806 * Broadcast Action: A user ID has been removed from the system. The user
1807 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001808 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001809 * <p class="note">This is a protected intent that can only be sent
1810 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001811 */
1812 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1813 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001814
1815 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001816 * Broadcast Action: Sent to the installer package of an application
1817 * when that application is first launched (that is the first time it
1818 * is moved out of the stopped state). The data contains the name of the package.
1819 *
1820 * <p class="note">This is a protected intent that can only be sent
1821 * by the system.
1822 */
1823 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1824 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1825
1826 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001827 * Broadcast Action: Sent to the system package verifier when a package
1828 * needs to be verified. The data contains the package URI.
1829 * <p class="note">
1830 * This is a protected intent that can only be sent by the system.
1831 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001832 */
1833 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1834 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1835
1836 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001837 * Broadcast Action: Sent to the system package verifier when a package is
1838 * verified. The data contains the package URI.
1839 * <p class="note">
1840 * This is a protected intent that can only be sent by the system.
1841 */
1842 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1843 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1844
1845 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001846 * Broadcast Action: Resources for a set of packages (which were
1847 * previously unavailable) are currently
1848 * available since the media on which they exist is available.
1849 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1850 * list of packages whose availability changed.
1851 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1852 * list of uids of packages whose availability changed.
1853 * Note that the
1854 * packages in this list do <em>not</em> receive this broadcast.
1855 * The specified set of packages are now available on the system.
1856 * <p>Includes the following extras:
1857 * <ul>
1858 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1859 * whose resources(were previously unavailable) are currently available.
1860 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1861 * packages whose resources(were previously unavailable)
1862 * are currently available.
1863 * </ul>
1864 *
1865 * <p class="note">This is a protected intent that can only be sent
1866 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001867 */
1868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001869 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1870 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001871
1872 /**
1873 * Broadcast Action: Resources for a set of packages are currently
1874 * unavailable since the media on which they exist is unavailable.
1875 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1876 * list of packages whose availability changed.
1877 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1878 * list of uids of packages whose availability changed.
1879 * The specified set of packages can no longer be
1880 * launched and are practically unavailable on the system.
1881 * <p>Inclues the following extras:
1882 * <ul>
1883 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1884 * whose resources are no longer available.
1885 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1886 * whose resources are no longer available.
1887 * </ul>
1888 *
1889 * <p class="note">This is a protected intent that can only be sent
1890 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001891 */
1892 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001893 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001894 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001895
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001896 /**
1897 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001898 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001899 * This should <em>only</em> be used to determine when the wallpaper
1900 * has changed to show the new wallpaper to the user. You should certainly
1901 * never, in response to this, change the wallpaper or other attributes of
1902 * it such as the suggested size. That would be crazy, right? You'd cause
1903 * all kinds of loops, especially if other apps are doing similar things,
1904 * right? Of course. So please don't do this.
1905 *
1906 * @deprecated Modern applications should use
1907 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
1908 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
1909 * shown behind their UI, rather than watching for this broadcast and
1910 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001911 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001912 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001913 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1914 /**
1915 * Broadcast Action: The current device {@link android.content.res.Configuration}
1916 * (orientation, locale, etc) has changed. When such a change happens, the
1917 * UIs (view hierarchy) will need to be rebuilt based on this new
1918 * information; for the most part, applications don't need to worry about
1919 * this, because the system will take care of stopping and restarting the
1920 * application to make sure it sees the new changes. Some system code that
1921 * can not be restarted will need to watch for this action and handle it
1922 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001923 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001924 * <p class="note">
1925 * You can <em>not</em> receive this through components declared
1926 * in manifests, only by explicitly registering for it with
1927 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1928 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001929 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001930 * <p class="note">This is a protected intent that can only be sent
1931 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001932 *
1933 * @see android.content.res.Configuration
1934 */
1935 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1936 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1937 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001938 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001939 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001940 * <p class="note">This is a protected intent that can only be sent
1941 * by the system.
1942 */
1943 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1944 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1945 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001946 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1947 * charging state, level, and other information about the battery.
1948 * See {@link android.os.BatteryManager} for documentation on the
1949 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001950 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001951 * <p class="note">
1952 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001953 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001954 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001955 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1956 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1957 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1958 * broadcasts that are sent and can be received through manifest
1959 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001960 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001961 * <p class="note">This is a protected intent that can only be sent
1962 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001963 */
1964 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1965 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1966 /**
1967 * Broadcast Action: Indicates low battery condition on the device.
1968 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001969 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001970 * <p class="note">This is a protected intent that can only be sent
1971 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001972 */
1973 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1974 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1975 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001976 * Broadcast Action: Indicates the battery is now okay after being low.
1977 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1978 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001979 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001980 * <p class="note">This is a protected intent that can only be sent
1981 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001982 */
1983 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1984 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1985 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001986 * Broadcast Action: External power has been connected to the device.
1987 * This is intended for applications that wish to register specifically to this notification.
1988 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1989 * stay active to receive this notification. This action can be used to implement actions
1990 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001991 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001992 * <p class="note">This is a protected intent that can only be sent
1993 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001994 */
1995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001996 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001997 /**
1998 * Broadcast Action: External power has been removed from the device.
1999 * This is intended for applications that wish to register specifically to this notification.
2000 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2001 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002002 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002003 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002004 * <p class="note">This is a protected intent that can only be sent
2005 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002006 */
2007 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002008 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002009 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002010 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002011 * Broadcast Action: Device is shutting down.
2012 * This is broadcast when the device is being shut down (completely turned
2013 * off, not sleeping). Once the broadcast is complete, the final shutdown
2014 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002015 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002016 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002017 * <p class="note">This is a protected intent that can only be sent
2018 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002019 * <p>May include the following extras:
2020 * <ul>
2021 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2022 * shutdown is only for userspace processes. If not set, assumed to be false.
2023 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002024 */
2025 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002026 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002027 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002028 * Activity Action: Start this activity to request system shutdown.
2029 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2030 * to request confirmation from the user before shutting down.
2031 *
2032 * <p class="note">This is a protected intent that can only be sent
2033 * by the system.
2034 *
2035 * {@hide}
2036 */
2037 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2038 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002039 * Broadcast Action: A sticky broadcast that indicates low memory
2040 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002041 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002042 * <p class="note">This is a protected intent that can only be sent
2043 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002044 */
2045 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2046 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2047 /**
2048 * Broadcast Action: Indicates low memory condition on the device no longer exists
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_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2055 /**
Jake Hambybb371632010-08-23 18:16:48 -07002056 * Broadcast Action: A sticky broadcast that indicates a memory full
2057 * condition on the device. This is intended for activities that want
2058 * to be able to fill the data partition completely, leaving only
2059 * enough free space to prevent system-wide SQLite failures.
2060 *
2061 * <p class="note">This is a protected intent that can only be sent
2062 * by the system.
2063 *
2064 * {@hide}
2065 */
2066 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2067 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2068 /**
2069 * Broadcast Action: Indicates memory full condition on the device
2070 * no longer exists.
2071 *
2072 * <p class="note">This is a protected intent that can only be sent
2073 * by the system.
2074 *
2075 * {@hide}
2076 */
2077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2078 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2079 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002080 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2081 * and package management should be started.
2082 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2083 * notification.
2084 */
2085 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2086 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2087 /**
2088 * Broadcast Action: The device has entered USB Mass Storage mode.
2089 * This is used mainly for the USB Settings panel.
2090 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2091 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002092 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002093 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002094 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002095 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2096
2097 /**
2098 * Broadcast Action: The device has exited USB Mass Storage mode.
2099 * This is used mainly for the USB Settings panel.
2100 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2101 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002102 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002103 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002104 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002105 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2106
2107 /**
2108 * Broadcast Action: External media has been removed.
2109 * The path to the mount point for the removed media is contained in the Intent.mData field.
2110 */
2111 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2112 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2113
2114 /**
2115 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002116 * 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 -07002117 */
2118 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2119 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2120
2121 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002122 * Broadcast Action: External media is present, and being disk-checked
2123 * 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 -08002124 */
2125 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2126 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2127
2128 /**
2129 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2130 * 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 -08002131 */
2132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2133 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2134
2135 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002136 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002137 * 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 -07002138 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2139 * media was mounted read only.
2140 */
2141 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2142 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2143
2144 /**
2145 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002146 * 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 -07002147 */
2148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2149 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2150
2151 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002152 * Broadcast Action: External media is no longer being shared via USB mass storage.
2153 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2154 *
2155 * @hide
2156 */
2157 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2158
2159 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002160 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2161 * The path to the mount point for the removed media is contained in the Intent.mData field.
2162 */
2163 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2164 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2165
2166 /**
2167 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002168 * 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 -07002169 */
2170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2171 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2172
2173 /**
2174 * Broadcast Action: User has expressed the desire to remove the external storage media.
2175 * Applications should close all files they have open within the mount point when they receive this intent.
2176 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2177 */
2178 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2179 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2180
2181 /**
2182 * Broadcast Action: The media scanner has started scanning a directory.
2183 * The path to the directory being scanned is contained in the Intent.mData field.
2184 */
2185 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2186 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2187
2188 /**
2189 * Broadcast Action: The media scanner has finished scanning a directory.
2190 * The path to the scanned directory is contained in the Intent.mData field.
2191 */
2192 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2193 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2194
2195 /**
2196 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2197 * The path to the file is contained in the Intent.mData field.
2198 */
2199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2200 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2201
2202 /**
2203 * Broadcast Action: The "Media Button" was pressed. Includes a single
2204 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2205 * caused the broadcast.
2206 */
2207 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2208 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2209
2210 /**
2211 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2212 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2213 * caused the broadcast.
2214 */
2215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2216 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2217
2218 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2219 // location; they are not general-purpose actions.
2220
2221 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002222 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002223 */
2224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2225 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2226 "android.intent.action.GTALK_CONNECTED";
2227
2228 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002229 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002230 */
2231 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2232 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2233 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002234
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002235 /**
2236 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002237 */
2238 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2239 public static final String ACTION_INPUT_METHOD_CHANGED =
2240 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002241
2242 /**
2243 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2244 * more radios have been turned off or on. The intent will have the following extra value:</p>
2245 * <ul>
2246 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2247 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2248 * turned off</li>
2249 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002250 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002251 * <p class="note">This is a protected intent that can only be sent
2252 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002253 */
2254 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2255 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2256
2257 /**
2258 * Broadcast Action: Some content providers have parts of their namespace
2259 * where they publish new events or items that the user may be especially
2260 * interested in. For these things, they may broadcast this action when the
2261 * set of interesting items change.
2262 *
2263 * For example, GmailProvider sends this notification when the set of unread
2264 * mail in the inbox changes.
2265 *
2266 * <p>The data of the intent identifies which part of which provider
2267 * changed. When queried through the content resolver, the data URI will
2268 * return the data set in question.
2269 *
2270 * <p>The intent will have the following extra values:
2271 * <ul>
2272 * <li><em>count</em> - The number of items in the data set. This is the
2273 * same as the number of items in the cursor returned by querying the
2274 * data URI. </li>
2275 * </ul>
2276 *
2277 * This intent will be sent at boot (if the count is non-zero) and when the
2278 * data set changes. It is possible for the data set to change without the
2279 * count changing (for example, if a new unread message arrives in the same
2280 * sync operation in which a message is archived). The phone should still
2281 * ring/vibrate/etc as normal in this case.
2282 */
2283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2284 public static final String ACTION_PROVIDER_CHANGED =
2285 "android.intent.action.PROVIDER_CHANGED";
2286
2287 /**
2288 * Broadcast Action: Wired Headset plugged in or unplugged.
2289 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002290 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2291 * and documentation.
2292 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002293 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002294 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002295 */
2296 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002297 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002298
2299 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002300 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2301 * <ul>
2302 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2303 * </ul>
2304 *
2305 * <p class="note">This is a protected intent that can only be sent
2306 * by the system.
2307 *
2308 * @hide
2309 */
2310 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2311 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2312 = "android.intent.action.ADVANCED_SETTINGS";
2313
2314 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002315 * Broadcast Action: Sent after application restrictions are changed.
2316 *
2317 * <p class="note">This is a protected intent that can only be sent
2318 * by the system.</p>
2319 */
2320 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2321 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2322 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2323
2324 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002325 * Broadcast Action: An outgoing call is about to be placed.
2326 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002327 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002328 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002329 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002330 * the phone number originally intended to be dialed.</li>
2331 * </ul>
2332 * <p>Once the broadcast is finished, the resultData is used as the actual
2333 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002334 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002335 * outgoing call in turn: for example, a parental control application
2336 * might verify that the user is authorized to place the call at that
2337 * time, then a number-rewriting application might add an area code if
2338 * one was not specified.</p>
2339 * <p>For consistency, any receiver whose purpose is to prohibit phone
2340 * calls should have a priority of 0, to ensure it will see the final
2341 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002342 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002343 * should have a positive priority.
2344 * Negative priorities are reserved for the system for this broadcast;
2345 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002346 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2347 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002348 * <p>Emergency calls cannot be intercepted using this mechanism, and
2349 * other calls cannot be modified to call emergency numbers using this
2350 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002351 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2352 * call to use their own service instead. Those apps should first prevent
2353 * the call from being placed by setting resultData to <code>null</code>
2354 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002355 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002356 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2357 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002358 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002359 * <p class="note">This is a protected intent that can only be sent
2360 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002361 */
2362 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2363 public static final String ACTION_NEW_OUTGOING_CALL =
2364 "android.intent.action.NEW_OUTGOING_CALL";
2365
2366 /**
2367 * Broadcast Action: Have the device reboot. This is only for use by
2368 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002369 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002370 * <p class="note">This is a protected intent that can only be sent
2371 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002372 */
2373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2374 public static final String ACTION_REBOOT =
2375 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002376
Wei Huang97ecc9c2009-05-11 17:44:20 -07002377 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002378 * Broadcast Action: A sticky broadcast for changes in the physical
2379 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002380 *
2381 * <p>The intent will have the following extra values:
2382 * <ul>
2383 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002384 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002385 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002386 * <p>This is intended for monitoring the current physical dock state.
2387 * See {@link android.app.UiModeManager} for the normal API dealing with
2388 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002389 */
2390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2391 public static final String ACTION_DOCK_EVENT =
2392 "android.intent.action.DOCK_EVENT";
2393
2394 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002395 * Broadcast Action: A broadcast when idle maintenance can be started.
2396 * This means that the user is not interacting with the device and is
2397 * not expected to do so soon. Typical use of the idle maintenance is
2398 * to perform somehow expensive tasks that can be postponed at a moment
2399 * when they will not degrade user experience.
2400 * <p>
2401 * <p class="note">In order to keep the device responsive in case of an
2402 * unexpected user interaction, implementations of a maintenance task
2403 * should be interruptible. In such a scenario a broadcast with action
2404 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2405 * should not do the maintenance work in
2406 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2407 * maintenance service by {@link Context#startService(Intent)}. Also
2408 * you should hold a wake lock while your maintenance service is running
2409 * to prevent the device going to sleep.
2410 * </p>
2411 * <p>
2412 * <p class="note">This is a protected intent that can only be sent by
2413 * the system.
2414 * </p>
2415 *
2416 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002417 *
2418 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002419 */
2420 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2421 public static final String ACTION_IDLE_MAINTENANCE_START =
2422 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2423
2424 /**
2425 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2426 * This means that the user was not interacting with the device as a result
2427 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2428 * was sent and now the user started interacting with the device. Typical
2429 * use of the idle maintenance is to perform somehow expensive tasks that
2430 * can be postponed at a moment when they will not degrade user experience.
2431 * <p>
2432 * <p class="note">In order to keep the device responsive in case of an
2433 * unexpected user interaction, implementations of a maintenance task
2434 * should be interruptible. Hence, on receiving a broadcast with this
2435 * action, the maintenance task should be interrupted as soon as possible.
2436 * In other words, you should not do the maintenance work in
2437 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2438 * maintenance service that was started on receiving of
2439 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2440 * lock you acquired when your maintenance service started.
2441 * </p>
2442 * <p class="note">This is a protected intent that can only be sent
2443 * by the system.
2444 *
2445 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002446 *
2447 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002448 */
2449 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2450 public static final String ACTION_IDLE_MAINTENANCE_END =
2451 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2452
2453 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002454 * Broadcast Action: a remote intent is to be broadcasted.
2455 *
2456 * A remote intent is used for remote RPC between devices. The remote intent
2457 * is serialized and sent from one device to another device. The receiving
2458 * device parses the remote intent and broadcasts it. Note that anyone can
2459 * broadcast a remote intent. However, if the intent receiver of the remote intent
2460 * does not trust intent broadcasts from arbitrary intent senders, it should require
2461 * the sender to hold certain permissions so only trusted sender's broadcast will be
2462 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002463 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002464 */
2465 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002466 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002467
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002468 /**
2469 * Broadcast Action: hook for permforming cleanup after a system update.
2470 *
2471 * The broadcast is sent when the system is booting, before the
2472 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2473 * image. A receiver for this should do its work and then disable itself
2474 * so that it does not get run again at the next boot.
2475 * @hide
2476 */
2477 public static final String ACTION_PRE_BOOT_COMPLETED =
2478 "android.intent.action.PRE_BOOT_COMPLETED";
2479
Amith Yamasani13593602012-03-22 16:16:17 -07002480 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002481 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002482 * on restricted users. The broadcast intent contains an extra
2483 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2484 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2485 * String[] depending on the restriction type.<p/>
2486 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002487 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2488 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2489 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002490 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2491 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002492 * @see RestrictionEntry
2493 */
2494 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2495 "android.intent.action.GET_RESTRICTION_ENTRIES";
2496
2497 /**
Amith Yamasanid304af62013-09-05 09:30:23 -07002498 * @hide
Amith Yamasani655d0e22013-06-12 14:19:10 -07002499 * Activity to challenge the user for a PIN that was configured when setting up
Amith Yamasanid304af62013-09-05 09:30:23 -07002500 * restrictions. Restrictions include blocking of apps and preventing certain user operations,
2501 * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle).
2502 * Launch the activity using
Amith Yamasani655d0e22013-06-12 14:19:10 -07002503 * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the
2504 * result is {@link android.app.Activity#RESULT_OK} for a successful response to the
2505 * challenge.<p/>
2506 * Before launching this activity, make sure that there is a PIN in effect, by calling
Amith Yamasanid304af62013-09-05 09:30:23 -07002507 * {@link android.os.UserManager#hasRestrictionsChallenge()}.
Amith Yamasani655d0e22013-06-12 14:19:10 -07002508 */
Amith Yamasanid304af62013-09-05 09:30:23 -07002509 public static final String ACTION_RESTRICTIONS_CHALLENGE =
2510 "android.intent.action.RESTRICTIONS_CHALLENGE";
Amith Yamasani655d0e22013-06-12 14:19:10 -07002511
2512 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002513 * Sent the first time a user is starting, to allow system apps to
2514 * perform one time initialization. (This will not be seen by third
2515 * party applications because a newly initialized user does not have any
2516 * third party applications installed for it.) This is sent early in
2517 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002518 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2519 * broadcast, since it is part of a visible user interaction; be as quick
2520 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002521 */
2522 public static final String ACTION_USER_INITIALIZE =
2523 "android.intent.action.USER_INITIALIZE";
2524
2525 /**
2526 * Sent when a user switch is happening, causing the process's user to be
2527 * brought to the foreground. This is only sent to receivers registered
2528 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2529 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002530 * foreground. This is sent as a foreground
2531 * broadcast, since it is part of a visible user interaction; be as quick
2532 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002533 */
2534 public static final String ACTION_USER_FOREGROUND =
2535 "android.intent.action.USER_FOREGROUND";
2536
2537 /**
2538 * Sent when a user switch is happening, causing the process's user to be
2539 * sent to the background. This is only sent to receivers registered
2540 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2541 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002542 * background. This is sent as a foreground
2543 * broadcast, since it is part of a visible user interaction; be as quick
2544 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002545 */
2546 public static final String ACTION_USER_BACKGROUND =
2547 "android.intent.action.USER_BACKGROUND";
2548
2549 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002550 * Broadcast sent to the system when a user is added. Carries an extra
2551 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2552 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002553 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002554 * @hide
2555 */
2556 public static final String ACTION_USER_ADDED =
2557 "android.intent.action.USER_ADDED";
2558
2559 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002560 * Broadcast sent by the system when a user is started. Carries an extra
2561 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002562 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002563 * that has been started. This is sent as a foreground
2564 * broadcast, since it is part of a visible user interaction; be as quick
2565 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002566 * @hide
2567 */
2568 public static final String ACTION_USER_STARTED =
2569 "android.intent.action.USER_STARTED";
2570
2571 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002572 * Broadcast sent when a user is in the process of starting. Carries an extra
2573 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2574 * sent to registered receivers, not manifest receivers. It is sent to all
2575 * users (including the one that is being started). You must hold
2576 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2577 * this broadcast. This is sent as a background broadcast, since
2578 * its result is not part of the primary UX flow; to safely keep track of
2579 * started/stopped state of a user you can use this in conjunction with
2580 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2581 * other user state broadcasts since those are foreground broadcasts so can
2582 * execute in a different order.
2583 * @hide
2584 */
2585 public static final String ACTION_USER_STARTING =
2586 "android.intent.action.USER_STARTING";
2587
2588 /**
2589 * Broadcast sent when a user is going to be stopped. Carries an extra
2590 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2591 * sent to registered receivers, not manifest receivers. It is sent to all
2592 * users (including the one that is being stopped). You must hold
2593 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2594 * this broadcast. The user will not stop until all receivers have
2595 * handled the broadcast. This is sent as a background broadcast, since
2596 * its result is not part of the primary UX flow; to safely keep track of
2597 * started/stopped state of a user you can use this in conjunction with
2598 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2599 * other user state broadcasts since those are foreground broadcasts so can
2600 * execute in a different order.
2601 * @hide
2602 */
2603 public static final String ACTION_USER_STOPPING =
2604 "android.intent.action.USER_STOPPING";
2605
2606 /**
2607 * Broadcast sent to the system when a user is stopped. Carries an extra
2608 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2609 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2610 * specific package. This is only sent to registered receivers, not manifest
2611 * receivers. It is sent to all running users <em>except</em> the one that
2612 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002613 * @hide
2614 */
2615 public static final String ACTION_USER_STOPPED =
2616 "android.intent.action.USER_STOPPED";
2617
2618 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002619 * 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 -07002620 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002621 * one that has been removed. The user will not be completely removed until all receivers have
2622 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002623 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002624 * @hide
2625 */
2626 public static final String ACTION_USER_REMOVED =
2627 "android.intent.action.USER_REMOVED";
2628
2629 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002630 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002631 * the userHandle of the user to become the current one. This is only sent to
2632 * registered receivers, not manifest receivers. It is sent to all running users.
2633 * You must hold
2634 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002635 * @hide
2636 */
2637 public static final String ACTION_USER_SWITCHED =
2638 "android.intent.action.USER_SWITCHED";
2639
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002640 /**
2641 * Broadcast sent to the system when a user's information changes. Carries an extra
2642 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002643 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002644 * @hide
2645 */
2646 public static final String ACTION_USER_INFO_CHANGED =
2647 "android.intent.action.USER_INFO_CHANGED";
2648
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002649 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002650 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2651 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002652 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2653 * that need to display merged content across both primary and managed profiles need to
2654 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002655 * not manifest receivers.
2656 */
2657 public static final String ACTION_MANAGED_PROFILE_ADDED =
2658 "android.intent.action.MANAGED_PROFILE_ADDED";
2659
2660 /**
2661 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002662 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2663 * Only applications (for example Launchers) that need to display merged content across both
2664 * primary and managed profiles need to worry about this broadcast. This is only sent to
2665 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002666 */
2667 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2668 "android.intent.action.MANAGED_PROFILE_REMOVED";
2669
2670 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002671 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2672 */
2673 public static final String ACTION_QUICK_CLOCK =
2674 "android.intent.action.QUICK_CLOCK";
2675
Michael Wright0087a142013-02-05 16:29:39 -08002676 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002677 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002678 * @hide
2679 */
2680 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2681 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2682
Justin Kohd378ad72013-04-01 12:18:26 -07002683 /**
2684 * Broadcast Action: A global button was pressed. Includes a single
2685 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2686 * caused the broadcast.
2687 * @hide
2688 */
2689 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2690
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002691 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002692 * Activity Action: Allow the user to select and return one or more existing
2693 * documents. When invoked, the system will display the various
2694 * {@link DocumentsProvider} instances installed on the device, letting the
2695 * user interactively navigate through them. These documents include local
2696 * media, such as photos and video, and documents provided by installed
2697 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002698 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002699 * Each document is represented as a {@code content://} URI backed by a
2700 * {@link DocumentsProvider}, which can be opened as a stream with
2701 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2702 * {@link android.provider.DocumentsContract.Document} metadata.
2703 * <p>
2704 * All selected documents are returned to the calling application with
2705 * persistable read and write permission grants. If you want to maintain
2706 * access to the documents across device reboots, you need to explicitly
2707 * take the persistable permissions using
2708 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2709 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002710 * Callers must indicate the acceptable document MIME types through
2711 * {@link #setType(String)}. For example, to select photos, use
2712 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2713 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2714 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002715 * <p>
2716 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002717 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2718 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002719 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002720 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2721 * returned URIs can be opened with
2722 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002723 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002724 * Output: The URI of the item that was picked, returned in
2725 * {@link #getData()}. This must be a {@code content://} URI so that any
2726 * receiver can access it. If multiple documents were selected, they are
2727 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002728 *
2729 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002730 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002731 * @see #ACTION_CREATE_DOCUMENT
2732 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002733 */
2734 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2735 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2736
2737 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002738 * Activity Action: Allow the user to create a new document. When invoked,
2739 * the system will display the various {@link DocumentsProvider} instances
2740 * installed on the device, letting the user navigate through them. The
2741 * returned document may be a newly created document with no content, or it
2742 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002743 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002744 * Each document is represented as a {@code content://} URI backed by a
2745 * {@link DocumentsProvider}, which can be opened as a stream with
2746 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2747 * {@link android.provider.DocumentsContract.Document} metadata.
2748 * <p>
2749 * Callers must indicate the concrete MIME type of the document being
2750 * created by setting {@link #setType(String)}. This MIME type cannot be
2751 * changed after the document is created.
2752 * <p>
2753 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2754 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002755 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002756 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2757 * returned URIs can be opened with
2758 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002759 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002760 * Output: The URI of the item that was created. This must be a
2761 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002762 *
2763 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002764 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002765 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002766 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002767 */
2768 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2769 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2770
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002771 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002772 * Activity Action: Allow the user to pick a directory subtree. When
2773 * invoked, the system will display the various {@link DocumentsProvider}
2774 * instances installed on the device, letting the user navigate through
2775 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002776 * <p>
2777 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002778 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2779 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2780 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002781 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002782 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002783 *
2784 * @see DocumentsContract
2785 */
2786 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002787 public static final String
2788 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002789
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002790 /** {@hide} */
2791 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2792
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002793 // ---------------------------------------------------------------------
2794 // ---------------------------------------------------------------------
2795 // Standard intent categories (see addCategory()).
2796
2797 /**
2798 * Set if the activity should be an option for the default action
2799 * (center press) to perform on a piece of data. Setting this will
2800 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002801 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002802 * Intent when initiating an action -- it is for use in intent filters
2803 * specified in packages.
2804 */
2805 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2806 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2807 /**
2808 * Activities that can be safely invoked from a browser must support this
2809 * category. For example, if the user is viewing a web page or an e-mail
2810 * and clicks on a link in the text, the Intent generated execute that
2811 * link will require the BROWSABLE category, so that only activities
2812 * supporting this category will be considered as possible actions. By
2813 * supporting this category, you are promising that there is nothing
2814 * damaging (without user intervention) that can happen by invoking any
2815 * matching Intent.
2816 */
2817 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2818 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2819 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002820 * Categories for activities that can participate in voice interaction.
2821 * An activity that supports this category must be prepared to run with
2822 * no UI shown at all (though in some case it may have a UI shown), and
2823 * rely on {@link android.app.VoiceInteractor} to interact with the user.
2824 */
2825 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2826 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
2827 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002828 * Set if the activity should be considered as an alternative action to
2829 * the data the user is currently viewing. See also
2830 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2831 * applies to the selection in a list of items.
2832 *
2833 * <p>Supporting this category means that you would like your activity to be
2834 * displayed in the set of alternative things the user can do, usually as
2835 * part of the current activity's options menu. You will usually want to
2836 * include a specific label in the &lt;intent-filter&gt; of this action
2837 * describing to the user what it does.
2838 *
2839 * <p>The action of IntentFilter with this category is important in that it
2840 * describes the specific action the target will perform. This generally
2841 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2842 * a specific name such as "com.android.camera.action.CROP. Only one
2843 * alternative of any particular action will be shown to the user, so using
2844 * a specific action like this makes sure that your alternative will be
2845 * displayed while also allowing other applications to provide their own
2846 * overrides of that particular action.
2847 */
2848 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2849 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2850 /**
2851 * Set if the activity should be considered as an alternative selection
2852 * action to the data the user has currently selected. This is like
2853 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2854 * of items from which the user can select, giving them alternatives to the
2855 * default action that will be performed on it.
2856 */
2857 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2858 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2859 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002860 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002861 */
2862 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2863 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2864 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002865 * Should be displayed in the top-level launcher.
2866 */
2867 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2868 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2869 /**
Jose Lima38b75b62014-03-11 10:41:39 -07002870 * Indicates an activity optimized for Leanback mode, and that should
2871 * be displayed in the Leanback launcher.
2872 */
2873 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2874 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
2875 /**
Jose Lima73915cf2014-07-29 17:16:31 -07002876 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
2877 * @hide
2878 */
2879 @SystemApi
2880 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
2881 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002882 * Provides information about the package it is in; typically used if
2883 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2884 * a front-door to the user without having to be shown in the all apps list.
2885 */
2886 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2887 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2888 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002889 * This is the home activity, that is the first activity that is displayed
2890 * when the device boots.
2891 */
2892 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2893 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2894 /**
2895 * This activity is a preference panel.
2896 */
2897 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2898 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2899 /**
2900 * This activity is a development preference panel.
2901 */
2902 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2903 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2904 /**
2905 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002906 */
2907 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2908 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2909 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002910 * This activity allows the user to browse and download new applications.
2911 */
2912 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2913 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2914 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002915 * This activity may be exercised by the monkey or other automated test tools.
2916 */
2917 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2918 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2919 /**
2920 * To be used as a test (not part of the normal user experience).
2921 */
2922 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2923 /**
2924 * To be used as a unit test (run through the Test Harness).
2925 */
2926 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2927 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002928 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002929 * experience).
2930 */
2931 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002932
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002933 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002934 * Used to indicate that an intent only wants URIs that can be opened with
2935 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
2936 * must support at least the columns defined in {@link OpenableColumns} when
2937 * queried.
2938 *
2939 * @see #ACTION_GET_CONTENT
2940 * @see #ACTION_OPEN_DOCUMENT
2941 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002942 */
2943 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2944 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2945
2946 /**
2947 * To be used as code under test for framework instrumentation tests.
2948 */
2949 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2950 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002951 /**
2952 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002953 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2954 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002955 */
2956 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2957 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2958 /**
2959 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002960 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2961 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002962 */
2963 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2964 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002965 /**
2966 * An activity to run when device is inserted into a analog (low end) dock.
2967 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2968 * information, see {@link android.app.UiModeManager}.
2969 */
2970 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2971 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2972
2973 /**
2974 * An activity to run when device is inserted into a digital (high end) dock.
2975 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2976 * information, see {@link android.app.UiModeManager}.
2977 */
2978 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2979 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002980
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002981 /**
2982 * Used to indicate that the activity can be used in a car environment.
2983 */
2984 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2985 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2986
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002987 // ---------------------------------------------------------------------
2988 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08002989 // Application launch intent categories (see addCategory()).
2990
2991 /**
2992 * Used with {@link #ACTION_MAIN} to launch the browser application.
2993 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002994 * <p>NOTE: This should not be used as the primary key of an Intent,
2995 * since it will not result in the app launching with the correct
2996 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002997 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002998 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002999 */
3000 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3001 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3002
3003 /**
3004 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3005 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003006 * <p>NOTE: This should not be used as the primary key of an Intent,
3007 * since it will not result in the app launching with the correct
3008 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003009 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003010 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003011 */
3012 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3013 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3014
3015 /**
3016 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3017 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003018 * <p>NOTE: This should not be used as the primary key of an Intent,
3019 * since it will not result in the app launching with the correct
3020 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003021 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003022 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003023 */
3024 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3025 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3026
3027 /**
3028 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3029 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003030 * <p>NOTE: This should not be used as the primary key of an Intent,
3031 * since it will not result in the app launching with the correct
3032 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003033 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003034 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003035 */
3036 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3037 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3038
3039 /**
3040 * Used with {@link #ACTION_MAIN} to launch the email application.
3041 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003042 * <p>NOTE: This should not be used as the primary key of an Intent,
3043 * since it will not result in the app launching with the correct
3044 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003045 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003046 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003047 */
3048 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3049 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3050
3051 /**
3052 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3053 * The activity should be able to view and manipulate image and video files
3054 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003055 * <p>NOTE: This should not be used as the primary key of an Intent,
3056 * since it will not result in the app launching with the correct
3057 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003058 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003059 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003060 */
3061 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3062 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3063
3064 /**
3065 * Used with {@link #ACTION_MAIN} to launch the maps application.
3066 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003067 * <p>NOTE: This should not be used as the primary key of an Intent,
3068 * since it will not result in the app launching with the correct
3069 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003070 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003071 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003072 */
3073 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3074 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3075
3076 /**
3077 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3078 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003079 * <p>NOTE: This should not be used as the primary key of an Intent,
3080 * since it will not result in the app launching with the correct
3081 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003082 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003083 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003084 */
3085 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3086 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3087
3088 /**
3089 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003090 * The activity should be able to play, browse, or manipulate music files
3091 * stored on the device.
3092 * <p>NOTE: This should not be used as the primary key of an Intent,
3093 * since it will not result in the app launching with the correct
3094 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003095 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003096 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003097 */
3098 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3099 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3100
3101 // ---------------------------------------------------------------------
3102 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003103 // Standard extra data keys.
3104
3105 /**
3106 * The initial data to place in a newly created record. Use with
3107 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3108 * fields as would be given to the underlying ContentProvider.insert()
3109 * call.
3110 */
3111 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3112
3113 /**
3114 * A constant CharSequence that is associated with the Intent, used with
3115 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3116 * this may be a styled CharSequence, so you must use
3117 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3118 * retrieve it.
3119 */
3120 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3121
3122 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003123 * A constant String that is associated with the Intent, used with
3124 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3125 * as HTML formatted text. Note that you <em>must</em> also supply
3126 * {@link #EXTRA_TEXT}.
3127 */
3128 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3129
3130 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003131 * A content: URI holding a stream of data associated with the Intent,
3132 * used with {@link #ACTION_SEND} to supply the data being sent.
3133 */
3134 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3135
3136 /**
3137 * A String[] holding e-mail addresses that should be delivered to.
3138 */
3139 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3140
3141 /**
3142 * A String[] holding e-mail addresses that should be carbon copied.
3143 */
3144 public static final String EXTRA_CC = "android.intent.extra.CC";
3145
3146 /**
3147 * A String[] holding e-mail addresses that should be blind carbon copied.
3148 */
3149 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3150
3151 /**
3152 * A constant string holding the desired subject line of a message.
3153 */
3154 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3155
3156 /**
3157 * An Intent describing the choices you would like shown with
3158 * {@link #ACTION_PICK_ACTIVITY}.
3159 */
3160 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3161
3162 /**
3163 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003164 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003165 */
3166 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3167
3168 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003169 * A Parcelable[] of {@link Intent} or
3170 * {@link android.content.pm.LabeledIntent} objects as set with
3171 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3172 * a the front of the list of choices, when shown to the user with a
3173 * {@link #ACTION_CHOOSER}.
3174 */
3175 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3176
3177 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003178 * A Bundle forming a mapping of potential target package names to different extras Bundles
3179 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3180 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3181 * be currently installed on the device.
3182 *
3183 * <p>An application may choose to provide alternate extras for the case where a user
3184 * selects an activity from a predetermined set of target packages. If the activity
3185 * the user selects from the chooser belongs to a package with its package name as
3186 * a key in this bundle, the corresponding extras for that package will be merged with
3187 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3188 * extra has the same key as an extra already present in the intent it will overwrite
3189 * the extra from the intent.</p>
3190 *
3191 * <p><em>Examples:</em>
3192 * <ul>
3193 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3194 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3195 * parameters for that target.</li>
3196 * <li>An application may offer additional metadata for known targets of a given intent
3197 * to pass along information only relevant to that target such as account or content
3198 * identifiers already known to that application.</li>
3199 * </ul></p>
3200 */
3201 public static final String EXTRA_REPLACEMENT_EXTRAS =
3202 "android.intent.extra.REPLACEMENT_EXTRAS";
3203
3204 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003205 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3206 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3207 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3208 * {@link ComponentName} of the chosen component.
3209 *
3210 * <p>In some situations this callback may never come, for example if the user abandons
3211 * the chooser, switches to another task or any number of other reasons. Apps should not
3212 * be written assuming that this callback will always occur.</p>
3213 */
3214 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3215 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3216
3217 /**
3218 * The {@link ComponentName} chosen by the user to complete an action.
3219 *
3220 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3221 */
3222 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3223
3224 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003225 * A {@link android.view.KeyEvent} object containing the event that
3226 * triggered the creation of the Intent it is in.
3227 */
3228 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3229
3230 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003231 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3232 * before shutting down.
3233 *
3234 * {@hide}
3235 */
3236 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3237
3238 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003239 * 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 -07003240 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3241 * of restarting the application.
3242 */
3243 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3244
3245 /**
3246 * A String holding the phone number originally entered in
3247 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3248 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3249 */
3250 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003251
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003252 /**
3253 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3254 * intents to supply the uid the package had been assigned. Also an optional
3255 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3256 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3257 * purpose.
3258 */
3259 public static final String EXTRA_UID = "android.intent.extra.UID";
3260
3261 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003262 * @hide String array of package names.
3263 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003264 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003265 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3266
3267 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003268 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3269 * intents to indicate whether this represents a full uninstall (removing
3270 * both the code and its data) or a partial uninstall (leaving its data,
3271 * implying that this is an update).
3272 */
3273 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003274
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003275 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003276 * @hide
3277 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3278 * intents to indicate that at this point the package has been removed for
3279 * all users on the device.
3280 */
3281 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3282 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3283
3284 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003285 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3286 * intents to indicate that this is a replacement of the package, so this
3287 * broadcast will immediately be followed by an add broadcast for a
3288 * different version of the same package.
3289 */
3290 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003291
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003292 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003293 * Used as an int extra field in {@link android.app.AlarmManager} intents
3294 * to tell the application being invoked how many pending alarms are being
3295 * delievered with the intent. For one-shot alarms this will always be 1.
3296 * For recurring alarms, this might be greater than 1 if the device was
3297 * asleep or powered off at the time an earlier alarm would have been
3298 * delivered.
3299 */
3300 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003301
Jacek Surazski86b6c532009-05-13 14:38:28 +02003302 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003303 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3304 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003305 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3306 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003307 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3308 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3309 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003310 */
3311 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3312
3313 /**
3314 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3315 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003316 */
3317 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3318
3319 /**
3320 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3321 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003322 */
3323 public static final int EXTRA_DOCK_STATE_DESK = 1;
3324
3325 /**
3326 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3327 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003328 */
3329 public static final int EXTRA_DOCK_STATE_CAR = 2;
3330
3331 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003332 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3333 * to represent that the phone is in a analog (low end) dock.
3334 */
3335 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3336
3337 /**
3338 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3339 * to represent that the phone is in a digital (high end) dock.
3340 */
3341 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3342
3343 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003344 * Boolean that can be supplied as meta-data with a dock activity, to
3345 * indicate that the dock should take over the home key when it is active.
3346 */
3347 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003348
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003349 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003350 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3351 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003352 */
3353 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3354
3355 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003356 * Used in the extra field in the remote intent. It's astring token passed with the
3357 * remote intent.
3358 */
3359 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3360 "android.intent.extra.remote_intent_token";
3361
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003362 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003363 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003364 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003365 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003366 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003367 "android.intent.extra.changed_component_name";
3368
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003369 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003370 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003371 * and contains a string array of all of the components that have changed. If
3372 * the state of the overall package has changed, then it will contain an entry
3373 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003374 */
3375 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3376 "android.intent.extra.changed_component_name_list";
3377
3378 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003379 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003380 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3381 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003382 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003383 */
3384 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3385 "android.intent.extra.changed_package_list";
3386
3387 /**
3388 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003389 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3390 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003391 * and contains an integer array of uids of all of the components
3392 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003393 */
3394 public static final String EXTRA_CHANGED_UID_LIST =
3395 "android.intent.extra.changed_uid_list";
3396
3397 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003398 * @hide
3399 * Magic extra system code can use when binding, to give a label for
3400 * who it is that has bound to a service. This is an integer giving
3401 * a framework string resource that can be displayed to the user.
3402 */
3403 public static final String EXTRA_CLIENT_LABEL =
3404 "android.intent.extra.client_label";
3405
3406 /**
3407 * @hide
3408 * Magic extra system code can use when binding, to give a PendingIntent object
3409 * that can be launched for the user to disable the system's use of this
3410 * service.
3411 */
3412 public static final String EXTRA_CLIENT_INTENT =
3413 "android.intent.extra.client_intent";
3414
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003415 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003416 * Extra used to indicate that an intent should only return data that is on
3417 * the local device. This is a boolean extra; the default is false. If true,
3418 * an implementation should only allow the user to select data that is
3419 * already on the device, not requiring it be downloaded from a remote
3420 * service when opened.
3421 *
3422 * @see #ACTION_GET_CONTENT
3423 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003424 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003425 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003426 */
3427 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003428 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003429
Amith Yamasani13593602012-03-22 16:16:17 -07003430 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003431 * Extra used to indicate that an intent can allow the user to select and
3432 * return multiple items. This is a boolean extra; the default is false. If
3433 * true, an implementation is allowed to present the user with a UI where
3434 * they can pick multiple items that are all returned to the caller. When
3435 * this happens, they should be returned as the {@link #getClipData()} part
3436 * of the result Intent.
3437 *
3438 * @see #ACTION_GET_CONTENT
3439 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003440 */
3441 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003442 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003443
3444 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003445 * The integer userHandle carried with broadcast intents related to addition, removal and
3446 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3447 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3448 *
Amith Yamasani13593602012-03-22 16:16:17 -07003449 * @hide
3450 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003451 public static final String EXTRA_USER_HANDLE =
3452 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003453
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003454 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003455 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3456 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3457 */
3458 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003459 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003460
3461 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003462 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003463 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3464 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003465 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003466 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3467
3468 /**
3469 * Extra sent in the intent to the BroadcastReceiver that handles
3470 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3471 * the restrictions as key/value pairs.
3472 */
3473 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3474 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003475
Amith Yamasani86118ba2013-03-28 14:33:16 -07003476 /**
3477 * Extra used in the response from a BroadcastReceiver that handles
3478 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3479 */
3480 public static final String EXTRA_RESTRICTIONS_INTENT =
3481 "android.intent.extra.restrictions_intent";
3482
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003483 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003484 * Extra used to communicate a set of acceptable MIME types. The type of the
3485 * extra is {@code String[]}. Values may be a combination of concrete MIME
3486 * types (such as "image/png") and/or partial MIME types (such as
3487 * "audio/*").
3488 *
3489 * @see #ACTION_GET_CONTENT
3490 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003491 */
3492 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3493
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003494 /**
3495 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3496 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003497 * When this is true, hardware devices can use this information to determine that
3498 * they shouldn't do a complete shutdown of their device since this is not a
3499 * complete shutdown down to the kernel, but only user space restarting.
3500 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003501 */
3502 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3503 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3504
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003505 /**
3506 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3507 * user has set their time format preferences to the 24 hour format.
3508 *
3509 * @hide for internal use only.
3510 */
3511 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3512 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3513
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003514 /** {@hide} */
3515 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3516
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003517 // ---------------------------------------------------------------------
3518 // ---------------------------------------------------------------------
3519 // Intent flags (see mFlags variable).
3520
Tor Norbyed9273d62013-05-30 15:59:53 -07003521 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003522 @IntDef(flag = true, value = {
3523 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3524 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003525 @Retention(RetentionPolicy.SOURCE)
3526 public @interface GrantUriMode {}
3527
Jeff Sharkey846318a2014-04-04 12:12:41 -07003528 /** @hide */
3529 @IntDef(flag = true, value = {
3530 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3531 @Retention(RetentionPolicy.SOURCE)
3532 public @interface AccessUriMode {}
3533
3534 /**
3535 * Test if given mode flags specify an access mode, which must be at least
3536 * read and/or write.
3537 *
3538 * @hide
3539 */
3540 public static boolean isAccessUriMode(int modeFlags) {
3541 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3542 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3543 }
3544
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003545 /**
3546 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003547 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003548 * specified in its ClipData. When applying to an Intent's ClipData,
3549 * all URIs as well as recursive traversals through data or other ClipData
3550 * in Intent items will be granted; only the grant flags of the top-level
3551 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003552 */
3553 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3554 /**
3555 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003556 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003557 * specified in its ClipData. When applying to an Intent's ClipData,
3558 * all URIs as well as recursive traversals through data or other ClipData
3559 * in Intent items will be granted; only the grant flags of the top-level
3560 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003561 */
3562 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3563 /**
3564 * Can be set by the caller to indicate that this Intent is coming from
3565 * a background operation, not from direct user interaction.
3566 */
3567 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3568 /**
3569 * A flag you can enable for debugging: when set, log messages will be
3570 * printed during the resolution of this intent to show you what has
3571 * been found to create the final resolved list.
3572 */
3573 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003574 /**
3575 * If set, this intent will not match any components in packages that
3576 * are currently stopped. If this is not set, then the default behavior
3577 * is to include such applications in the result.
3578 */
3579 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3580 /**
3581 * If set, this intent will always match any components in packages that
3582 * are currently stopped. This is the default behavior when
3583 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3584 * flags are set, this one wins (it allows overriding of exclude for
3585 * places where the framework may automatically set the exclude flag).
3586 */
3587 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003588
3589 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003590 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003591 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003592 * persisted across device reboots until explicitly revoked with
3593 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3594 * grant for possible persisting; the receiving application must call
3595 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3596 * actually persist.
3597 *
3598 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3599 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3600 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003601 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003602 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003603 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003604
3605 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003606 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3607 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3608 * applies to any URI that is a prefix match against the original granted
3609 * URI. (Without this flag, the URI must match exactly for access to be
3610 * granted.) Another URI is considered a prefix match only when scheme,
3611 * authority, and all path segments defined by the prefix are an exact
3612 * match.
3613 */
3614 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3615
3616 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003617 * If set, the new activity is not kept in the history stack. As soon as
3618 * the user navigates away from it, the activity is finished. This may also
3619 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3620 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003621 *
3622 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3623 * is never invoked when the current activity starts a new activity which
3624 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003625 */
3626 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3627 /**
3628 * If set, the activity will not be launched if it is already running
3629 * at the top of the history stack.
3630 */
3631 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3632 /**
3633 * If set, this activity will become the start of a new task on this
3634 * history stack. A task (from the activity that started it to the
3635 * next task activity) defines an atomic group of activities that the
3636 * user can move to. Tasks can be moved to the foreground and background;
3637 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003638 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003639 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3640 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003641 *
3642 * <p>This flag is generally used by activities that want
3643 * to present a "launcher" style behavior: they give the user a list of
3644 * separate things that can be done, which otherwise run completely
3645 * independently of the activity launching them.
3646 *
3647 * <p>When using this flag, if a task is already running for the activity
3648 * you are now starting, then a new activity will not be started; instead,
3649 * the current task will simply be brought to the front of the screen with
3650 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3651 * to disable this behavior.
3652 *
3653 * <p>This flag can not be used when the caller is requesting a result from
3654 * the activity being launched.
3655 */
3656 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3657 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003658 * This flag is used to create a new task and launch an activity into it.
3659 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3660 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3661 * search through existing tasks for ones matching this Intent. Only if no such
3662 * task is found would a new task be created. When paired with
3663 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3664 * the search for a matching task and unconditionally start a new task.
3665 *
3666 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3667 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003668 * top-level application launcher.</strong> Used in conjunction with
3669 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3670 * behavior of bringing an existing task to the foreground. When set,
3671 * a new task is <em>always</em> started to host the Activity for the
3672 * Intent, regardless of whether there is already an existing task running
3673 * the same thing.
3674 *
3675 * <p><strong>Because the default system does not include graphical task management,
3676 * you should not use this flag unless you provide some way for a user to
3677 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003678 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003679 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3680 * creating new document tasks.
3681 *
3682 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003683 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003684 *
Scott Main7aee61f2011-02-08 11:25:01 -08003685 * <p>See
3686 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3687 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003688 *
3689 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3690 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003691 */
3692 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3693 /**
3694 * If set, and the activity being launched is already running in the
3695 * current task, then instead of launching a new instance of that activity,
3696 * all of the other activities on top of it will be closed and this Intent
3697 * will be delivered to the (now on top) old activity as a new Intent.
3698 *
3699 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3700 * If D calls startActivity() with an Intent that resolves to the component
3701 * of activity B, then C and D will be finished and B receive the given
3702 * Intent, resulting in the stack now being: A, B.
3703 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003704 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003705 * either receive the new intent you are starting here in its
3706 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003707 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003708 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3709 * the same intent, then it will be finished and re-created; for all other
3710 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3711 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003712 *
3713 * <p>This launch mode can also be used to good effect in conjunction with
3714 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3715 * of a task, it will bring any currently running instance of that task
3716 * to the foreground, and then clear it to its root state. This is
3717 * especially useful, for example, when launching an activity from the
3718 * notification manager.
3719 *
Scott Main7aee61f2011-02-08 11:25:01 -08003720 * <p>See
3721 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3722 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003723 */
3724 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3725 /**
3726 * If set and this intent is being used to launch a new activity from an
3727 * existing one, then the reply target of the existing activity will be
3728 * transfered to the new activity. This way the new activity can call
3729 * {@link android.app.Activity#setResult} and have that result sent back to
3730 * the reply target of the original activity.
3731 */
3732 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3733 /**
3734 * If set and this intent is being used to launch a new activity from an
3735 * existing one, the current activity will not be counted as the top
3736 * activity for deciding whether the new intent should be delivered to
3737 * the top instead of starting a new one. The previous activity will
3738 * be used as the top, with the assumption being that the current activity
3739 * will finish itself immediately.
3740 */
3741 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3742 /**
3743 * If set, the new activity is not kept in the list of recently launched
3744 * activities.
3745 */
3746 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3747 /**
3748 * This flag is not normally set by application code, but set for you by
3749 * the system as described in the
3750 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3751 * launchMode} documentation for the singleTask mode.
3752 */
3753 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3754 /**
3755 * If set, and this activity is either being started in a new task or
3756 * bringing to the top an existing task, then it will be launched as
3757 * the front door of the task. This will result in the application of
3758 * any affinities needed to have that task in the proper state (either
3759 * moving activities to or from it), or simply resetting that task to
3760 * its initial state if needed.
3761 */
3762 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3763 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003764 * This flag is not normally set by application code, but set for you by
3765 * the system if this activity is being launched from history
3766 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003767 */
3768 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003769 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003770 * @deprecated As of API 21 this performs identically to
3771 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003772 */
3773 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003774 /**
Craig Mautner026596b2014-05-21 15:35:44 -07003775 * This flag is used to open a document into a new task rooted at the activity launched
3776 * by this Intent. Through the use of this flag, or its equivalent attribute,
3777 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00003778 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003779 *
Craig Mautner026596b2014-05-21 15:35:44 -07003780 * <p>The use of the activity attribute form of this,
3781 * {@link android.R.attr#documentLaunchMode}, is
3782 * preferred over the Intent flag described here. The attribute form allows the
3783 * Activity to specify multiple document behavior for all launchers of the Activity
3784 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003785 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07003786 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
3787 * it is kept after the activity is finished is different than the use of
3788 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
3789 * this flag is being used to create a new recents entry, then by default that entry
3790 * will be removed once the activity is finished. You can modify this behavior with
3791 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
3792 *
Craig Mautner026596b2014-05-21 15:35:44 -07003793 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
3794 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
3795 * equivalent of the Activity manifest specifying {@link
3796 * android.R.attr#documentLaunchMode}="intoExisting". When used with
3797 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
3798 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07003799 *
Craig Mautner026596b2014-05-21 15:35:44 -07003800 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003801 *
Craig Mautner026596b2014-05-21 15:35:44 -07003802 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07003803 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
3804 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003805 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07003806 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003807 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003808 * callback from occurring on the current frontmost activity before it is
3809 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07003810 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003811 * <p>Typically, an activity can rely on that callback to indicate that an
3812 * explicit user action has caused their activity to be moved out of the
3813 * foreground. The callback marks an appropriate point in the activity's
3814 * lifecycle for it to dismiss any notifications that it intends to display
3815 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07003816 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003817 * <p>If an activity is ever started via any non-user-driven events such as
3818 * phone-call receipt or an alarm handler, this flag should be passed to {@link
3819 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07003820 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003821 */
3822 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003823 /**
3824 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3825 * this flag will cause the launched activity to be brought to the front of its
3826 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07003827 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003828 * <p>For example, consider a task consisting of four activities: A, B, C, D.
3829 * If D calls startActivity() with an Intent that resolves to the component
3830 * of activity B, then B will be brought to the front of the history stack,
3831 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07003832 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003833 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07003834 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003835 */
3836 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003837 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003838 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3839 * this flag will prevent the system from applying an activity transition
3840 * animation to go to the next activity state. This doesn't mean an
3841 * animation will never run -- if another activity change happens that doesn't
3842 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003843 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003844 * when you are going to do a series of activity operations but the
3845 * animation seen by the user shouldn't be driven by the first activity
3846 * change but rather a later one.
3847 */
3848 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
3849 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003850 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3851 * this flag will cause any existing task that would be associated with the
3852 * activity to be cleared before the activity is started. That is, the activity
3853 * becomes the new root of an otherwise empty task, and any old activities
3854 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3855 */
3856 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
3857 /**
3858 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3859 * this flag will cause a newly launching task to be placed on top of the current
3860 * home activity task (if there is one). That is, pressing back from the task
3861 * will always return the user to home even if that was not the last activity they
3862 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3863 */
3864 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
3865 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07003866 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
3867 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07003868 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07003869 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07003870 * this flag. When set and the task's activity is finished, the recents
3871 * entry will remain in the interface for the user to re-launch it, like a
3872 * recents entry for a top-level application.
3873 * <p>
3874 * The receiving activity can override this request with
3875 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
3876 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07003877 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07003878 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07003879 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07003880
3881 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003882 * If set, when sending a broadcast only registered receivers will be
3883 * called -- no BroadcastReceiver components will be launched.
3884 */
3885 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003886 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003887 * If set, when sending a broadcast the new broadcast will replace
3888 * any existing pending broadcast that matches it. Matching is defined
3889 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
3890 * true for the intents of the two broadcasts. When a match is found,
3891 * the new broadcast (and receivers associated with it) will replace the
3892 * existing one in the pending broadcast list, remaining at the same
3893 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08003894 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003895 * <p>This flag is most typically used with sticky broadcasts, which
3896 * only care about delivering the most recent values of the broadcast
3897 * to their receivers.
3898 */
3899 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
3900 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08003901 * If set, when sending a broadcast the recipient is allowed to run at
3902 * foreground priority, with a shorter timeout interval. During normal
3903 * broadcasts the receivers are not automatically hoisted out of the
3904 * background priority class.
3905 */
3906 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
3907 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07003908 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
3909 * They can still propagate results through to later receivers, but they can not prevent
3910 * later receivers from seeing the broadcast.
3911 */
3912 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
3913 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003914 * If set, when sending a broadcast <i>before boot has completed</i> only
3915 * registered receivers will be called -- no BroadcastReceiver components
3916 * will be launched. Sticky intent state will be recorded properly even
3917 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
3918 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07003919 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003920 * <p>This flag is only for use by system sevices as a convenience to
3921 * avoid having to implement a more complex mechanism around detection
3922 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07003923 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003924 * @hide
3925 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003926 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003927 /**
3928 * Set when this broadcast is for a boot upgrade, a special mode that
3929 * allows the broadcast to be sent before the system is ready and launches
3930 * the app process with no providers running in it.
3931 * @hide
3932 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003933 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003934
Dianne Hackbornfa82f222009-09-17 15:14:12 -07003935 /**
3936 * @hide Flags that can't be changed with PendingIntent.
3937 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003938 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
3939 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3940 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08003941
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003942 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003943 // ---------------------------------------------------------------------
3944 // toUri() and parseUri() options.
3945
3946 /**
3947 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
3948 * always has the "intent:" scheme. This syntax can be used when you want
3949 * to later disambiguate between URIs that are intended to describe an
3950 * Intent vs. all others that should be treated as raw URIs. When used
3951 * with {@link #parseUri}, any other scheme will result in a generic
3952 * VIEW action for that raw URI.
3953 */
3954 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08003955
Dianne Hackborn85d558c2014-11-04 10:31:54 -08003956 /**
3957 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
3958 * always has the "android-app:" scheme. This is a variation of
3959 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
3960 * http/https URI being delivered to a specific package name. The format
3961 * is:
3962 *
3963 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08003964 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08003965 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08003966 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
3967 * you must also include a scheme; including a path also requires both a host and a scheme.
3968 * The final #Intent; fragment can be used without a scheme, host, or path.
3969 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08003970 * used with intents that have a {@link #setSelector}, since the base intent
3971 * will always have an explicit package name.</p>
3972 *
3973 * <p>Some examples of how this scheme maps to Intent objects:</p>
3974 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
3975 * <colgroup align="left" />
3976 * <colgroup align="left" />
3977 * <thead>
3978 * <tr><th>URI</th> <th>Intent</th></tr>
3979 * </thead>
3980 *
3981 * <tbody>
3982 * <tr><td><code>android-app://com.example.app</code></td>
3983 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
3984 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
3985 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
3986 * </table></td>
3987 * </tr>
3988 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
3989 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
3990 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
3991 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
3992 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
3993 * </table></td>
3994 * </tr>
3995 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
3996 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
3997 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
3998 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
3999 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4000 * </table></td>
4001 * </tr>
4002 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4003 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4004 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4005 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4006 * </table></td>
4007 * </tr>
4008 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4009 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4010 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4011 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4012 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4013 * </table></td>
4014 * </tr>
4015 * <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>
4016 * <td><table border="" style="margin:0" >
4017 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4018 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4019 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4020 * </table></td>
4021 * </tr>
4022 * </tbody>
4023 * </table>
4024 */
4025 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4026
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004027 /**
4028 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4029 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4030 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4031 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4032 * generated Intent can not cause unexpected data access to happen.
4033 *
4034 * <p>If you do not trust the source of the URI being parsed, you should still do further
4035 * processing to protect yourself from it. In particular, when using it to start an
4036 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4037 * that can handle it.</p>
4038 */
4039 public static final int URI_ALLOW_UNSAFE = 1<<2;
4040
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004041 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004042
4043 private String mAction;
4044 private Uri mData;
4045 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004046 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004047 private ComponentName mComponent;
4048 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004049 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004050 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004051 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004052 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004053 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004054 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004055
4056 // ---------------------------------------------------------------------
4057
4058 /**
4059 * Create an empty intent.
4060 */
4061 public Intent() {
4062 }
4063
4064 /**
4065 * Copy constructor.
4066 */
4067 public Intent(Intent o) {
4068 this.mAction = o.mAction;
4069 this.mData = o.mData;
4070 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004071 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004072 this.mComponent = o.mComponent;
4073 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004074 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004075 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004076 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004077 }
4078 if (o.mExtras != null) {
4079 this.mExtras = new Bundle(o.mExtras);
4080 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004081 if (o.mSourceBounds != null) {
4082 this.mSourceBounds = new Rect(o.mSourceBounds);
4083 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004084 if (o.mSelector != null) {
4085 this.mSelector = new Intent(o.mSelector);
4086 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004087 if (o.mClipData != null) {
4088 this.mClipData = new ClipData(o.mClipData);
4089 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004090 }
4091
4092 @Override
4093 public Object clone() {
4094 return new Intent(this);
4095 }
4096
4097 private Intent(Intent o, boolean all) {
4098 this.mAction = o.mAction;
4099 this.mData = o.mData;
4100 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004101 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004102 this.mComponent = o.mComponent;
4103 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004104 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004105 }
4106 }
4107
4108 /**
4109 * Make a clone of only the parts of the Intent that are relevant for
4110 * filter matching: the action, data, type, component, and categories.
4111 */
4112 public Intent cloneFilter() {
4113 return new Intent(this, false);
4114 }
4115
4116 /**
4117 * Create an intent with a given action. All other fields (data, type,
4118 * class) are null. Note that the action <em>must</em> be in a
4119 * namespace because Intents are used globally in the system -- for
4120 * example the system VIEW action is android.intent.action.VIEW; an
4121 * application's custom action would be something like
4122 * com.google.app.myapp.CUSTOM_ACTION.
4123 *
4124 * @param action The Intent action, such as ACTION_VIEW.
4125 */
4126 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004127 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004128 }
4129
4130 /**
4131 * Create an intent with a given action and for a given data url. Note
4132 * that the action <em>must</em> be in a namespace because Intents are
4133 * used globally in the system -- for example the system VIEW action is
4134 * android.intent.action.VIEW; an application's custom action would be
4135 * something like com.google.app.myapp.CUSTOM_ACTION.
4136 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004137 * <p><em>Note: scheme and host name matching in the Android framework is
4138 * case-sensitive, unlike the formal RFC. As a result,
4139 * you should always ensure that you write your Uri with these elements
4140 * using lower case letters, and normalize any Uris you receive from
4141 * outside of Android to ensure the scheme and host is lower case.</em></p>
4142 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004143 * @param action The Intent action, such as ACTION_VIEW.
4144 * @param uri The Intent data URI.
4145 */
4146 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004147 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004148 mData = uri;
4149 }
4150
4151 /**
4152 * Create an intent for a specific component. All other fields (action, data,
4153 * type, class) are null, though they can be modified later with explicit
4154 * calls. This provides a convenient way to create an intent that is
4155 * intended to execute a hard-coded class name, rather than relying on the
4156 * system to find an appropriate class for you; see {@link #setComponent}
4157 * for more information on the repercussions of this.
4158 *
4159 * @param packageContext A Context of the application package implementing
4160 * this class.
4161 * @param cls The component class that is to be used for the intent.
4162 *
4163 * @see #setClass
4164 * @see #setComponent
4165 * @see #Intent(String, android.net.Uri , Context, Class)
4166 */
4167 public Intent(Context packageContext, Class<?> cls) {
4168 mComponent = new ComponentName(packageContext, cls);
4169 }
4170
4171 /**
4172 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004173 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004174 * construct the Intent and then calling {@link #setClass} to set its
4175 * class.
4176 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004177 * <p><em>Note: scheme and host name matching in the Android framework is
4178 * case-sensitive, unlike the formal RFC. As a result,
4179 * you should always ensure that you write your Uri with these elements
4180 * using lower case letters, and normalize any Uris you receive from
4181 * outside of Android to ensure the scheme and host is lower case.</em></p>
4182 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004183 * @param action The Intent action, such as ACTION_VIEW.
4184 * @param uri The Intent data URI.
4185 * @param packageContext A Context of the application package implementing
4186 * this class.
4187 * @param cls The component class that is to be used for the intent.
4188 *
4189 * @see #Intent(String, android.net.Uri)
4190 * @see #Intent(Context, Class)
4191 * @see #setClass
4192 * @see #setComponent
4193 */
4194 public Intent(String action, Uri uri,
4195 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004196 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004197 mData = uri;
4198 mComponent = new ComponentName(packageContext, cls);
4199 }
4200
4201 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004202 * Create an intent to launch the main (root) activity of a task. This
4203 * is the Intent that is started when the application's is launched from
4204 * Home. For anything else that wants to launch an application in the
4205 * same way, it is important that they use an Intent structured the same
4206 * way, and can use this function to ensure this is the case.
4207 *
4208 * <p>The returned Intent has the given Activity component as its explicit
4209 * component, {@link #ACTION_MAIN} as its action, and includes the
4210 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4211 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4212 * to do that through {@link #addFlags(int)} on the returned Intent.
4213 *
4214 * @param mainActivity The main activity component that this Intent will
4215 * launch.
4216 * @return Returns a newly created Intent that can be used to launch the
4217 * activity as a main application entry.
4218 *
4219 * @see #setClass
4220 * @see #setComponent
4221 */
4222 public static Intent makeMainActivity(ComponentName mainActivity) {
4223 Intent intent = new Intent(ACTION_MAIN);
4224 intent.setComponent(mainActivity);
4225 intent.addCategory(CATEGORY_LAUNCHER);
4226 return intent;
4227 }
4228
4229 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004230 * Make an Intent for the main activity of an application, without
4231 * specifying a specific activity to run but giving a selector to find
4232 * the activity. This results in a final Intent that is structured
4233 * the same as when the application is launched from
4234 * Home. For anything else that wants to launch an application in the
4235 * same way, it is important that they use an Intent structured the same
4236 * way, and can use this function to ensure this is the case.
4237 *
4238 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4239 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4240 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4241 * to do that through {@link #addFlags(int)} on the returned Intent.
4242 *
4243 * @param selectorAction The action name of the Intent's selector.
4244 * @param selectorCategory The name of a category to add to the Intent's
4245 * selector.
4246 * @return Returns a newly created Intent that can be used to launch the
4247 * activity as a main application entry.
4248 *
4249 * @see #setSelector(Intent)
4250 */
4251 public static Intent makeMainSelectorActivity(String selectorAction,
4252 String selectorCategory) {
4253 Intent intent = new Intent(ACTION_MAIN);
4254 intent.addCategory(CATEGORY_LAUNCHER);
4255 Intent selector = new Intent();
4256 selector.setAction(selectorAction);
4257 selector.addCategory(selectorCategory);
4258 intent.setSelector(selector);
4259 return intent;
4260 }
4261
4262 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004263 * Make an Intent that can be used to re-launch an application's task
4264 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4265 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4266 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4267 *
4268 * @param mainActivity The activity component that is the root of the
4269 * task; this is the activity that has been published in the application's
4270 * manifest as the main launcher icon.
4271 *
4272 * @return Returns a newly created Intent that can be used to relaunch the
4273 * activity's task in its root state.
4274 */
4275 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4276 Intent intent = makeMainActivity(mainActivity);
4277 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4278 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4279 return intent;
4280 }
4281
4282 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004283 * Call {@link #parseUri} with 0 flags.
4284 * @deprecated Use {@link #parseUri} instead.
4285 */
4286 @Deprecated
4287 public static Intent getIntent(String uri) throws URISyntaxException {
4288 return parseUri(uri, 0);
4289 }
Tom Taylord4a47292009-12-21 13:59:18 -08004290
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004291 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004292 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004293 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004294 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004295 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004296 *
4297 * <p>The URI given here must not be relative -- that is, it must include
4298 * the scheme and full path.
4299 *
4300 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004301 * @param flags Additional processing flags. Either 0,
4302 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004303 *
4304 * @return Intent The newly created Intent object.
4305 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004306 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4307 * it bad (as parsed by the Uri class) or the Intent data within the
4308 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004309 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004310 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004311 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004312 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004313 int i = 0;
4314 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004315 final boolean androidApp = uri.startsWith("android-app:");
4316
4317 // Validate intent scheme if requested.
4318 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4319 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004320 Intent intent = new Intent(ACTION_VIEW);
4321 try {
4322 intent.setData(Uri.parse(uri));
4323 } catch (IllegalArgumentException e) {
4324 throw new URISyntaxException(uri, e.getMessage());
4325 }
4326 return intent;
4327 }
4328 }
Tom Taylord4a47292009-12-21 13:59:18 -08004329
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004330 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004331 // simple case
4332 if (i == -1) {
4333 if (!androidApp) {
4334 return new Intent(ACTION_VIEW, Uri.parse(uri));
4335 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004336
4337 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004338 } else if (!uri.startsWith("#Intent;", i)) {
4339 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004340 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004341 } else {
4342 i = -1;
4343 }
4344 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004345
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004346 // new format
4347 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004348 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004349 boolean explicitAction = false;
4350 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004351
4352 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004353 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004354 String data;
4355 if (i >= 0) {
4356 data = uri.substring(0, i);
4357 i += 8; // length of "#Intent;"
4358 } else {
4359 data = uri;
4360 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004361
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004362 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004363 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004364 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004365 if (eq < 0) eq = i-1;
4366 int semi = uri.indexOf(';', i);
4367 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004368
4369 // action
4370 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004371 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004372 if (!inSelector) {
4373 explicitAction = true;
4374 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004375 }
4376
4377 // categories
4378 else if (uri.startsWith("category=", i)) {
4379 intent.addCategory(value);
4380 }
4381
4382 // type
4383 else if (uri.startsWith("type=", i)) {
4384 intent.mType = value;
4385 }
4386
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004387 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004388 else if (uri.startsWith("launchFlags=", i)) {
4389 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004390 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4391 intent.mFlags &= ~IMMUTABLE_FLAGS;
4392 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004393 }
4394
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004395 // package
4396 else if (uri.startsWith("package=", i)) {
4397 intent.mPackage = value;
4398 }
4399
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004400 // component
4401 else if (uri.startsWith("component=", i)) {
4402 intent.mComponent = ComponentName.unflattenFromString(value);
4403 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004404
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004405 // scheme
4406 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004407 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004408 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004409 } else {
4410 scheme = value;
4411 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004412 }
4413
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004414 // source bounds
4415 else if (uri.startsWith("sourceBounds=", i)) {
4416 intent.mSourceBounds = Rect.unflattenFromString(value);
4417 }
4418
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004419 // selector
4420 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4421 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004422 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004423 }
4424
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004425 // extra
4426 else {
4427 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004428 // create Bundle if it doesn't already exist
4429 if (intent.mExtras == null) intent.mExtras = new Bundle();
4430 Bundle b = intent.mExtras;
4431 // add EXTRA
4432 if (uri.startsWith("S.", i)) b.putString(key, value);
4433 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4434 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4435 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4436 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4437 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4438 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4439 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4440 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4441 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4442 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004443
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004444 // move to the next item
4445 i = semi + 1;
4446 }
4447
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004448 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004449 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004450 if (baseIntent.mPackage == null) {
4451 baseIntent.setSelector(intent);
4452 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004453 intent = baseIntent;
4454 }
4455
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004456 if (data != null) {
4457 if (data.startsWith("intent:")) {
4458 data = data.substring(7);
4459 if (scheme != null) {
4460 data = scheme + ':' + data;
4461 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004462 } else if (data.startsWith("android-app:")) {
4463 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4464 // Correctly formed android-app, first part is package name.
4465 int end = data.indexOf('/', 14);
4466 if (end < 0) {
4467 // All we have is a package name.
4468 intent.mPackage = data.substring(14);
4469 if (!explicitAction) {
4470 intent.setAction(ACTION_MAIN);
4471 }
4472 data = "";
4473 } else {
4474 // Target the Intent at the given package name always.
4475 String authority = null;
4476 intent.mPackage = data.substring(14, end);
4477 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004478 if ((end+1) < data.length()) {
4479 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4480 // Found a scheme, remember it.
4481 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004482 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004483 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4484 // Found a authority, remember it.
4485 authority = data.substring(end+1, newEnd);
4486 end = newEnd;
4487 }
4488 } else {
4489 // All we have is a scheme.
4490 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004491 }
4492 }
4493 if (scheme == null) {
4494 // If there was no scheme, then this just targets the package.
4495 if (!explicitAction) {
4496 intent.setAction(ACTION_MAIN);
4497 }
4498 data = "";
4499 } else if (authority == null) {
4500 data = scheme + ":";
4501 } else {
4502 data = scheme + "://" + authority + data.substring(end);
4503 }
4504 }
4505 } else {
4506 data = "";
4507 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004508 }
Tom Taylord4a47292009-12-21 13:59:18 -08004509
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004510 if (data.length() > 0) {
4511 try {
4512 intent.mData = Uri.parse(data);
4513 } catch (IllegalArgumentException e) {
4514 throw new URISyntaxException(uri, e.getMessage());
4515 }
4516 }
4517 }
Tom Taylord4a47292009-12-21 13:59:18 -08004518
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004519 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004520
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004521 } catch (IndexOutOfBoundsException e) {
4522 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4523 }
4524 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004525
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004526 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004527 return getIntentOld(uri, 0);
4528 }
4529
4530 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004531 Intent intent;
4532
4533 int i = uri.lastIndexOf('#');
4534 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004535 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004536 final int intentFragmentStart = i;
4537 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004538
4539 i++;
4540
4541 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004542 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004543 i += 7;
4544 int j = uri.indexOf(')', i);
4545 action = uri.substring(i, j);
4546 i = j + 1;
4547 }
4548
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004549 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004550
4551 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004552 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004553 i += 11;
4554 int j = uri.indexOf(')', i);
4555 while (i < j) {
4556 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004557 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004558 if (i < sep) {
4559 intent.addCategory(uri.substring(i, sep));
4560 }
4561 i = sep + 1;
4562 }
4563 i = j + 1;
4564 }
4565
4566 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004567 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004568 i += 5;
4569 int j = uri.indexOf(')', i);
4570 intent.mType = uri.substring(i, j);
4571 i = j + 1;
4572 }
4573
4574 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004575 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004576 i += 12;
4577 int j = uri.indexOf(')', i);
4578 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004579 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4580 intent.mFlags &= ~IMMUTABLE_FLAGS;
4581 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004582 i = j + 1;
4583 }
4584
4585 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004586 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004587 i += 10;
4588 int j = uri.indexOf(')', i);
4589 int sep = uri.indexOf('!', i);
4590 if (sep >= 0 && sep < j) {
4591 String pkg = uri.substring(i, sep);
4592 String cls = uri.substring(sep + 1, j);
4593 intent.mComponent = new ComponentName(pkg, cls);
4594 }
4595 i = j + 1;
4596 }
4597
4598 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004599 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004600 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004601
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004602 final int closeParen = uri.indexOf(')', i);
4603 if (closeParen == -1) throw new URISyntaxException(uri,
4604 "EXTRA missing trailing ')'", i);
4605
4606 while (i < closeParen) {
4607 // fetch the key value
4608 int j = uri.indexOf('=', i);
4609 if (j <= i + 1 || i >= closeParen) {
4610 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4611 }
4612 char type = uri.charAt(i);
4613 i++;
4614 String key = uri.substring(i, j);
4615 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004616
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004617 // get type-value
4618 j = uri.indexOf('!', i);
4619 if (j == -1 || j >= closeParen) j = closeParen;
4620 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4621 String value = uri.substring(i, j);
4622 i = j;
4623
4624 // create Bundle if it doesn't already exist
4625 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004626
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004627 // add item to bundle
4628 try {
4629 switch (type) {
4630 case 'S':
4631 intent.mExtras.putString(key, Uri.decode(value));
4632 break;
4633 case 'B':
4634 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4635 break;
4636 case 'b':
4637 intent.mExtras.putByte(key, Byte.parseByte(value));
4638 break;
4639 case 'c':
4640 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4641 break;
4642 case 'd':
4643 intent.mExtras.putDouble(key, Double.parseDouble(value));
4644 break;
4645 case 'f':
4646 intent.mExtras.putFloat(key, Float.parseFloat(value));
4647 break;
4648 case 'i':
4649 intent.mExtras.putInt(key, Integer.parseInt(value));
4650 break;
4651 case 'l':
4652 intent.mExtras.putLong(key, Long.parseLong(value));
4653 break;
4654 case 's':
4655 intent.mExtras.putShort(key, Short.parseShort(value));
4656 break;
4657 default:
4658 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4659 }
4660 } catch (NumberFormatException e) {
4661 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4662 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004663
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004664 char ch = uri.charAt(i);
4665 if (ch == ')') break;
4666 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4667 i++;
4668 }
4669 }
4670
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004671 if (isIntentFragment) {
4672 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4673 } else {
4674 intent.mData = Uri.parse(uri);
4675 }
Tom Taylord4a47292009-12-21 13:59:18 -08004676
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004677 if (intent.mAction == null) {
4678 // By default, if no action is specified, then use VIEW.
4679 intent.mAction = ACTION_VIEW;
4680 }
4681
4682 } else {
4683 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4684 }
4685
4686 return intent;
4687 }
4688
4689 /**
4690 * Retrieve the general action to be performed, such as
4691 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4692 * the information in the intent should be interpreted -- most importantly,
4693 * what to do with the data returned by {@link #getData}.
4694 *
4695 * @return The action of this intent or null if none is specified.
4696 *
4697 * @see #setAction
4698 */
4699 public String getAction() {
4700 return mAction;
4701 }
4702
4703 /**
4704 * Retrieve data this intent is operating on. This URI specifies the name
4705 * of the data; often it uses the content: scheme, specifying data in a
4706 * content provider. Other schemes may be handled by specific activities,
4707 * such as http: by the web browser.
4708 *
4709 * @return The URI of the data this intent is targeting or null.
4710 *
4711 * @see #getScheme
4712 * @see #setData
4713 */
4714 public Uri getData() {
4715 return mData;
4716 }
4717
4718 /**
4719 * The same as {@link #getData()}, but returns the URI as an encoded
4720 * String.
4721 */
4722 public String getDataString() {
4723 return mData != null ? mData.toString() : null;
4724 }
4725
4726 /**
4727 * Return the scheme portion of the intent's data. If the data is null or
4728 * does not include a scheme, null is returned. Otherwise, the scheme
4729 * prefix without the final ':' is returned, i.e. "http".
4730 *
4731 * <p>This is the same as calling getData().getScheme() (and checking for
4732 * null data).
4733 *
4734 * @return The scheme of this intent.
4735 *
4736 * @see #getData
4737 */
4738 public String getScheme() {
4739 return mData != null ? mData.getScheme() : null;
4740 }
4741
4742 /**
4743 * Retrieve any explicit MIME type included in the intent. This is usually
4744 * null, as the type is determined by the intent data.
4745 *
4746 * @return If a type was manually set, it is returned; else null is
4747 * returned.
4748 *
4749 * @see #resolveType(ContentResolver)
4750 * @see #setType
4751 */
4752 public String getType() {
4753 return mType;
4754 }
4755
4756 /**
4757 * Return the MIME data type of this intent. If the type field is
4758 * explicitly set, that is simply returned. Otherwise, if the data is set,
4759 * the type of that data is returned. If neither fields are set, a null is
4760 * returned.
4761 *
4762 * @return The MIME type of this intent.
4763 *
4764 * @see #getType
4765 * @see #resolveType(ContentResolver)
4766 */
4767 public String resolveType(Context context) {
4768 return resolveType(context.getContentResolver());
4769 }
4770
4771 /**
4772 * Return the MIME data type of this intent. If the type field is
4773 * explicitly set, that is simply returned. Otherwise, if the data is set,
4774 * the type of that data is returned. If neither fields are set, a null is
4775 * returned.
4776 *
4777 * @param resolver A ContentResolver that can be used to determine the MIME
4778 * type of the intent's data.
4779 *
4780 * @return The MIME type of this intent.
4781 *
4782 * @see #getType
4783 * @see #resolveType(Context)
4784 */
4785 public String resolveType(ContentResolver resolver) {
4786 if (mType != null) {
4787 return mType;
4788 }
4789 if (mData != null) {
4790 if ("content".equals(mData.getScheme())) {
4791 return resolver.getType(mData);
4792 }
4793 }
4794 return null;
4795 }
4796
4797 /**
4798 * Return the MIME data type of this intent, only if it will be needed for
4799 * intent resolution. This is not generally useful for application code;
4800 * it is used by the frameworks for communicating with back-end system
4801 * services.
4802 *
4803 * @param resolver A ContentResolver that can be used to determine the MIME
4804 * type of the intent's data.
4805 *
4806 * @return The MIME type of this intent, or null if it is unknown or not
4807 * needed.
4808 */
4809 public String resolveTypeIfNeeded(ContentResolver resolver) {
4810 if (mComponent != null) {
4811 return mType;
4812 }
4813 return resolveType(resolver);
4814 }
4815
4816 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004817 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004818 *
4819 * @param category The category to check.
4820 *
4821 * @return boolean True if the intent contains the category, else false.
4822 *
4823 * @see #getCategories
4824 * @see #addCategory
4825 */
4826 public boolean hasCategory(String category) {
4827 return mCategories != null && mCategories.contains(category);
4828 }
4829
4830 /**
4831 * Return the set of all categories in the intent. If there are no categories,
4832 * returns NULL.
4833 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004834 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004835 *
4836 * @see #hasCategory
4837 * @see #addCategory
4838 */
4839 public Set<String> getCategories() {
4840 return mCategories;
4841 }
4842
4843 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004844 * Return the specific selector associated with this Intent. If there is
4845 * none, returns null. See {@link #setSelector} for more information.
4846 *
4847 * @see #setSelector
4848 */
4849 public Intent getSelector() {
4850 return mSelector;
4851 }
4852
4853 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004854 * Return the {@link ClipData} associated with this Intent. If there is
4855 * none, returns null. See {@link #setClipData} for more information.
4856 *
John Spurlock125d1332013-11-25 11:58:37 -05004857 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004858 */
4859 public ClipData getClipData() {
4860 return mClipData;
4861 }
4862
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004863 /** @hide */
4864 public int getContentUserHint() {
4865 return mContentUserHint;
4866 }
4867
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004868 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004869 * Sets the ClassLoader that will be used when unmarshalling
4870 * any Parcelable values from the extras of this Intent.
4871 *
4872 * @param loader a ClassLoader, or null to use the default loader
4873 * at the time of unmarshalling.
4874 */
4875 public void setExtrasClassLoader(ClassLoader loader) {
4876 if (mExtras != null) {
4877 mExtras.setClassLoader(loader);
4878 }
4879 }
4880
4881 /**
4882 * Returns true if an extra value is associated with the given name.
4883 * @param name the extra's name
4884 * @return true if the given extra is present.
4885 */
4886 public boolean hasExtra(String name) {
4887 return mExtras != null && mExtras.containsKey(name);
4888 }
4889
4890 /**
4891 * Returns true if the Intent's extras contain a parcelled file descriptor.
4892 * @return true if the Intent contains a parcelled file descriptor.
4893 */
4894 public boolean hasFileDescriptors() {
4895 return mExtras != null && mExtras.hasFileDescriptors();
4896 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004897
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04004898 /** @hide */
4899 public void setAllowFds(boolean allowFds) {
4900 if (mExtras != null) {
4901 mExtras.setAllowFds(allowFds);
4902 }
4903 }
4904
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004905 /**
4906 * Retrieve extended data from the intent.
4907 *
4908 * @param name The name of the desired item.
4909 *
4910 * @return the value of an item that previously added with putExtra()
4911 * or null if none was found.
4912 *
4913 * @deprecated
4914 * @hide
4915 */
4916 @Deprecated
4917 public Object getExtra(String name) {
4918 return getExtra(name, null);
4919 }
4920
4921 /**
4922 * Retrieve extended data from the intent.
4923 *
4924 * @param name The name of the desired item.
4925 * @param defaultValue the value to be returned if no value of the desired
4926 * type is stored with the given name.
4927 *
4928 * @return the value of an item that previously added with putExtra()
4929 * or the default value if none was found.
4930 *
4931 * @see #putExtra(String, boolean)
4932 */
4933 public boolean getBooleanExtra(String name, boolean defaultValue) {
4934 return mExtras == null ? defaultValue :
4935 mExtras.getBoolean(name, defaultValue);
4936 }
4937
4938 /**
4939 * Retrieve extended data from the intent.
4940 *
4941 * @param name The name of the desired item.
4942 * @param defaultValue the value to be returned if no value of the desired
4943 * type is stored with the given name.
4944 *
4945 * @return the value of an item that previously added with putExtra()
4946 * or the default value if none was found.
4947 *
4948 * @see #putExtra(String, byte)
4949 */
4950 public byte getByteExtra(String name, byte defaultValue) {
4951 return mExtras == null ? defaultValue :
4952 mExtras.getByte(name, defaultValue);
4953 }
4954
4955 /**
4956 * Retrieve extended data from the intent.
4957 *
4958 * @param name The name of the desired item.
4959 * @param defaultValue the value to be returned if no value of the desired
4960 * type is stored with the given name.
4961 *
4962 * @return the value of an item that previously added with putExtra()
4963 * or the default value if none was found.
4964 *
4965 * @see #putExtra(String, short)
4966 */
4967 public short getShortExtra(String name, short defaultValue) {
4968 return mExtras == null ? defaultValue :
4969 mExtras.getShort(name, defaultValue);
4970 }
4971
4972 /**
4973 * Retrieve extended data from the intent.
4974 *
4975 * @param name The name of the desired item.
4976 * @param defaultValue the value to be returned if no value of the desired
4977 * type is stored with the given name.
4978 *
4979 * @return the value of an item that previously added with putExtra()
4980 * or the default value if none was found.
4981 *
4982 * @see #putExtra(String, char)
4983 */
4984 public char getCharExtra(String name, char defaultValue) {
4985 return mExtras == null ? defaultValue :
4986 mExtras.getChar(name, defaultValue);
4987 }
4988
4989 /**
4990 * Retrieve extended data from the intent.
4991 *
4992 * @param name The name of the desired item.
4993 * @param defaultValue the value to be returned if no value of the desired
4994 * type is stored with the given name.
4995 *
4996 * @return the value of an item that previously added with putExtra()
4997 * or the default value if none was found.
4998 *
4999 * @see #putExtra(String, int)
5000 */
5001 public int getIntExtra(String name, int defaultValue) {
5002 return mExtras == null ? defaultValue :
5003 mExtras.getInt(name, defaultValue);
5004 }
5005
5006 /**
5007 * Retrieve extended data from the intent.
5008 *
5009 * @param name The name of the desired item.
5010 * @param defaultValue the value to be returned if no value of the desired
5011 * type is stored with the given name.
5012 *
5013 * @return the value of an item that previously added with putExtra()
5014 * or the default value if none was found.
5015 *
5016 * @see #putExtra(String, long)
5017 */
5018 public long getLongExtra(String name, long defaultValue) {
5019 return mExtras == null ? defaultValue :
5020 mExtras.getLong(name, defaultValue);
5021 }
5022
5023 /**
5024 * Retrieve extended data from the intent.
5025 *
5026 * @param name The name of the desired item.
5027 * @param defaultValue the value to be returned if no value of the desired
5028 * type is stored with the given name.
5029 *
5030 * @return the value of an item that previously added with putExtra(),
5031 * or the default value if no such item is present
5032 *
5033 * @see #putExtra(String, float)
5034 */
5035 public float getFloatExtra(String name, float defaultValue) {
5036 return mExtras == null ? defaultValue :
5037 mExtras.getFloat(name, defaultValue);
5038 }
5039
5040 /**
5041 * Retrieve extended data from the intent.
5042 *
5043 * @param name The name of the desired item.
5044 * @param defaultValue the value to be returned if no value of the desired
5045 * type is stored with the given name.
5046 *
5047 * @return the value of an item that previously added with putExtra()
5048 * or the default value if none was found.
5049 *
5050 * @see #putExtra(String, double)
5051 */
5052 public double getDoubleExtra(String name, double defaultValue) {
5053 return mExtras == null ? defaultValue :
5054 mExtras.getDouble(name, defaultValue);
5055 }
5056
5057 /**
5058 * Retrieve extended data from the intent.
5059 *
5060 * @param name The name of the desired item.
5061 *
5062 * @return the value of an item that previously added with putExtra()
5063 * or null if no String value was found.
5064 *
5065 * @see #putExtra(String, String)
5066 */
5067 public String getStringExtra(String name) {
5068 return mExtras == null ? null : mExtras.getString(name);
5069 }
5070
5071 /**
5072 * Retrieve extended data from the intent.
5073 *
5074 * @param name The name of the desired item.
5075 *
5076 * @return the value of an item that previously added with putExtra()
5077 * or null if no CharSequence value was found.
5078 *
5079 * @see #putExtra(String, CharSequence)
5080 */
5081 public CharSequence getCharSequenceExtra(String name) {
5082 return mExtras == null ? null : mExtras.getCharSequence(name);
5083 }
5084
5085 /**
5086 * Retrieve extended data from the intent.
5087 *
5088 * @param name The name of the desired item.
5089 *
5090 * @return the value of an item that previously added with putExtra()
5091 * or null if no Parcelable value was found.
5092 *
5093 * @see #putExtra(String, Parcelable)
5094 */
5095 public <T extends Parcelable> T getParcelableExtra(String name) {
5096 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5097 }
5098
5099 /**
5100 * Retrieve extended data from the intent.
5101 *
5102 * @param name The name of the desired item.
5103 *
5104 * @return the value of an item that previously added with putExtra()
5105 * or null if no Parcelable[] value was found.
5106 *
5107 * @see #putExtra(String, Parcelable[])
5108 */
5109 public Parcelable[] getParcelableArrayExtra(String name) {
5110 return mExtras == null ? null : mExtras.getParcelableArray(name);
5111 }
5112
5113 /**
5114 * Retrieve extended data from the intent.
5115 *
5116 * @param name The name of the desired item.
5117 *
5118 * @return the value of an item that previously added with putExtra()
5119 * or null if no ArrayList<Parcelable> value was found.
5120 *
5121 * @see #putParcelableArrayListExtra(String, ArrayList)
5122 */
5123 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5124 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5125 }
5126
5127 /**
5128 * Retrieve extended data from the intent.
5129 *
5130 * @param name The name of the desired item.
5131 *
5132 * @return the value of an item that previously added with putExtra()
5133 * or null if no Serializable value was found.
5134 *
5135 * @see #putExtra(String, Serializable)
5136 */
5137 public Serializable getSerializableExtra(String name) {
5138 return mExtras == null ? null : mExtras.getSerializable(name);
5139 }
5140
5141 /**
5142 * Retrieve extended data from the intent.
5143 *
5144 * @param name The name of the desired item.
5145 *
5146 * @return the value of an item that previously added with putExtra()
5147 * or null if no ArrayList<Integer> value was found.
5148 *
5149 * @see #putIntegerArrayListExtra(String, ArrayList)
5150 */
5151 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5152 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5153 }
5154
5155 /**
5156 * Retrieve extended data from the intent.
5157 *
5158 * @param name The name of the desired item.
5159 *
5160 * @return the value of an item that previously added with putExtra()
5161 * or null if no ArrayList<String> value was found.
5162 *
5163 * @see #putStringArrayListExtra(String, ArrayList)
5164 */
5165 public ArrayList<String> getStringArrayListExtra(String name) {
5166 return mExtras == null ? null : mExtras.getStringArrayList(name);
5167 }
5168
5169 /**
5170 * Retrieve extended data from the intent.
5171 *
5172 * @param name The name of the desired item.
5173 *
5174 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005175 * or null if no ArrayList<CharSequence> value was found.
5176 *
5177 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5178 */
5179 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5180 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5181 }
5182
5183 /**
5184 * Retrieve extended data from the intent.
5185 *
5186 * @param name The name of the desired item.
5187 *
5188 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005189 * or null if no boolean array value was found.
5190 *
5191 * @see #putExtra(String, boolean[])
5192 */
5193 public boolean[] getBooleanArrayExtra(String name) {
5194 return mExtras == null ? null : mExtras.getBooleanArray(name);
5195 }
5196
5197 /**
5198 * Retrieve extended data from the intent.
5199 *
5200 * @param name The name of the desired item.
5201 *
5202 * @return the value of an item that previously added with putExtra()
5203 * or null if no byte array value was found.
5204 *
5205 * @see #putExtra(String, byte[])
5206 */
5207 public byte[] getByteArrayExtra(String name) {
5208 return mExtras == null ? null : mExtras.getByteArray(name);
5209 }
5210
5211 /**
5212 * Retrieve extended data from the intent.
5213 *
5214 * @param name The name of the desired item.
5215 *
5216 * @return the value of an item that previously added with putExtra()
5217 * or null if no short array value was found.
5218 *
5219 * @see #putExtra(String, short[])
5220 */
5221 public short[] getShortArrayExtra(String name) {
5222 return mExtras == null ? null : mExtras.getShortArray(name);
5223 }
5224
5225 /**
5226 * Retrieve extended data from the intent.
5227 *
5228 * @param name The name of the desired item.
5229 *
5230 * @return the value of an item that previously added with putExtra()
5231 * or null if no char array value was found.
5232 *
5233 * @see #putExtra(String, char[])
5234 */
5235 public char[] getCharArrayExtra(String name) {
5236 return mExtras == null ? null : mExtras.getCharArray(name);
5237 }
5238
5239 /**
5240 * Retrieve extended data from the intent.
5241 *
5242 * @param name The name of the desired item.
5243 *
5244 * @return the value of an item that previously added with putExtra()
5245 * or null if no int array value was found.
5246 *
5247 * @see #putExtra(String, int[])
5248 */
5249 public int[] getIntArrayExtra(String name) {
5250 return mExtras == null ? null : mExtras.getIntArray(name);
5251 }
5252
5253 /**
5254 * Retrieve extended data from the intent.
5255 *
5256 * @param name The name of the desired item.
5257 *
5258 * @return the value of an item that previously added with putExtra()
5259 * or null if no long array value was found.
5260 *
5261 * @see #putExtra(String, long[])
5262 */
5263 public long[] getLongArrayExtra(String name) {
5264 return mExtras == null ? null : mExtras.getLongArray(name);
5265 }
5266
5267 /**
5268 * Retrieve extended data from the intent.
5269 *
5270 * @param name The name of the desired item.
5271 *
5272 * @return the value of an item that previously added with putExtra()
5273 * or null if no float array value was found.
5274 *
5275 * @see #putExtra(String, float[])
5276 */
5277 public float[] getFloatArrayExtra(String name) {
5278 return mExtras == null ? null : mExtras.getFloatArray(name);
5279 }
5280
5281 /**
5282 * Retrieve extended data from the intent.
5283 *
5284 * @param name The name of the desired item.
5285 *
5286 * @return the value of an item that previously added with putExtra()
5287 * or null if no double array value was found.
5288 *
5289 * @see #putExtra(String, double[])
5290 */
5291 public double[] getDoubleArrayExtra(String name) {
5292 return mExtras == null ? null : mExtras.getDoubleArray(name);
5293 }
5294
5295 /**
5296 * Retrieve extended data from the intent.
5297 *
5298 * @param name The name of the desired item.
5299 *
5300 * @return the value of an item that previously added with putExtra()
5301 * or null if no String array value was found.
5302 *
5303 * @see #putExtra(String, String[])
5304 */
5305 public String[] getStringArrayExtra(String name) {
5306 return mExtras == null ? null : mExtras.getStringArray(name);
5307 }
5308
5309 /**
5310 * Retrieve extended data from the intent.
5311 *
5312 * @param name The name of the desired item.
5313 *
5314 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005315 * or null if no CharSequence array value was found.
5316 *
5317 * @see #putExtra(String, CharSequence[])
5318 */
5319 public CharSequence[] getCharSequenceArrayExtra(String name) {
5320 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5321 }
5322
5323 /**
5324 * Retrieve extended data from the intent.
5325 *
5326 * @param name The name of the desired item.
5327 *
5328 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005329 * or null if no Bundle value was found.
5330 *
5331 * @see #putExtra(String, Bundle)
5332 */
5333 public Bundle getBundleExtra(String name) {
5334 return mExtras == null ? null : mExtras.getBundle(name);
5335 }
5336
5337 /**
5338 * Retrieve extended data from the intent.
5339 *
5340 * @param name The name of the desired item.
5341 *
5342 * @return the value of an item that previously added with putExtra()
5343 * or null if no IBinder value was found.
5344 *
5345 * @see #putExtra(String, IBinder)
5346 *
5347 * @deprecated
5348 * @hide
5349 */
5350 @Deprecated
5351 public IBinder getIBinderExtra(String name) {
5352 return mExtras == null ? null : mExtras.getIBinder(name);
5353 }
5354
5355 /**
5356 * Retrieve extended data from the intent.
5357 *
5358 * @param name The name of the desired item.
5359 * @param defaultValue The default value to return in case no item is
5360 * associated with the key 'name'
5361 *
5362 * @return the value of an item that previously added with putExtra()
5363 * or defaultValue if none was found.
5364 *
5365 * @see #putExtra
5366 *
5367 * @deprecated
5368 * @hide
5369 */
5370 @Deprecated
5371 public Object getExtra(String name, Object defaultValue) {
5372 Object result = defaultValue;
5373 if (mExtras != null) {
5374 Object result2 = mExtras.get(name);
5375 if (result2 != null) {
5376 result = result2;
5377 }
5378 }
5379
5380 return result;
5381 }
5382
5383 /**
5384 * Retrieves a map of extended data from the intent.
5385 *
5386 * @return the map of all extras previously added with putExtra(),
5387 * or null if none have been added.
5388 */
5389 public Bundle getExtras() {
5390 return (mExtras != null)
5391 ? new Bundle(mExtras)
5392 : null;
5393 }
5394
5395 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005396 * Filter extras to only basic types.
5397 * @hide
5398 */
5399 public void removeUnsafeExtras() {
5400 if (mExtras != null) {
5401 mExtras.filterValues();
5402 }
5403 }
5404
5405 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005406 * Retrieve any special flags associated with this intent. You will
5407 * normally just set them with {@link #setFlags} and let the system
5408 * take the appropriate action with them.
5409 *
5410 * @return int The currently set flags.
5411 *
5412 * @see #setFlags
5413 */
5414 public int getFlags() {
5415 return mFlags;
5416 }
5417
Dianne Hackborne7f97212011-02-24 14:40:20 -08005418 /** @hide */
5419 public boolean isExcludingStopped() {
5420 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5421 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5422 }
5423
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005424 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005425 * Retrieve the application package name this Intent is limited to. When
5426 * resolving an Intent, if non-null this limits the resolution to only
5427 * components in the given application package.
5428 *
5429 * @return The name of the application package for the Intent.
5430 *
5431 * @see #resolveActivity
5432 * @see #setPackage
5433 */
5434 public String getPackage() {
5435 return mPackage;
5436 }
5437
5438 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005439 * Retrieve the concrete component associated with the intent. When receiving
5440 * an intent, this is the component that was found to best handle it (that is,
5441 * yourself) and will always be non-null; in all other cases it will be
5442 * null unless explicitly set.
5443 *
5444 * @return The name of the application component to handle the intent.
5445 *
5446 * @see #resolveActivity
5447 * @see #setComponent
5448 */
5449 public ComponentName getComponent() {
5450 return mComponent;
5451 }
5452
5453 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005454 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5455 * used as a hint to the receiver for animations and the like. Null means that there
5456 * is no source bounds.
5457 */
5458 public Rect getSourceBounds() {
5459 return mSourceBounds;
5460 }
5461
5462 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005463 * Return the Activity component that should be used to handle this intent.
5464 * The appropriate component is determined based on the information in the
5465 * intent, evaluated as follows:
5466 *
5467 * <p>If {@link #getComponent} returns an explicit class, that is returned
5468 * without any further consideration.
5469 *
5470 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5471 * category to be considered.
5472 *
5473 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5474 * action.
5475 *
5476 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5477 * this type.
5478 *
5479 * <p>If {@link #addCategory} has added any categories, the activity must
5480 * handle ALL of the categories specified.
5481 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005482 * <p>If {@link #getPackage} is non-NULL, only activity components in
5483 * that application package will be considered.
5484 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005485 * <p>If there are no activities that satisfy all of these conditions, a
5486 * null string is returned.
5487 *
5488 * <p>If multiple activities are found to satisfy the intent, the one with
5489 * the highest priority will be used. If there are multiple activities
5490 * with the same priority, the system will either pick the best activity
5491 * based on user preference, or resolve to a system class that will allow
5492 * the user to pick an activity and forward from there.
5493 *
5494 * <p>This method is implemented simply by calling
5495 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5496 * true.</p>
5497 * <p> This API is called for you as part of starting an activity from an
5498 * intent. You do not normally need to call it yourself.</p>
5499 *
5500 * @param pm The package manager with which to resolve the Intent.
5501 *
5502 * @return Name of the component implementing an activity that can
5503 * display the intent.
5504 *
5505 * @see #setComponent
5506 * @see #getComponent
5507 * @see #resolveActivityInfo
5508 */
5509 public ComponentName resolveActivity(PackageManager pm) {
5510 if (mComponent != null) {
5511 return mComponent;
5512 }
5513
5514 ResolveInfo info = pm.resolveActivity(
5515 this, PackageManager.MATCH_DEFAULT_ONLY);
5516 if (info != null) {
5517 return new ComponentName(
5518 info.activityInfo.applicationInfo.packageName,
5519 info.activityInfo.name);
5520 }
5521
5522 return null;
5523 }
5524
5525 /**
5526 * Resolve the Intent into an {@link ActivityInfo}
5527 * describing the activity that should execute the intent. Resolution
5528 * follows the same rules as described for {@link #resolveActivity}, but
5529 * you get back the completely information about the resolved activity
5530 * instead of just its class name.
5531 *
5532 * @param pm The package manager with which to resolve the Intent.
5533 * @param flags Addition information to retrieve as per
5534 * {@link PackageManager#getActivityInfo(ComponentName, int)
5535 * PackageManager.getActivityInfo()}.
5536 *
5537 * @return PackageManager.ActivityInfo
5538 *
5539 * @see #resolveActivity
5540 */
5541 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5542 ActivityInfo ai = null;
5543 if (mComponent != null) {
5544 try {
5545 ai = pm.getActivityInfo(mComponent, flags);
5546 } catch (PackageManager.NameNotFoundException e) {
5547 // ignore
5548 }
5549 } else {
5550 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005551 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005552 if (info != null) {
5553 ai = info.activityInfo;
5554 }
5555 }
5556
5557 return ai;
5558 }
5559
5560 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005561 * Special function for use by the system to resolve service
5562 * intents to system apps. Throws an exception if there are
5563 * multiple potential matches to the Intent. Returns null if
5564 * there are no matches.
5565 * @hide
5566 */
5567 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5568 if (mComponent != null) {
5569 return mComponent;
5570 }
5571
5572 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5573 if (results == null) {
5574 return null;
5575 }
5576 ComponentName comp = null;
5577 for (int i=0; i<results.size(); i++) {
5578 ResolveInfo ri = results.get(i);
5579 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5580 continue;
5581 }
5582 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5583 ri.serviceInfo.name);
5584 if (comp != null) {
5585 throw new IllegalStateException("Multiple system services handle " + this
5586 + ": " + comp + ", " + foundComp);
5587 }
5588 comp = foundComp;
5589 }
5590 return comp;
5591 }
5592
5593 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005594 * Set the general action to be performed.
5595 *
5596 * @param action An action name, such as ACTION_VIEW. Application-specific
5597 * actions should be prefixed with the vendor's package name.
5598 *
5599 * @return Returns the same Intent object, for chaining multiple calls
5600 * into a single statement.
5601 *
5602 * @see #getAction
5603 */
5604 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005605 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005606 return this;
5607 }
5608
5609 /**
5610 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005611 * clears any type that was previously set by {@link #setType} or
5612 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005613 *
Nick Pellyccae4122012-01-09 14:12:58 -08005614 * <p><em>Note: scheme matching in the Android framework is
5615 * case-sensitive, unlike the formal RFC. As a result,
5616 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005617 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005618 * {@link #setDataAndNormalize}
5619 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005620 *
Nick Pellyccae4122012-01-09 14:12:58 -08005621 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005622 *
5623 * @return Returns the same Intent object, for chaining multiple calls
5624 * into a single statement.
5625 *
5626 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005627 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005628 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005629 */
5630 public Intent setData(Uri data) {
5631 mData = data;
5632 mType = null;
5633 return this;
5634 }
5635
5636 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005637 * Normalize and set the data this intent is operating on.
5638 *
5639 * <p>This method automatically clears any type that was
5640 * previously set (for example, by {@link #setType}).
5641 *
5642 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005643 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005644 * so really this is just a convenience method for
5645 * <pre>
5646 * setData(data.normalize())
5647 * </pre>
5648 *
5649 * @param data The Uri of the data this intent is now targeting.
5650 *
5651 * @return Returns the same Intent object, for chaining multiple calls
5652 * into a single statement.
5653 *
5654 * @see #getData
5655 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005656 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005657 */
5658 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005659 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005660 }
5661
5662 /**
5663 * Set an explicit MIME data type.
5664 *
5665 * <p>This is used to create intents that only specify a type and not data,
5666 * for example to indicate the type of data to return.
5667 *
5668 * <p>This method automatically clears any data that was
5669 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005670 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005671 * <p><em>Note: MIME type matching in the Android framework is
5672 * case-sensitive, unlike formal RFC MIME types. As a result,
5673 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005674 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5675 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005676 *
5677 * @param type The MIME type of the data being handled by this intent.
5678 *
5679 * @return Returns the same Intent object, for chaining multiple calls
5680 * into a single statement.
5681 *
5682 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005683 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005684 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005685 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005686 */
5687 public Intent setType(String type) {
5688 mData = null;
5689 mType = type;
5690 return this;
5691 }
5692
5693 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005694 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005695 *
Nick Pellyccae4122012-01-09 14:12:58 -08005696 * <p>This is used to create intents that only specify a type and not data,
5697 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005698 *
Nick Pellyccae4122012-01-09 14:12:58 -08005699 * <p>This method automatically clears any data that was
5700 * previously set (for example by {@link #setData}).
5701 *
5702 * <p>The MIME type is normalized using
5703 * {@link #normalizeMimeType} before it is set,
5704 * so really this is just a convenience method for
5705 * <pre>
5706 * setType(Intent.normalizeMimeType(type))
5707 * </pre>
5708 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005709 * @param type The MIME type of the data being handled by this intent.
5710 *
5711 * @return Returns the same Intent object, for chaining multiple calls
5712 * into a single statement.
5713 *
Nick Pellyccae4122012-01-09 14:12:58 -08005714 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005715 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005716 * @see #normalizeMimeType
5717 */
5718 public Intent setTypeAndNormalize(String type) {
5719 return setType(normalizeMimeType(type));
5720 }
5721
5722 /**
5723 * (Usually optional) Set the data for the intent along with an explicit
5724 * MIME data type. This method should very rarely be used -- it allows you
5725 * to override the MIME type that would ordinarily be inferred from the
5726 * data with your own type given here.
5727 *
5728 * <p><em>Note: MIME type and Uri scheme matching in the
5729 * Android framework is case-sensitive, unlike the formal RFC definitions.
5730 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005731 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005732 * {@link #setDataAndTypeAndNormalize}
5733 * to ensure that they are converted to lower case.</em>
5734 *
5735 * @param data The Uri of the data this intent is now targeting.
5736 * @param type The MIME type of the data being handled by this intent.
5737 *
5738 * @return Returns the same Intent object, for chaining multiple calls
5739 * into a single statement.
5740 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005741 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08005742 * @see #setData
5743 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005744 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005745 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005746 */
5747 public Intent setDataAndType(Uri data, String type) {
5748 mData = data;
5749 mType = type;
5750 return this;
5751 }
5752
5753 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005754 * (Usually optional) Normalize and set both the data Uri and an explicit
5755 * MIME data type. This method should very rarely be used -- it allows you
5756 * to override the MIME type that would ordinarily be inferred from the
5757 * data with your own type given here.
5758 *
5759 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005760 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08005761 * before they are set, so really this is just a convenience method for
5762 * <pre>
5763 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
5764 * </pre>
5765 *
5766 * @param data The Uri of the data this intent is now targeting.
5767 * @param type The MIME type of the data being handled by this intent.
5768 *
5769 * @return Returns the same Intent object, for chaining multiple calls
5770 * into a single statement.
5771 *
5772 * @see #setType
5773 * @see #setData
5774 * @see #setDataAndType
5775 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005776 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005777 */
5778 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005779 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08005780 }
5781
5782 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005783 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005784 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005785 * activities that provide <em>all</em> of the requested categories will be
5786 * used.
5787 *
5788 * @param category The desired category. This can be either one of the
5789 * predefined Intent categories, or a custom category in your own
5790 * namespace.
5791 *
5792 * @return Returns the same Intent object, for chaining multiple calls
5793 * into a single statement.
5794 *
5795 * @see #hasCategory
5796 * @see #removeCategory
5797 */
5798 public Intent addCategory(String category) {
5799 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005800 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005801 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08005802 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005803 return this;
5804 }
5805
5806 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005807 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005808 *
5809 * @param category The category to remove.
5810 *
5811 * @see #addCategory
5812 */
5813 public void removeCategory(String category) {
5814 if (mCategories != null) {
5815 mCategories.remove(category);
5816 if (mCategories.size() == 0) {
5817 mCategories = null;
5818 }
5819 }
5820 }
5821
5822 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005823 * Set a selector for this Intent. This is a modification to the kinds of
5824 * things the Intent will match. If the selector is set, it will be used
5825 * when trying to find entities that can handle the Intent, instead of the
5826 * main contents of the Intent. This allows you build an Intent containing
5827 * a generic protocol while targeting it more specifically.
5828 *
5829 * <p>An example of where this may be used is with things like
5830 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
5831 * Intent that will launch the Browser application. However, the correct
5832 * main entry point of an application is actually {@link #ACTION_MAIN}
5833 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
5834 * used to specify the actual Activity to launch. If you launch the browser
5835 * with something different, undesired behavior may happen if the user has
5836 * previously or later launches it the normal way, since they do not match.
5837 * Instead, you can build an Intent with the MAIN action (but no ComponentName
5838 * yet specified) and set a selector with {@link #ACTION_MAIN} and
5839 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
5840 *
5841 * <p>Setting a selector does not impact the behavior of
5842 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
5843 * desired behavior of a selector -- it does not impact the base meaning
5844 * of the Intent, just what kinds of things will be matched against it
5845 * when determining who can handle it.</p>
5846 *
5847 * <p>You can not use both a selector and {@link #setPackage(String)} on
5848 * the same base Intent.</p>
5849 *
5850 * @param selector The desired selector Intent; set to null to not use
5851 * a special selector.
5852 */
5853 public void setSelector(Intent selector) {
5854 if (selector == this) {
5855 throw new IllegalArgumentException(
5856 "Intent being set as a selector of itself");
5857 }
5858 if (selector != null && mPackage != null) {
5859 throw new IllegalArgumentException(
5860 "Can't set selector when package name is already set");
5861 }
5862 mSelector = selector;
5863 }
5864
5865 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005866 * Set a {@link ClipData} associated with this Intent. This replaces any
5867 * previously set ClipData.
5868 *
5869 * <p>The ClipData in an intent is not used for Intent matching or other
5870 * such operations. Semantically it is like extras, used to transmit
5871 * additional data with the Intent. The main feature of using this over
5872 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
5873 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
5874 * items included in the clip data. This is useful, in particular, if
5875 * you want to transmit an Intent containing multiple <code>content:</code>
5876 * URIs for which the recipient may not have global permission to access the
5877 * content provider.
5878 *
5879 * <p>If the ClipData contains items that are themselves Intents, any
5880 * grant flags in those Intents will be ignored. Only the top-level flags
5881 * of the main Intent are respected, and will be applied to all Uri or
5882 * Intent items in the clip (or sub-items of the clip).
5883 *
5884 * <p>The MIME type, label, and icon in the ClipData object are not
5885 * directly used by Intent. Applications should generally rely on the
5886 * MIME type of the Intent itself, not what it may find in the ClipData.
5887 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05005888 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005889 *
5890 * @param clip The new clip to set. May be null to clear the current clip.
5891 */
5892 public void setClipData(ClipData clip) {
5893 mClipData = clip;
5894 }
5895
5896 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005897 * This is NOT a secure mechanism to identify the user who sent the intent.
5898 * When the intent is sent to a different user, it is used to fix uris by adding the userId
5899 * who sent the intent.
5900 * @hide
5901 */
5902 public void setContentUserHint(int contentUserHint) {
5903 mContentUserHint = contentUserHint;
5904 }
5905
5906 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005907 * Add extended data to the intent. The name must include a package
5908 * prefix, for example the app com.android.contacts would use names
5909 * like "com.android.contacts.ShowAll".
5910 *
5911 * @param name The name of the extra data, with package prefix.
5912 * @param value The boolean data value.
5913 *
5914 * @return Returns the same Intent object, for chaining multiple calls
5915 * into a single statement.
5916 *
5917 * @see #putExtras
5918 * @see #removeExtra
5919 * @see #getBooleanExtra(String, boolean)
5920 */
5921 public Intent putExtra(String name, boolean value) {
5922 if (mExtras == null) {
5923 mExtras = new Bundle();
5924 }
5925 mExtras.putBoolean(name, value);
5926 return this;
5927 }
5928
5929 /**
5930 * Add extended data to the intent. The name must include a package
5931 * prefix, for example the app com.android.contacts would use names
5932 * like "com.android.contacts.ShowAll".
5933 *
5934 * @param name The name of the extra data, with package prefix.
5935 * @param value The byte data value.
5936 *
5937 * @return Returns the same Intent object, for chaining multiple calls
5938 * into a single statement.
5939 *
5940 * @see #putExtras
5941 * @see #removeExtra
5942 * @see #getByteExtra(String, byte)
5943 */
5944 public Intent putExtra(String name, byte value) {
5945 if (mExtras == null) {
5946 mExtras = new Bundle();
5947 }
5948 mExtras.putByte(name, value);
5949 return this;
5950 }
5951
5952 /**
5953 * Add extended data to the intent. The name must include a package
5954 * prefix, for example the app com.android.contacts would use names
5955 * like "com.android.contacts.ShowAll".
5956 *
5957 * @param name The name of the extra data, with package prefix.
5958 * @param value The char data value.
5959 *
5960 * @return Returns the same Intent object, for chaining multiple calls
5961 * into a single statement.
5962 *
5963 * @see #putExtras
5964 * @see #removeExtra
5965 * @see #getCharExtra(String, char)
5966 */
5967 public Intent putExtra(String name, char value) {
5968 if (mExtras == null) {
5969 mExtras = new Bundle();
5970 }
5971 mExtras.putChar(name, value);
5972 return this;
5973 }
5974
5975 /**
5976 * Add extended data to the intent. The name must include a package
5977 * prefix, for example the app com.android.contacts would use names
5978 * like "com.android.contacts.ShowAll".
5979 *
5980 * @param name The name of the extra data, with package prefix.
5981 * @param value The short data value.
5982 *
5983 * @return Returns the same Intent object, for chaining multiple calls
5984 * into a single statement.
5985 *
5986 * @see #putExtras
5987 * @see #removeExtra
5988 * @see #getShortExtra(String, short)
5989 */
5990 public Intent putExtra(String name, short value) {
5991 if (mExtras == null) {
5992 mExtras = new Bundle();
5993 }
5994 mExtras.putShort(name, value);
5995 return this;
5996 }
5997
5998 /**
5999 * Add extended data to the intent. The name must include a package
6000 * prefix, for example the app com.android.contacts would use names
6001 * like "com.android.contacts.ShowAll".
6002 *
6003 * @param name The name of the extra data, with package prefix.
6004 * @param value The integer data value.
6005 *
6006 * @return Returns the same Intent object, for chaining multiple calls
6007 * into a single statement.
6008 *
6009 * @see #putExtras
6010 * @see #removeExtra
6011 * @see #getIntExtra(String, int)
6012 */
6013 public Intent putExtra(String name, int value) {
6014 if (mExtras == null) {
6015 mExtras = new Bundle();
6016 }
6017 mExtras.putInt(name, value);
6018 return this;
6019 }
6020
6021 /**
6022 * Add extended data to the intent. The name must include a package
6023 * prefix, for example the app com.android.contacts would use names
6024 * like "com.android.contacts.ShowAll".
6025 *
6026 * @param name The name of the extra data, with package prefix.
6027 * @param value The long data value.
6028 *
6029 * @return Returns the same Intent object, for chaining multiple calls
6030 * into a single statement.
6031 *
6032 * @see #putExtras
6033 * @see #removeExtra
6034 * @see #getLongExtra(String, long)
6035 */
6036 public Intent putExtra(String name, long value) {
6037 if (mExtras == null) {
6038 mExtras = new Bundle();
6039 }
6040 mExtras.putLong(name, value);
6041 return this;
6042 }
6043
6044 /**
6045 * Add extended data to the intent. The name must include a package
6046 * prefix, for example the app com.android.contacts would use names
6047 * like "com.android.contacts.ShowAll".
6048 *
6049 * @param name The name of the extra data, with package prefix.
6050 * @param value The float data value.
6051 *
6052 * @return Returns the same Intent object, for chaining multiple calls
6053 * into a single statement.
6054 *
6055 * @see #putExtras
6056 * @see #removeExtra
6057 * @see #getFloatExtra(String, float)
6058 */
6059 public Intent putExtra(String name, float value) {
6060 if (mExtras == null) {
6061 mExtras = new Bundle();
6062 }
6063 mExtras.putFloat(name, value);
6064 return this;
6065 }
6066
6067 /**
6068 * Add extended data to the intent. The name must include a package
6069 * prefix, for example the app com.android.contacts would use names
6070 * like "com.android.contacts.ShowAll".
6071 *
6072 * @param name The name of the extra data, with package prefix.
6073 * @param value The double data value.
6074 *
6075 * @return Returns the same Intent object, for chaining multiple calls
6076 * into a single statement.
6077 *
6078 * @see #putExtras
6079 * @see #removeExtra
6080 * @see #getDoubleExtra(String, double)
6081 */
6082 public Intent putExtra(String name, double value) {
6083 if (mExtras == null) {
6084 mExtras = new Bundle();
6085 }
6086 mExtras.putDouble(name, value);
6087 return this;
6088 }
6089
6090 /**
6091 * Add extended data to the intent. The name must include a package
6092 * prefix, for example the app com.android.contacts would use names
6093 * like "com.android.contacts.ShowAll".
6094 *
6095 * @param name The name of the extra data, with package prefix.
6096 * @param value The String data value.
6097 *
6098 * @return Returns the same Intent object, for chaining multiple calls
6099 * into a single statement.
6100 *
6101 * @see #putExtras
6102 * @see #removeExtra
6103 * @see #getStringExtra(String)
6104 */
6105 public Intent putExtra(String name, String value) {
6106 if (mExtras == null) {
6107 mExtras = new Bundle();
6108 }
6109 mExtras.putString(name, value);
6110 return this;
6111 }
6112
6113 /**
6114 * Add extended data to the intent. The name must include a package
6115 * prefix, for example the app com.android.contacts would use names
6116 * like "com.android.contacts.ShowAll".
6117 *
6118 * @param name The name of the extra data, with package prefix.
6119 * @param value The CharSequence data value.
6120 *
6121 * @return Returns the same Intent object, for chaining multiple calls
6122 * into a single statement.
6123 *
6124 * @see #putExtras
6125 * @see #removeExtra
6126 * @see #getCharSequenceExtra(String)
6127 */
6128 public Intent putExtra(String name, CharSequence value) {
6129 if (mExtras == null) {
6130 mExtras = new Bundle();
6131 }
6132 mExtras.putCharSequence(name, value);
6133 return this;
6134 }
6135
6136 /**
6137 * Add extended data to the intent. The name must include a package
6138 * prefix, for example the app com.android.contacts would use names
6139 * like "com.android.contacts.ShowAll".
6140 *
6141 * @param name The name of the extra data, with package prefix.
6142 * @param value The Parcelable data value.
6143 *
6144 * @return Returns the same Intent object, for chaining multiple calls
6145 * into a single statement.
6146 *
6147 * @see #putExtras
6148 * @see #removeExtra
6149 * @see #getParcelableExtra(String)
6150 */
6151 public Intent putExtra(String name, Parcelable value) {
6152 if (mExtras == null) {
6153 mExtras = new Bundle();
6154 }
6155 mExtras.putParcelable(name, value);
6156 return this;
6157 }
6158
6159 /**
6160 * Add extended data to the intent. The name must include a package
6161 * prefix, for example the app com.android.contacts would use names
6162 * like "com.android.contacts.ShowAll".
6163 *
6164 * @param name The name of the extra data, with package prefix.
6165 * @param value The Parcelable[] data value.
6166 *
6167 * @return Returns the same Intent object, for chaining multiple calls
6168 * into a single statement.
6169 *
6170 * @see #putExtras
6171 * @see #removeExtra
6172 * @see #getParcelableArrayExtra(String)
6173 */
6174 public Intent putExtra(String name, Parcelable[] value) {
6175 if (mExtras == null) {
6176 mExtras = new Bundle();
6177 }
6178 mExtras.putParcelableArray(name, value);
6179 return this;
6180 }
6181
6182 /**
6183 * Add extended data to the intent. The name must include a package
6184 * prefix, for example the app com.android.contacts would use names
6185 * like "com.android.contacts.ShowAll".
6186 *
6187 * @param name The name of the extra data, with package prefix.
6188 * @param value The ArrayList<Parcelable> data value.
6189 *
6190 * @return Returns the same Intent object, for chaining multiple calls
6191 * into a single statement.
6192 *
6193 * @see #putExtras
6194 * @see #removeExtra
6195 * @see #getParcelableArrayListExtra(String)
6196 */
6197 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6198 if (mExtras == null) {
6199 mExtras = new Bundle();
6200 }
6201 mExtras.putParcelableArrayList(name, value);
6202 return this;
6203 }
6204
6205 /**
6206 * Add extended data to the intent. The name must include a package
6207 * prefix, for example the app com.android.contacts would use names
6208 * like "com.android.contacts.ShowAll".
6209 *
6210 * @param name The name of the extra data, with package prefix.
6211 * @param value The ArrayList<Integer> data value.
6212 *
6213 * @return Returns the same Intent object, for chaining multiple calls
6214 * into a single statement.
6215 *
6216 * @see #putExtras
6217 * @see #removeExtra
6218 * @see #getIntegerArrayListExtra(String)
6219 */
6220 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6221 if (mExtras == null) {
6222 mExtras = new Bundle();
6223 }
6224 mExtras.putIntegerArrayList(name, value);
6225 return this;
6226 }
6227
6228 /**
6229 * Add extended data to the intent. The name must include a package
6230 * prefix, for example the app com.android.contacts would use names
6231 * like "com.android.contacts.ShowAll".
6232 *
6233 * @param name The name of the extra data, with package prefix.
6234 * @param value The ArrayList<String> data value.
6235 *
6236 * @return Returns the same Intent object, for chaining multiple calls
6237 * into a single statement.
6238 *
6239 * @see #putExtras
6240 * @see #removeExtra
6241 * @see #getStringArrayListExtra(String)
6242 */
6243 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6244 if (mExtras == null) {
6245 mExtras = new Bundle();
6246 }
6247 mExtras.putStringArrayList(name, value);
6248 return this;
6249 }
6250
6251 /**
6252 * Add extended data to the intent. The name must include a package
6253 * prefix, for example the app com.android.contacts would use names
6254 * like "com.android.contacts.ShowAll".
6255 *
6256 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006257 * @param value The ArrayList<CharSequence> data value.
6258 *
6259 * @return Returns the same Intent object, for chaining multiple calls
6260 * into a single statement.
6261 *
6262 * @see #putExtras
6263 * @see #removeExtra
6264 * @see #getCharSequenceArrayListExtra(String)
6265 */
6266 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6267 if (mExtras == null) {
6268 mExtras = new Bundle();
6269 }
6270 mExtras.putCharSequenceArrayList(name, value);
6271 return this;
6272 }
6273
6274 /**
6275 * Add extended data to the intent. The name must include a package
6276 * prefix, for example the app com.android.contacts would use names
6277 * like "com.android.contacts.ShowAll".
6278 *
6279 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006280 * @param value The Serializable data value.
6281 *
6282 * @return Returns the same Intent object, for chaining multiple calls
6283 * into a single statement.
6284 *
6285 * @see #putExtras
6286 * @see #removeExtra
6287 * @see #getSerializableExtra(String)
6288 */
6289 public Intent putExtra(String name, Serializable value) {
6290 if (mExtras == null) {
6291 mExtras = new Bundle();
6292 }
6293 mExtras.putSerializable(name, value);
6294 return this;
6295 }
6296
6297 /**
6298 * Add extended data to the intent. The name must include a package
6299 * prefix, for example the app com.android.contacts would use names
6300 * like "com.android.contacts.ShowAll".
6301 *
6302 * @param name The name of the extra data, with package prefix.
6303 * @param value The boolean array data value.
6304 *
6305 * @return Returns the same Intent object, for chaining multiple calls
6306 * into a single statement.
6307 *
6308 * @see #putExtras
6309 * @see #removeExtra
6310 * @see #getBooleanArrayExtra(String)
6311 */
6312 public Intent putExtra(String name, boolean[] value) {
6313 if (mExtras == null) {
6314 mExtras = new Bundle();
6315 }
6316 mExtras.putBooleanArray(name, value);
6317 return this;
6318 }
6319
6320 /**
6321 * Add extended data to the intent. The name must include a package
6322 * prefix, for example the app com.android.contacts would use names
6323 * like "com.android.contacts.ShowAll".
6324 *
6325 * @param name The name of the extra data, with package prefix.
6326 * @param value The byte array data value.
6327 *
6328 * @return Returns the same Intent object, for chaining multiple calls
6329 * into a single statement.
6330 *
6331 * @see #putExtras
6332 * @see #removeExtra
6333 * @see #getByteArrayExtra(String)
6334 */
6335 public Intent putExtra(String name, byte[] value) {
6336 if (mExtras == null) {
6337 mExtras = new Bundle();
6338 }
6339 mExtras.putByteArray(name, value);
6340 return this;
6341 }
6342
6343 /**
6344 * Add extended data to the intent. The name must include a package
6345 * prefix, for example the app com.android.contacts would use names
6346 * like "com.android.contacts.ShowAll".
6347 *
6348 * @param name The name of the extra data, with package prefix.
6349 * @param value The short array data value.
6350 *
6351 * @return Returns the same Intent object, for chaining multiple calls
6352 * into a single statement.
6353 *
6354 * @see #putExtras
6355 * @see #removeExtra
6356 * @see #getShortArrayExtra(String)
6357 */
6358 public Intent putExtra(String name, short[] value) {
6359 if (mExtras == null) {
6360 mExtras = new Bundle();
6361 }
6362 mExtras.putShortArray(name, value);
6363 return this;
6364 }
6365
6366 /**
6367 * Add extended data to the intent. The name must include a package
6368 * prefix, for example the app com.android.contacts would use names
6369 * like "com.android.contacts.ShowAll".
6370 *
6371 * @param name The name of the extra data, with package prefix.
6372 * @param value The char array data value.
6373 *
6374 * @return Returns the same Intent object, for chaining multiple calls
6375 * into a single statement.
6376 *
6377 * @see #putExtras
6378 * @see #removeExtra
6379 * @see #getCharArrayExtra(String)
6380 */
6381 public Intent putExtra(String name, char[] value) {
6382 if (mExtras == null) {
6383 mExtras = new Bundle();
6384 }
6385 mExtras.putCharArray(name, value);
6386 return this;
6387 }
6388
6389 /**
6390 * Add extended data to the intent. The name must include a package
6391 * prefix, for example the app com.android.contacts would use names
6392 * like "com.android.contacts.ShowAll".
6393 *
6394 * @param name The name of the extra data, with package prefix.
6395 * @param value The int array data value.
6396 *
6397 * @return Returns the same Intent object, for chaining multiple calls
6398 * into a single statement.
6399 *
6400 * @see #putExtras
6401 * @see #removeExtra
6402 * @see #getIntArrayExtra(String)
6403 */
6404 public Intent putExtra(String name, int[] value) {
6405 if (mExtras == null) {
6406 mExtras = new Bundle();
6407 }
6408 mExtras.putIntArray(name, value);
6409 return this;
6410 }
6411
6412 /**
6413 * Add extended data to the intent. The name must include a package
6414 * prefix, for example the app com.android.contacts would use names
6415 * like "com.android.contacts.ShowAll".
6416 *
6417 * @param name The name of the extra data, with package prefix.
6418 * @param value The byte array data value.
6419 *
6420 * @return Returns the same Intent object, for chaining multiple calls
6421 * into a single statement.
6422 *
6423 * @see #putExtras
6424 * @see #removeExtra
6425 * @see #getLongArrayExtra(String)
6426 */
6427 public Intent putExtra(String name, long[] value) {
6428 if (mExtras == null) {
6429 mExtras = new Bundle();
6430 }
6431 mExtras.putLongArray(name, value);
6432 return this;
6433 }
6434
6435 /**
6436 * Add extended data to the intent. The name must include a package
6437 * prefix, for example the app com.android.contacts would use names
6438 * like "com.android.contacts.ShowAll".
6439 *
6440 * @param name The name of the extra data, with package prefix.
6441 * @param value The float array data value.
6442 *
6443 * @return Returns the same Intent object, for chaining multiple calls
6444 * into a single statement.
6445 *
6446 * @see #putExtras
6447 * @see #removeExtra
6448 * @see #getFloatArrayExtra(String)
6449 */
6450 public Intent putExtra(String name, float[] value) {
6451 if (mExtras == null) {
6452 mExtras = new Bundle();
6453 }
6454 mExtras.putFloatArray(name, value);
6455 return this;
6456 }
6457
6458 /**
6459 * Add extended data to the intent. The name must include a package
6460 * prefix, for example the app com.android.contacts would use names
6461 * like "com.android.contacts.ShowAll".
6462 *
6463 * @param name The name of the extra data, with package prefix.
6464 * @param value The double array data value.
6465 *
6466 * @return Returns the same Intent object, for chaining multiple calls
6467 * into a single statement.
6468 *
6469 * @see #putExtras
6470 * @see #removeExtra
6471 * @see #getDoubleArrayExtra(String)
6472 */
6473 public Intent putExtra(String name, double[] value) {
6474 if (mExtras == null) {
6475 mExtras = new Bundle();
6476 }
6477 mExtras.putDoubleArray(name, value);
6478 return this;
6479 }
6480
6481 /**
6482 * Add extended data to the intent. The name must include a package
6483 * prefix, for example the app com.android.contacts would use names
6484 * like "com.android.contacts.ShowAll".
6485 *
6486 * @param name The name of the extra data, with package prefix.
6487 * @param value The String array data value.
6488 *
6489 * @return Returns the same Intent object, for chaining multiple calls
6490 * into a single statement.
6491 *
6492 * @see #putExtras
6493 * @see #removeExtra
6494 * @see #getStringArrayExtra(String)
6495 */
6496 public Intent putExtra(String name, String[] value) {
6497 if (mExtras == null) {
6498 mExtras = new Bundle();
6499 }
6500 mExtras.putStringArray(name, value);
6501 return this;
6502 }
6503
6504 /**
6505 * Add extended data to the intent. The name must include a package
6506 * prefix, for example the app com.android.contacts would use names
6507 * like "com.android.contacts.ShowAll".
6508 *
6509 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006510 * @param value The CharSequence array data value.
6511 *
6512 * @return Returns the same Intent object, for chaining multiple calls
6513 * into a single statement.
6514 *
6515 * @see #putExtras
6516 * @see #removeExtra
6517 * @see #getCharSequenceArrayExtra(String)
6518 */
6519 public Intent putExtra(String name, CharSequence[] value) {
6520 if (mExtras == null) {
6521 mExtras = new Bundle();
6522 }
6523 mExtras.putCharSequenceArray(name, value);
6524 return this;
6525 }
6526
6527 /**
6528 * Add extended data to the intent. The name must include a package
6529 * prefix, for example the app com.android.contacts would use names
6530 * like "com.android.contacts.ShowAll".
6531 *
6532 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006533 * @param value The Bundle data value.
6534 *
6535 * @return Returns the same Intent object, for chaining multiple calls
6536 * into a single statement.
6537 *
6538 * @see #putExtras
6539 * @see #removeExtra
6540 * @see #getBundleExtra(String)
6541 */
6542 public Intent putExtra(String name, Bundle value) {
6543 if (mExtras == null) {
6544 mExtras = new Bundle();
6545 }
6546 mExtras.putBundle(name, value);
6547 return this;
6548 }
6549
6550 /**
6551 * Add extended data to the intent. The name must include a package
6552 * prefix, for example the app com.android.contacts would use names
6553 * like "com.android.contacts.ShowAll".
6554 *
6555 * @param name The name of the extra data, with package prefix.
6556 * @param value The IBinder data value.
6557 *
6558 * @return Returns the same Intent object, for chaining multiple calls
6559 * into a single statement.
6560 *
6561 * @see #putExtras
6562 * @see #removeExtra
6563 * @see #getIBinderExtra(String)
6564 *
6565 * @deprecated
6566 * @hide
6567 */
6568 @Deprecated
6569 public Intent putExtra(String name, IBinder value) {
6570 if (mExtras == null) {
6571 mExtras = new Bundle();
6572 }
6573 mExtras.putIBinder(name, value);
6574 return this;
6575 }
6576
6577 /**
6578 * Copy all extras in 'src' in to this intent.
6579 *
6580 * @param src Contains the extras to copy.
6581 *
6582 * @see #putExtra
6583 */
6584 public Intent putExtras(Intent src) {
6585 if (src.mExtras != null) {
6586 if (mExtras == null) {
6587 mExtras = new Bundle(src.mExtras);
6588 } else {
6589 mExtras.putAll(src.mExtras);
6590 }
6591 }
6592 return this;
6593 }
6594
6595 /**
6596 * Add a set of extended data to the intent. The keys 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 extras The Bundle of extras to add to this intent.
6601 *
6602 * @see #putExtra
6603 * @see #removeExtra
6604 */
6605 public Intent putExtras(Bundle extras) {
6606 if (mExtras == null) {
6607 mExtras = new Bundle();
6608 }
6609 mExtras.putAll(extras);
6610 return this;
6611 }
6612
6613 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006614 * Completely replace the extras in the Intent with the extras in the
6615 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006616 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006617 * @param src The exact extras contained in this Intent are copied
6618 * into the target intent, replacing any that were previously there.
6619 */
6620 public Intent replaceExtras(Intent src) {
6621 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6622 return this;
6623 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006624
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006625 /**
6626 * Completely replace the extras in the Intent with the given Bundle of
6627 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006628 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006629 * @param extras The new set of extras in the Intent, or null to erase
6630 * all extras.
6631 */
6632 public Intent replaceExtras(Bundle extras) {
6633 mExtras = extras != null ? new Bundle(extras) : null;
6634 return this;
6635 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006636
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006637 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006638 * Remove extended data from the intent.
6639 *
6640 * @see #putExtra
6641 */
6642 public void removeExtra(String name) {
6643 if (mExtras != null) {
6644 mExtras.remove(name);
6645 if (mExtras.size() == 0) {
6646 mExtras = null;
6647 }
6648 }
6649 }
6650
6651 /**
6652 * Set special flags controlling how this intent is handled. Most values
6653 * here depend on the type of component being executed by the Intent,
6654 * specifically the FLAG_ACTIVITY_* flags are all for use with
6655 * {@link Context#startActivity Context.startActivity()} and the
6656 * FLAG_RECEIVER_* flags are all for use with
6657 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6658 *
Scott Main7aee61f2011-02-08 11:25:01 -08006659 * <p>See the
6660 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6661 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006662 * the behavior of your application.
6663 *
6664 * @param flags The desired flags.
6665 *
6666 * @return Returns the same Intent object, for chaining multiple calls
6667 * into a single statement.
6668 *
6669 * @see #getFlags
6670 * @see #addFlags
6671 *
6672 * @see #FLAG_GRANT_READ_URI_PERMISSION
6673 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006674 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6675 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006676 * @see #FLAG_DEBUG_LOG_RESOLUTION
6677 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006678 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006679 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006680 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006681 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006682 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6683 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006684 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006685 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006686 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006687 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006688 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006689 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006690 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006691 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6692 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006693 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006694 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006695 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006696 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6697 */
6698 public Intent setFlags(int flags) {
6699 mFlags = flags;
6700 return this;
6701 }
6702
6703 /**
6704 * Add additional flags to the intent (or with existing flags
6705 * value).
6706 *
6707 * @param flags The new flags to set.
6708 *
6709 * @return Returns the same Intent object, for chaining multiple calls
6710 * into a single statement.
6711 *
6712 * @see #setFlags
6713 */
6714 public Intent addFlags(int flags) {
6715 mFlags |= flags;
6716 return this;
6717 }
6718
6719 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006720 * (Usually optional) Set an explicit application package name that limits
6721 * the components this Intent will resolve to. If left to the default
6722 * value of null, all components in all applications will considered.
6723 * If non-null, the Intent can only match the components in the given
6724 * application package.
6725 *
6726 * @param packageName The name of the application package to handle the
6727 * intent, or null to allow any application package.
6728 *
6729 * @return Returns the same Intent object, for chaining multiple calls
6730 * into a single statement.
6731 *
6732 * @see #getPackage
6733 * @see #resolveActivity
6734 */
6735 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006736 if (packageName != null && mSelector != null) {
6737 throw new IllegalArgumentException(
6738 "Can't set package name when selector is already set");
6739 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006740 mPackage = packageName;
6741 return this;
6742 }
6743
6744 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006745 * (Usually optional) Explicitly set the component to handle the intent.
6746 * If left with the default value of null, the system will determine the
6747 * appropriate class to use based on the other fields (action, data,
6748 * type, categories) in the Intent. If this class is defined, the
6749 * specified class will always be used regardless of the other fields. You
6750 * should only set this value when you know you absolutely want a specific
6751 * class to be used; otherwise it is better to let the system find the
6752 * appropriate class so that you will respect the installed applications
6753 * and user preferences.
6754 *
6755 * @param component The name of the application component to handle the
6756 * intent, or null to let the system find one for you.
6757 *
6758 * @return Returns the same Intent object, for chaining multiple calls
6759 * into a single statement.
6760 *
6761 * @see #setClass
6762 * @see #setClassName(Context, String)
6763 * @see #setClassName(String, String)
6764 * @see #getComponent
6765 * @see #resolveActivity
6766 */
6767 public Intent setComponent(ComponentName component) {
6768 mComponent = component;
6769 return this;
6770 }
6771
6772 /**
6773 * Convenience for calling {@link #setComponent} with an
6774 * explicit class name.
6775 *
6776 * @param packageContext A Context of the application package implementing
6777 * this class.
6778 * @param className The name of a class inside of the application package
6779 * that will be used as the component for this Intent.
6780 *
6781 * @return Returns the same Intent object, for chaining multiple calls
6782 * into a single statement.
6783 *
6784 * @see #setComponent
6785 * @see #setClass
6786 */
6787 public Intent setClassName(Context packageContext, String className) {
6788 mComponent = new ComponentName(packageContext, className);
6789 return this;
6790 }
6791
6792 /**
6793 * Convenience for calling {@link #setComponent} with an
6794 * explicit application package name and class name.
6795 *
6796 * @param packageName The name of the package implementing the desired
6797 * component.
6798 * @param className The name of a class inside of the application package
6799 * that will be used as the component for this Intent.
6800 *
6801 * @return Returns the same Intent object, for chaining multiple calls
6802 * into a single statement.
6803 *
6804 * @see #setComponent
6805 * @see #setClass
6806 */
6807 public Intent setClassName(String packageName, String className) {
6808 mComponent = new ComponentName(packageName, className);
6809 return this;
6810 }
6811
6812 /**
6813 * Convenience for calling {@link #setComponent(ComponentName)} with the
6814 * name returned by a {@link Class} object.
6815 *
6816 * @param packageContext A Context of the application package implementing
6817 * this class.
6818 * @param cls The class name to set, equivalent to
6819 * <code>setClassName(context, cls.getName())</code>.
6820 *
6821 * @return Returns the same Intent object, for chaining multiple calls
6822 * into a single statement.
6823 *
6824 * @see #setComponent
6825 */
6826 public Intent setClass(Context packageContext, Class<?> cls) {
6827 mComponent = new ComponentName(packageContext, cls);
6828 return this;
6829 }
6830
6831 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006832 * Set the bounds of the sender of this intent, in screen coordinates. This can be
6833 * used as a hint to the receiver for animations and the like. Null means that there
6834 * is no source bounds.
6835 */
6836 public void setSourceBounds(Rect r) {
6837 if (r != null) {
6838 mSourceBounds = new Rect(r);
6839 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07006840 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006841 }
6842 }
6843
Tor Norbyed9273d62013-05-30 15:59:53 -07006844 /** @hide */
6845 @IntDef(flag = true,
6846 value = {
6847 FILL_IN_ACTION,
6848 FILL_IN_DATA,
6849 FILL_IN_CATEGORIES,
6850 FILL_IN_COMPONENT,
6851 FILL_IN_PACKAGE,
6852 FILL_IN_SOURCE_BOUNDS,
6853 FILL_IN_SELECTOR,
6854 FILL_IN_CLIP_DATA
6855 })
6856 @Retention(RetentionPolicy.SOURCE)
6857 public @interface FillInFlags {}
6858
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006859 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006860 * Use with {@link #fillIn} to allow the current action value to be
6861 * overwritten, even if it is already set.
6862 */
6863 public static final int FILL_IN_ACTION = 1<<0;
6864
6865 /**
6866 * Use with {@link #fillIn} to allow the current data or type value
6867 * overwritten, even if it is already set.
6868 */
6869 public static final int FILL_IN_DATA = 1<<1;
6870
6871 /**
6872 * Use with {@link #fillIn} to allow the current categories to be
6873 * overwritten, even if they are already set.
6874 */
6875 public static final int FILL_IN_CATEGORIES = 1<<2;
6876
6877 /**
6878 * Use with {@link #fillIn} to allow the current component value to be
6879 * overwritten, even if it is already set.
6880 */
6881 public static final int FILL_IN_COMPONENT = 1<<3;
6882
6883 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006884 * Use with {@link #fillIn} to allow the current package value to be
6885 * overwritten, even if it is already set.
6886 */
6887 public static final int FILL_IN_PACKAGE = 1<<4;
6888
6889 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006890 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006891 * overwritten, even if it is already set.
6892 */
6893 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
6894
6895 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006896 * Use with {@link #fillIn} to allow the current selector to be
6897 * overwritten, even if it is already set.
6898 */
6899 public static final int FILL_IN_SELECTOR = 1<<6;
6900
6901 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006902 * Use with {@link #fillIn} to allow the current ClipData to be
6903 * overwritten, even if it is already set.
6904 */
6905 public static final int FILL_IN_CLIP_DATA = 1<<7;
6906
6907 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006908 * Copy the contents of <var>other</var> in to this object, but only
6909 * where fields are not defined by this object. For purposes of a field
6910 * being defined, the following pieces of data in the Intent are
6911 * considered to be separate fields:
6912 *
6913 * <ul>
6914 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08006915 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006916 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
6917 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006918 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006919 * <li> component, as set by {@link #setComponent(ComponentName)} or
6920 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006921 * <li> source bounds, as set by {@link #setSourceBounds}.
6922 * <li> selector, as set by {@link #setSelector(Intent)}.
6923 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006924 * <li> each top-level name in the associated extras.
6925 * </ul>
6926 *
6927 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006928 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006929 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
6930 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
6931 * the restriction where the corresponding field will not be replaced if
6932 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006933 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006934 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
6935 * is explicitly specified. The selector will only be copied if
6936 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07006937 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006938 * <p>For example, consider Intent A with {data="foo", categories="bar"}
6939 * and Intent B with {action="gotit", data-type="some/thing",
6940 * categories="one","two"}.
6941 *
6942 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
6943 * containing: {action="gotit", data-type="some/thing",
6944 * categories="bar"}.
6945 *
6946 * @param other Another Intent whose values are to be used to fill in
6947 * the current one.
6948 * @param flags Options to control which fields can be filled in.
6949 *
6950 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006951 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07006952 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
6953 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
6954 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006955 */
Tor Norbyed9273d62013-05-30 15:59:53 -07006956 @FillInFlags
6957 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006958 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006959 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006960 if (other.mAction != null
6961 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006962 mAction = other.mAction;
6963 changes |= FILL_IN_ACTION;
6964 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006965 if ((other.mData != null || other.mType != null)
6966 && ((mData == null && mType == null)
6967 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006968 mData = other.mData;
6969 mType = other.mType;
6970 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006971 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006972 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006973 if (other.mCategories != null
6974 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006975 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006976 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006977 }
6978 changes |= FILL_IN_CATEGORIES;
6979 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006980 if (other.mPackage != null
6981 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006982 // Only do this if mSelector is not set.
6983 if (mSelector == null) {
6984 mPackage = other.mPackage;
6985 changes |= FILL_IN_PACKAGE;
6986 }
6987 }
6988 // Selector is special: it can only be set if explicitly allowed,
6989 // for the same reason as the component name.
6990 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
6991 if (mPackage == null) {
6992 mSelector = new Intent(other.mSelector);
6993 mPackage = null;
6994 changes |= FILL_IN_SELECTOR;
6995 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006996 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006997 if (other.mClipData != null
6998 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
6999 mClipData = other.mClipData;
7000 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007001 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007002 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007003 // Component is special: it can -only- be set if explicitly allowed,
7004 // since otherwise the sender could force the intent somewhere the
7005 // originator didn't intend.
7006 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007007 mComponent = other.mComponent;
7008 changes |= FILL_IN_COMPONENT;
7009 }
7010 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007011 if (other.mSourceBounds != null
7012 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7013 mSourceBounds = new Rect(other.mSourceBounds);
7014 changes |= FILL_IN_SOURCE_BOUNDS;
7015 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007016 if (mExtras == null) {
7017 if (other.mExtras != null) {
7018 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007019 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007020 }
7021 } else if (other.mExtras != null) {
7022 try {
7023 Bundle newb = new Bundle(other.mExtras);
7024 newb.putAll(mExtras);
7025 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007026 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007027 } catch (RuntimeException e) {
7028 // Modifying the extras can cause us to unparcel the contents
7029 // of the bundle, and if we do this in the system process that
7030 // may fail. We really should handle this (i.e., the Bundle
7031 // impl shouldn't be on top of a plain map), but for now just
7032 // ignore it and keep the original contents. :(
7033 Log.w("Intent", "Failure filling in extras", e);
7034 }
7035 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007036 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7037 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7038 mContentUserHint = other.mContentUserHint;
7039 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007040 return changes;
7041 }
7042
7043 /**
7044 * Wrapper class holding an Intent and implementing comparisons on it for
7045 * the purpose of filtering. The class implements its
7046 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7047 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7048 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7049 * on the wrapped Intent.
7050 */
7051 public static final class FilterComparison {
7052 private final Intent mIntent;
7053 private final int mHashCode;
7054
7055 public FilterComparison(Intent intent) {
7056 mIntent = intent;
7057 mHashCode = intent.filterHashCode();
7058 }
7059
7060 /**
7061 * Return the Intent that this FilterComparison represents.
7062 * @return Returns the Intent held by the FilterComparison. Do
7063 * not modify!
7064 */
7065 public Intent getIntent() {
7066 return mIntent;
7067 }
7068
7069 @Override
7070 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007071 if (obj instanceof FilterComparison) {
7072 Intent other = ((FilterComparison)obj).mIntent;
7073 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007074 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007075 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007076 }
7077
7078 @Override
7079 public int hashCode() {
7080 return mHashCode;
7081 }
7082 }
7083
7084 /**
7085 * Determine if two intents are the same for the purposes of intent
7086 * resolution (filtering). That is, if their action, data, type,
7087 * class, and categories are the same. This does <em>not</em> compare
7088 * any extra data included in the intents.
7089 *
7090 * @param other The other Intent to compare against.
7091 *
7092 * @return Returns true if action, data, type, class, and categories
7093 * are the same.
7094 */
7095 public boolean filterEquals(Intent other) {
7096 if (other == null) {
7097 return false;
7098 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007099 if (!Objects.equals(this.mAction, other.mAction)) return false;
7100 if (!Objects.equals(this.mData, other.mData)) return false;
7101 if (!Objects.equals(this.mType, other.mType)) return false;
7102 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7103 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7104 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007105
7106 return true;
7107 }
7108
7109 /**
7110 * Generate hash code that matches semantics of filterEquals().
7111 *
7112 * @return Returns the hash value of the action, data, type, class, and
7113 * categories.
7114 *
7115 * @see #filterEquals
7116 */
7117 public int filterHashCode() {
7118 int code = 0;
7119 if (mAction != null) {
7120 code += mAction.hashCode();
7121 }
7122 if (mData != null) {
7123 code += mData.hashCode();
7124 }
7125 if (mType != null) {
7126 code += mType.hashCode();
7127 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007128 if (mPackage != null) {
7129 code += mPackage.hashCode();
7130 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007131 if (mComponent != null) {
7132 code += mComponent.hashCode();
7133 }
7134 if (mCategories != null) {
7135 code += mCategories.hashCode();
7136 }
7137 return code;
7138 }
7139
7140 @Override
7141 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007142 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007143
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007144 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007145 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007146 b.append(" }");
7147
7148 return b.toString();
7149 }
7150
7151 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007152 public String toInsecureString() {
7153 StringBuilder b = new StringBuilder(128);
7154
7155 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007156 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007157 b.append(" }");
7158
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007159 return b.toString();
7160 }
Romain Guy4969af72009-06-17 10:53:19 -07007161
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007162 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007163 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007164 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007165
7166 b.append("Intent { ");
7167 toShortString(b, false, true, true, true);
7168 b.append(" }");
7169
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007170 return b.toString();
7171 }
7172
7173 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007174 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7175 StringBuilder b = new StringBuilder(128);
7176 toShortString(b, secure, comp, extras, clip);
7177 return b.toString();
7178 }
7179
7180 /** @hide */
7181 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7182 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007183 boolean first = true;
7184 if (mAction != null) {
7185 b.append("act=").append(mAction);
7186 first = false;
7187 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007188 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007189 if (!first) {
7190 b.append(' ');
7191 }
7192 first = false;
7193 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007194 for (int i=0; i<mCategories.size(); i++) {
7195 if (i > 0) b.append(',');
7196 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007197 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007198 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007199 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007200 if (mData != null) {
7201 if (!first) {
7202 b.append(' ');
7203 }
7204 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007205 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007206 if (secure) {
7207 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007208 } else {
7209 b.append(mData);
7210 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007211 }
7212 if (mType != null) {
7213 if (!first) {
7214 b.append(' ');
7215 }
7216 first = false;
7217 b.append("typ=").append(mType);
7218 }
7219 if (mFlags != 0) {
7220 if (!first) {
7221 b.append(' ');
7222 }
7223 first = false;
7224 b.append("flg=0x").append(Integer.toHexString(mFlags));
7225 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007226 if (mPackage != null) {
7227 if (!first) {
7228 b.append(' ');
7229 }
7230 first = false;
7231 b.append("pkg=").append(mPackage);
7232 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007233 if (comp && mComponent != null) {
7234 if (!first) {
7235 b.append(' ');
7236 }
7237 first = false;
7238 b.append("cmp=").append(mComponent.flattenToShortString());
7239 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007240 if (mSourceBounds != null) {
7241 if (!first) {
7242 b.append(' ');
7243 }
7244 first = false;
7245 b.append("bnds=").append(mSourceBounds.toShortString());
7246 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007247 if (mClipData != null) {
7248 if (!first) {
7249 b.append(' ');
7250 }
7251 first = false;
7252 if (clip) {
7253 b.append("clip={");
7254 mClipData.toShortString(b);
7255 b.append('}');
7256 } else {
7257 b.append("(has clip)");
7258 }
7259 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007260 if (extras && mExtras != null) {
7261 if (!first) {
7262 b.append(' ');
7263 }
7264 first = false;
7265 b.append("(has extras)");
7266 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007267 if (mContentUserHint != UserHandle.USER_CURRENT) {
7268 if (!first) {
7269 b.append(' ');
7270 }
7271 first = false;
7272 b.append("u=").append(mContentUserHint);
7273 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007274 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007275 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007276 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007277 b.append("}");
7278 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007279 }
7280
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007281 /**
7282 * Call {@link #toUri} with 0 flags.
7283 * @deprecated Use {@link #toUri} instead.
7284 */
7285 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007286 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007287 return toUri(0);
7288 }
7289
7290 /**
7291 * Convert this Intent into a String holding a URI representation of it.
7292 * The returned URI string has been properly URI encoded, so it can be
7293 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7294 * Intent's data as the base URI, with an additional fragment describing
7295 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007296 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007297 * <p>You can convert the returned string back to an Intent with
7298 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007299 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007300 * @param flags Additional operating flags. Either 0,
7301 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007302 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007303 * @return Returns a URI encoding URI string describing the entire contents
7304 * of the Intent.
7305 */
7306 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007307 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007308 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7309 if (mPackage == null) {
7310 throw new IllegalArgumentException(
7311 "Intent must include an explicit package name to build an android-app: "
7312 + this);
7313 }
7314 uri.append("android-app://");
7315 uri.append(mPackage);
7316 String scheme = null;
7317 if (mData != null) {
7318 scheme = mData.getScheme();
7319 if (scheme != null) {
7320 uri.append('/');
7321 uri.append(scheme);
7322 String authority = mData.getEncodedAuthority();
7323 if (authority != null) {
7324 uri.append('/');
7325 uri.append(authority);
7326 String path = mData.getEncodedPath();
7327 if (path != null) {
7328 uri.append(path);
7329 }
7330 String queryParams = mData.getEncodedQuery();
7331 if (queryParams != null) {
7332 uri.append('?');
7333 uri.append(queryParams);
7334 }
7335 String fragment = mData.getEncodedFragment();
7336 if (fragment != null) {
7337 uri.append('#');
7338 uri.append(fragment);
7339 }
7340 }
7341 }
7342 }
7343 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7344 mPackage, flags);
7345 return uri.toString();
7346 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007347 String scheme = null;
7348 if (mData != null) {
7349 String data = mData.toString();
7350 if ((flags&URI_INTENT_SCHEME) != 0) {
7351 final int N = data.length();
7352 for (int i=0; i<N; i++) {
7353 char c = data.charAt(i);
7354 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7355 || c == '.' || c == '-') {
7356 continue;
7357 }
7358 if (c == ':' && i > 0) {
7359 // Valid scheme.
7360 scheme = data.substring(0, i);
7361 uri.append("intent:");
7362 data = data.substring(i+1);
7363 break;
7364 }
Tom Taylord4a47292009-12-21 13:59:18 -08007365
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007366 // No scheme.
7367 break;
7368 }
7369 }
7370 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007371
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007372 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7373 uri.append("intent:");
7374 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007375
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007376 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007377
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007378 return uri.toString();
7379 }
7380
7381 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7382 String defPackage, int flags) {
7383 StringBuilder frag = new StringBuilder(128);
7384
7385 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007386 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007387 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007388 // Note that for now we are not going to try to handle the
7389 // data part; not clear how to represent this as a URI, and
7390 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007391 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7392 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007393 }
7394
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007395 if (frag.length() > 0) {
7396 uri.append("#Intent;");
7397 uri.append(frag);
7398 uri.append("end");
7399 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007400 }
7401
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007402 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7403 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007404 if (scheme != null) {
7405 uri.append("scheme=").append(scheme).append(';');
7406 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007407 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007408 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007409 }
7410 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007411 for (int i=0; i<mCategories.size(); i++) {
7412 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007413 }
7414 }
7415 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007416 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007417 }
7418 if (mFlags != 0) {
7419 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7420 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007421 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007422 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7423 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007424 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007425 uri.append("component=").append(Uri.encode(
7426 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007427 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007428 if (mSourceBounds != null) {
7429 uri.append("sourceBounds=")
7430 .append(Uri.encode(mSourceBounds.flattenToString()))
7431 .append(';');
7432 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007433 if (mExtras != null) {
7434 for (String key : mExtras.keySet()) {
7435 final Object value = mExtras.get(key);
7436 char entryType =
7437 value instanceof String ? 'S' :
7438 value instanceof Boolean ? 'B' :
7439 value instanceof Byte ? 'b' :
7440 value instanceof Character ? 'c' :
7441 value instanceof Double ? 'd' :
7442 value instanceof Float ? 'f' :
7443 value instanceof Integer ? 'i' :
7444 value instanceof Long ? 'l' :
7445 value instanceof Short ? 's' :
7446 '\0';
7447
7448 if (entryType != '\0') {
7449 uri.append(entryType);
7450 uri.append('.');
7451 uri.append(Uri.encode(key));
7452 uri.append('=');
7453 uri.append(Uri.encode(value.toString()));
7454 uri.append(';');
7455 }
7456 }
7457 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007458 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007459
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007460 public int describeContents() {
7461 return (mExtras != null) ? mExtras.describeContents() : 0;
7462 }
7463
7464 public void writeToParcel(Parcel out, int flags) {
7465 out.writeString(mAction);
7466 Uri.writeToParcel(out, mData);
7467 out.writeString(mType);
7468 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007469 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007470 ComponentName.writeToParcel(mComponent, out);
7471
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007472 if (mSourceBounds != null) {
7473 out.writeInt(1);
7474 mSourceBounds.writeToParcel(out, flags);
7475 } else {
7476 out.writeInt(0);
7477 }
7478
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007479 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007480 final int N = mCategories.size();
7481 out.writeInt(N);
7482 for (int i=0; i<N; i++) {
7483 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007484 }
7485 } else {
7486 out.writeInt(0);
7487 }
7488
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007489 if (mSelector != null) {
7490 out.writeInt(1);
7491 mSelector.writeToParcel(out, flags);
7492 } else {
7493 out.writeInt(0);
7494 }
7495
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007496 if (mClipData != null) {
7497 out.writeInt(1);
7498 mClipData.writeToParcel(out, flags);
7499 } else {
7500 out.writeInt(0);
7501 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007502 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007503 out.writeBundle(mExtras);
7504 }
7505
7506 public static final Parcelable.Creator<Intent> CREATOR
7507 = new Parcelable.Creator<Intent>() {
7508 public Intent createFromParcel(Parcel in) {
7509 return new Intent(in);
7510 }
7511 public Intent[] newArray(int size) {
7512 return new Intent[size];
7513 }
7514 };
7515
Dianne Hackborneb034652009-09-07 00:49:58 -07007516 /** @hide */
7517 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007518 readFromParcel(in);
7519 }
7520
7521 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007522 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007523 mData = Uri.CREATOR.createFromParcel(in);
7524 mType = in.readString();
7525 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007526 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007527 mComponent = ComponentName.readFromParcel(in);
7528
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007529 if (in.readInt() != 0) {
7530 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7531 }
7532
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007533 int N = in.readInt();
7534 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007535 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007536 int i;
7537 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007538 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007539 }
7540 } else {
7541 mCategories = null;
7542 }
7543
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007544 if (in.readInt() != 0) {
7545 mSelector = new Intent(in);
7546 }
7547
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007548 if (in.readInt() != 0) {
7549 mClipData = new ClipData(in);
7550 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007551 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007552 mExtras = in.readBundle();
7553 }
7554
7555 /**
7556 * Parses the "intent" element (and its children) from XML and instantiates
7557 * an Intent object. The given XML parser should be located at the tag
7558 * where parsing should start (often named "intent"), from which the
7559 * basic action, data, type, and package and class name will be
7560 * retrieved. The function will then parse in to any child elements,
7561 * looking for <category android:name="xxx"> tags to add categories and
7562 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7563 * to the intent.
7564 *
7565 * @param resources The Resources to use when inflating resources.
7566 * @param parser The XML parser pointing at an "intent" tag.
7567 * @param attrs The AttributeSet interface for retrieving extended
7568 * attribute data at the current <var>parser</var> location.
7569 * @return An Intent object matching the XML data.
7570 * @throws XmlPullParserException If there was an XML parsing error.
7571 * @throws IOException If there was an I/O error.
7572 */
7573 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7574 throws XmlPullParserException, IOException {
7575 Intent intent = new Intent();
7576
7577 TypedArray sa = resources.obtainAttributes(attrs,
7578 com.android.internal.R.styleable.Intent);
7579
7580 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7581
7582 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7583 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7584 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7585
7586 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7587 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7588 if (packageName != null && className != null) {
7589 intent.setComponent(new ComponentName(packageName, className));
7590 }
7591
7592 sa.recycle();
7593
7594 int outerDepth = parser.getDepth();
7595 int type;
7596 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7597 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7598 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7599 continue;
7600 }
7601
7602 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007603 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007604 sa = resources.obtainAttributes(attrs,
7605 com.android.internal.R.styleable.IntentCategory);
7606 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7607 sa.recycle();
7608
7609 if (cat != null) {
7610 intent.addCategory(cat);
7611 }
7612 XmlUtils.skipCurrentTag(parser);
7613
Craig Mautner21d24a22014-04-23 11:45:37 -07007614 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007615 if (intent.mExtras == null) {
7616 intent.mExtras = new Bundle();
7617 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007618 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007619 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007620
7621 } else {
7622 XmlUtils.skipCurrentTag(parser);
7623 }
7624 }
7625
7626 return intent;
7627 }
Nick Pellyccae4122012-01-09 14:12:58 -08007628
Craig Mautner21d24a22014-04-23 11:45:37 -07007629 /** @hide */
7630 public void saveToXml(XmlSerializer out) throws IOException {
7631 if (mAction != null) {
7632 out.attribute(null, ATTR_ACTION, mAction);
7633 }
7634 if (mData != null) {
7635 out.attribute(null, ATTR_DATA, mData.toString());
7636 }
7637 if (mType != null) {
7638 out.attribute(null, ATTR_TYPE, mType);
7639 }
7640 if (mComponent != null) {
7641 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7642 }
7643 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7644
7645 if (mCategories != null) {
7646 out.startTag(null, TAG_CATEGORIES);
7647 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7648 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7649 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007650 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007651 }
7652 }
7653
7654 /** @hide */
7655 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7656 XmlPullParserException {
7657 Intent intent = new Intent();
7658 final int outerDepth = in.getDepth();
7659
7660 int attrCount = in.getAttributeCount();
7661 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7662 final String attrName = in.getAttributeName(attrNdx);
7663 final String attrValue = in.getAttributeValue(attrNdx);
7664 if (ATTR_ACTION.equals(attrName)) {
7665 intent.setAction(attrValue);
7666 } else if (ATTR_DATA.equals(attrName)) {
7667 intent.setData(Uri.parse(attrValue));
7668 } else if (ATTR_TYPE.equals(attrName)) {
7669 intent.setType(attrValue);
7670 } else if (ATTR_COMPONENT.equals(attrName)) {
7671 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7672 } else if (ATTR_FLAGS.equals(attrName)) {
7673 intent.setFlags(Integer.valueOf(attrValue, 16));
7674 } else {
7675 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7676 }
7677 }
7678
7679 int event;
7680 String name;
7681 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7682 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7683 if (event == XmlPullParser.START_TAG) {
7684 name = in.getName();
7685 if (TAG_CATEGORIES.equals(name)) {
7686 attrCount = in.getAttributeCount();
7687 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7688 intent.addCategory(in.getAttributeValue(attrNdx));
7689 }
7690 } else {
7691 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7692 XmlUtils.skipCurrentTag(in);
7693 }
7694 }
7695 }
7696
7697 return intent;
7698 }
7699
Nick Pellyccae4122012-01-09 14:12:58 -08007700 /**
7701 * Normalize a MIME data type.
7702 *
7703 * <p>A normalized MIME type has white-space trimmed,
7704 * content-type parameters removed, and is lower-case.
7705 * This aligns the type with Android best practices for
7706 * intent filtering.
7707 *
7708 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7709 * "text/x-vCard" becomes "text/x-vcard".
7710 *
7711 * <p>All MIME types received from outside Android (such as user input,
7712 * or external sources like Bluetooth, NFC, or the Internet) should
7713 * be normalized before they are used to create an Intent.
7714 *
7715 * @param type MIME data type to normalize
7716 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007717 * @see #setType
7718 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007719 */
7720 public static String normalizeMimeType(String type) {
7721 if (type == null) {
7722 return null;
7723 }
7724
Elliott Hughescb64d432013-08-02 10:00:44 -07007725 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007726
7727 final int semicolonIndex = type.indexOf(';');
7728 if (semicolonIndex != -1) {
7729 type = type.substring(0, semicolonIndex);
7730 }
7731 return type;
7732 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007733
7734 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007735 * Prepare this {@link Intent} to leave an app process.
7736 *
7737 * @hide
7738 */
7739 public void prepareToLeaveProcess() {
7740 setAllowFds(false);
7741
7742 if (mSelector != null) {
7743 mSelector.prepareToLeaveProcess();
7744 }
7745 if (mClipData != null) {
7746 mClipData.prepareToLeaveProcess();
7747 }
7748
7749 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
7750 // There are several ACTION_MEDIA_* broadcasts that send file://
7751 // Uris, so only check common actions.
7752 if (ACTION_VIEW.equals(mAction) ||
7753 ACTION_EDIT.equals(mAction) ||
7754 ACTION_ATTACH_DATA.equals(mAction)) {
7755 mData.checkFileUriExposed("Intent.getData()");
7756 }
7757 }
7758 }
7759
7760 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007761 * @hide
7762 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007763 public void prepareToEnterProcess() {
7764 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00007765 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
7766 fixUris(mContentUserHint);
7767 mContentUserHint = UserHandle.USER_CURRENT;
7768 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007769 }
7770 }
7771
7772 /**
7773 * @hide
7774 */
7775 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007776 Uri data = getData();
7777 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007778 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007779 }
7780 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007781 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007782 }
7783 String action = getAction();
7784 if (ACTION_SEND.equals(action)) {
7785 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7786 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007787 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007788 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007789 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007790 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7791 if (streams != null) {
7792 ArrayList<Uri> newStreams = new ArrayList<Uri>();
7793 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007794 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007795 }
7796 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
7797 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007798 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
7799 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
7800 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
7801 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
7802 if (output != null) {
7803 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
7804 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007805 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007806 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007807
7808 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007809 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007810 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
7811 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007812 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007813 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007814 * @hide
7815 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007816 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007817 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007818 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007819
7820 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007821 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007822
7823 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007824 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007825 // Inspect contained intents to see if we need to migrate extras. We
7826 // don't promote ClipData to the parent, since ChooserActivity will
7827 // already start the picked item as the caller, and we can't combine
7828 // the flags in a safe way.
7829
7830 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07007831 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007832 final Intent intent = getParcelableExtra(EXTRA_INTENT);
7833 if (intent != null) {
7834 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07007835 }
7836 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007837 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007838 try {
7839 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
7840 if (intents != null) {
7841 for (int i = 0; i < intents.length; i++) {
7842 final Intent intent = (Intent) intents[i];
7843 if (intent != null) {
7844 migrated |= intent.migrateExtraStreamToClipData();
7845 }
7846 }
7847 }
7848 } catch (ClassCastException e) {
7849 }
7850 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007851
7852 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007853 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007854 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7855 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
7856 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
7857 if (stream != null || text != null || htmlText != null) {
7858 final ClipData clipData = new ClipData(
7859 null, new String[] { getType() },
7860 new ClipData.Item(text, htmlText, null, stream));
7861 setClipData(clipData);
7862 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007863 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007864 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007865 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007866 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007867
7868 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007869 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007870 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7871 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
7872 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
7873 int num = -1;
7874 if (streams != null) {
7875 num = streams.size();
7876 }
7877 if (texts != null) {
7878 if (num >= 0 && num != texts.size()) {
7879 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007880 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007881 }
7882 num = texts.size();
7883 }
7884 if (htmlTexts != null) {
7885 if (num >= 0 && num != htmlTexts.size()) {
7886 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007887 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007888 }
7889 num = htmlTexts.size();
7890 }
7891 if (num > 0) {
7892 final ClipData clipData = new ClipData(
7893 null, new String[] { getType() },
7894 makeClipItem(streams, texts, htmlTexts, 0));
7895
7896 for (int i = 1; i < num; i++) {
7897 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
7898 }
7899
7900 setClipData(clipData);
7901 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007902 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007903 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007904 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007905 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007906 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
7907 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
7908 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
7909 final Uri output;
7910 try {
7911 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
7912 } catch (ClassCastException e) {
7913 return false;
7914 }
7915 if (output != null) {
7916 setClipData(ClipData.newRawUri("", output));
7917 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
7918 return true;
7919 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007920 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007921
7922 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007923 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07007924
7925 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
7926 ArrayList<String> htmlTexts, int which) {
7927 Uri uri = streams != null ? streams.get(which) : null;
7928 CharSequence text = texts != null ? texts.get(which) : null;
7929 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
7930 return new ClipData.Item(text, htmlText, null, uri);
7931 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07007932
7933 /** @hide */
7934 public boolean isDocument() {
7935 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
7936 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007937}