blob: 8632db105e1700f062c7016f96c17625aa5ca00f [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 /**
Adam Skory7140a252013-09-11 12:04:58 +01001242 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1243 * information supplied by the current foreground app at the time of the assist request.
1244 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001245 */
1246 public static final String EXTRA_ASSIST_CONTEXT
1247 = "android.intent.extra.ASSIST_CONTEXT";
1248
Jim Miller07994402012-05-02 14:22:27 -07001249 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001250 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1251 * keyboard as the primary input device for assistance.
1252 */
1253 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1254 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1255
1256 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001257 * Activity Action: List all available applications
1258 * <p>Input: Nothing.
1259 * <p>Output: nothing.
1260 */
1261 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1262 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1263 /**
1264 * Activity Action: Show settings for choosing wallpaper
1265 * <p>Input: Nothing.
1266 * <p>Output: Nothing.
1267 */
1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1269 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1270
1271 /**
1272 * Activity Action: Show activity for reporting a bug.
1273 * <p>Input: Nothing.
1274 * <p>Output: Nothing.
1275 */
1276 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1277 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1278
1279 /**
1280 * Activity Action: Main entry point for factory tests. Only used when
1281 * the device is booting in factory test node. The implementing package
1282 * must be installed in the system image.
1283 * <p>Input: nothing
1284 * <p>Output: nothing
1285 */
1286 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1287
1288 /**
1289 * Activity Action: The user pressed the "call" button to go to the dialer
1290 * or other appropriate UI for placing a call.
1291 * <p>Input: Nothing.
1292 * <p>Output: Nothing.
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1296
1297 /**
1298 * Activity Action: Start Voice Command.
1299 * <p>Input: Nothing.
1300 * <p>Output: Nothing.
1301 */
1302 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1303 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001304
1305 /**
1306 * Activity Action: Start action associated with long pressing on the
1307 * search key.
1308 * <p>Input: Nothing.
1309 * <p>Output: Nothing.
1310 */
1311 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1312 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001313
Jacek Surazski86b6c532009-05-13 14:38:28 +02001314 /**
1315 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1316 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001317 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001318 * <p>Input: No data is specified. The bug report is passed in using
1319 * an {@link #EXTRA_BUG_REPORT} field.
1320 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001321 *
1322 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001323 */
1324 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1325 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001326
1327 /**
1328 * Activity Action: Show power usage information to the user.
1329 * <p>Input: Nothing.
1330 * <p>Output: Nothing.
1331 */
1332 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1333 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001334
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001335 /**
1336 * Activity Action: Setup wizard to launch after a platform update. This
1337 * activity should have a string meta-data field associated with it,
1338 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1339 * the platform for setup. The activity will be launched only if
1340 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1341 * same value.
1342 * <p>Input: Nothing.
1343 * <p>Output: Nothing.
1344 * @hide
1345 */
1346 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1347 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001348
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001349 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001350 * Activity Action: Show settings for managing network data usage of a
1351 * specific application. Applications should define an activity that offers
1352 * options to control data usage.
1353 */
1354 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1355 public static final String ACTION_MANAGE_NETWORK_USAGE =
1356 "android.intent.action.MANAGE_NETWORK_USAGE";
1357
1358 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001359 * Activity Action: Launch application installer.
1360 * <p>
1361 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001362 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1363 * you can also use "package:<package-name>" to install an application for the
1364 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001365 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1366 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1367 * <p>
1368 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1369 * succeeded.
1370 *
1371 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1372 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1373 * @see #EXTRA_RETURN_RESULT
1374 */
1375 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1376 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1377
1378 /**
1379 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1380 * package. Specifies the installer package name; this package will receive the
1381 * {@link #ACTION_APP_ERROR} intent.
1382 */
1383 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1384 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1385
1386 /**
1387 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1388 * package. Specifies that the application being installed should not be
1389 * treated as coming from an unknown source, but as coming from the app
1390 * invoking the Intent. For this to work you must start the installer with
1391 * startActivityForResult().
1392 */
1393 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1394 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1395
1396 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001397 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1398 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001399 * data field originated from.
1400 */
rich cannings706e8ba2012-08-20 13:20:14 -07001401 public static final String EXTRA_ORIGINATING_URI
1402 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001403
1404 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001405 * This extra can be used with any Intent used to launch an activity, supplying information
1406 * about who is launching that activity. This field contains a {@link android.net.Uri}
1407 * object, typically an http: or https: URI of the web site that the referral came from;
1408 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1409 * a native application that it came from.
1410 *
1411 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1412 * instead of directly retrieving the extra. It is also valid for applications to
1413 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1414 * a string, not a Uri; the field here, if supplied, will always take precedence,
1415 * however.</p>
1416 *
1417 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001418 */
1419 public static final String EXTRA_REFERRER
1420 = "android.intent.extra.REFERRER";
1421
1422 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001423 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1424 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1425 * not be created, in particular when Intent extras are supplied through the
1426 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1427 * schemes.
1428 *
1429 * @see #EXTRA_REFERRER
1430 */
1431 public static final String EXTRA_REFERRER_NAME
1432 = "android.intent.extra.REFERRER_NAME";
1433
1434 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001435 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1436 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1437 * @hide
1438 */
1439 public static final String EXTRA_ORIGINATING_UID
1440 = "android.intent.extra.ORIGINATING_UID";
1441
1442 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001443 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1444 * package. Tells the installer UI to skip the confirmation with the user
1445 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001446 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1447 * will no longer show an interstitial message about updating existing
1448 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001449 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001450 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001451 public static final String EXTRA_ALLOW_REPLACE
1452 = "android.intent.extra.ALLOW_REPLACE";
1453
1454 /**
1455 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1456 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1457 * return to the application the result code of the install/uninstall. The returned result
1458 * code will be {@link android.app.Activity#RESULT_OK} on success or
1459 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1460 */
1461 public static final String EXTRA_RETURN_RESULT
1462 = "android.intent.extra.RETURN_RESULT";
1463
1464 /**
1465 * Package manager install result code. @hide because result codes are not
1466 * yet ready to be exposed.
1467 */
1468 public static final String EXTRA_INSTALL_RESULT
1469 = "android.intent.extra.INSTALL_RESULT";
1470
1471 /**
1472 * Activity Action: Launch application uninstaller.
1473 * <p>
1474 * Input: The data must be a package: URI whose scheme specific part is
1475 * the package name of the current installed package to be uninstalled.
1476 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1477 * <p>
1478 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1479 * succeeded.
1480 */
1481 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1482 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1483
1484 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001485 * Specify whether the package should be uninstalled for all users.
1486 * @hide because these should not be part of normal application flow.
1487 */
1488 public static final String EXTRA_UNINSTALL_ALL_USERS
1489 = "android.intent.extra.UNINSTALL_ALL_USERS";
1490
1491 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001492 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1493 * describing the last run version of the platform that was setup.
1494 * @hide
1495 */
1496 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1497
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001498 // ---------------------------------------------------------------------
1499 // ---------------------------------------------------------------------
1500 // Standard intent broadcast actions (see action variable).
1501
1502 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001503 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1504 * <p>
1505 * For historical reasons, the name of this broadcast action refers to the power
1506 * state of the screen but it is actually sent in response to changes in the
1507 * overall interactive state of the device.
1508 * </p><p>
1509 * This broadcast is sent when the device becomes non-interactive which may have
1510 * nothing to do with the screen turning off. To determine the
1511 * actual state of the screen, use {@link android.view.Display#getState}.
1512 * </p><p>
1513 * See {@link android.os.PowerManager#isInteractive} for details.
1514 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001515 * You <em>cannot</em> receive this through components declared in
1516 * manifests, only by explicitly registering for it with
1517 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1518 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001519 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001520 * <p class="note">This is a protected intent that can only be sent
1521 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001522 */
1523 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1524 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001525
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001526 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001527 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1528 * <p>
1529 * For historical reasons, the name of this broadcast action refers to the power
1530 * state of the screen but it is actually sent in response to changes in the
1531 * overall interactive state of the device.
1532 * </p><p>
1533 * This broadcast is sent when the device becomes interactive which may have
1534 * nothing to do with the screen turning on. To determine the
1535 * actual state of the screen, use {@link android.view.Display#getState}.
1536 * </p><p>
1537 * See {@link android.os.PowerManager#isInteractive} for details.
1538 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001539 * You <em>cannot</em> receive this through components declared in
1540 * manifests, only by explicitly registering for it with
1541 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1542 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001543 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001544 * <p class="note">This is a protected intent that can only be sent
1545 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001546 */
1547 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1548 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001549
1550 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001551 * Broadcast Action: Sent after the system stops dreaming.
1552 *
1553 * <p class="note">This is a protected intent that can only be sent by the system.
1554 * It is only sent to registered receivers.</p>
1555 */
1556 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1557 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1558
1559 /**
1560 * Broadcast Action: Sent after the system starts dreaming.
1561 *
1562 * <p class="note">This is a protected intent that can only be sent by the system.
1563 * It is only sent to registered receivers.</p>
1564 */
1565 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1566 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1567
1568 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001569 * 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 -07001570 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001571 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001572 * <p class="note">This is a protected intent that can only be sent
1573 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001574 */
1575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001576 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001577
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001578 /**
1579 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001580 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001581 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001582 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1583 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001584 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001585 * <p class="note">This is a protected intent that can only be sent
1586 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001587 */
1588 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1589 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1590 /**
1591 * Broadcast Action: The time was set.
1592 */
1593 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1594 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1595 /**
1596 * Broadcast Action: The date has changed.
1597 */
1598 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1599 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1600 /**
1601 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1602 * <ul>
1603 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1604 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001605 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001606 * <p class="note">This is a protected intent that can only be sent
1607 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001608 */
1609 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1610 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1611 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001612 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1613 * DNS entries should be tossed.
1614 * @hide
1615 */
1616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1617 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1618 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001619 * Alarm Changed Action: This is broadcast when the AlarmClock
1620 * application's alarm is set or unset. It is used by the
1621 * AlarmClock application and the StatusBar service.
1622 * @hide
1623 */
1624 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1625 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1626 /**
1627 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1628 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1629 * @hide
1630 */
1631 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1632 public static final String ACTION_SYNC_STATE_CHANGED
1633 = "android.intent.action.SYNC_STATE_CHANGED";
1634 /**
1635 * Broadcast Action: This is broadcast once, after the system has finished
1636 * booting. It can be used to perform application-specific initialization,
1637 * such as installing alarms. You must hold the
1638 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1639 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001640 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001641 * <p class="note">This is a protected intent that can only be sent
1642 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001643 */
1644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1645 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1646 /**
1647 * Broadcast Action: This is broadcast when a user action should request a
1648 * temporary system dialog to dismiss. Some examples of temporary system
1649 * dialogs are the notification window-shade and the recent tasks dialog.
1650 */
1651 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1652 /**
1653 * Broadcast Action: Trigger the download and eventual installation
1654 * of a package.
1655 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001656 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001657 * <p class="note">This is a protected intent that can only be sent
1658 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001659 *
1660 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001661 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001662 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001663 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1664 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1665 /**
1666 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001667 * device. The data contains the name of the package. Note that the
1668 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001669 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001670 * <ul>
1671 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1672 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1673 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1674 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001675 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001676 * <p class="note">This is a protected intent that can only be sent
1677 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001678 */
1679 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1680 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1681 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001682 * Broadcast Action: A new version of an application package has been
1683 * installed, replacing an existing version that was previously installed.
1684 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001685 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001686 * <ul>
1687 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1688 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001689 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001690 * <p class="note">This is a protected intent that can only be sent
1691 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001692 */
1693 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1694 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1695 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001696 * Broadcast Action: A new version of your application has been installed
1697 * over an existing one. This is only sent to the application that was
1698 * replaced. It does not contain any additional data; to receive it, just
1699 * use an intent filter for this action.
1700 *
1701 * <p class="note">This is a protected intent that can only be sent
1702 * by the system.
1703 */
1704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1705 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1706 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001707 * Broadcast Action: An existing application package has been removed from
1708 * the device. The data contains the name of the package. The package
1709 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001710 * <ul>
1711 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1712 * to the package.
1713 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1714 * application -- data and code -- is being removed.
1715 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1716 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1717 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001718 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001719 * <p class="note">This is a protected intent that can only be sent
1720 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001721 */
1722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1723 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1724 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001725 * Broadcast Action: An existing application package has been completely
1726 * removed from the device. The data contains the name of the package.
1727 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1728 * {@link #EXTRA_DATA_REMOVED} is true and
1729 * {@link #EXTRA_REPLACING} is false of that broadcast.
1730 *
1731 * <ul>
1732 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1733 * to the package.
1734 * </ul>
1735 *
1736 * <p class="note">This is a protected intent that can only be sent
1737 * by the system.
1738 */
1739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1740 public static final String ACTION_PACKAGE_FULLY_REMOVED
1741 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1742 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001743 * Broadcast Action: An existing application package has been changed (e.g.
1744 * a component has been enabled or disabled). The data contains the name of
1745 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001746 * <ul>
1747 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001748 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001749 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001750 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1751 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001752 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001753 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001754 * <p class="note">This is a protected intent that can only be sent
1755 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001756 */
1757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1758 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1759 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001760 * @hide
1761 * Broadcast Action: Ask system services if there is any reason to
1762 * restart the given package. The data contains the name of the
1763 * package.
1764 * <ul>
1765 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1766 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1767 * </ul>
1768 *
1769 * <p class="note">This is a protected intent that can only be sent
1770 * by the system.
1771 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001772 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1774 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1775 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001776 * Broadcast Action: The user has restarted a package, and all of its
1777 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001778 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001779 * be removed. Note that the restarted package does <em>not</em>
1780 * receive this broadcast.
1781 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001782 * <ul>
1783 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1784 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001785 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001786 * <p class="note">This is a protected intent that can only be sent
1787 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001788 */
1789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1790 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1791 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001792 * Broadcast Action: The user has cleared the data of a package. This should
1793 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001794 * its persistent data is erased and this broadcast sent.
1795 * Note that the cleared package does <em>not</em>
1796 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001797 * <ul>
1798 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1799 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001800 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001801 * <p class="note">This is a protected intent that can only be sent
1802 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001803 */
1804 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1805 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1806 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001807 * Broadcast Action: A user ID has been removed from the system. The user
1808 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001809 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001810 * <p class="note">This is a protected intent that can only be sent
1811 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001812 */
1813 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1814 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001815
1816 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001817 * Broadcast Action: Sent to the installer package of an application
1818 * when that application is first launched (that is the first time it
1819 * is moved out of the stopped state). The data contains the name of the package.
1820 *
1821 * <p class="note">This is a protected intent that can only be sent
1822 * by the system.
1823 */
1824 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1825 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1826
1827 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001828 * Broadcast Action: Sent to the system package verifier when a package
1829 * needs to be verified. The data contains the package URI.
1830 * <p class="note">
1831 * This is a protected intent that can only be sent by the system.
1832 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001833 */
1834 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1835 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1836
1837 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001838 * Broadcast Action: Sent to the system package verifier when a package is
1839 * verified. The data contains the package URI.
1840 * <p class="note">
1841 * This is a protected intent that can only be sent by the system.
1842 */
1843 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1844 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1845
1846 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001847 * Broadcast Action: Resources for a set of packages (which were
1848 * previously unavailable) are currently
1849 * available since the media on which they exist is available.
1850 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1851 * list of packages whose availability changed.
1852 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1853 * list of uids of packages whose availability changed.
1854 * Note that the
1855 * packages in this list do <em>not</em> receive this broadcast.
1856 * The specified set of packages are now available on the system.
1857 * <p>Includes the following extras:
1858 * <ul>
1859 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1860 * whose resources(were previously unavailable) are currently available.
1861 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1862 * packages whose resources(were previously unavailable)
1863 * are currently available.
1864 * </ul>
1865 *
1866 * <p class="note">This is a protected intent that can only be sent
1867 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001868 */
1869 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001870 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1871 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001872
1873 /**
1874 * Broadcast Action: Resources for a set of packages are currently
1875 * unavailable since the media on which they exist is unavailable.
1876 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1877 * list of packages whose availability changed.
1878 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1879 * list of uids of packages whose availability changed.
1880 * The specified set of packages can no longer be
1881 * launched and are practically unavailable on the system.
1882 * <p>Inclues the following extras:
1883 * <ul>
1884 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1885 * whose resources are no longer available.
1886 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1887 * whose resources are no longer available.
1888 * </ul>
1889 *
1890 * <p class="note">This is a protected intent that can only be sent
1891 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001892 */
1893 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001894 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001895 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001896
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001897 /**
1898 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001899 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001900 * This should <em>only</em> be used to determine when the wallpaper
1901 * has changed to show the new wallpaper to the user. You should certainly
1902 * never, in response to this, change the wallpaper or other attributes of
1903 * it such as the suggested size. That would be crazy, right? You'd cause
1904 * all kinds of loops, especially if other apps are doing similar things,
1905 * right? Of course. So please don't do this.
1906 *
1907 * @deprecated Modern applications should use
1908 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
1909 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
1910 * shown behind their UI, rather than watching for this broadcast and
1911 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001912 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001913 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001914 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1915 /**
1916 * Broadcast Action: The current device {@link android.content.res.Configuration}
1917 * (orientation, locale, etc) has changed. When such a change happens, the
1918 * UIs (view hierarchy) will need to be rebuilt based on this new
1919 * information; for the most part, applications don't need to worry about
1920 * this, because the system will take care of stopping and restarting the
1921 * application to make sure it sees the new changes. Some system code that
1922 * can not be restarted will need to watch for this action and handle it
1923 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001924 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001925 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07001926 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001927 * in manifests, only by explicitly registering for it with
1928 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1929 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001930 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001931 * <p class="note">This is a protected intent that can only be sent
1932 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001933 *
1934 * @see android.content.res.Configuration
1935 */
1936 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1937 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1938 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001939 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001940 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001941 * <p class="note">This is a protected intent that can only be sent
1942 * by the system.
1943 */
1944 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1945 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1946 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001947 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1948 * charging state, level, and other information about the battery.
1949 * See {@link android.os.BatteryManager} for documentation on the
1950 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001951 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001952 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07001953 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001954 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001955 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001956 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1957 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1958 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1959 * broadcasts that are sent and can be received through manifest
1960 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001961 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001962 * <p class="note">This is a protected intent that can only be sent
1963 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001964 */
1965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1966 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1967 /**
1968 * Broadcast Action: Indicates low battery condition on the device.
1969 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001970 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001971 * <p class="note">This is a protected intent that can only be sent
1972 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001973 */
1974 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1975 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1976 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001977 * Broadcast Action: Indicates the battery is now okay after being low.
1978 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1979 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001980 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001981 * <p class="note">This is a protected intent that can only be sent
1982 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001983 */
1984 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1985 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1986 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001987 * Broadcast Action: External power has been connected to the device.
1988 * This is intended for applications that wish to register specifically to this notification.
1989 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1990 * stay active to receive this notification. This action can be used to implement actions
1991 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001992 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001993 * <p class="note">This is a protected intent that can only be sent
1994 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001995 */
1996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001997 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001998 /**
1999 * Broadcast Action: External power has been removed from the device.
2000 * This is intended for applications that wish to register specifically to this notification.
2001 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2002 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002003 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002004 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002005 * <p class="note">This is a protected intent that can only be sent
2006 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002007 */
2008 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002009 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002010 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002011 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002012 * Broadcast Action: Device is shutting down.
2013 * This is broadcast when the device is being shut down (completely turned
2014 * off, not sleeping). Once the broadcast is complete, the final shutdown
2015 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002016 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002017 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002018 * <p class="note">This is a protected intent that can only be sent
2019 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002020 * <p>May include the following extras:
2021 * <ul>
2022 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2023 * shutdown is only for userspace processes. If not set, assumed to be false.
2024 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002025 */
2026 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002027 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002028 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002029 * Activity Action: Start this activity to request system shutdown.
2030 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2031 * to request confirmation from the user before shutting down.
2032 *
2033 * <p class="note">This is a protected intent that can only be sent
2034 * by the system.
2035 *
2036 * {@hide}
2037 */
2038 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2039 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002040 * Broadcast Action: A sticky broadcast that indicates low memory
2041 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002042 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002043 * <p class="note">This is a protected intent that can only be sent
2044 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002045 */
2046 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2047 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2048 /**
2049 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002050 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002051 * <p class="note">This is a protected intent that can only be sent
2052 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002053 */
2054 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2055 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2056 /**
Jake Hambybb371632010-08-23 18:16:48 -07002057 * Broadcast Action: A sticky broadcast that indicates a memory full
2058 * condition on the device. This is intended for activities that want
2059 * to be able to fill the data partition completely, leaving only
2060 * enough free space to prevent system-wide SQLite failures.
2061 *
2062 * <p class="note">This is a protected intent that can only be sent
2063 * by the system.
2064 *
2065 * {@hide}
2066 */
2067 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2068 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2069 /**
2070 * Broadcast Action: Indicates memory full condition on the device
2071 * no longer exists.
2072 *
2073 * <p class="note">This is a protected intent that can only be sent
2074 * by the system.
2075 *
2076 * {@hide}
2077 */
2078 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2079 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2080 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002081 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2082 * and package management should be started.
2083 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2084 * notification.
2085 */
2086 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2087 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2088 /**
2089 * Broadcast Action: The device has entered USB Mass Storage mode.
2090 * This is used mainly for the USB Settings panel.
2091 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2092 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002093 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002094 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002095 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002096 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2097
2098 /**
2099 * Broadcast Action: The device has exited USB Mass Storage mode.
2100 * This is used mainly for the USB Settings panel.
2101 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2102 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002103 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002104 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002105 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002106 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2107
2108 /**
2109 * Broadcast Action: External media has been removed.
2110 * The path to the mount point for the removed media is contained in the Intent.mData field.
2111 */
2112 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2113 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2114
2115 /**
2116 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002117 * 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 -07002118 */
2119 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2120 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2121
2122 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002123 * Broadcast Action: External media is present, and being disk-checked
2124 * 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 -08002125 */
2126 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2127 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2128
2129 /**
2130 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2131 * 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 -08002132 */
2133 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2134 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2135
2136 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002137 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002138 * 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 -07002139 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2140 * media was mounted read only.
2141 */
2142 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2143 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2144
2145 /**
2146 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002147 * 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 -07002148 */
2149 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2150 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2151
2152 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002153 * Broadcast Action: External media is no longer being shared via USB mass storage.
2154 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2155 *
2156 * @hide
2157 */
2158 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2159
2160 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002161 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2162 * The path to the mount point for the removed media is contained in the Intent.mData field.
2163 */
2164 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2165 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2166
2167 /**
2168 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002169 * 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 -07002170 */
2171 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2172 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2173
2174 /**
2175 * Broadcast Action: User has expressed the desire to remove the external storage media.
2176 * Applications should close all files they have open within the mount point when they receive this intent.
2177 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2178 */
2179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2180 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2181
2182 /**
2183 * Broadcast Action: The media scanner has started scanning a directory.
2184 * The path to the directory being scanned is contained in the Intent.mData field.
2185 */
2186 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2187 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2188
2189 /**
2190 * Broadcast Action: The media scanner has finished scanning a directory.
2191 * The path to the scanned directory is contained in the Intent.mData field.
2192 */
2193 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2194 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2195
2196 /**
2197 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2198 * The path to the file is contained in the Intent.mData field.
2199 */
2200 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2201 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2202
2203 /**
2204 * Broadcast Action: The "Media Button" was pressed. Includes a single
2205 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2206 * caused the broadcast.
2207 */
2208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2209 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2210
2211 /**
2212 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2213 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2214 * caused the broadcast.
2215 */
2216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2217 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2218
2219 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2220 // location; they are not general-purpose actions.
2221
2222 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002223 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002224 */
2225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2227 "android.intent.action.GTALK_CONNECTED";
2228
2229 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002230 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002231 */
2232 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2233 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2234 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002235
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002236 /**
2237 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002238 */
2239 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2240 public static final String ACTION_INPUT_METHOD_CHANGED =
2241 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002242
2243 /**
2244 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2245 * more radios have been turned off or on. The intent will have the following extra value:</p>
2246 * <ul>
2247 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2248 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2249 * turned off</li>
2250 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002251 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002252 * <p class="note">This is a protected intent that can only be sent
2253 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002254 */
2255 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2256 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2257
2258 /**
2259 * Broadcast Action: Some content providers have parts of their namespace
2260 * where they publish new events or items that the user may be especially
2261 * interested in. For these things, they may broadcast this action when the
2262 * set of interesting items change.
2263 *
2264 * For example, GmailProvider sends this notification when the set of unread
2265 * mail in the inbox changes.
2266 *
2267 * <p>The data of the intent identifies which part of which provider
2268 * changed. When queried through the content resolver, the data URI will
2269 * return the data set in question.
2270 *
2271 * <p>The intent will have the following extra values:
2272 * <ul>
2273 * <li><em>count</em> - The number of items in the data set. This is the
2274 * same as the number of items in the cursor returned by querying the
2275 * data URI. </li>
2276 * </ul>
2277 *
2278 * This intent will be sent at boot (if the count is non-zero) and when the
2279 * data set changes. It is possible for the data set to change without the
2280 * count changing (for example, if a new unread message arrives in the same
2281 * sync operation in which a message is archived). The phone should still
2282 * ring/vibrate/etc as normal in this case.
2283 */
2284 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2285 public static final String ACTION_PROVIDER_CHANGED =
2286 "android.intent.action.PROVIDER_CHANGED";
2287
2288 /**
2289 * Broadcast Action: Wired Headset plugged in or unplugged.
2290 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002291 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2292 * and documentation.
2293 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002294 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002295 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002296 */
2297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002298 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002299
2300 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002301 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2302 * <ul>
2303 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2304 * </ul>
2305 *
2306 * <p class="note">This is a protected intent that can only be sent
2307 * by the system.
2308 *
2309 * @hide
2310 */
2311 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2312 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2313 = "android.intent.action.ADVANCED_SETTINGS";
2314
2315 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002316 * Broadcast Action: Sent after application restrictions are changed.
2317 *
2318 * <p class="note">This is a protected intent that can only be sent
2319 * by the system.</p>
2320 */
2321 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2322 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2323 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2324
2325 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002326 * Broadcast Action: An outgoing call is about to be placed.
2327 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002328 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002329 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002330 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002331 * the phone number originally intended to be dialed.</li>
2332 * </ul>
2333 * <p>Once the broadcast is finished, the resultData is used as the actual
2334 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002335 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002336 * outgoing call in turn: for example, a parental control application
2337 * might verify that the user is authorized to place the call at that
2338 * time, then a number-rewriting application might add an area code if
2339 * one was not specified.</p>
2340 * <p>For consistency, any receiver whose purpose is to prohibit phone
2341 * calls should have a priority of 0, to ensure it will see the final
2342 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002343 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002344 * should have a positive priority.
2345 * Negative priorities are reserved for the system for this broadcast;
2346 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002347 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2348 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002349 * <p>Emergency calls cannot be intercepted using this mechanism, and
2350 * other calls cannot be modified to call emergency numbers using this
2351 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002352 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2353 * call to use their own service instead. Those apps should first prevent
2354 * the call from being placed by setting resultData to <code>null</code>
2355 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002356 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002357 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2358 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002359 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002360 * <p class="note">This is a protected intent that can only be sent
2361 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002362 */
2363 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2364 public static final String ACTION_NEW_OUTGOING_CALL =
2365 "android.intent.action.NEW_OUTGOING_CALL";
2366
2367 /**
2368 * Broadcast Action: Have the device reboot. This is only for use by
2369 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002370 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002371 * <p class="note">This is a protected intent that can only be sent
2372 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002373 */
2374 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2375 public static final String ACTION_REBOOT =
2376 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002377
Wei Huang97ecc9c2009-05-11 17:44:20 -07002378 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002379 * Broadcast Action: A sticky broadcast for changes in the physical
2380 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002381 *
2382 * <p>The intent will have the following extra values:
2383 * <ul>
2384 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002385 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002386 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002387 * <p>This is intended for monitoring the current physical dock state.
2388 * See {@link android.app.UiModeManager} for the normal API dealing with
2389 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002390 */
2391 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2392 public static final String ACTION_DOCK_EVENT =
2393 "android.intent.action.DOCK_EVENT";
2394
2395 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002396 * Broadcast Action: A broadcast when idle maintenance can be started.
2397 * This means that the user is not interacting with the device and is
2398 * not expected to do so soon. Typical use of the idle maintenance is
2399 * to perform somehow expensive tasks that can be postponed at a moment
2400 * when they will not degrade user experience.
2401 * <p>
2402 * <p class="note">In order to keep the device responsive in case of an
2403 * unexpected user interaction, implementations of a maintenance task
2404 * should be interruptible. In such a scenario a broadcast with action
2405 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2406 * should not do the maintenance work in
2407 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2408 * maintenance service by {@link Context#startService(Intent)}. Also
2409 * you should hold a wake lock while your maintenance service is running
2410 * to prevent the device going to sleep.
2411 * </p>
2412 * <p>
2413 * <p class="note">This is a protected intent that can only be sent by
2414 * the system.
2415 * </p>
2416 *
2417 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002418 *
2419 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002420 */
2421 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2422 public static final String ACTION_IDLE_MAINTENANCE_START =
2423 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2424
2425 /**
2426 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2427 * This means that the user was not interacting with the device as a result
2428 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2429 * was sent and now the user started interacting with the device. Typical
2430 * use of the idle maintenance is to perform somehow expensive tasks that
2431 * can be postponed at a moment when they will not degrade user experience.
2432 * <p>
2433 * <p class="note">In order to keep the device responsive in case of an
2434 * unexpected user interaction, implementations of a maintenance task
2435 * should be interruptible. Hence, on receiving a broadcast with this
2436 * action, the maintenance task should be interrupted as soon as possible.
2437 * In other words, you should not do the maintenance work in
2438 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2439 * maintenance service that was started on receiving of
2440 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2441 * lock you acquired when your maintenance service started.
2442 * </p>
2443 * <p class="note">This is a protected intent that can only be sent
2444 * by the system.
2445 *
2446 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002447 *
2448 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002449 */
2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2451 public static final String ACTION_IDLE_MAINTENANCE_END =
2452 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2453
2454 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002455 * Broadcast Action: a remote intent is to be broadcasted.
2456 *
2457 * A remote intent is used for remote RPC between devices. The remote intent
2458 * is serialized and sent from one device to another device. The receiving
2459 * device parses the remote intent and broadcasts it. Note that anyone can
2460 * broadcast a remote intent. However, if the intent receiver of the remote intent
2461 * does not trust intent broadcasts from arbitrary intent senders, it should require
2462 * the sender to hold certain permissions so only trusted sender's broadcast will be
2463 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002464 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002465 */
2466 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002467 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002468
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002469 /**
2470 * Broadcast Action: hook for permforming cleanup after a system update.
2471 *
2472 * The broadcast is sent when the system is booting, before the
2473 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2474 * image. A receiver for this should do its work and then disable itself
2475 * so that it does not get run again at the next boot.
2476 * @hide
2477 */
2478 public static final String ACTION_PRE_BOOT_COMPLETED =
2479 "android.intent.action.PRE_BOOT_COMPLETED";
2480
Amith Yamasani13593602012-03-22 16:16:17 -07002481 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002482 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002483 * on restricted users. The broadcast intent contains an extra
2484 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2485 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2486 * String[] depending on the restriction type.<p/>
2487 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002488 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2489 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2490 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002491 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2492 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002493 * @see RestrictionEntry
2494 */
2495 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2496 "android.intent.action.GET_RESTRICTION_ENTRIES";
2497
2498 /**
Amith Yamasanid304af62013-09-05 09:30:23 -07002499 * @hide
Amith Yamasani655d0e22013-06-12 14:19:10 -07002500 * Activity to challenge the user for a PIN that was configured when setting up
Amith Yamasanid304af62013-09-05 09:30:23 -07002501 * restrictions. Restrictions include blocking of apps and preventing certain user operations,
2502 * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle).
2503 * Launch the activity using
Amith Yamasani655d0e22013-06-12 14:19:10 -07002504 * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the
2505 * result is {@link android.app.Activity#RESULT_OK} for a successful response to the
2506 * challenge.<p/>
2507 * Before launching this activity, make sure that there is a PIN in effect, by calling
Amith Yamasanid304af62013-09-05 09:30:23 -07002508 * {@link android.os.UserManager#hasRestrictionsChallenge()}.
Amith Yamasani655d0e22013-06-12 14:19:10 -07002509 */
Amith Yamasanid304af62013-09-05 09:30:23 -07002510 public static final String ACTION_RESTRICTIONS_CHALLENGE =
2511 "android.intent.action.RESTRICTIONS_CHALLENGE";
Amith Yamasani655d0e22013-06-12 14:19:10 -07002512
2513 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002514 * Sent the first time a user is starting, to allow system apps to
2515 * perform one time initialization. (This will not be seen by third
2516 * party applications because a newly initialized user does not have any
2517 * third party applications installed for it.) This is sent early in
2518 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002519 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2520 * broadcast, since it is part of a visible user interaction; be as quick
2521 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002522 */
2523 public static final String ACTION_USER_INITIALIZE =
2524 "android.intent.action.USER_INITIALIZE";
2525
2526 /**
2527 * Sent when a user switch is happening, causing the process's user to be
2528 * brought to the foreground. This is only sent to receivers registered
2529 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2530 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002531 * foreground. This is sent as a foreground
2532 * broadcast, since it is part of a visible user interaction; be as quick
2533 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002534 */
2535 public static final String ACTION_USER_FOREGROUND =
2536 "android.intent.action.USER_FOREGROUND";
2537
2538 /**
2539 * Sent when a user switch is happening, causing the process's user to be
2540 * sent to the background. This is only sent to receivers registered
2541 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2542 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002543 * background. This is sent as a foreground
2544 * broadcast, since it is part of a visible user interaction; be as quick
2545 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002546 */
2547 public static final String ACTION_USER_BACKGROUND =
2548 "android.intent.action.USER_BACKGROUND";
2549
2550 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002551 * Broadcast sent to the system when a user is added. Carries an extra
2552 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2553 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002554 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002555 * @hide
2556 */
2557 public static final String ACTION_USER_ADDED =
2558 "android.intent.action.USER_ADDED";
2559
2560 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002561 * Broadcast sent by the system when a user is started. Carries an extra
2562 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002563 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002564 * that has been started. This is sent as a foreground
2565 * broadcast, since it is part of a visible user interaction; be as quick
2566 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002567 * @hide
2568 */
2569 public static final String ACTION_USER_STARTED =
2570 "android.intent.action.USER_STARTED";
2571
2572 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002573 * Broadcast sent when a user is in the process of starting. Carries an extra
2574 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2575 * sent to registered receivers, not manifest receivers. It is sent to all
2576 * users (including the one that is being started). You must hold
2577 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2578 * this broadcast. This is sent as a background broadcast, since
2579 * its result is not part of the primary UX flow; to safely keep track of
2580 * started/stopped state of a user you can use this in conjunction with
2581 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2582 * other user state broadcasts since those are foreground broadcasts so can
2583 * execute in a different order.
2584 * @hide
2585 */
2586 public static final String ACTION_USER_STARTING =
2587 "android.intent.action.USER_STARTING";
2588
2589 /**
2590 * Broadcast sent when a user is going to be stopped. Carries an extra
2591 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2592 * sent to registered receivers, not manifest receivers. It is sent to all
2593 * users (including the one that is being stopped). You must hold
2594 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2595 * this broadcast. The user will not stop until all receivers have
2596 * handled the broadcast. This is sent as a background broadcast, since
2597 * its result is not part of the primary UX flow; to safely keep track of
2598 * started/stopped state of a user you can use this in conjunction with
2599 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2600 * other user state broadcasts since those are foreground broadcasts so can
2601 * execute in a different order.
2602 * @hide
2603 */
2604 public static final String ACTION_USER_STOPPING =
2605 "android.intent.action.USER_STOPPING";
2606
2607 /**
2608 * Broadcast sent to the system when a user is stopped. Carries an extra
2609 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2610 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2611 * specific package. This is only sent to registered receivers, not manifest
2612 * receivers. It is sent to all running users <em>except</em> the one that
2613 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002614 * @hide
2615 */
2616 public static final String ACTION_USER_STOPPED =
2617 "android.intent.action.USER_STOPPED";
2618
2619 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002620 * 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 -07002621 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002622 * one that has been removed. The user will not be completely removed until all receivers have
2623 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002624 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002625 * @hide
2626 */
2627 public static final String ACTION_USER_REMOVED =
2628 "android.intent.action.USER_REMOVED";
2629
2630 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002631 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002632 * the userHandle of the user to become the current one. This is only sent to
2633 * registered receivers, not manifest receivers. It is sent to all running users.
2634 * You must hold
2635 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002636 * @hide
2637 */
2638 public static final String ACTION_USER_SWITCHED =
2639 "android.intent.action.USER_SWITCHED";
2640
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002641 /**
2642 * Broadcast sent to the system when a user's information changes. Carries an extra
2643 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002644 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002645 * @hide
2646 */
2647 public static final String ACTION_USER_INFO_CHANGED =
2648 "android.intent.action.USER_INFO_CHANGED";
2649
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002650 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002651 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2652 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002653 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2654 * that need to display merged content across both primary and managed profiles need to
2655 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002656 * not manifest receivers.
2657 */
2658 public static final String ACTION_MANAGED_PROFILE_ADDED =
2659 "android.intent.action.MANAGED_PROFILE_ADDED";
2660
2661 /**
2662 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002663 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2664 * Only applications (for example Launchers) that need to display merged content across both
2665 * primary and managed profiles need to worry about this broadcast. This is only sent to
2666 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002667 */
2668 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2669 "android.intent.action.MANAGED_PROFILE_REMOVED";
2670
2671 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002672 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2673 */
2674 public static final String ACTION_QUICK_CLOCK =
2675 "android.intent.action.QUICK_CLOCK";
2676
Michael Wright0087a142013-02-05 16:29:39 -08002677 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002678 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002679 * @hide
2680 */
2681 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2682 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2683
Justin Kohd378ad72013-04-01 12:18:26 -07002684 /**
2685 * Broadcast Action: A global button was pressed. Includes a single
2686 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2687 * caused the broadcast.
2688 * @hide
2689 */
2690 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2691
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002692 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002693 * Activity Action: Allow the user to select and return one or more existing
2694 * documents. When invoked, the system will display the various
2695 * {@link DocumentsProvider} instances installed on the device, letting the
2696 * user interactively navigate through them. These documents include local
2697 * media, such as photos and video, and documents provided by installed
2698 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002699 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002700 * Each document is represented as a {@code content://} URI backed by a
2701 * {@link DocumentsProvider}, which can be opened as a stream with
2702 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2703 * {@link android.provider.DocumentsContract.Document} metadata.
2704 * <p>
2705 * All selected documents are returned to the calling application with
2706 * persistable read and write permission grants. If you want to maintain
2707 * access to the documents across device reboots, you need to explicitly
2708 * take the persistable permissions using
2709 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2710 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002711 * Callers must indicate the acceptable document MIME types through
2712 * {@link #setType(String)}. For example, to select photos, use
2713 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2714 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2715 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002716 * <p>
2717 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002718 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2719 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002720 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002721 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2722 * returned URIs can be opened with
2723 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002724 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002725 * Output: The URI of the item that was picked, returned in
2726 * {@link #getData()}. This must be a {@code content://} URI so that any
2727 * receiver can access it. If multiple documents were selected, they are
2728 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002729 *
2730 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002731 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002732 * @see #ACTION_CREATE_DOCUMENT
2733 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002734 */
2735 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2736 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2737
2738 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002739 * Activity Action: Allow the user to create a new document. When invoked,
2740 * the system will display the various {@link DocumentsProvider} instances
2741 * installed on the device, letting the user navigate through them. The
2742 * returned document may be a newly created document with no content, or it
2743 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002744 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002745 * Each document is represented as a {@code content://} URI backed by a
2746 * {@link DocumentsProvider}, which can be opened as a stream with
2747 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2748 * {@link android.provider.DocumentsContract.Document} metadata.
2749 * <p>
2750 * Callers must indicate the concrete MIME type of the document being
2751 * created by setting {@link #setType(String)}. This MIME type cannot be
2752 * changed after the document is created.
2753 * <p>
2754 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2755 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002756 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002757 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2758 * returned URIs can be opened with
2759 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002760 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002761 * Output: The URI of the item that was created. This must be a
2762 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002763 *
2764 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002765 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002766 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002767 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002768 */
2769 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2770 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2771
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002772 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002773 * Activity Action: Allow the user to pick a directory subtree. When
2774 * invoked, the system will display the various {@link DocumentsProvider}
2775 * instances installed on the device, letting the user navigate through
2776 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002777 * <p>
2778 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002779 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2780 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2781 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002782 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002783 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002784 *
2785 * @see DocumentsContract
2786 */
2787 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002788 public static final String
2789 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002790
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002791 /** {@hide} */
2792 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2793
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002794 // ---------------------------------------------------------------------
2795 // ---------------------------------------------------------------------
2796 // Standard intent categories (see addCategory()).
2797
2798 /**
2799 * Set if the activity should be an option for the default action
2800 * (center press) to perform on a piece of data. Setting this will
2801 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002802 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002803 * Intent when initiating an action -- it is for use in intent filters
2804 * specified in packages.
2805 */
2806 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2807 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2808 /**
2809 * Activities that can be safely invoked from a browser must support this
2810 * category. For example, if the user is viewing a web page or an e-mail
2811 * and clicks on a link in the text, the Intent generated execute that
2812 * link will require the BROWSABLE category, so that only activities
2813 * supporting this category will be considered as possible actions. By
2814 * supporting this category, you are promising that there is nothing
2815 * damaging (without user intervention) that can happen by invoking any
2816 * matching Intent.
2817 */
2818 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2819 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2820 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002821 * Categories for activities that can participate in voice interaction.
2822 * An activity that supports this category must be prepared to run with
2823 * no UI shown at all (though in some case it may have a UI shown), and
2824 * rely on {@link android.app.VoiceInteractor} to interact with the user.
2825 */
2826 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2827 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
2828 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002829 * Set if the activity should be considered as an alternative action to
2830 * the data the user is currently viewing. See also
2831 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2832 * applies to the selection in a list of items.
2833 *
2834 * <p>Supporting this category means that you would like your activity to be
2835 * displayed in the set of alternative things the user can do, usually as
2836 * part of the current activity's options menu. You will usually want to
2837 * include a specific label in the &lt;intent-filter&gt; of this action
2838 * describing to the user what it does.
2839 *
2840 * <p>The action of IntentFilter with this category is important in that it
2841 * describes the specific action the target will perform. This generally
2842 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2843 * a specific name such as "com.android.camera.action.CROP. Only one
2844 * alternative of any particular action will be shown to the user, so using
2845 * a specific action like this makes sure that your alternative will be
2846 * displayed while also allowing other applications to provide their own
2847 * overrides of that particular action.
2848 */
2849 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2850 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2851 /**
2852 * Set if the activity should be considered as an alternative selection
2853 * action to the data the user has currently selected. This is like
2854 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2855 * of items from which the user can select, giving them alternatives to the
2856 * default action that will be performed on it.
2857 */
2858 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2859 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2860 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002861 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002862 */
2863 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2864 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2865 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002866 * Should be displayed in the top-level launcher.
2867 */
2868 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2869 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2870 /**
Jose Lima38b75b62014-03-11 10:41:39 -07002871 * Indicates an activity optimized for Leanback mode, and that should
2872 * be displayed in the Leanback launcher.
2873 */
2874 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2875 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
2876 /**
Jose Lima73915cf2014-07-29 17:16:31 -07002877 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
2878 * @hide
2879 */
2880 @SystemApi
2881 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
2882 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002883 * Provides information about the package it is in; typically used if
2884 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2885 * a front-door to the user without having to be shown in the all apps list.
2886 */
2887 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2888 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2889 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002890 * This is the home activity, that is the first activity that is displayed
2891 * when the device boots.
2892 */
2893 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2894 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2895 /**
2896 * This activity is a preference panel.
2897 */
2898 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2899 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2900 /**
2901 * This activity is a development preference panel.
2902 */
2903 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2904 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2905 /**
2906 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002907 */
2908 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2909 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2910 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002911 * This activity allows the user to browse and download new applications.
2912 */
2913 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2914 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2915 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002916 * This activity may be exercised by the monkey or other automated test tools.
2917 */
2918 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2919 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2920 /**
2921 * To be used as a test (not part of the normal user experience).
2922 */
2923 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2924 /**
2925 * To be used as a unit test (run through the Test Harness).
2926 */
2927 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2928 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002929 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002930 * experience).
2931 */
2932 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002933
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002934 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002935 * Used to indicate that an intent only wants URIs that can be opened with
2936 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
2937 * must support at least the columns defined in {@link OpenableColumns} when
2938 * queried.
2939 *
2940 * @see #ACTION_GET_CONTENT
2941 * @see #ACTION_OPEN_DOCUMENT
2942 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002943 */
2944 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2945 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2946
2947 /**
2948 * To be used as code under test for framework instrumentation tests.
2949 */
2950 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2951 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002952 /**
2953 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002954 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2955 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002956 */
2957 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2958 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2959 /**
2960 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002961 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2962 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002963 */
2964 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2965 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002966 /**
2967 * An activity to run when device is inserted into a analog (low end) dock.
2968 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2969 * information, see {@link android.app.UiModeManager}.
2970 */
2971 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2972 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2973
2974 /**
2975 * An activity to run when device is inserted into a digital (high end) dock.
2976 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2977 * information, see {@link android.app.UiModeManager}.
2978 */
2979 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2980 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002981
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002982 /**
2983 * Used to indicate that the activity can be used in a car environment.
2984 */
2985 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2986 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2987
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002988 // ---------------------------------------------------------------------
2989 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08002990 // Application launch intent categories (see addCategory()).
2991
2992 /**
2993 * Used with {@link #ACTION_MAIN} to launch the browser application.
2994 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002995 * <p>NOTE: This should not be used as the primary key of an Intent,
2996 * since it will not result in the app launching with the correct
2997 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002998 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002999 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003000 */
3001 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3002 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3003
3004 /**
3005 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3006 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003007 * <p>NOTE: This should not be used as the primary key of an Intent,
3008 * since it will not result in the app launching with the correct
3009 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003010 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003011 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003012 */
3013 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3014 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3015
3016 /**
3017 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3018 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003019 * <p>NOTE: This should not be used as the primary key of an Intent,
3020 * since it will not result in the app launching with the correct
3021 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003022 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003023 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003024 */
3025 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3026 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3027
3028 /**
3029 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3030 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003031 * <p>NOTE: This should not be used as the primary key of an Intent,
3032 * since it will not result in the app launching with the correct
3033 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003034 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003035 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003036 */
3037 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3038 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3039
3040 /**
3041 * Used with {@link #ACTION_MAIN} to launch the email application.
3042 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003043 * <p>NOTE: This should not be used as the primary key of an Intent,
3044 * since it will not result in the app launching with the correct
3045 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003046 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003047 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003048 */
3049 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3050 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3051
3052 /**
3053 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3054 * The activity should be able to view and manipulate image and video files
3055 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003056 * <p>NOTE: This should not be used as the primary key of an Intent,
3057 * since it will not result in the app launching with the correct
3058 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003059 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003060 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003061 */
3062 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3063 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3064
3065 /**
3066 * Used with {@link #ACTION_MAIN} to launch the maps application.
3067 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003068 * <p>NOTE: This should not be used as the primary key of an Intent,
3069 * since it will not result in the app launching with the correct
3070 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003071 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003072 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003073 */
3074 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3075 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3076
3077 /**
3078 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3079 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003080 * <p>NOTE: This should not be used as the primary key of an Intent,
3081 * since it will not result in the app launching with the correct
3082 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003083 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003084 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003085 */
3086 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3087 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3088
3089 /**
3090 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003091 * The activity should be able to play, browse, or manipulate music files
3092 * stored on the device.
3093 * <p>NOTE: This should not be used as the primary key of an Intent,
3094 * since it will not result in the app launching with the correct
3095 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003096 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003097 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003098 */
3099 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3100 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3101
3102 // ---------------------------------------------------------------------
3103 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003104 // Standard extra data keys.
3105
3106 /**
3107 * The initial data to place in a newly created record. Use with
3108 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3109 * fields as would be given to the underlying ContentProvider.insert()
3110 * call.
3111 */
3112 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3113
3114 /**
3115 * A constant CharSequence that is associated with the Intent, used with
3116 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3117 * this may be a styled CharSequence, so you must use
3118 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3119 * retrieve it.
3120 */
3121 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3122
3123 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003124 * A constant String that is associated with the Intent, used with
3125 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3126 * as HTML formatted text. Note that you <em>must</em> also supply
3127 * {@link #EXTRA_TEXT}.
3128 */
3129 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3130
3131 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003132 * A content: URI holding a stream of data associated with the Intent,
3133 * used with {@link #ACTION_SEND} to supply the data being sent.
3134 */
3135 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3136
3137 /**
3138 * A String[] holding e-mail addresses that should be delivered to.
3139 */
3140 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3141
3142 /**
3143 * A String[] holding e-mail addresses that should be carbon copied.
3144 */
3145 public static final String EXTRA_CC = "android.intent.extra.CC";
3146
3147 /**
3148 * A String[] holding e-mail addresses that should be blind carbon copied.
3149 */
3150 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3151
3152 /**
3153 * A constant string holding the desired subject line of a message.
3154 */
3155 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3156
3157 /**
3158 * An Intent describing the choices you would like shown with
3159 * {@link #ACTION_PICK_ACTIVITY}.
3160 */
3161 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3162
3163 /**
3164 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003165 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003166 */
3167 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3168
3169 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003170 * A Parcelable[] of {@link Intent} or
3171 * {@link android.content.pm.LabeledIntent} objects as set with
3172 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3173 * a the front of the list of choices, when shown to the user with a
3174 * {@link #ACTION_CHOOSER}.
3175 */
3176 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3177
3178 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003179 * A Bundle forming a mapping of potential target package names to different extras Bundles
3180 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3181 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3182 * be currently installed on the device.
3183 *
3184 * <p>An application may choose to provide alternate extras for the case where a user
3185 * selects an activity from a predetermined set of target packages. If the activity
3186 * the user selects from the chooser belongs to a package with its package name as
3187 * a key in this bundle, the corresponding extras for that package will be merged with
3188 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3189 * extra has the same key as an extra already present in the intent it will overwrite
3190 * the extra from the intent.</p>
3191 *
3192 * <p><em>Examples:</em>
3193 * <ul>
3194 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3195 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3196 * parameters for that target.</li>
3197 * <li>An application may offer additional metadata for known targets of a given intent
3198 * to pass along information only relevant to that target such as account or content
3199 * identifiers already known to that application.</li>
3200 * </ul></p>
3201 */
3202 public static final String EXTRA_REPLACEMENT_EXTRAS =
3203 "android.intent.extra.REPLACEMENT_EXTRAS";
3204
3205 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003206 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3207 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3208 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3209 * {@link ComponentName} of the chosen component.
3210 *
3211 * <p>In some situations this callback may never come, for example if the user abandons
3212 * the chooser, switches to another task or any number of other reasons. Apps should not
3213 * be written assuming that this callback will always occur.</p>
3214 */
3215 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3216 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3217
3218 /**
3219 * The {@link ComponentName} chosen by the user to complete an action.
3220 *
3221 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3222 */
3223 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3224
3225 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003226 * A {@link android.view.KeyEvent} object containing the event that
3227 * triggered the creation of the Intent it is in.
3228 */
3229 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3230
3231 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003232 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3233 * before shutting down.
3234 *
3235 * {@hide}
3236 */
3237 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3238
3239 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003240 * 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 -07003241 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3242 * of restarting the application.
3243 */
3244 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3245
3246 /**
3247 * A String holding the phone number originally entered in
3248 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3249 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3250 */
3251 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003252
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003253 /**
3254 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3255 * intents to supply the uid the package had been assigned. Also an optional
3256 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3257 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3258 * purpose.
3259 */
3260 public static final String EXTRA_UID = "android.intent.extra.UID";
3261
3262 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003263 * @hide String array of package names.
3264 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003265 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003266 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3267
3268 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003269 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3270 * intents to indicate whether this represents a full uninstall (removing
3271 * both the code and its data) or a partial uninstall (leaving its data,
3272 * implying that this is an update).
3273 */
3274 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003275
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003276 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003277 * @hide
3278 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3279 * intents to indicate that at this point the package has been removed for
3280 * all users on the device.
3281 */
3282 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3283 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3284
3285 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003286 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3287 * intents to indicate that this is a replacement of the package, so this
3288 * broadcast will immediately be followed by an add broadcast for a
3289 * different version of the same package.
3290 */
3291 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003292
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003293 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003294 * Used as an int extra field in {@link android.app.AlarmManager} intents
3295 * to tell the application being invoked how many pending alarms are being
3296 * delievered with the intent. For one-shot alarms this will always be 1.
3297 * For recurring alarms, this might be greater than 1 if the device was
3298 * asleep or powered off at the time an earlier alarm would have been
3299 * delivered.
3300 */
3301 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003302
Jacek Surazski86b6c532009-05-13 14:38:28 +02003303 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003304 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3305 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003306 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3307 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003308 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3309 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3310 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003311 */
3312 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3313
3314 /**
3315 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3316 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003317 */
3318 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3319
3320 /**
3321 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3322 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003323 */
3324 public static final int EXTRA_DOCK_STATE_DESK = 1;
3325
3326 /**
3327 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3328 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003329 */
3330 public static final int EXTRA_DOCK_STATE_CAR = 2;
3331
3332 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003333 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3334 * to represent that the phone is in a analog (low end) dock.
3335 */
3336 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3337
3338 /**
3339 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3340 * to represent that the phone is in a digital (high end) dock.
3341 */
3342 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3343
3344 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003345 * Boolean that can be supplied as meta-data with a dock activity, to
3346 * indicate that the dock should take over the home key when it is active.
3347 */
3348 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003349
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003350 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003351 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3352 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003353 */
3354 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3355
3356 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003357 * Used in the extra field in the remote intent. It's astring token passed with the
3358 * remote intent.
3359 */
3360 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3361 "android.intent.extra.remote_intent_token";
3362
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003363 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003364 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003365 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003366 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003367 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003368 "android.intent.extra.changed_component_name";
3369
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003370 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003371 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003372 * and contains a string array of all of the components that have changed. If
3373 * the state of the overall package has changed, then it will contain an entry
3374 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003375 */
3376 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3377 "android.intent.extra.changed_component_name_list";
3378
3379 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003380 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003381 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3382 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003383 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003384 */
3385 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3386 "android.intent.extra.changed_package_list";
3387
3388 /**
3389 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003390 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3391 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003392 * and contains an integer array of uids of all of the components
3393 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003394 */
3395 public static final String EXTRA_CHANGED_UID_LIST =
3396 "android.intent.extra.changed_uid_list";
3397
3398 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003399 * @hide
3400 * Magic extra system code can use when binding, to give a label for
3401 * who it is that has bound to a service. This is an integer giving
3402 * a framework string resource that can be displayed to the user.
3403 */
3404 public static final String EXTRA_CLIENT_LABEL =
3405 "android.intent.extra.client_label";
3406
3407 /**
3408 * @hide
3409 * Magic extra system code can use when binding, to give a PendingIntent object
3410 * that can be launched for the user to disable the system's use of this
3411 * service.
3412 */
3413 public static final String EXTRA_CLIENT_INTENT =
3414 "android.intent.extra.client_intent";
3415
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003416 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003417 * Extra used to indicate that an intent should only return data that is on
3418 * the local device. This is a boolean extra; the default is false. If true,
3419 * an implementation should only allow the user to select data that is
3420 * already on the device, not requiring it be downloaded from a remote
3421 * service when opened.
3422 *
3423 * @see #ACTION_GET_CONTENT
3424 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003425 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003426 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003427 */
3428 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003429 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003430
Amith Yamasani13593602012-03-22 16:16:17 -07003431 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003432 * Extra used to indicate that an intent can allow the user to select and
3433 * return multiple items. This is a boolean extra; the default is false. If
3434 * true, an implementation is allowed to present the user with a UI where
3435 * they can pick multiple items that are all returned to the caller. When
3436 * this happens, they should be returned as the {@link #getClipData()} part
3437 * of the result Intent.
3438 *
3439 * @see #ACTION_GET_CONTENT
3440 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003441 */
3442 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003443 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003444
3445 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003446 * The integer userHandle carried with broadcast intents related to addition, removal and
3447 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3448 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3449 *
Amith Yamasani13593602012-03-22 16:16:17 -07003450 * @hide
3451 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003452 public static final String EXTRA_USER_HANDLE =
3453 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003454
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003455 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003456 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3457 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3458 */
3459 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003460 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003461
3462 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003463 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003464 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3465 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003466 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003467 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3468
3469 /**
3470 * Extra sent in the intent to the BroadcastReceiver that handles
3471 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3472 * the restrictions as key/value pairs.
3473 */
3474 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3475 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003476
Amith Yamasani86118ba2013-03-28 14:33:16 -07003477 /**
3478 * Extra used in the response from a BroadcastReceiver that handles
3479 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3480 */
3481 public static final String EXTRA_RESTRICTIONS_INTENT =
3482 "android.intent.extra.restrictions_intent";
3483
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003484 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003485 * Extra used to communicate a set of acceptable MIME types. The type of the
3486 * extra is {@code String[]}. Values may be a combination of concrete MIME
3487 * types (such as "image/png") and/or partial MIME types (such as
3488 * "audio/*").
3489 *
3490 * @see #ACTION_GET_CONTENT
3491 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003492 */
3493 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3494
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003495 /**
3496 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3497 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003498 * When this is true, hardware devices can use this information to determine that
3499 * they shouldn't do a complete shutdown of their device since this is not a
3500 * complete shutdown down to the kernel, but only user space restarting.
3501 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003502 */
3503 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3504 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3505
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003506 /**
3507 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3508 * user has set their time format preferences to the 24 hour format.
3509 *
3510 * @hide for internal use only.
3511 */
3512 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3513 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3514
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003515 /** {@hide} */
3516 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3517
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003518 // ---------------------------------------------------------------------
3519 // ---------------------------------------------------------------------
3520 // Intent flags (see mFlags variable).
3521
Tor Norbyed9273d62013-05-30 15:59:53 -07003522 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003523 @IntDef(flag = true, value = {
3524 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3525 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003526 @Retention(RetentionPolicy.SOURCE)
3527 public @interface GrantUriMode {}
3528
Jeff Sharkey846318a2014-04-04 12:12:41 -07003529 /** @hide */
3530 @IntDef(flag = true, value = {
3531 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3532 @Retention(RetentionPolicy.SOURCE)
3533 public @interface AccessUriMode {}
3534
3535 /**
3536 * Test if given mode flags specify an access mode, which must be at least
3537 * read and/or write.
3538 *
3539 * @hide
3540 */
3541 public static boolean isAccessUriMode(int modeFlags) {
3542 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3543 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3544 }
3545
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003546 /**
3547 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003548 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003549 * specified in its ClipData. When applying to an Intent's ClipData,
3550 * all URIs as well as recursive traversals through data or other ClipData
3551 * in Intent items will be granted; only the grant flags of the top-level
3552 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003553 */
3554 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3555 /**
3556 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003557 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003558 * specified in its ClipData. When applying to an Intent's ClipData,
3559 * all URIs as well as recursive traversals through data or other ClipData
3560 * in Intent items will be granted; only the grant flags of the top-level
3561 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003562 */
3563 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3564 /**
3565 * Can be set by the caller to indicate that this Intent is coming from
3566 * a background operation, not from direct user interaction.
3567 */
3568 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3569 /**
3570 * A flag you can enable for debugging: when set, log messages will be
3571 * printed during the resolution of this intent to show you what has
3572 * been found to create the final resolved list.
3573 */
3574 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003575 /**
3576 * If set, this intent will not match any components in packages that
3577 * are currently stopped. If this is not set, then the default behavior
3578 * is to include such applications in the result.
3579 */
3580 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3581 /**
3582 * If set, this intent will always match any components in packages that
3583 * are currently stopped. This is the default behavior when
3584 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3585 * flags are set, this one wins (it allows overriding of exclude for
3586 * places where the framework may automatically set the exclude flag).
3587 */
3588 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003589
3590 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003591 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003592 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003593 * persisted across device reboots until explicitly revoked with
3594 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3595 * grant for possible persisting; the receiving application must call
3596 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3597 * actually persist.
3598 *
3599 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3600 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3601 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003602 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003603 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003604 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003605
3606 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003607 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3608 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3609 * applies to any URI that is a prefix match against the original granted
3610 * URI. (Without this flag, the URI must match exactly for access to be
3611 * granted.) Another URI is considered a prefix match only when scheme,
3612 * authority, and all path segments defined by the prefix are an exact
3613 * match.
3614 */
3615 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3616
3617 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003618 * If set, the new activity is not kept in the history stack. As soon as
3619 * the user navigates away from it, the activity is finished. This may also
3620 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3621 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003622 *
3623 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3624 * is never invoked when the current activity starts a new activity which
3625 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003626 */
3627 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3628 /**
3629 * If set, the activity will not be launched if it is already running
3630 * at the top of the history stack.
3631 */
3632 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3633 /**
3634 * If set, this activity will become the start of a new task on this
3635 * history stack. A task (from the activity that started it to the
3636 * next task activity) defines an atomic group of activities that the
3637 * user can move to. Tasks can be moved to the foreground and background;
3638 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003639 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003640 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3641 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003642 *
3643 * <p>This flag is generally used by activities that want
3644 * to present a "launcher" style behavior: they give the user a list of
3645 * separate things that can be done, which otherwise run completely
3646 * independently of the activity launching them.
3647 *
3648 * <p>When using this flag, if a task is already running for the activity
3649 * you are now starting, then a new activity will not be started; instead,
3650 * the current task will simply be brought to the front of the screen with
3651 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3652 * to disable this behavior.
3653 *
3654 * <p>This flag can not be used when the caller is requesting a result from
3655 * the activity being launched.
3656 */
3657 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3658 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003659 * This flag is used to create a new task and launch an activity into it.
3660 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3661 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3662 * search through existing tasks for ones matching this Intent. Only if no such
3663 * task is found would a new task be created. When paired with
3664 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3665 * the search for a matching task and unconditionally start a new task.
3666 *
3667 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3668 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003669 * top-level application launcher.</strong> Used in conjunction with
3670 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3671 * behavior of bringing an existing task to the foreground. When set,
3672 * a new task is <em>always</em> started to host the Activity for the
3673 * Intent, regardless of whether there is already an existing task running
3674 * the same thing.
3675 *
3676 * <p><strong>Because the default system does not include graphical task management,
3677 * you should not use this flag unless you provide some way for a user to
3678 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003679 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003680 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3681 * creating new document tasks.
3682 *
3683 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003684 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003685 *
Scott Main7aee61f2011-02-08 11:25:01 -08003686 * <p>See
3687 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3688 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003689 *
3690 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3691 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003692 */
3693 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3694 /**
3695 * If set, and the activity being launched is already running in the
3696 * current task, then instead of launching a new instance of that activity,
3697 * all of the other activities on top of it will be closed and this Intent
3698 * will be delivered to the (now on top) old activity as a new Intent.
3699 *
3700 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3701 * If D calls startActivity() with an Intent that resolves to the component
3702 * of activity B, then C and D will be finished and B receive the given
3703 * Intent, resulting in the stack now being: A, B.
3704 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003705 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003706 * either receive the new intent you are starting here in its
3707 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003708 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003709 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3710 * the same intent, then it will be finished and re-created; for all other
3711 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3712 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003713 *
3714 * <p>This launch mode can also be used to good effect in conjunction with
3715 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3716 * of a task, it will bring any currently running instance of that task
3717 * to the foreground, and then clear it to its root state. This is
3718 * especially useful, for example, when launching an activity from the
3719 * notification manager.
3720 *
Scott Main7aee61f2011-02-08 11:25:01 -08003721 * <p>See
3722 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3723 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003724 */
3725 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3726 /**
3727 * If set and this intent is being used to launch a new activity from an
3728 * existing one, then the reply target of the existing activity will be
3729 * transfered to the new activity. This way the new activity can call
3730 * {@link android.app.Activity#setResult} and have that result sent back to
3731 * the reply target of the original activity.
3732 */
3733 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3734 /**
3735 * If set and this intent is being used to launch a new activity from an
3736 * existing one, the current activity will not be counted as the top
3737 * activity for deciding whether the new intent should be delivered to
3738 * the top instead of starting a new one. The previous activity will
3739 * be used as the top, with the assumption being that the current activity
3740 * will finish itself immediately.
3741 */
3742 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3743 /**
3744 * If set, the new activity is not kept in the list of recently launched
3745 * activities.
3746 */
3747 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3748 /**
3749 * This flag is not normally set by application code, but set for you by
3750 * the system as described in the
3751 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3752 * launchMode} documentation for the singleTask mode.
3753 */
3754 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3755 /**
3756 * If set, and this activity is either being started in a new task or
3757 * bringing to the top an existing task, then it will be launched as
3758 * the front door of the task. This will result in the application of
3759 * any affinities needed to have that task in the proper state (either
3760 * moving activities to or from it), or simply resetting that task to
3761 * its initial state if needed.
3762 */
3763 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3764 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003765 * This flag is not normally set by application code, but set for you by
3766 * the system if this activity is being launched from history
3767 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003768 */
3769 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003770 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003771 * @deprecated As of API 21 this performs identically to
3772 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003773 */
3774 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003775 /**
Craig Mautner026596b2014-05-21 15:35:44 -07003776 * This flag is used to open a document into a new task rooted at the activity launched
3777 * by this Intent. Through the use of this flag, or its equivalent attribute,
3778 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00003779 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003780 *
Craig Mautner026596b2014-05-21 15:35:44 -07003781 * <p>The use of the activity attribute form of this,
3782 * {@link android.R.attr#documentLaunchMode}, is
3783 * preferred over the Intent flag described here. The attribute form allows the
3784 * Activity to specify multiple document behavior for all launchers of the Activity
3785 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003786 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07003787 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
3788 * it is kept after the activity is finished is different than the use of
3789 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
3790 * this flag is being used to create a new recents entry, then by default that entry
3791 * will be removed once the activity is finished. You can modify this behavior with
3792 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
3793 *
Craig Mautner026596b2014-05-21 15:35:44 -07003794 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
3795 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
3796 * equivalent of the Activity manifest specifying {@link
3797 * android.R.attr#documentLaunchMode}="intoExisting". When used with
3798 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
3799 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07003800 *
Craig Mautner026596b2014-05-21 15:35:44 -07003801 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003802 *
Craig Mautner026596b2014-05-21 15:35:44 -07003803 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07003804 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
3805 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003806 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07003807 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003808 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003809 * callback from occurring on the current frontmost activity before it is
3810 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07003811 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003812 * <p>Typically, an activity can rely on that callback to indicate that an
3813 * explicit user action has caused their activity to be moved out of the
3814 * foreground. The callback marks an appropriate point in the activity's
3815 * lifecycle for it to dismiss any notifications that it intends to display
3816 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07003817 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003818 * <p>If an activity is ever started via any non-user-driven events such as
3819 * phone-call receipt or an alarm handler, this flag should be passed to {@link
3820 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07003821 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003822 */
3823 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003824 /**
3825 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3826 * this flag will cause the launched activity to be brought to the front of its
3827 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07003828 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003829 * <p>For example, consider a task consisting of four activities: A, B, C, D.
3830 * If D calls startActivity() with an Intent that resolves to the component
3831 * of activity B, then B will be brought to the front of the history stack,
3832 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07003833 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003834 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07003835 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003836 */
3837 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003838 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003839 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3840 * this flag will prevent the system from applying an activity transition
3841 * animation to go to the next activity state. This doesn't mean an
3842 * animation will never run -- if another activity change happens that doesn't
3843 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003844 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003845 * when you are going to do a series of activity operations but the
3846 * animation seen by the user shouldn't be driven by the first activity
3847 * change but rather a later one.
3848 */
3849 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
3850 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003851 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3852 * this flag will cause any existing task that would be associated with the
3853 * activity to be cleared before the activity is started. That is, the activity
3854 * becomes the new root of an otherwise empty task, and any old activities
3855 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3856 */
3857 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
3858 /**
3859 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3860 * this flag will cause a newly launching task to be placed on top of the current
3861 * home activity task (if there is one). That is, pressing back from the task
3862 * will always return the user to home even if that was not the last activity they
3863 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3864 */
3865 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
3866 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07003867 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
3868 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07003869 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07003870 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07003871 * this flag. When set and the task's activity is finished, the recents
3872 * entry will remain in the interface for the user to re-launch it, like a
3873 * recents entry for a top-level application.
3874 * <p>
3875 * The receiving activity can override this request with
3876 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
3877 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07003878 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07003879 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07003880 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07003881
3882 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003883 * If set, when sending a broadcast only registered receivers will be
3884 * called -- no BroadcastReceiver components will be launched.
3885 */
3886 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003887 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003888 * If set, when sending a broadcast the new broadcast will replace
3889 * any existing pending broadcast that matches it. Matching is defined
3890 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
3891 * true for the intents of the two broadcasts. When a match is found,
3892 * the new broadcast (and receivers associated with it) will replace the
3893 * existing one in the pending broadcast list, remaining at the same
3894 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08003895 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003896 * <p>This flag is most typically used with sticky broadcasts, which
3897 * only care about delivering the most recent values of the broadcast
3898 * to their receivers.
3899 */
3900 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
3901 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08003902 * If set, when sending a broadcast the recipient is allowed to run at
3903 * foreground priority, with a shorter timeout interval. During normal
3904 * broadcasts the receivers are not automatically hoisted out of the
3905 * background priority class.
3906 */
3907 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
3908 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07003909 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
3910 * They can still propagate results through to later receivers, but they can not prevent
3911 * later receivers from seeing the broadcast.
3912 */
3913 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
3914 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003915 * If set, when sending a broadcast <i>before boot has completed</i> only
3916 * registered receivers will be called -- no BroadcastReceiver components
3917 * will be launched. Sticky intent state will be recorded properly even
3918 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
3919 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07003920 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003921 * <p>This flag is only for use by system sevices as a convenience to
3922 * avoid having to implement a more complex mechanism around detection
3923 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07003924 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003925 * @hide
3926 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003927 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003928 /**
3929 * Set when this broadcast is for a boot upgrade, a special mode that
3930 * allows the broadcast to be sent before the system is ready and launches
3931 * the app process with no providers running in it.
3932 * @hide
3933 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003934 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003935
Dianne Hackbornfa82f222009-09-17 15:14:12 -07003936 /**
3937 * @hide Flags that can't be changed with PendingIntent.
3938 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003939 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
3940 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3941 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08003942
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003943 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003944 // ---------------------------------------------------------------------
3945 // toUri() and parseUri() options.
3946
3947 /**
3948 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
3949 * always has the "intent:" scheme. This syntax can be used when you want
3950 * to later disambiguate between URIs that are intended to describe an
3951 * Intent vs. all others that should be treated as raw URIs. When used
3952 * with {@link #parseUri}, any other scheme will result in a generic
3953 * VIEW action for that raw URI.
3954 */
3955 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08003956
Dianne Hackborn85d558c2014-11-04 10:31:54 -08003957 /**
3958 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
3959 * always has the "android-app:" scheme. This is a variation of
3960 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
3961 * http/https URI being delivered to a specific package name. The format
3962 * is:
3963 *
3964 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08003965 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08003966 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08003967 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
3968 * you must also include a scheme; including a path also requires both a host and a scheme.
3969 * The final #Intent; fragment can be used without a scheme, host, or path.
3970 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08003971 * used with intents that have a {@link #setSelector}, since the base intent
3972 * will always have an explicit package name.</p>
3973 *
3974 * <p>Some examples of how this scheme maps to Intent objects:</p>
3975 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
3976 * <colgroup align="left" />
3977 * <colgroup align="left" />
3978 * <thead>
3979 * <tr><th>URI</th> <th>Intent</th></tr>
3980 * </thead>
3981 *
3982 * <tbody>
3983 * <tr><td><code>android-app://com.example.app</code></td>
3984 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
3985 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
3986 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
3987 * </table></td>
3988 * </tr>
3989 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
3990 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
3991 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
3992 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
3993 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
3994 * </table></td>
3995 * </tr>
3996 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
3997 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
3998 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
3999 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4000 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4001 * </table></td>
4002 * </tr>
4003 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4004 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4005 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4006 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4007 * </table></td>
4008 * </tr>
4009 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4010 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4011 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4012 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4013 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4014 * </table></td>
4015 * </tr>
4016 * <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>
4017 * <td><table border="" style="margin:0" >
4018 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4019 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4020 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4021 * </table></td>
4022 * </tr>
4023 * </tbody>
4024 * </table>
4025 */
4026 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4027
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004028 /**
4029 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4030 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4031 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4032 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4033 * generated Intent can not cause unexpected data access to happen.
4034 *
4035 * <p>If you do not trust the source of the URI being parsed, you should still do further
4036 * processing to protect yourself from it. In particular, when using it to start an
4037 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4038 * that can handle it.</p>
4039 */
4040 public static final int URI_ALLOW_UNSAFE = 1<<2;
4041
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004042 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004043
4044 private String mAction;
4045 private Uri mData;
4046 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004047 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004048 private ComponentName mComponent;
4049 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004050 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004051 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004052 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004053 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004054 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004055 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004056
4057 // ---------------------------------------------------------------------
4058
4059 /**
4060 * Create an empty intent.
4061 */
4062 public Intent() {
4063 }
4064
4065 /**
4066 * Copy constructor.
4067 */
4068 public Intent(Intent o) {
4069 this.mAction = o.mAction;
4070 this.mData = o.mData;
4071 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004072 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004073 this.mComponent = o.mComponent;
4074 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004075 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004076 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004077 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004078 }
4079 if (o.mExtras != null) {
4080 this.mExtras = new Bundle(o.mExtras);
4081 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004082 if (o.mSourceBounds != null) {
4083 this.mSourceBounds = new Rect(o.mSourceBounds);
4084 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004085 if (o.mSelector != null) {
4086 this.mSelector = new Intent(o.mSelector);
4087 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004088 if (o.mClipData != null) {
4089 this.mClipData = new ClipData(o.mClipData);
4090 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004091 }
4092
4093 @Override
4094 public Object clone() {
4095 return new Intent(this);
4096 }
4097
4098 private Intent(Intent o, boolean all) {
4099 this.mAction = o.mAction;
4100 this.mData = o.mData;
4101 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004102 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004103 this.mComponent = o.mComponent;
4104 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004105 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004106 }
4107 }
4108
4109 /**
4110 * Make a clone of only the parts of the Intent that are relevant for
4111 * filter matching: the action, data, type, component, and categories.
4112 */
4113 public Intent cloneFilter() {
4114 return new Intent(this, false);
4115 }
4116
4117 /**
4118 * Create an intent with a given action. All other fields (data, type,
4119 * class) are null. Note that the action <em>must</em> be in a
4120 * namespace because Intents are used globally in the system -- for
4121 * example the system VIEW action is android.intent.action.VIEW; an
4122 * application's custom action would be something like
4123 * com.google.app.myapp.CUSTOM_ACTION.
4124 *
4125 * @param action The Intent action, such as ACTION_VIEW.
4126 */
4127 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004128 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004129 }
4130
4131 /**
4132 * Create an intent with a given action and for a given data url. Note
4133 * that the action <em>must</em> be in a namespace because Intents are
4134 * used globally in the system -- for example the system VIEW action is
4135 * android.intent.action.VIEW; an application's custom action would be
4136 * something like com.google.app.myapp.CUSTOM_ACTION.
4137 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004138 * <p><em>Note: scheme and host name matching in the Android framework is
4139 * case-sensitive, unlike the formal RFC. As a result,
4140 * you should always ensure that you write your Uri with these elements
4141 * using lower case letters, and normalize any Uris you receive from
4142 * outside of Android to ensure the scheme and host is lower case.</em></p>
4143 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004144 * @param action The Intent action, such as ACTION_VIEW.
4145 * @param uri The Intent data URI.
4146 */
4147 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004148 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004149 mData = uri;
4150 }
4151
4152 /**
4153 * Create an intent for a specific component. All other fields (action, data,
4154 * type, class) are null, though they can be modified later with explicit
4155 * calls. This provides a convenient way to create an intent that is
4156 * intended to execute a hard-coded class name, rather than relying on the
4157 * system to find an appropriate class for you; see {@link #setComponent}
4158 * for more information on the repercussions of this.
4159 *
4160 * @param packageContext A Context of the application package implementing
4161 * this class.
4162 * @param cls The component class that is to be used for the intent.
4163 *
4164 * @see #setClass
4165 * @see #setComponent
4166 * @see #Intent(String, android.net.Uri , Context, Class)
4167 */
4168 public Intent(Context packageContext, Class<?> cls) {
4169 mComponent = new ComponentName(packageContext, cls);
4170 }
4171
4172 /**
4173 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004174 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004175 * construct the Intent and then calling {@link #setClass} to set its
4176 * class.
4177 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004178 * <p><em>Note: scheme and host name matching in the Android framework is
4179 * case-sensitive, unlike the formal RFC. As a result,
4180 * you should always ensure that you write your Uri with these elements
4181 * using lower case letters, and normalize any Uris you receive from
4182 * outside of Android to ensure the scheme and host is lower case.</em></p>
4183 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004184 * @param action The Intent action, such as ACTION_VIEW.
4185 * @param uri The Intent data URI.
4186 * @param packageContext A Context of the application package implementing
4187 * this class.
4188 * @param cls The component class that is to be used for the intent.
4189 *
4190 * @see #Intent(String, android.net.Uri)
4191 * @see #Intent(Context, Class)
4192 * @see #setClass
4193 * @see #setComponent
4194 */
4195 public Intent(String action, Uri uri,
4196 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004197 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004198 mData = uri;
4199 mComponent = new ComponentName(packageContext, cls);
4200 }
4201
4202 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004203 * Create an intent to launch the main (root) activity of a task. This
4204 * is the Intent that is started when the application's is launched from
4205 * Home. For anything else that wants to launch an application in the
4206 * same way, it is important that they use an Intent structured the same
4207 * way, and can use this function to ensure this is the case.
4208 *
4209 * <p>The returned Intent has the given Activity component as its explicit
4210 * component, {@link #ACTION_MAIN} as its action, and includes the
4211 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4212 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4213 * to do that through {@link #addFlags(int)} on the returned Intent.
4214 *
4215 * @param mainActivity The main activity component that this Intent will
4216 * launch.
4217 * @return Returns a newly created Intent that can be used to launch the
4218 * activity as a main application entry.
4219 *
4220 * @see #setClass
4221 * @see #setComponent
4222 */
4223 public static Intent makeMainActivity(ComponentName mainActivity) {
4224 Intent intent = new Intent(ACTION_MAIN);
4225 intent.setComponent(mainActivity);
4226 intent.addCategory(CATEGORY_LAUNCHER);
4227 return intent;
4228 }
4229
4230 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004231 * Make an Intent for the main activity of an application, without
4232 * specifying a specific activity to run but giving a selector to find
4233 * the activity. This results in a final Intent that is structured
4234 * the same as when the application is launched from
4235 * Home. For anything else that wants to launch an application in the
4236 * same way, it is important that they use an Intent structured the same
4237 * way, and can use this function to ensure this is the case.
4238 *
4239 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4240 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4241 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4242 * to do that through {@link #addFlags(int)} on the returned Intent.
4243 *
4244 * @param selectorAction The action name of the Intent's selector.
4245 * @param selectorCategory The name of a category to add to the Intent's
4246 * selector.
4247 * @return Returns a newly created Intent that can be used to launch the
4248 * activity as a main application entry.
4249 *
4250 * @see #setSelector(Intent)
4251 */
4252 public static Intent makeMainSelectorActivity(String selectorAction,
4253 String selectorCategory) {
4254 Intent intent = new Intent(ACTION_MAIN);
4255 intent.addCategory(CATEGORY_LAUNCHER);
4256 Intent selector = new Intent();
4257 selector.setAction(selectorAction);
4258 selector.addCategory(selectorCategory);
4259 intent.setSelector(selector);
4260 return intent;
4261 }
4262
4263 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004264 * Make an Intent that can be used to re-launch an application's task
4265 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4266 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4267 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4268 *
4269 * @param mainActivity The activity component that is the root of the
4270 * task; this is the activity that has been published in the application's
4271 * manifest as the main launcher icon.
4272 *
4273 * @return Returns a newly created Intent that can be used to relaunch the
4274 * activity's task in its root state.
4275 */
4276 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4277 Intent intent = makeMainActivity(mainActivity);
4278 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4279 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4280 return intent;
4281 }
4282
4283 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004284 * Call {@link #parseUri} with 0 flags.
4285 * @deprecated Use {@link #parseUri} instead.
4286 */
4287 @Deprecated
4288 public static Intent getIntent(String uri) throws URISyntaxException {
4289 return parseUri(uri, 0);
4290 }
Tom Taylord4a47292009-12-21 13:59:18 -08004291
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004292 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004293 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004294 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004295 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004296 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004297 *
4298 * <p>The URI given here must not be relative -- that is, it must include
4299 * the scheme and full path.
4300 *
4301 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004302 * @param flags Additional processing flags. Either 0,
4303 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004304 *
4305 * @return Intent The newly created Intent object.
4306 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004307 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4308 * it bad (as parsed by the Uri class) or the Intent data within the
4309 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004310 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004311 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004312 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004313 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004314 int i = 0;
4315 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004316 final boolean androidApp = uri.startsWith("android-app:");
4317
4318 // Validate intent scheme if requested.
4319 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4320 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004321 Intent intent = new Intent(ACTION_VIEW);
4322 try {
4323 intent.setData(Uri.parse(uri));
4324 } catch (IllegalArgumentException e) {
4325 throw new URISyntaxException(uri, e.getMessage());
4326 }
4327 return intent;
4328 }
4329 }
Tom Taylord4a47292009-12-21 13:59:18 -08004330
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004331 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004332 // simple case
4333 if (i == -1) {
4334 if (!androidApp) {
4335 return new Intent(ACTION_VIEW, Uri.parse(uri));
4336 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004337
4338 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004339 } else if (!uri.startsWith("#Intent;", i)) {
4340 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004341 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004342 } else {
4343 i = -1;
4344 }
4345 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004346
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004347 // new format
4348 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004349 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004350 boolean explicitAction = false;
4351 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004352
4353 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004354 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004355 String data;
4356 if (i >= 0) {
4357 data = uri.substring(0, i);
4358 i += 8; // length of "#Intent;"
4359 } else {
4360 data = uri;
4361 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004362
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004363 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004364 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004365 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004366 if (eq < 0) eq = i-1;
4367 int semi = uri.indexOf(';', i);
4368 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004369
4370 // action
4371 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004372 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004373 if (!inSelector) {
4374 explicitAction = true;
4375 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004376 }
4377
4378 // categories
4379 else if (uri.startsWith("category=", i)) {
4380 intent.addCategory(value);
4381 }
4382
4383 // type
4384 else if (uri.startsWith("type=", i)) {
4385 intent.mType = value;
4386 }
4387
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004388 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004389 else if (uri.startsWith("launchFlags=", i)) {
4390 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004391 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4392 intent.mFlags &= ~IMMUTABLE_FLAGS;
4393 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004394 }
4395
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004396 // package
4397 else if (uri.startsWith("package=", i)) {
4398 intent.mPackage = value;
4399 }
4400
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004401 // component
4402 else if (uri.startsWith("component=", i)) {
4403 intent.mComponent = ComponentName.unflattenFromString(value);
4404 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004405
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004406 // scheme
4407 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004408 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004409 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004410 } else {
4411 scheme = value;
4412 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004413 }
4414
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004415 // source bounds
4416 else if (uri.startsWith("sourceBounds=", i)) {
4417 intent.mSourceBounds = Rect.unflattenFromString(value);
4418 }
4419
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004420 // selector
4421 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4422 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004423 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004424 }
4425
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004426 // extra
4427 else {
4428 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004429 // create Bundle if it doesn't already exist
4430 if (intent.mExtras == null) intent.mExtras = new Bundle();
4431 Bundle b = intent.mExtras;
4432 // add EXTRA
4433 if (uri.startsWith("S.", i)) b.putString(key, value);
4434 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4435 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4436 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4437 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4438 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4439 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4440 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4441 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4442 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4443 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004444
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004445 // move to the next item
4446 i = semi + 1;
4447 }
4448
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004449 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004450 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004451 if (baseIntent.mPackage == null) {
4452 baseIntent.setSelector(intent);
4453 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004454 intent = baseIntent;
4455 }
4456
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004457 if (data != null) {
4458 if (data.startsWith("intent:")) {
4459 data = data.substring(7);
4460 if (scheme != null) {
4461 data = scheme + ':' + data;
4462 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004463 } else if (data.startsWith("android-app:")) {
4464 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4465 // Correctly formed android-app, first part is package name.
4466 int end = data.indexOf('/', 14);
4467 if (end < 0) {
4468 // All we have is a package name.
4469 intent.mPackage = data.substring(14);
4470 if (!explicitAction) {
4471 intent.setAction(ACTION_MAIN);
4472 }
4473 data = "";
4474 } else {
4475 // Target the Intent at the given package name always.
4476 String authority = null;
4477 intent.mPackage = data.substring(14, end);
4478 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004479 if ((end+1) < data.length()) {
4480 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4481 // Found a scheme, remember it.
4482 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004483 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004484 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4485 // Found a authority, remember it.
4486 authority = data.substring(end+1, newEnd);
4487 end = newEnd;
4488 }
4489 } else {
4490 // All we have is a scheme.
4491 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004492 }
4493 }
4494 if (scheme == null) {
4495 // If there was no scheme, then this just targets the package.
4496 if (!explicitAction) {
4497 intent.setAction(ACTION_MAIN);
4498 }
4499 data = "";
4500 } else if (authority == null) {
4501 data = scheme + ":";
4502 } else {
4503 data = scheme + "://" + authority + data.substring(end);
4504 }
4505 }
4506 } else {
4507 data = "";
4508 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004509 }
Tom Taylord4a47292009-12-21 13:59:18 -08004510
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004511 if (data.length() > 0) {
4512 try {
4513 intent.mData = Uri.parse(data);
4514 } catch (IllegalArgumentException e) {
4515 throw new URISyntaxException(uri, e.getMessage());
4516 }
4517 }
4518 }
Tom Taylord4a47292009-12-21 13:59:18 -08004519
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004520 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004521
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004522 } catch (IndexOutOfBoundsException e) {
4523 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4524 }
4525 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004526
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004527 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004528 return getIntentOld(uri, 0);
4529 }
4530
4531 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 Intent intent;
4533
4534 int i = uri.lastIndexOf('#');
4535 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004536 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004537 final int intentFragmentStart = i;
4538 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004539
4540 i++;
4541
4542 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004543 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004544 i += 7;
4545 int j = uri.indexOf(')', i);
4546 action = uri.substring(i, j);
4547 i = j + 1;
4548 }
4549
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004550 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004551
4552 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004553 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004554 i += 11;
4555 int j = uri.indexOf(')', i);
4556 while (i < j) {
4557 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004558 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004559 if (i < sep) {
4560 intent.addCategory(uri.substring(i, sep));
4561 }
4562 i = sep + 1;
4563 }
4564 i = j + 1;
4565 }
4566
4567 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004568 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004569 i += 5;
4570 int j = uri.indexOf(')', i);
4571 intent.mType = uri.substring(i, j);
4572 i = j + 1;
4573 }
4574
4575 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004576 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004577 i += 12;
4578 int j = uri.indexOf(')', i);
4579 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004580 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4581 intent.mFlags &= ~IMMUTABLE_FLAGS;
4582 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004583 i = j + 1;
4584 }
4585
4586 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004587 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004588 i += 10;
4589 int j = uri.indexOf(')', i);
4590 int sep = uri.indexOf('!', i);
4591 if (sep >= 0 && sep < j) {
4592 String pkg = uri.substring(i, sep);
4593 String cls = uri.substring(sep + 1, j);
4594 intent.mComponent = new ComponentName(pkg, cls);
4595 }
4596 i = j + 1;
4597 }
4598
4599 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004600 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004601 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004602
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004603 final int closeParen = uri.indexOf(')', i);
4604 if (closeParen == -1) throw new URISyntaxException(uri,
4605 "EXTRA missing trailing ')'", i);
4606
4607 while (i < closeParen) {
4608 // fetch the key value
4609 int j = uri.indexOf('=', i);
4610 if (j <= i + 1 || i >= closeParen) {
4611 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4612 }
4613 char type = uri.charAt(i);
4614 i++;
4615 String key = uri.substring(i, j);
4616 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004617
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004618 // get type-value
4619 j = uri.indexOf('!', i);
4620 if (j == -1 || j >= closeParen) j = closeParen;
4621 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4622 String value = uri.substring(i, j);
4623 i = j;
4624
4625 // create Bundle if it doesn't already exist
4626 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004627
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004628 // add item to bundle
4629 try {
4630 switch (type) {
4631 case 'S':
4632 intent.mExtras.putString(key, Uri.decode(value));
4633 break;
4634 case 'B':
4635 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4636 break;
4637 case 'b':
4638 intent.mExtras.putByte(key, Byte.parseByte(value));
4639 break;
4640 case 'c':
4641 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4642 break;
4643 case 'd':
4644 intent.mExtras.putDouble(key, Double.parseDouble(value));
4645 break;
4646 case 'f':
4647 intent.mExtras.putFloat(key, Float.parseFloat(value));
4648 break;
4649 case 'i':
4650 intent.mExtras.putInt(key, Integer.parseInt(value));
4651 break;
4652 case 'l':
4653 intent.mExtras.putLong(key, Long.parseLong(value));
4654 break;
4655 case 's':
4656 intent.mExtras.putShort(key, Short.parseShort(value));
4657 break;
4658 default:
4659 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4660 }
4661 } catch (NumberFormatException e) {
4662 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4663 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004665 char ch = uri.charAt(i);
4666 if (ch == ')') break;
4667 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4668 i++;
4669 }
4670 }
4671
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004672 if (isIntentFragment) {
4673 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4674 } else {
4675 intent.mData = Uri.parse(uri);
4676 }
Tom Taylord4a47292009-12-21 13:59:18 -08004677
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004678 if (intent.mAction == null) {
4679 // By default, if no action is specified, then use VIEW.
4680 intent.mAction = ACTION_VIEW;
4681 }
4682
4683 } else {
4684 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4685 }
4686
4687 return intent;
4688 }
4689
4690 /**
4691 * Retrieve the general action to be performed, such as
4692 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4693 * the information in the intent should be interpreted -- most importantly,
4694 * what to do with the data returned by {@link #getData}.
4695 *
4696 * @return The action of this intent or null if none is specified.
4697 *
4698 * @see #setAction
4699 */
4700 public String getAction() {
4701 return mAction;
4702 }
4703
4704 /**
4705 * Retrieve data this intent is operating on. This URI specifies the name
4706 * of the data; often it uses the content: scheme, specifying data in a
4707 * content provider. Other schemes may be handled by specific activities,
4708 * such as http: by the web browser.
4709 *
4710 * @return The URI of the data this intent is targeting or null.
4711 *
4712 * @see #getScheme
4713 * @see #setData
4714 */
4715 public Uri getData() {
4716 return mData;
4717 }
4718
4719 /**
4720 * The same as {@link #getData()}, but returns the URI as an encoded
4721 * String.
4722 */
4723 public String getDataString() {
4724 return mData != null ? mData.toString() : null;
4725 }
4726
4727 /**
4728 * Return the scheme portion of the intent's data. If the data is null or
4729 * does not include a scheme, null is returned. Otherwise, the scheme
4730 * prefix without the final ':' is returned, i.e. "http".
4731 *
4732 * <p>This is the same as calling getData().getScheme() (and checking for
4733 * null data).
4734 *
4735 * @return The scheme of this intent.
4736 *
4737 * @see #getData
4738 */
4739 public String getScheme() {
4740 return mData != null ? mData.getScheme() : null;
4741 }
4742
4743 /**
4744 * Retrieve any explicit MIME type included in the intent. This is usually
4745 * null, as the type is determined by the intent data.
4746 *
4747 * @return If a type was manually set, it is returned; else null is
4748 * returned.
4749 *
4750 * @see #resolveType(ContentResolver)
4751 * @see #setType
4752 */
4753 public String getType() {
4754 return mType;
4755 }
4756
4757 /**
4758 * Return the MIME data type of this intent. If the type field is
4759 * explicitly set, that is simply returned. Otherwise, if the data is set,
4760 * the type of that data is returned. If neither fields are set, a null is
4761 * returned.
4762 *
4763 * @return The MIME type of this intent.
4764 *
4765 * @see #getType
4766 * @see #resolveType(ContentResolver)
4767 */
4768 public String resolveType(Context context) {
4769 return resolveType(context.getContentResolver());
4770 }
4771
4772 /**
4773 * Return the MIME data type of this intent. If the type field is
4774 * explicitly set, that is simply returned. Otherwise, if the data is set,
4775 * the type of that data is returned. If neither fields are set, a null is
4776 * returned.
4777 *
4778 * @param resolver A ContentResolver that can be used to determine the MIME
4779 * type of the intent's data.
4780 *
4781 * @return The MIME type of this intent.
4782 *
4783 * @see #getType
4784 * @see #resolveType(Context)
4785 */
4786 public String resolveType(ContentResolver resolver) {
4787 if (mType != null) {
4788 return mType;
4789 }
4790 if (mData != null) {
4791 if ("content".equals(mData.getScheme())) {
4792 return resolver.getType(mData);
4793 }
4794 }
4795 return null;
4796 }
4797
4798 /**
4799 * Return the MIME data type of this intent, only if it will be needed for
4800 * intent resolution. This is not generally useful for application code;
4801 * it is used by the frameworks for communicating with back-end system
4802 * services.
4803 *
4804 * @param resolver A ContentResolver that can be used to determine the MIME
4805 * type of the intent's data.
4806 *
4807 * @return The MIME type of this intent, or null if it is unknown or not
4808 * needed.
4809 */
4810 public String resolveTypeIfNeeded(ContentResolver resolver) {
4811 if (mComponent != null) {
4812 return mType;
4813 }
4814 return resolveType(resolver);
4815 }
4816
4817 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004818 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004819 *
4820 * @param category The category to check.
4821 *
4822 * @return boolean True if the intent contains the category, else false.
4823 *
4824 * @see #getCategories
4825 * @see #addCategory
4826 */
4827 public boolean hasCategory(String category) {
4828 return mCategories != null && mCategories.contains(category);
4829 }
4830
4831 /**
4832 * Return the set of all categories in the intent. If there are no categories,
4833 * returns NULL.
4834 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004835 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004836 *
4837 * @see #hasCategory
4838 * @see #addCategory
4839 */
4840 public Set<String> getCategories() {
4841 return mCategories;
4842 }
4843
4844 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004845 * Return the specific selector associated with this Intent. If there is
4846 * none, returns null. See {@link #setSelector} for more information.
4847 *
4848 * @see #setSelector
4849 */
4850 public Intent getSelector() {
4851 return mSelector;
4852 }
4853
4854 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004855 * Return the {@link ClipData} associated with this Intent. If there is
4856 * none, returns null. See {@link #setClipData} for more information.
4857 *
John Spurlock125d1332013-11-25 11:58:37 -05004858 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004859 */
4860 public ClipData getClipData() {
4861 return mClipData;
4862 }
4863
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004864 /** @hide */
4865 public int getContentUserHint() {
4866 return mContentUserHint;
4867 }
4868
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004869 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004870 * Sets the ClassLoader that will be used when unmarshalling
4871 * any Parcelable values from the extras of this Intent.
4872 *
4873 * @param loader a ClassLoader, or null to use the default loader
4874 * at the time of unmarshalling.
4875 */
4876 public void setExtrasClassLoader(ClassLoader loader) {
4877 if (mExtras != null) {
4878 mExtras.setClassLoader(loader);
4879 }
4880 }
4881
4882 /**
4883 * Returns true if an extra value is associated with the given name.
4884 * @param name the extra's name
4885 * @return true if the given extra is present.
4886 */
4887 public boolean hasExtra(String name) {
4888 return mExtras != null && mExtras.containsKey(name);
4889 }
4890
4891 /**
4892 * Returns true if the Intent's extras contain a parcelled file descriptor.
4893 * @return true if the Intent contains a parcelled file descriptor.
4894 */
4895 public boolean hasFileDescriptors() {
4896 return mExtras != null && mExtras.hasFileDescriptors();
4897 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004898
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04004899 /** @hide */
4900 public void setAllowFds(boolean allowFds) {
4901 if (mExtras != null) {
4902 mExtras.setAllowFds(allowFds);
4903 }
4904 }
4905
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004906 /**
4907 * Retrieve extended data from the intent.
4908 *
4909 * @param name The name of the desired item.
4910 *
4911 * @return the value of an item that previously added with putExtra()
4912 * or null if none was found.
4913 *
4914 * @deprecated
4915 * @hide
4916 */
4917 @Deprecated
4918 public Object getExtra(String name) {
4919 return getExtra(name, null);
4920 }
4921
4922 /**
4923 * Retrieve extended data from the intent.
4924 *
4925 * @param name The name of the desired item.
4926 * @param defaultValue the value to be returned if no value of the desired
4927 * type is stored with the given name.
4928 *
4929 * @return the value of an item that previously added with putExtra()
4930 * or the default value if none was found.
4931 *
4932 * @see #putExtra(String, boolean)
4933 */
4934 public boolean getBooleanExtra(String name, boolean defaultValue) {
4935 return mExtras == null ? defaultValue :
4936 mExtras.getBoolean(name, defaultValue);
4937 }
4938
4939 /**
4940 * Retrieve extended data from the intent.
4941 *
4942 * @param name The name of the desired item.
4943 * @param defaultValue the value to be returned if no value of the desired
4944 * type is stored with the given name.
4945 *
4946 * @return the value of an item that previously added with putExtra()
4947 * or the default value if none was found.
4948 *
4949 * @see #putExtra(String, byte)
4950 */
4951 public byte getByteExtra(String name, byte defaultValue) {
4952 return mExtras == null ? defaultValue :
4953 mExtras.getByte(name, defaultValue);
4954 }
4955
4956 /**
4957 * Retrieve extended data from the intent.
4958 *
4959 * @param name The name of the desired item.
4960 * @param defaultValue the value to be returned if no value of the desired
4961 * type is stored with the given name.
4962 *
4963 * @return the value of an item that previously added with putExtra()
4964 * or the default value if none was found.
4965 *
4966 * @see #putExtra(String, short)
4967 */
4968 public short getShortExtra(String name, short defaultValue) {
4969 return mExtras == null ? defaultValue :
4970 mExtras.getShort(name, defaultValue);
4971 }
4972
4973 /**
4974 * Retrieve extended data from the intent.
4975 *
4976 * @param name The name of the desired item.
4977 * @param defaultValue the value to be returned if no value of the desired
4978 * type is stored with the given name.
4979 *
4980 * @return the value of an item that previously added with putExtra()
4981 * or the default value if none was found.
4982 *
4983 * @see #putExtra(String, char)
4984 */
4985 public char getCharExtra(String name, char defaultValue) {
4986 return mExtras == null ? defaultValue :
4987 mExtras.getChar(name, defaultValue);
4988 }
4989
4990 /**
4991 * Retrieve extended data from the intent.
4992 *
4993 * @param name The name of the desired item.
4994 * @param defaultValue the value to be returned if no value of the desired
4995 * type is stored with the given name.
4996 *
4997 * @return the value of an item that previously added with putExtra()
4998 * or the default value if none was found.
4999 *
5000 * @see #putExtra(String, int)
5001 */
5002 public int getIntExtra(String name, int defaultValue) {
5003 return mExtras == null ? defaultValue :
5004 mExtras.getInt(name, defaultValue);
5005 }
5006
5007 /**
5008 * Retrieve extended data from the intent.
5009 *
5010 * @param name The name of the desired item.
5011 * @param defaultValue the value to be returned if no value of the desired
5012 * type is stored with the given name.
5013 *
5014 * @return the value of an item that previously added with putExtra()
5015 * or the default value if none was found.
5016 *
5017 * @see #putExtra(String, long)
5018 */
5019 public long getLongExtra(String name, long defaultValue) {
5020 return mExtras == null ? defaultValue :
5021 mExtras.getLong(name, defaultValue);
5022 }
5023
5024 /**
5025 * Retrieve extended data from the intent.
5026 *
5027 * @param name The name of the desired item.
5028 * @param defaultValue the value to be returned if no value of the desired
5029 * type is stored with the given name.
5030 *
5031 * @return the value of an item that previously added with putExtra(),
5032 * or the default value if no such item is present
5033 *
5034 * @see #putExtra(String, float)
5035 */
5036 public float getFloatExtra(String name, float defaultValue) {
5037 return mExtras == null ? defaultValue :
5038 mExtras.getFloat(name, defaultValue);
5039 }
5040
5041 /**
5042 * Retrieve extended data from the intent.
5043 *
5044 * @param name The name of the desired item.
5045 * @param defaultValue the value to be returned if no value of the desired
5046 * type is stored with the given name.
5047 *
5048 * @return the value of an item that previously added with putExtra()
5049 * or the default value if none was found.
5050 *
5051 * @see #putExtra(String, double)
5052 */
5053 public double getDoubleExtra(String name, double defaultValue) {
5054 return mExtras == null ? defaultValue :
5055 mExtras.getDouble(name, defaultValue);
5056 }
5057
5058 /**
5059 * Retrieve extended data from the intent.
5060 *
5061 * @param name The name of the desired item.
5062 *
5063 * @return the value of an item that previously added with putExtra()
5064 * or null if no String value was found.
5065 *
5066 * @see #putExtra(String, String)
5067 */
5068 public String getStringExtra(String name) {
5069 return mExtras == null ? null : mExtras.getString(name);
5070 }
5071
5072 /**
5073 * Retrieve extended data from the intent.
5074 *
5075 * @param name The name of the desired item.
5076 *
5077 * @return the value of an item that previously added with putExtra()
5078 * or null if no CharSequence value was found.
5079 *
5080 * @see #putExtra(String, CharSequence)
5081 */
5082 public CharSequence getCharSequenceExtra(String name) {
5083 return mExtras == null ? null : mExtras.getCharSequence(name);
5084 }
5085
5086 /**
5087 * Retrieve extended data from the intent.
5088 *
5089 * @param name The name of the desired item.
5090 *
5091 * @return the value of an item that previously added with putExtra()
5092 * or null if no Parcelable value was found.
5093 *
5094 * @see #putExtra(String, Parcelable)
5095 */
5096 public <T extends Parcelable> T getParcelableExtra(String name) {
5097 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5098 }
5099
5100 /**
5101 * Retrieve extended data from the intent.
5102 *
5103 * @param name The name of the desired item.
5104 *
5105 * @return the value of an item that previously added with putExtra()
5106 * or null if no Parcelable[] value was found.
5107 *
5108 * @see #putExtra(String, Parcelable[])
5109 */
5110 public Parcelable[] getParcelableArrayExtra(String name) {
5111 return mExtras == null ? null : mExtras.getParcelableArray(name);
5112 }
5113
5114 /**
5115 * Retrieve extended data from the intent.
5116 *
5117 * @param name The name of the desired item.
5118 *
5119 * @return the value of an item that previously added with putExtra()
5120 * or null if no ArrayList<Parcelable> value was found.
5121 *
5122 * @see #putParcelableArrayListExtra(String, ArrayList)
5123 */
5124 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5125 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5126 }
5127
5128 /**
5129 * Retrieve extended data from the intent.
5130 *
5131 * @param name The name of the desired item.
5132 *
5133 * @return the value of an item that previously added with putExtra()
5134 * or null if no Serializable value was found.
5135 *
5136 * @see #putExtra(String, Serializable)
5137 */
5138 public Serializable getSerializableExtra(String name) {
5139 return mExtras == null ? null : mExtras.getSerializable(name);
5140 }
5141
5142 /**
5143 * Retrieve extended data from the intent.
5144 *
5145 * @param name The name of the desired item.
5146 *
5147 * @return the value of an item that previously added with putExtra()
5148 * or null if no ArrayList<Integer> value was found.
5149 *
5150 * @see #putIntegerArrayListExtra(String, ArrayList)
5151 */
5152 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5153 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5154 }
5155
5156 /**
5157 * Retrieve extended data from the intent.
5158 *
5159 * @param name The name of the desired item.
5160 *
5161 * @return the value of an item that previously added with putExtra()
5162 * or null if no ArrayList<String> value was found.
5163 *
5164 * @see #putStringArrayListExtra(String, ArrayList)
5165 */
5166 public ArrayList<String> getStringArrayListExtra(String name) {
5167 return mExtras == null ? null : mExtras.getStringArrayList(name);
5168 }
5169
5170 /**
5171 * Retrieve extended data from the intent.
5172 *
5173 * @param name The name of the desired item.
5174 *
5175 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005176 * or null if no ArrayList<CharSequence> value was found.
5177 *
5178 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5179 */
5180 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5181 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5182 }
5183
5184 /**
5185 * Retrieve extended data from the intent.
5186 *
5187 * @param name The name of the desired item.
5188 *
5189 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005190 * or null if no boolean array value was found.
5191 *
5192 * @see #putExtra(String, boolean[])
5193 */
5194 public boolean[] getBooleanArrayExtra(String name) {
5195 return mExtras == null ? null : mExtras.getBooleanArray(name);
5196 }
5197
5198 /**
5199 * Retrieve extended data from the intent.
5200 *
5201 * @param name The name of the desired item.
5202 *
5203 * @return the value of an item that previously added with putExtra()
5204 * or null if no byte array value was found.
5205 *
5206 * @see #putExtra(String, byte[])
5207 */
5208 public byte[] getByteArrayExtra(String name) {
5209 return mExtras == null ? null : mExtras.getByteArray(name);
5210 }
5211
5212 /**
5213 * Retrieve extended data from the intent.
5214 *
5215 * @param name The name of the desired item.
5216 *
5217 * @return the value of an item that previously added with putExtra()
5218 * or null if no short array value was found.
5219 *
5220 * @see #putExtra(String, short[])
5221 */
5222 public short[] getShortArrayExtra(String name) {
5223 return mExtras == null ? null : mExtras.getShortArray(name);
5224 }
5225
5226 /**
5227 * Retrieve extended data from the intent.
5228 *
5229 * @param name The name of the desired item.
5230 *
5231 * @return the value of an item that previously added with putExtra()
5232 * or null if no char array value was found.
5233 *
5234 * @see #putExtra(String, char[])
5235 */
5236 public char[] getCharArrayExtra(String name) {
5237 return mExtras == null ? null : mExtras.getCharArray(name);
5238 }
5239
5240 /**
5241 * Retrieve extended data from the intent.
5242 *
5243 * @param name The name of the desired item.
5244 *
5245 * @return the value of an item that previously added with putExtra()
5246 * or null if no int array value was found.
5247 *
5248 * @see #putExtra(String, int[])
5249 */
5250 public int[] getIntArrayExtra(String name) {
5251 return mExtras == null ? null : mExtras.getIntArray(name);
5252 }
5253
5254 /**
5255 * Retrieve extended data from the intent.
5256 *
5257 * @param name The name of the desired item.
5258 *
5259 * @return the value of an item that previously added with putExtra()
5260 * or null if no long array value was found.
5261 *
5262 * @see #putExtra(String, long[])
5263 */
5264 public long[] getLongArrayExtra(String name) {
5265 return mExtras == null ? null : mExtras.getLongArray(name);
5266 }
5267
5268 /**
5269 * Retrieve extended data from the intent.
5270 *
5271 * @param name The name of the desired item.
5272 *
5273 * @return the value of an item that previously added with putExtra()
5274 * or null if no float array value was found.
5275 *
5276 * @see #putExtra(String, float[])
5277 */
5278 public float[] getFloatArrayExtra(String name) {
5279 return mExtras == null ? null : mExtras.getFloatArray(name);
5280 }
5281
5282 /**
5283 * Retrieve extended data from the intent.
5284 *
5285 * @param name The name of the desired item.
5286 *
5287 * @return the value of an item that previously added with putExtra()
5288 * or null if no double array value was found.
5289 *
5290 * @see #putExtra(String, double[])
5291 */
5292 public double[] getDoubleArrayExtra(String name) {
5293 return mExtras == null ? null : mExtras.getDoubleArray(name);
5294 }
5295
5296 /**
5297 * Retrieve extended data from the intent.
5298 *
5299 * @param name The name of the desired item.
5300 *
5301 * @return the value of an item that previously added with putExtra()
5302 * or null if no String array value was found.
5303 *
5304 * @see #putExtra(String, String[])
5305 */
5306 public String[] getStringArrayExtra(String name) {
5307 return mExtras == null ? null : mExtras.getStringArray(name);
5308 }
5309
5310 /**
5311 * Retrieve extended data from the intent.
5312 *
5313 * @param name The name of the desired item.
5314 *
5315 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005316 * or null if no CharSequence array value was found.
5317 *
5318 * @see #putExtra(String, CharSequence[])
5319 */
5320 public CharSequence[] getCharSequenceArrayExtra(String name) {
5321 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5322 }
5323
5324 /**
5325 * Retrieve extended data from the intent.
5326 *
5327 * @param name The name of the desired item.
5328 *
5329 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005330 * or null if no Bundle value was found.
5331 *
5332 * @see #putExtra(String, Bundle)
5333 */
5334 public Bundle getBundleExtra(String name) {
5335 return mExtras == null ? null : mExtras.getBundle(name);
5336 }
5337
5338 /**
5339 * Retrieve extended data from the intent.
5340 *
5341 * @param name The name of the desired item.
5342 *
5343 * @return the value of an item that previously added with putExtra()
5344 * or null if no IBinder value was found.
5345 *
5346 * @see #putExtra(String, IBinder)
5347 *
5348 * @deprecated
5349 * @hide
5350 */
5351 @Deprecated
5352 public IBinder getIBinderExtra(String name) {
5353 return mExtras == null ? null : mExtras.getIBinder(name);
5354 }
5355
5356 /**
5357 * Retrieve extended data from the intent.
5358 *
5359 * @param name The name of the desired item.
5360 * @param defaultValue The default value to return in case no item is
5361 * associated with the key 'name'
5362 *
5363 * @return the value of an item that previously added with putExtra()
5364 * or defaultValue if none was found.
5365 *
5366 * @see #putExtra
5367 *
5368 * @deprecated
5369 * @hide
5370 */
5371 @Deprecated
5372 public Object getExtra(String name, Object defaultValue) {
5373 Object result = defaultValue;
5374 if (mExtras != null) {
5375 Object result2 = mExtras.get(name);
5376 if (result2 != null) {
5377 result = result2;
5378 }
5379 }
5380
5381 return result;
5382 }
5383
5384 /**
5385 * Retrieves a map of extended data from the intent.
5386 *
5387 * @return the map of all extras previously added with putExtra(),
5388 * or null if none have been added.
5389 */
5390 public Bundle getExtras() {
5391 return (mExtras != null)
5392 ? new Bundle(mExtras)
5393 : null;
5394 }
5395
5396 /**
5397 * Retrieve any special flags associated with this intent. You will
5398 * normally just set them with {@link #setFlags} and let the system
5399 * take the appropriate action with them.
5400 *
5401 * @return int The currently set flags.
5402 *
5403 * @see #setFlags
5404 */
5405 public int getFlags() {
5406 return mFlags;
5407 }
5408
Dianne Hackborne7f97212011-02-24 14:40:20 -08005409 /** @hide */
5410 public boolean isExcludingStopped() {
5411 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5412 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5413 }
5414
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005415 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005416 * Retrieve the application package name this Intent is limited to. When
5417 * resolving an Intent, if non-null this limits the resolution to only
5418 * components in the given application package.
5419 *
5420 * @return The name of the application package for the Intent.
5421 *
5422 * @see #resolveActivity
5423 * @see #setPackage
5424 */
5425 public String getPackage() {
5426 return mPackage;
5427 }
5428
5429 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005430 * Retrieve the concrete component associated with the intent. When receiving
5431 * an intent, this is the component that was found to best handle it (that is,
5432 * yourself) and will always be non-null; in all other cases it will be
5433 * null unless explicitly set.
5434 *
5435 * @return The name of the application component to handle the intent.
5436 *
5437 * @see #resolveActivity
5438 * @see #setComponent
5439 */
5440 public ComponentName getComponent() {
5441 return mComponent;
5442 }
5443
5444 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005445 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5446 * used as a hint to the receiver for animations and the like. Null means that there
5447 * is no source bounds.
5448 */
5449 public Rect getSourceBounds() {
5450 return mSourceBounds;
5451 }
5452
5453 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005454 * Return the Activity component that should be used to handle this intent.
5455 * The appropriate component is determined based on the information in the
5456 * intent, evaluated as follows:
5457 *
5458 * <p>If {@link #getComponent} returns an explicit class, that is returned
5459 * without any further consideration.
5460 *
5461 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5462 * category to be considered.
5463 *
5464 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5465 * action.
5466 *
5467 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5468 * this type.
5469 *
5470 * <p>If {@link #addCategory} has added any categories, the activity must
5471 * handle ALL of the categories specified.
5472 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005473 * <p>If {@link #getPackage} is non-NULL, only activity components in
5474 * that application package will be considered.
5475 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005476 * <p>If there are no activities that satisfy all of these conditions, a
5477 * null string is returned.
5478 *
5479 * <p>If multiple activities are found to satisfy the intent, the one with
5480 * the highest priority will be used. If there are multiple activities
5481 * with the same priority, the system will either pick the best activity
5482 * based on user preference, or resolve to a system class that will allow
5483 * the user to pick an activity and forward from there.
5484 *
5485 * <p>This method is implemented simply by calling
5486 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5487 * true.</p>
5488 * <p> This API is called for you as part of starting an activity from an
5489 * intent. You do not normally need to call it yourself.</p>
5490 *
5491 * @param pm The package manager with which to resolve the Intent.
5492 *
5493 * @return Name of the component implementing an activity that can
5494 * display the intent.
5495 *
5496 * @see #setComponent
5497 * @see #getComponent
5498 * @see #resolveActivityInfo
5499 */
5500 public ComponentName resolveActivity(PackageManager pm) {
5501 if (mComponent != null) {
5502 return mComponent;
5503 }
5504
5505 ResolveInfo info = pm.resolveActivity(
5506 this, PackageManager.MATCH_DEFAULT_ONLY);
5507 if (info != null) {
5508 return new ComponentName(
5509 info.activityInfo.applicationInfo.packageName,
5510 info.activityInfo.name);
5511 }
5512
5513 return null;
5514 }
5515
5516 /**
5517 * Resolve the Intent into an {@link ActivityInfo}
5518 * describing the activity that should execute the intent. Resolution
5519 * follows the same rules as described for {@link #resolveActivity}, but
5520 * you get back the completely information about the resolved activity
5521 * instead of just its class name.
5522 *
5523 * @param pm The package manager with which to resolve the Intent.
5524 * @param flags Addition information to retrieve as per
5525 * {@link PackageManager#getActivityInfo(ComponentName, int)
5526 * PackageManager.getActivityInfo()}.
5527 *
5528 * @return PackageManager.ActivityInfo
5529 *
5530 * @see #resolveActivity
5531 */
5532 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5533 ActivityInfo ai = null;
5534 if (mComponent != null) {
5535 try {
5536 ai = pm.getActivityInfo(mComponent, flags);
5537 } catch (PackageManager.NameNotFoundException e) {
5538 // ignore
5539 }
5540 } else {
5541 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005542 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005543 if (info != null) {
5544 ai = info.activityInfo;
5545 }
5546 }
5547
5548 return ai;
5549 }
5550
5551 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005552 * Special function for use by the system to resolve service
5553 * intents to system apps. Throws an exception if there are
5554 * multiple potential matches to the Intent. Returns null if
5555 * there are no matches.
5556 * @hide
5557 */
5558 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5559 if (mComponent != null) {
5560 return mComponent;
5561 }
5562
5563 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5564 if (results == null) {
5565 return null;
5566 }
5567 ComponentName comp = null;
5568 for (int i=0; i<results.size(); i++) {
5569 ResolveInfo ri = results.get(i);
5570 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5571 continue;
5572 }
5573 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5574 ri.serviceInfo.name);
5575 if (comp != null) {
5576 throw new IllegalStateException("Multiple system services handle " + this
5577 + ": " + comp + ", " + foundComp);
5578 }
5579 comp = foundComp;
5580 }
5581 return comp;
5582 }
5583
5584 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005585 * Set the general action to be performed.
5586 *
5587 * @param action An action name, such as ACTION_VIEW. Application-specific
5588 * actions should be prefixed with the vendor's package name.
5589 *
5590 * @return Returns the same Intent object, for chaining multiple calls
5591 * into a single statement.
5592 *
5593 * @see #getAction
5594 */
5595 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005596 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005597 return this;
5598 }
5599
5600 /**
5601 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005602 * clears any type that was previously set by {@link #setType} or
5603 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005604 *
Nick Pellyccae4122012-01-09 14:12:58 -08005605 * <p><em>Note: scheme matching in the Android framework is
5606 * case-sensitive, unlike the formal RFC. As a result,
5607 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005608 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005609 * {@link #setDataAndNormalize}
5610 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005611 *
Nick Pellyccae4122012-01-09 14:12:58 -08005612 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005613 *
5614 * @return Returns the same Intent object, for chaining multiple calls
5615 * into a single statement.
5616 *
5617 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005618 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005619 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005620 */
5621 public Intent setData(Uri data) {
5622 mData = data;
5623 mType = null;
5624 return this;
5625 }
5626
5627 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005628 * Normalize and set the data this intent is operating on.
5629 *
5630 * <p>This method automatically clears any type that was
5631 * previously set (for example, by {@link #setType}).
5632 *
5633 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005634 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005635 * so really this is just a convenience method for
5636 * <pre>
5637 * setData(data.normalize())
5638 * </pre>
5639 *
5640 * @param data The Uri of the data this intent is now targeting.
5641 *
5642 * @return Returns the same Intent object, for chaining multiple calls
5643 * into a single statement.
5644 *
5645 * @see #getData
5646 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005647 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005648 */
5649 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005650 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005651 }
5652
5653 /**
5654 * Set an explicit MIME data type.
5655 *
5656 * <p>This is used to create intents that only specify a type and not data,
5657 * for example to indicate the type of data to return.
5658 *
5659 * <p>This method automatically clears any data that was
5660 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005661 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005662 * <p><em>Note: MIME type matching in the Android framework is
5663 * case-sensitive, unlike formal RFC MIME types. As a result,
5664 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005665 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5666 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005667 *
5668 * @param type The MIME type of the data being handled by this intent.
5669 *
5670 * @return Returns the same Intent object, for chaining multiple calls
5671 * into a single statement.
5672 *
5673 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005674 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005675 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005676 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005677 */
5678 public Intent setType(String type) {
5679 mData = null;
5680 mType = type;
5681 return this;
5682 }
5683
5684 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005685 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005686 *
Nick Pellyccae4122012-01-09 14:12:58 -08005687 * <p>This is used to create intents that only specify a type and not data,
5688 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005689 *
Nick Pellyccae4122012-01-09 14:12:58 -08005690 * <p>This method automatically clears any data that was
5691 * previously set (for example by {@link #setData}).
5692 *
5693 * <p>The MIME type is normalized using
5694 * {@link #normalizeMimeType} before it is set,
5695 * so really this is just a convenience method for
5696 * <pre>
5697 * setType(Intent.normalizeMimeType(type))
5698 * </pre>
5699 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005700 * @param type The MIME type of the data being handled by this intent.
5701 *
5702 * @return Returns the same Intent object, for chaining multiple calls
5703 * into a single statement.
5704 *
Nick Pellyccae4122012-01-09 14:12:58 -08005705 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005706 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005707 * @see #normalizeMimeType
5708 */
5709 public Intent setTypeAndNormalize(String type) {
5710 return setType(normalizeMimeType(type));
5711 }
5712
5713 /**
5714 * (Usually optional) Set the data for the intent along with an explicit
5715 * MIME data type. This method should very rarely be used -- it allows you
5716 * to override the MIME type that would ordinarily be inferred from the
5717 * data with your own type given here.
5718 *
5719 * <p><em>Note: MIME type and Uri scheme matching in the
5720 * Android framework is case-sensitive, unlike the formal RFC definitions.
5721 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005722 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005723 * {@link #setDataAndTypeAndNormalize}
5724 * to ensure that they are converted to lower case.</em>
5725 *
5726 * @param data The Uri of the data this intent is now targeting.
5727 * @param type The MIME type of the data being handled by this intent.
5728 *
5729 * @return Returns the same Intent object, for chaining multiple calls
5730 * into a single statement.
5731 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005732 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08005733 * @see #setData
5734 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005735 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005736 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005737 */
5738 public Intent setDataAndType(Uri data, String type) {
5739 mData = data;
5740 mType = type;
5741 return this;
5742 }
5743
5744 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005745 * (Usually optional) Normalize and set both the data Uri and an explicit
5746 * MIME data type. This method should very rarely be used -- it allows you
5747 * to override the MIME type that would ordinarily be inferred from the
5748 * data with your own type given here.
5749 *
5750 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005751 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08005752 * before they are set, so really this is just a convenience method for
5753 * <pre>
5754 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
5755 * </pre>
5756 *
5757 * @param data The Uri of the data this intent is now targeting.
5758 * @param type The MIME type of the data being handled by this intent.
5759 *
5760 * @return Returns the same Intent object, for chaining multiple calls
5761 * into a single statement.
5762 *
5763 * @see #setType
5764 * @see #setData
5765 * @see #setDataAndType
5766 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005767 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005768 */
5769 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005770 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08005771 }
5772
5773 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005774 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005775 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005776 * activities that provide <em>all</em> of the requested categories will be
5777 * used.
5778 *
5779 * @param category The desired category. This can be either one of the
5780 * predefined Intent categories, or a custom category in your own
5781 * namespace.
5782 *
5783 * @return Returns the same Intent object, for chaining multiple calls
5784 * into a single statement.
5785 *
5786 * @see #hasCategory
5787 * @see #removeCategory
5788 */
5789 public Intent addCategory(String category) {
5790 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005791 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005792 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08005793 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005794 return this;
5795 }
5796
5797 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005798 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005799 *
5800 * @param category The category to remove.
5801 *
5802 * @see #addCategory
5803 */
5804 public void removeCategory(String category) {
5805 if (mCategories != null) {
5806 mCategories.remove(category);
5807 if (mCategories.size() == 0) {
5808 mCategories = null;
5809 }
5810 }
5811 }
5812
5813 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005814 * Set a selector for this Intent. This is a modification to the kinds of
5815 * things the Intent will match. If the selector is set, it will be used
5816 * when trying to find entities that can handle the Intent, instead of the
5817 * main contents of the Intent. This allows you build an Intent containing
5818 * a generic protocol while targeting it more specifically.
5819 *
5820 * <p>An example of where this may be used is with things like
5821 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
5822 * Intent that will launch the Browser application. However, the correct
5823 * main entry point of an application is actually {@link #ACTION_MAIN}
5824 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
5825 * used to specify the actual Activity to launch. If you launch the browser
5826 * with something different, undesired behavior may happen if the user has
5827 * previously or later launches it the normal way, since they do not match.
5828 * Instead, you can build an Intent with the MAIN action (but no ComponentName
5829 * yet specified) and set a selector with {@link #ACTION_MAIN} and
5830 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
5831 *
5832 * <p>Setting a selector does not impact the behavior of
5833 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
5834 * desired behavior of a selector -- it does not impact the base meaning
5835 * of the Intent, just what kinds of things will be matched against it
5836 * when determining who can handle it.</p>
5837 *
5838 * <p>You can not use both a selector and {@link #setPackage(String)} on
5839 * the same base Intent.</p>
5840 *
5841 * @param selector The desired selector Intent; set to null to not use
5842 * a special selector.
5843 */
5844 public void setSelector(Intent selector) {
5845 if (selector == this) {
5846 throw new IllegalArgumentException(
5847 "Intent being set as a selector of itself");
5848 }
5849 if (selector != null && mPackage != null) {
5850 throw new IllegalArgumentException(
5851 "Can't set selector when package name is already set");
5852 }
5853 mSelector = selector;
5854 }
5855
5856 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005857 * Set a {@link ClipData} associated with this Intent. This replaces any
5858 * previously set ClipData.
5859 *
5860 * <p>The ClipData in an intent is not used for Intent matching or other
5861 * such operations. Semantically it is like extras, used to transmit
5862 * additional data with the Intent. The main feature of using this over
5863 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
5864 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
5865 * items included in the clip data. This is useful, in particular, if
5866 * you want to transmit an Intent containing multiple <code>content:</code>
5867 * URIs for which the recipient may not have global permission to access the
5868 * content provider.
5869 *
5870 * <p>If the ClipData contains items that are themselves Intents, any
5871 * grant flags in those Intents will be ignored. Only the top-level flags
5872 * of the main Intent are respected, and will be applied to all Uri or
5873 * Intent items in the clip (or sub-items of the clip).
5874 *
5875 * <p>The MIME type, label, and icon in the ClipData object are not
5876 * directly used by Intent. Applications should generally rely on the
5877 * MIME type of the Intent itself, not what it may find in the ClipData.
5878 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05005879 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005880 *
5881 * @param clip The new clip to set. May be null to clear the current clip.
5882 */
5883 public void setClipData(ClipData clip) {
5884 mClipData = clip;
5885 }
5886
5887 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005888 * This is NOT a secure mechanism to identify the user who sent the intent.
5889 * When the intent is sent to a different user, it is used to fix uris by adding the userId
5890 * who sent the intent.
5891 * @hide
5892 */
5893 public void setContentUserHint(int contentUserHint) {
5894 mContentUserHint = contentUserHint;
5895 }
5896
5897 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005898 * Add extended data to the intent. The name must include a package
5899 * prefix, for example the app com.android.contacts would use names
5900 * like "com.android.contacts.ShowAll".
5901 *
5902 * @param name The name of the extra data, with package prefix.
5903 * @param value The boolean data value.
5904 *
5905 * @return Returns the same Intent object, for chaining multiple calls
5906 * into a single statement.
5907 *
5908 * @see #putExtras
5909 * @see #removeExtra
5910 * @see #getBooleanExtra(String, boolean)
5911 */
5912 public Intent putExtra(String name, boolean value) {
5913 if (mExtras == null) {
5914 mExtras = new Bundle();
5915 }
5916 mExtras.putBoolean(name, value);
5917 return this;
5918 }
5919
5920 /**
5921 * Add extended data to the intent. The name must include a package
5922 * prefix, for example the app com.android.contacts would use names
5923 * like "com.android.contacts.ShowAll".
5924 *
5925 * @param name The name of the extra data, with package prefix.
5926 * @param value The byte data value.
5927 *
5928 * @return Returns the same Intent object, for chaining multiple calls
5929 * into a single statement.
5930 *
5931 * @see #putExtras
5932 * @see #removeExtra
5933 * @see #getByteExtra(String, byte)
5934 */
5935 public Intent putExtra(String name, byte value) {
5936 if (mExtras == null) {
5937 mExtras = new Bundle();
5938 }
5939 mExtras.putByte(name, value);
5940 return this;
5941 }
5942
5943 /**
5944 * Add extended data to the intent. The name must include a package
5945 * prefix, for example the app com.android.contacts would use names
5946 * like "com.android.contacts.ShowAll".
5947 *
5948 * @param name The name of the extra data, with package prefix.
5949 * @param value The char data value.
5950 *
5951 * @return Returns the same Intent object, for chaining multiple calls
5952 * into a single statement.
5953 *
5954 * @see #putExtras
5955 * @see #removeExtra
5956 * @see #getCharExtra(String, char)
5957 */
5958 public Intent putExtra(String name, char value) {
5959 if (mExtras == null) {
5960 mExtras = new Bundle();
5961 }
5962 mExtras.putChar(name, value);
5963 return this;
5964 }
5965
5966 /**
5967 * Add extended data to the intent. The name must include a package
5968 * prefix, for example the app com.android.contacts would use names
5969 * like "com.android.contacts.ShowAll".
5970 *
5971 * @param name The name of the extra data, with package prefix.
5972 * @param value The short data value.
5973 *
5974 * @return Returns the same Intent object, for chaining multiple calls
5975 * into a single statement.
5976 *
5977 * @see #putExtras
5978 * @see #removeExtra
5979 * @see #getShortExtra(String, short)
5980 */
5981 public Intent putExtra(String name, short value) {
5982 if (mExtras == null) {
5983 mExtras = new Bundle();
5984 }
5985 mExtras.putShort(name, value);
5986 return this;
5987 }
5988
5989 /**
5990 * Add extended data to the intent. The name must include a package
5991 * prefix, for example the app com.android.contacts would use names
5992 * like "com.android.contacts.ShowAll".
5993 *
5994 * @param name The name of the extra data, with package prefix.
5995 * @param value The integer data value.
5996 *
5997 * @return Returns the same Intent object, for chaining multiple calls
5998 * into a single statement.
5999 *
6000 * @see #putExtras
6001 * @see #removeExtra
6002 * @see #getIntExtra(String, int)
6003 */
6004 public Intent putExtra(String name, int value) {
6005 if (mExtras == null) {
6006 mExtras = new Bundle();
6007 }
6008 mExtras.putInt(name, value);
6009 return this;
6010 }
6011
6012 /**
6013 * Add extended data to the intent. The name must include a package
6014 * prefix, for example the app com.android.contacts would use names
6015 * like "com.android.contacts.ShowAll".
6016 *
6017 * @param name The name of the extra data, with package prefix.
6018 * @param value The long data value.
6019 *
6020 * @return Returns the same Intent object, for chaining multiple calls
6021 * into a single statement.
6022 *
6023 * @see #putExtras
6024 * @see #removeExtra
6025 * @see #getLongExtra(String, long)
6026 */
6027 public Intent putExtra(String name, long value) {
6028 if (mExtras == null) {
6029 mExtras = new Bundle();
6030 }
6031 mExtras.putLong(name, value);
6032 return this;
6033 }
6034
6035 /**
6036 * Add extended data to the intent. The name must include a package
6037 * prefix, for example the app com.android.contacts would use names
6038 * like "com.android.contacts.ShowAll".
6039 *
6040 * @param name The name of the extra data, with package prefix.
6041 * @param value The float data value.
6042 *
6043 * @return Returns the same Intent object, for chaining multiple calls
6044 * into a single statement.
6045 *
6046 * @see #putExtras
6047 * @see #removeExtra
6048 * @see #getFloatExtra(String, float)
6049 */
6050 public Intent putExtra(String name, float value) {
6051 if (mExtras == null) {
6052 mExtras = new Bundle();
6053 }
6054 mExtras.putFloat(name, value);
6055 return this;
6056 }
6057
6058 /**
6059 * Add extended data to the intent. The name must include a package
6060 * prefix, for example the app com.android.contacts would use names
6061 * like "com.android.contacts.ShowAll".
6062 *
6063 * @param name The name of the extra data, with package prefix.
6064 * @param value The double data value.
6065 *
6066 * @return Returns the same Intent object, for chaining multiple calls
6067 * into a single statement.
6068 *
6069 * @see #putExtras
6070 * @see #removeExtra
6071 * @see #getDoubleExtra(String, double)
6072 */
6073 public Intent putExtra(String name, double value) {
6074 if (mExtras == null) {
6075 mExtras = new Bundle();
6076 }
6077 mExtras.putDouble(name, value);
6078 return this;
6079 }
6080
6081 /**
6082 * Add extended data to the intent. The name must include a package
6083 * prefix, for example the app com.android.contacts would use names
6084 * like "com.android.contacts.ShowAll".
6085 *
6086 * @param name The name of the extra data, with package prefix.
6087 * @param value The String data value.
6088 *
6089 * @return Returns the same Intent object, for chaining multiple calls
6090 * into a single statement.
6091 *
6092 * @see #putExtras
6093 * @see #removeExtra
6094 * @see #getStringExtra(String)
6095 */
6096 public Intent putExtra(String name, String value) {
6097 if (mExtras == null) {
6098 mExtras = new Bundle();
6099 }
6100 mExtras.putString(name, value);
6101 return this;
6102 }
6103
6104 /**
6105 * Add extended data to the intent. The name must include a package
6106 * prefix, for example the app com.android.contacts would use names
6107 * like "com.android.contacts.ShowAll".
6108 *
6109 * @param name The name of the extra data, with package prefix.
6110 * @param value The CharSequence data value.
6111 *
6112 * @return Returns the same Intent object, for chaining multiple calls
6113 * into a single statement.
6114 *
6115 * @see #putExtras
6116 * @see #removeExtra
6117 * @see #getCharSequenceExtra(String)
6118 */
6119 public Intent putExtra(String name, CharSequence value) {
6120 if (mExtras == null) {
6121 mExtras = new Bundle();
6122 }
6123 mExtras.putCharSequence(name, value);
6124 return this;
6125 }
6126
6127 /**
6128 * Add extended data to the intent. The name must include a package
6129 * prefix, for example the app com.android.contacts would use names
6130 * like "com.android.contacts.ShowAll".
6131 *
6132 * @param name The name of the extra data, with package prefix.
6133 * @param value The Parcelable data value.
6134 *
6135 * @return Returns the same Intent object, for chaining multiple calls
6136 * into a single statement.
6137 *
6138 * @see #putExtras
6139 * @see #removeExtra
6140 * @see #getParcelableExtra(String)
6141 */
6142 public Intent putExtra(String name, Parcelable value) {
6143 if (mExtras == null) {
6144 mExtras = new Bundle();
6145 }
6146 mExtras.putParcelable(name, value);
6147 return this;
6148 }
6149
6150 /**
6151 * Add extended data to the intent. The name must include a package
6152 * prefix, for example the app com.android.contacts would use names
6153 * like "com.android.contacts.ShowAll".
6154 *
6155 * @param name The name of the extra data, with package prefix.
6156 * @param value The Parcelable[] data value.
6157 *
6158 * @return Returns the same Intent object, for chaining multiple calls
6159 * into a single statement.
6160 *
6161 * @see #putExtras
6162 * @see #removeExtra
6163 * @see #getParcelableArrayExtra(String)
6164 */
6165 public Intent putExtra(String name, Parcelable[] value) {
6166 if (mExtras == null) {
6167 mExtras = new Bundle();
6168 }
6169 mExtras.putParcelableArray(name, value);
6170 return this;
6171 }
6172
6173 /**
6174 * Add extended data to the intent. The name must include a package
6175 * prefix, for example the app com.android.contacts would use names
6176 * like "com.android.contacts.ShowAll".
6177 *
6178 * @param name The name of the extra data, with package prefix.
6179 * @param value The ArrayList<Parcelable> data value.
6180 *
6181 * @return Returns the same Intent object, for chaining multiple calls
6182 * into a single statement.
6183 *
6184 * @see #putExtras
6185 * @see #removeExtra
6186 * @see #getParcelableArrayListExtra(String)
6187 */
6188 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6189 if (mExtras == null) {
6190 mExtras = new Bundle();
6191 }
6192 mExtras.putParcelableArrayList(name, value);
6193 return this;
6194 }
6195
6196 /**
6197 * Add extended data to the intent. The name must include a package
6198 * prefix, for example the app com.android.contacts would use names
6199 * like "com.android.contacts.ShowAll".
6200 *
6201 * @param name The name of the extra data, with package prefix.
6202 * @param value The ArrayList<Integer> data value.
6203 *
6204 * @return Returns the same Intent object, for chaining multiple calls
6205 * into a single statement.
6206 *
6207 * @see #putExtras
6208 * @see #removeExtra
6209 * @see #getIntegerArrayListExtra(String)
6210 */
6211 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6212 if (mExtras == null) {
6213 mExtras = new Bundle();
6214 }
6215 mExtras.putIntegerArrayList(name, value);
6216 return this;
6217 }
6218
6219 /**
6220 * Add extended data to the intent. The name must include a package
6221 * prefix, for example the app com.android.contacts would use names
6222 * like "com.android.contacts.ShowAll".
6223 *
6224 * @param name The name of the extra data, with package prefix.
6225 * @param value The ArrayList<String> data value.
6226 *
6227 * @return Returns the same Intent object, for chaining multiple calls
6228 * into a single statement.
6229 *
6230 * @see #putExtras
6231 * @see #removeExtra
6232 * @see #getStringArrayListExtra(String)
6233 */
6234 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6235 if (mExtras == null) {
6236 mExtras = new Bundle();
6237 }
6238 mExtras.putStringArrayList(name, value);
6239 return this;
6240 }
6241
6242 /**
6243 * Add extended data to the intent. The name must include a package
6244 * prefix, for example the app com.android.contacts would use names
6245 * like "com.android.contacts.ShowAll".
6246 *
6247 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006248 * @param value The ArrayList<CharSequence> data value.
6249 *
6250 * @return Returns the same Intent object, for chaining multiple calls
6251 * into a single statement.
6252 *
6253 * @see #putExtras
6254 * @see #removeExtra
6255 * @see #getCharSequenceArrayListExtra(String)
6256 */
6257 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6258 if (mExtras == null) {
6259 mExtras = new Bundle();
6260 }
6261 mExtras.putCharSequenceArrayList(name, value);
6262 return this;
6263 }
6264
6265 /**
6266 * Add extended data to the intent. The name must include a package
6267 * prefix, for example the app com.android.contacts would use names
6268 * like "com.android.contacts.ShowAll".
6269 *
6270 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006271 * @param value The Serializable data value.
6272 *
6273 * @return Returns the same Intent object, for chaining multiple calls
6274 * into a single statement.
6275 *
6276 * @see #putExtras
6277 * @see #removeExtra
6278 * @see #getSerializableExtra(String)
6279 */
6280 public Intent putExtra(String name, Serializable value) {
6281 if (mExtras == null) {
6282 mExtras = new Bundle();
6283 }
6284 mExtras.putSerializable(name, value);
6285 return this;
6286 }
6287
6288 /**
6289 * Add extended data to the intent. The name must include a package
6290 * prefix, for example the app com.android.contacts would use names
6291 * like "com.android.contacts.ShowAll".
6292 *
6293 * @param name The name of the extra data, with package prefix.
6294 * @param value The boolean array data value.
6295 *
6296 * @return Returns the same Intent object, for chaining multiple calls
6297 * into a single statement.
6298 *
6299 * @see #putExtras
6300 * @see #removeExtra
6301 * @see #getBooleanArrayExtra(String)
6302 */
6303 public Intent putExtra(String name, boolean[] value) {
6304 if (mExtras == null) {
6305 mExtras = new Bundle();
6306 }
6307 mExtras.putBooleanArray(name, value);
6308 return this;
6309 }
6310
6311 /**
6312 * Add extended data to the intent. The name must include a package
6313 * prefix, for example the app com.android.contacts would use names
6314 * like "com.android.contacts.ShowAll".
6315 *
6316 * @param name The name of the extra data, with package prefix.
6317 * @param value The byte array data value.
6318 *
6319 * @return Returns the same Intent object, for chaining multiple calls
6320 * into a single statement.
6321 *
6322 * @see #putExtras
6323 * @see #removeExtra
6324 * @see #getByteArrayExtra(String)
6325 */
6326 public Intent putExtra(String name, byte[] value) {
6327 if (mExtras == null) {
6328 mExtras = new Bundle();
6329 }
6330 mExtras.putByteArray(name, value);
6331 return this;
6332 }
6333
6334 /**
6335 * Add extended data to the intent. The name must include a package
6336 * prefix, for example the app com.android.contacts would use names
6337 * like "com.android.contacts.ShowAll".
6338 *
6339 * @param name The name of the extra data, with package prefix.
6340 * @param value The short array data value.
6341 *
6342 * @return Returns the same Intent object, for chaining multiple calls
6343 * into a single statement.
6344 *
6345 * @see #putExtras
6346 * @see #removeExtra
6347 * @see #getShortArrayExtra(String)
6348 */
6349 public Intent putExtra(String name, short[] value) {
6350 if (mExtras == null) {
6351 mExtras = new Bundle();
6352 }
6353 mExtras.putShortArray(name, value);
6354 return this;
6355 }
6356
6357 /**
6358 * Add extended data to the intent. The name must include a package
6359 * prefix, for example the app com.android.contacts would use names
6360 * like "com.android.contacts.ShowAll".
6361 *
6362 * @param name The name of the extra data, with package prefix.
6363 * @param value The char array data value.
6364 *
6365 * @return Returns the same Intent object, for chaining multiple calls
6366 * into a single statement.
6367 *
6368 * @see #putExtras
6369 * @see #removeExtra
6370 * @see #getCharArrayExtra(String)
6371 */
6372 public Intent putExtra(String name, char[] value) {
6373 if (mExtras == null) {
6374 mExtras = new Bundle();
6375 }
6376 mExtras.putCharArray(name, value);
6377 return this;
6378 }
6379
6380 /**
6381 * Add extended data to the intent. The name must include a package
6382 * prefix, for example the app com.android.contacts would use names
6383 * like "com.android.contacts.ShowAll".
6384 *
6385 * @param name The name of the extra data, with package prefix.
6386 * @param value The int array data value.
6387 *
6388 * @return Returns the same Intent object, for chaining multiple calls
6389 * into a single statement.
6390 *
6391 * @see #putExtras
6392 * @see #removeExtra
6393 * @see #getIntArrayExtra(String)
6394 */
6395 public Intent putExtra(String name, int[] value) {
6396 if (mExtras == null) {
6397 mExtras = new Bundle();
6398 }
6399 mExtras.putIntArray(name, value);
6400 return this;
6401 }
6402
6403 /**
6404 * Add extended data to the intent. The name must include a package
6405 * prefix, for example the app com.android.contacts would use names
6406 * like "com.android.contacts.ShowAll".
6407 *
6408 * @param name The name of the extra data, with package prefix.
6409 * @param value The byte array data value.
6410 *
6411 * @return Returns the same Intent object, for chaining multiple calls
6412 * into a single statement.
6413 *
6414 * @see #putExtras
6415 * @see #removeExtra
6416 * @see #getLongArrayExtra(String)
6417 */
6418 public Intent putExtra(String name, long[] value) {
6419 if (mExtras == null) {
6420 mExtras = new Bundle();
6421 }
6422 mExtras.putLongArray(name, value);
6423 return this;
6424 }
6425
6426 /**
6427 * Add extended data to the intent. The name must include a package
6428 * prefix, for example the app com.android.contacts would use names
6429 * like "com.android.contacts.ShowAll".
6430 *
6431 * @param name The name of the extra data, with package prefix.
6432 * @param value The float array data value.
6433 *
6434 * @return Returns the same Intent object, for chaining multiple calls
6435 * into a single statement.
6436 *
6437 * @see #putExtras
6438 * @see #removeExtra
6439 * @see #getFloatArrayExtra(String)
6440 */
6441 public Intent putExtra(String name, float[] value) {
6442 if (mExtras == null) {
6443 mExtras = new Bundle();
6444 }
6445 mExtras.putFloatArray(name, value);
6446 return this;
6447 }
6448
6449 /**
6450 * Add extended data to the intent. The name must include a package
6451 * prefix, for example the app com.android.contacts would use names
6452 * like "com.android.contacts.ShowAll".
6453 *
6454 * @param name The name of the extra data, with package prefix.
6455 * @param value The double array data value.
6456 *
6457 * @return Returns the same Intent object, for chaining multiple calls
6458 * into a single statement.
6459 *
6460 * @see #putExtras
6461 * @see #removeExtra
6462 * @see #getDoubleArrayExtra(String)
6463 */
6464 public Intent putExtra(String name, double[] value) {
6465 if (mExtras == null) {
6466 mExtras = new Bundle();
6467 }
6468 mExtras.putDoubleArray(name, value);
6469 return this;
6470 }
6471
6472 /**
6473 * Add extended data to the intent. The name must include a package
6474 * prefix, for example the app com.android.contacts would use names
6475 * like "com.android.contacts.ShowAll".
6476 *
6477 * @param name The name of the extra data, with package prefix.
6478 * @param value The String array data value.
6479 *
6480 * @return Returns the same Intent object, for chaining multiple calls
6481 * into a single statement.
6482 *
6483 * @see #putExtras
6484 * @see #removeExtra
6485 * @see #getStringArrayExtra(String)
6486 */
6487 public Intent putExtra(String name, String[] value) {
6488 if (mExtras == null) {
6489 mExtras = new Bundle();
6490 }
6491 mExtras.putStringArray(name, value);
6492 return this;
6493 }
6494
6495 /**
6496 * Add extended data to the intent. The name must include a package
6497 * prefix, for example the app com.android.contacts would use names
6498 * like "com.android.contacts.ShowAll".
6499 *
6500 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006501 * @param value The CharSequence array data value.
6502 *
6503 * @return Returns the same Intent object, for chaining multiple calls
6504 * into a single statement.
6505 *
6506 * @see #putExtras
6507 * @see #removeExtra
6508 * @see #getCharSequenceArrayExtra(String)
6509 */
6510 public Intent putExtra(String name, CharSequence[] value) {
6511 if (mExtras == null) {
6512 mExtras = new Bundle();
6513 }
6514 mExtras.putCharSequenceArray(name, value);
6515 return this;
6516 }
6517
6518 /**
6519 * Add extended data to the intent. The name must include a package
6520 * prefix, for example the app com.android.contacts would use names
6521 * like "com.android.contacts.ShowAll".
6522 *
6523 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006524 * @param value The Bundle data value.
6525 *
6526 * @return Returns the same Intent object, for chaining multiple calls
6527 * into a single statement.
6528 *
6529 * @see #putExtras
6530 * @see #removeExtra
6531 * @see #getBundleExtra(String)
6532 */
6533 public Intent putExtra(String name, Bundle value) {
6534 if (mExtras == null) {
6535 mExtras = new Bundle();
6536 }
6537 mExtras.putBundle(name, value);
6538 return this;
6539 }
6540
6541 /**
6542 * Add extended data to the intent. The name must include a package
6543 * prefix, for example the app com.android.contacts would use names
6544 * like "com.android.contacts.ShowAll".
6545 *
6546 * @param name The name of the extra data, with package prefix.
6547 * @param value The IBinder data value.
6548 *
6549 * @return Returns the same Intent object, for chaining multiple calls
6550 * into a single statement.
6551 *
6552 * @see #putExtras
6553 * @see #removeExtra
6554 * @see #getIBinderExtra(String)
6555 *
6556 * @deprecated
6557 * @hide
6558 */
6559 @Deprecated
6560 public Intent putExtra(String name, IBinder value) {
6561 if (mExtras == null) {
6562 mExtras = new Bundle();
6563 }
6564 mExtras.putIBinder(name, value);
6565 return this;
6566 }
6567
6568 /**
6569 * Copy all extras in 'src' in to this intent.
6570 *
6571 * @param src Contains the extras to copy.
6572 *
6573 * @see #putExtra
6574 */
6575 public Intent putExtras(Intent src) {
6576 if (src.mExtras != null) {
6577 if (mExtras == null) {
6578 mExtras = new Bundle(src.mExtras);
6579 } else {
6580 mExtras.putAll(src.mExtras);
6581 }
6582 }
6583 return this;
6584 }
6585
6586 /**
6587 * Add a set of extended data to the intent. The keys must include a package
6588 * prefix, for example the app com.android.contacts would use names
6589 * like "com.android.contacts.ShowAll".
6590 *
6591 * @param extras The Bundle of extras to add to this intent.
6592 *
6593 * @see #putExtra
6594 * @see #removeExtra
6595 */
6596 public Intent putExtras(Bundle extras) {
6597 if (mExtras == null) {
6598 mExtras = new Bundle();
6599 }
6600 mExtras.putAll(extras);
6601 return this;
6602 }
6603
6604 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006605 * Completely replace the extras in the Intent with the extras in the
6606 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006607 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006608 * @param src The exact extras contained in this Intent are copied
6609 * into the target intent, replacing any that were previously there.
6610 */
6611 public Intent replaceExtras(Intent src) {
6612 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6613 return this;
6614 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006615
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006616 /**
6617 * Completely replace the extras in the Intent with the given Bundle of
6618 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006619 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006620 * @param extras The new set of extras in the Intent, or null to erase
6621 * all extras.
6622 */
6623 public Intent replaceExtras(Bundle extras) {
6624 mExtras = extras != null ? new Bundle(extras) : null;
6625 return this;
6626 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006627
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006628 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006629 * Remove extended data from the intent.
6630 *
6631 * @see #putExtra
6632 */
6633 public void removeExtra(String name) {
6634 if (mExtras != null) {
6635 mExtras.remove(name);
6636 if (mExtras.size() == 0) {
6637 mExtras = null;
6638 }
6639 }
6640 }
6641
6642 /**
6643 * Set special flags controlling how this intent is handled. Most values
6644 * here depend on the type of component being executed by the Intent,
6645 * specifically the FLAG_ACTIVITY_* flags are all for use with
6646 * {@link Context#startActivity Context.startActivity()} and the
6647 * FLAG_RECEIVER_* flags are all for use with
6648 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6649 *
Scott Main7aee61f2011-02-08 11:25:01 -08006650 * <p>See the
6651 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6652 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006653 * the behavior of your application.
6654 *
6655 * @param flags The desired flags.
6656 *
6657 * @return Returns the same Intent object, for chaining multiple calls
6658 * into a single statement.
6659 *
6660 * @see #getFlags
6661 * @see #addFlags
6662 *
6663 * @see #FLAG_GRANT_READ_URI_PERMISSION
6664 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006665 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6666 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006667 * @see #FLAG_DEBUG_LOG_RESOLUTION
6668 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006669 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006670 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006671 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006672 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006673 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6674 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006675 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006676 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006677 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006678 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006679 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006680 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006681 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006682 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6683 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006684 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006685 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006686 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006687 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6688 */
6689 public Intent setFlags(int flags) {
6690 mFlags = flags;
6691 return this;
6692 }
6693
6694 /**
6695 * Add additional flags to the intent (or with existing flags
6696 * value).
6697 *
6698 * @param flags The new flags to set.
6699 *
6700 * @return Returns the same Intent object, for chaining multiple calls
6701 * into a single statement.
6702 *
6703 * @see #setFlags
6704 */
6705 public Intent addFlags(int flags) {
6706 mFlags |= flags;
6707 return this;
6708 }
6709
6710 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006711 * (Usually optional) Set an explicit application package name that limits
6712 * the components this Intent will resolve to. If left to the default
6713 * value of null, all components in all applications will considered.
6714 * If non-null, the Intent can only match the components in the given
6715 * application package.
6716 *
6717 * @param packageName The name of the application package to handle the
6718 * intent, or null to allow any application package.
6719 *
6720 * @return Returns the same Intent object, for chaining multiple calls
6721 * into a single statement.
6722 *
6723 * @see #getPackage
6724 * @see #resolveActivity
6725 */
6726 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006727 if (packageName != null && mSelector != null) {
6728 throw new IllegalArgumentException(
6729 "Can't set package name when selector is already set");
6730 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006731 mPackage = packageName;
6732 return this;
6733 }
6734
6735 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006736 * (Usually optional) Explicitly set the component to handle the intent.
6737 * If left with the default value of null, the system will determine the
6738 * appropriate class to use based on the other fields (action, data,
6739 * type, categories) in the Intent. If this class is defined, the
6740 * specified class will always be used regardless of the other fields. You
6741 * should only set this value when you know you absolutely want a specific
6742 * class to be used; otherwise it is better to let the system find the
6743 * appropriate class so that you will respect the installed applications
6744 * and user preferences.
6745 *
6746 * @param component The name of the application component to handle the
6747 * intent, or null to let the system find one for you.
6748 *
6749 * @return Returns the same Intent object, for chaining multiple calls
6750 * into a single statement.
6751 *
6752 * @see #setClass
6753 * @see #setClassName(Context, String)
6754 * @see #setClassName(String, String)
6755 * @see #getComponent
6756 * @see #resolveActivity
6757 */
6758 public Intent setComponent(ComponentName component) {
6759 mComponent = component;
6760 return this;
6761 }
6762
6763 /**
6764 * Convenience for calling {@link #setComponent} with an
6765 * explicit class name.
6766 *
6767 * @param packageContext A Context of the application package implementing
6768 * this class.
6769 * @param className The name of a class inside of the application package
6770 * that will be used as the component for this Intent.
6771 *
6772 * @return Returns the same Intent object, for chaining multiple calls
6773 * into a single statement.
6774 *
6775 * @see #setComponent
6776 * @see #setClass
6777 */
6778 public Intent setClassName(Context packageContext, String className) {
6779 mComponent = new ComponentName(packageContext, className);
6780 return this;
6781 }
6782
6783 /**
6784 * Convenience for calling {@link #setComponent} with an
6785 * explicit application package name and class name.
6786 *
6787 * @param packageName The name of the package implementing the desired
6788 * component.
6789 * @param className The name of a class inside of the application package
6790 * that will be used as the component for this Intent.
6791 *
6792 * @return Returns the same Intent object, for chaining multiple calls
6793 * into a single statement.
6794 *
6795 * @see #setComponent
6796 * @see #setClass
6797 */
6798 public Intent setClassName(String packageName, String className) {
6799 mComponent = new ComponentName(packageName, className);
6800 return this;
6801 }
6802
6803 /**
6804 * Convenience for calling {@link #setComponent(ComponentName)} with the
6805 * name returned by a {@link Class} object.
6806 *
6807 * @param packageContext A Context of the application package implementing
6808 * this class.
6809 * @param cls The class name to set, equivalent to
6810 * <code>setClassName(context, cls.getName())</code>.
6811 *
6812 * @return Returns the same Intent object, for chaining multiple calls
6813 * into a single statement.
6814 *
6815 * @see #setComponent
6816 */
6817 public Intent setClass(Context packageContext, Class<?> cls) {
6818 mComponent = new ComponentName(packageContext, cls);
6819 return this;
6820 }
6821
6822 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006823 * Set the bounds of the sender of this intent, in screen coordinates. This can be
6824 * used as a hint to the receiver for animations and the like. Null means that there
6825 * is no source bounds.
6826 */
6827 public void setSourceBounds(Rect r) {
6828 if (r != null) {
6829 mSourceBounds = new Rect(r);
6830 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07006831 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006832 }
6833 }
6834
Tor Norbyed9273d62013-05-30 15:59:53 -07006835 /** @hide */
6836 @IntDef(flag = true,
6837 value = {
6838 FILL_IN_ACTION,
6839 FILL_IN_DATA,
6840 FILL_IN_CATEGORIES,
6841 FILL_IN_COMPONENT,
6842 FILL_IN_PACKAGE,
6843 FILL_IN_SOURCE_BOUNDS,
6844 FILL_IN_SELECTOR,
6845 FILL_IN_CLIP_DATA
6846 })
6847 @Retention(RetentionPolicy.SOURCE)
6848 public @interface FillInFlags {}
6849
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006850 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006851 * Use with {@link #fillIn} to allow the current action value to be
6852 * overwritten, even if it is already set.
6853 */
6854 public static final int FILL_IN_ACTION = 1<<0;
6855
6856 /**
6857 * Use with {@link #fillIn} to allow the current data or type value
6858 * overwritten, even if it is already set.
6859 */
6860 public static final int FILL_IN_DATA = 1<<1;
6861
6862 /**
6863 * Use with {@link #fillIn} to allow the current categories to be
6864 * overwritten, even if they are already set.
6865 */
6866 public static final int FILL_IN_CATEGORIES = 1<<2;
6867
6868 /**
6869 * Use with {@link #fillIn} to allow the current component value to be
6870 * overwritten, even if it is already set.
6871 */
6872 public static final int FILL_IN_COMPONENT = 1<<3;
6873
6874 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006875 * Use with {@link #fillIn} to allow the current package value to be
6876 * overwritten, even if it is already set.
6877 */
6878 public static final int FILL_IN_PACKAGE = 1<<4;
6879
6880 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006881 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006882 * overwritten, even if it is already set.
6883 */
6884 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
6885
6886 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006887 * Use with {@link #fillIn} to allow the current selector to be
6888 * overwritten, even if it is already set.
6889 */
6890 public static final int FILL_IN_SELECTOR = 1<<6;
6891
6892 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006893 * Use with {@link #fillIn} to allow the current ClipData to be
6894 * overwritten, even if it is already set.
6895 */
6896 public static final int FILL_IN_CLIP_DATA = 1<<7;
6897
6898 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006899 * Copy the contents of <var>other</var> in to this object, but only
6900 * where fields are not defined by this object. For purposes of a field
6901 * being defined, the following pieces of data in the Intent are
6902 * considered to be separate fields:
6903 *
6904 * <ul>
6905 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08006906 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006907 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
6908 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006909 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006910 * <li> component, as set by {@link #setComponent(ComponentName)} or
6911 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006912 * <li> source bounds, as set by {@link #setSourceBounds}.
6913 * <li> selector, as set by {@link #setSelector(Intent)}.
6914 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006915 * <li> each top-level name in the associated extras.
6916 * </ul>
6917 *
6918 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006919 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006920 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
6921 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
6922 * the restriction where the corresponding field will not be replaced if
6923 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006924 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006925 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
6926 * is explicitly specified. The selector will only be copied if
6927 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07006928 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006929 * <p>For example, consider Intent A with {data="foo", categories="bar"}
6930 * and Intent B with {action="gotit", data-type="some/thing",
6931 * categories="one","two"}.
6932 *
6933 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
6934 * containing: {action="gotit", data-type="some/thing",
6935 * categories="bar"}.
6936 *
6937 * @param other Another Intent whose values are to be used to fill in
6938 * the current one.
6939 * @param flags Options to control which fields can be filled in.
6940 *
6941 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006942 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07006943 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
6944 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
6945 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006946 */
Tor Norbyed9273d62013-05-30 15:59:53 -07006947 @FillInFlags
6948 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006949 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006950 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006951 if (other.mAction != null
6952 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006953 mAction = other.mAction;
6954 changes |= FILL_IN_ACTION;
6955 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006956 if ((other.mData != null || other.mType != null)
6957 && ((mData == null && mType == null)
6958 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006959 mData = other.mData;
6960 mType = other.mType;
6961 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006962 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006963 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006964 if (other.mCategories != null
6965 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006966 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006967 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006968 }
6969 changes |= FILL_IN_CATEGORIES;
6970 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006971 if (other.mPackage != null
6972 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006973 // Only do this if mSelector is not set.
6974 if (mSelector == null) {
6975 mPackage = other.mPackage;
6976 changes |= FILL_IN_PACKAGE;
6977 }
6978 }
6979 // Selector is special: it can only be set if explicitly allowed,
6980 // for the same reason as the component name.
6981 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
6982 if (mPackage == null) {
6983 mSelector = new Intent(other.mSelector);
6984 mPackage = null;
6985 changes |= FILL_IN_SELECTOR;
6986 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006987 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006988 if (other.mClipData != null
6989 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
6990 mClipData = other.mClipData;
6991 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006992 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006993 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006994 // Component is special: it can -only- be set if explicitly allowed,
6995 // since otherwise the sender could force the intent somewhere the
6996 // originator didn't intend.
6997 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006998 mComponent = other.mComponent;
6999 changes |= FILL_IN_COMPONENT;
7000 }
7001 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007002 if (other.mSourceBounds != null
7003 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7004 mSourceBounds = new Rect(other.mSourceBounds);
7005 changes |= FILL_IN_SOURCE_BOUNDS;
7006 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007007 if (mExtras == null) {
7008 if (other.mExtras != null) {
7009 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007010 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007011 }
7012 } else if (other.mExtras != null) {
7013 try {
7014 Bundle newb = new Bundle(other.mExtras);
7015 newb.putAll(mExtras);
7016 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007017 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007018 } catch (RuntimeException e) {
7019 // Modifying the extras can cause us to unparcel the contents
7020 // of the bundle, and if we do this in the system process that
7021 // may fail. We really should handle this (i.e., the Bundle
7022 // impl shouldn't be on top of a plain map), but for now just
7023 // ignore it and keep the original contents. :(
7024 Log.w("Intent", "Failure filling in extras", e);
7025 }
7026 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007027 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7028 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7029 mContentUserHint = other.mContentUserHint;
7030 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007031 return changes;
7032 }
7033
7034 /**
7035 * Wrapper class holding an Intent and implementing comparisons on it for
7036 * the purpose of filtering. The class implements its
7037 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7038 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7039 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7040 * on the wrapped Intent.
7041 */
7042 public static final class FilterComparison {
7043 private final Intent mIntent;
7044 private final int mHashCode;
7045
7046 public FilterComparison(Intent intent) {
7047 mIntent = intent;
7048 mHashCode = intent.filterHashCode();
7049 }
7050
7051 /**
7052 * Return the Intent that this FilterComparison represents.
7053 * @return Returns the Intent held by the FilterComparison. Do
7054 * not modify!
7055 */
7056 public Intent getIntent() {
7057 return mIntent;
7058 }
7059
7060 @Override
7061 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007062 if (obj instanceof FilterComparison) {
7063 Intent other = ((FilterComparison)obj).mIntent;
7064 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007065 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007066 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007067 }
7068
7069 @Override
7070 public int hashCode() {
7071 return mHashCode;
7072 }
7073 }
7074
7075 /**
7076 * Determine if two intents are the same for the purposes of intent
7077 * resolution (filtering). That is, if their action, data, type,
7078 * class, and categories are the same. This does <em>not</em> compare
7079 * any extra data included in the intents.
7080 *
7081 * @param other The other Intent to compare against.
7082 *
7083 * @return Returns true if action, data, type, class, and categories
7084 * are the same.
7085 */
7086 public boolean filterEquals(Intent other) {
7087 if (other == null) {
7088 return false;
7089 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007090 if (!Objects.equals(this.mAction, other.mAction)) return false;
7091 if (!Objects.equals(this.mData, other.mData)) return false;
7092 if (!Objects.equals(this.mType, other.mType)) return false;
7093 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7094 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7095 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007096
7097 return true;
7098 }
7099
7100 /**
7101 * Generate hash code that matches semantics of filterEquals().
7102 *
7103 * @return Returns the hash value of the action, data, type, class, and
7104 * categories.
7105 *
7106 * @see #filterEquals
7107 */
7108 public int filterHashCode() {
7109 int code = 0;
7110 if (mAction != null) {
7111 code += mAction.hashCode();
7112 }
7113 if (mData != null) {
7114 code += mData.hashCode();
7115 }
7116 if (mType != null) {
7117 code += mType.hashCode();
7118 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007119 if (mPackage != null) {
7120 code += mPackage.hashCode();
7121 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007122 if (mComponent != null) {
7123 code += mComponent.hashCode();
7124 }
7125 if (mCategories != null) {
7126 code += mCategories.hashCode();
7127 }
7128 return code;
7129 }
7130
7131 @Override
7132 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007133 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007134
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007135 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007136 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007137 b.append(" }");
7138
7139 return b.toString();
7140 }
7141
7142 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007143 public String toInsecureString() {
7144 StringBuilder b = new StringBuilder(128);
7145
7146 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007147 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007148 b.append(" }");
7149
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007150 return b.toString();
7151 }
Romain Guy4969af72009-06-17 10:53:19 -07007152
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007153 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007154 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007155 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007156
7157 b.append("Intent { ");
7158 toShortString(b, false, true, true, true);
7159 b.append(" }");
7160
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007161 return b.toString();
7162 }
7163
7164 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007165 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7166 StringBuilder b = new StringBuilder(128);
7167 toShortString(b, secure, comp, extras, clip);
7168 return b.toString();
7169 }
7170
7171 /** @hide */
7172 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7173 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007174 boolean first = true;
7175 if (mAction != null) {
7176 b.append("act=").append(mAction);
7177 first = false;
7178 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007179 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007180 if (!first) {
7181 b.append(' ');
7182 }
7183 first = false;
7184 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007185 for (int i=0; i<mCategories.size(); i++) {
7186 if (i > 0) b.append(',');
7187 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007188 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007189 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007190 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007191 if (mData != null) {
7192 if (!first) {
7193 b.append(' ');
7194 }
7195 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007196 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007197 if (secure) {
7198 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007199 } else {
7200 b.append(mData);
7201 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007202 }
7203 if (mType != null) {
7204 if (!first) {
7205 b.append(' ');
7206 }
7207 first = false;
7208 b.append("typ=").append(mType);
7209 }
7210 if (mFlags != 0) {
7211 if (!first) {
7212 b.append(' ');
7213 }
7214 first = false;
7215 b.append("flg=0x").append(Integer.toHexString(mFlags));
7216 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007217 if (mPackage != null) {
7218 if (!first) {
7219 b.append(' ');
7220 }
7221 first = false;
7222 b.append("pkg=").append(mPackage);
7223 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007224 if (comp && mComponent != null) {
7225 if (!first) {
7226 b.append(' ');
7227 }
7228 first = false;
7229 b.append("cmp=").append(mComponent.flattenToShortString());
7230 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007231 if (mSourceBounds != null) {
7232 if (!first) {
7233 b.append(' ');
7234 }
7235 first = false;
7236 b.append("bnds=").append(mSourceBounds.toShortString());
7237 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007238 if (mClipData != null) {
7239 if (!first) {
7240 b.append(' ');
7241 }
7242 first = false;
7243 if (clip) {
7244 b.append("clip={");
7245 mClipData.toShortString(b);
7246 b.append('}');
7247 } else {
7248 b.append("(has clip)");
7249 }
7250 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007251 if (extras && mExtras != null) {
7252 if (!first) {
7253 b.append(' ');
7254 }
7255 first = false;
7256 b.append("(has extras)");
7257 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007258 if (mContentUserHint != UserHandle.USER_CURRENT) {
7259 if (!first) {
7260 b.append(' ');
7261 }
7262 first = false;
7263 b.append("u=").append(mContentUserHint);
7264 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007265 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007266 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007267 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007268 b.append("}");
7269 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007270 }
7271
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007272 /**
7273 * Call {@link #toUri} with 0 flags.
7274 * @deprecated Use {@link #toUri} instead.
7275 */
7276 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007277 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007278 return toUri(0);
7279 }
7280
7281 /**
7282 * Convert this Intent into a String holding a URI representation of it.
7283 * The returned URI string has been properly URI encoded, so it can be
7284 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7285 * Intent's data as the base URI, with an additional fragment describing
7286 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007287 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007288 * <p>You can convert the returned string back to an Intent with
7289 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007290 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007291 * @param flags Additional operating flags. Either 0,
7292 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007293 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007294 * @return Returns a URI encoding URI string describing the entire contents
7295 * of the Intent.
7296 */
7297 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007298 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007299 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7300 if (mPackage == null) {
7301 throw new IllegalArgumentException(
7302 "Intent must include an explicit package name to build an android-app: "
7303 + this);
7304 }
7305 uri.append("android-app://");
7306 uri.append(mPackage);
7307 String scheme = null;
7308 if (mData != null) {
7309 scheme = mData.getScheme();
7310 if (scheme != null) {
7311 uri.append('/');
7312 uri.append(scheme);
7313 String authority = mData.getEncodedAuthority();
7314 if (authority != null) {
7315 uri.append('/');
7316 uri.append(authority);
7317 String path = mData.getEncodedPath();
7318 if (path != null) {
7319 uri.append(path);
7320 }
7321 String queryParams = mData.getEncodedQuery();
7322 if (queryParams != null) {
7323 uri.append('?');
7324 uri.append(queryParams);
7325 }
7326 String fragment = mData.getEncodedFragment();
7327 if (fragment != null) {
7328 uri.append('#');
7329 uri.append(fragment);
7330 }
7331 }
7332 }
7333 }
7334 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7335 mPackage, flags);
7336 return uri.toString();
7337 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007338 String scheme = null;
7339 if (mData != null) {
7340 String data = mData.toString();
7341 if ((flags&URI_INTENT_SCHEME) != 0) {
7342 final int N = data.length();
7343 for (int i=0; i<N; i++) {
7344 char c = data.charAt(i);
7345 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7346 || c == '.' || c == '-') {
7347 continue;
7348 }
7349 if (c == ':' && i > 0) {
7350 // Valid scheme.
7351 scheme = data.substring(0, i);
7352 uri.append("intent:");
7353 data = data.substring(i+1);
7354 break;
7355 }
Tom Taylord4a47292009-12-21 13:59:18 -08007356
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007357 // No scheme.
7358 break;
7359 }
7360 }
7361 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007362
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007363 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7364 uri.append("intent:");
7365 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007366
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007367 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007368
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007369 return uri.toString();
7370 }
7371
7372 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7373 String defPackage, int flags) {
7374 StringBuilder frag = new StringBuilder(128);
7375
7376 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007377 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007378 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007379 // Note that for now we are not going to try to handle the
7380 // data part; not clear how to represent this as a URI, and
7381 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007382 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7383 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007384 }
7385
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007386 if (frag.length() > 0) {
7387 uri.append("#Intent;");
7388 uri.append(frag);
7389 uri.append("end");
7390 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007391 }
7392
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007393 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7394 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007395 if (scheme != null) {
7396 uri.append("scheme=").append(scheme).append(';');
7397 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007398 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007399 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007400 }
7401 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007402 for (int i=0; i<mCategories.size(); i++) {
7403 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007404 }
7405 }
7406 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007407 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007408 }
7409 if (mFlags != 0) {
7410 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7411 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007412 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007413 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7414 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007415 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007416 uri.append("component=").append(Uri.encode(
7417 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007418 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007419 if (mSourceBounds != null) {
7420 uri.append("sourceBounds=")
7421 .append(Uri.encode(mSourceBounds.flattenToString()))
7422 .append(';');
7423 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007424 if (mExtras != null) {
7425 for (String key : mExtras.keySet()) {
7426 final Object value = mExtras.get(key);
7427 char entryType =
7428 value instanceof String ? 'S' :
7429 value instanceof Boolean ? 'B' :
7430 value instanceof Byte ? 'b' :
7431 value instanceof Character ? 'c' :
7432 value instanceof Double ? 'd' :
7433 value instanceof Float ? 'f' :
7434 value instanceof Integer ? 'i' :
7435 value instanceof Long ? 'l' :
7436 value instanceof Short ? 's' :
7437 '\0';
7438
7439 if (entryType != '\0') {
7440 uri.append(entryType);
7441 uri.append('.');
7442 uri.append(Uri.encode(key));
7443 uri.append('=');
7444 uri.append(Uri.encode(value.toString()));
7445 uri.append(';');
7446 }
7447 }
7448 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007449 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007450
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007451 public int describeContents() {
7452 return (mExtras != null) ? mExtras.describeContents() : 0;
7453 }
7454
7455 public void writeToParcel(Parcel out, int flags) {
7456 out.writeString(mAction);
7457 Uri.writeToParcel(out, mData);
7458 out.writeString(mType);
7459 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007460 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007461 ComponentName.writeToParcel(mComponent, out);
7462
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007463 if (mSourceBounds != null) {
7464 out.writeInt(1);
7465 mSourceBounds.writeToParcel(out, flags);
7466 } else {
7467 out.writeInt(0);
7468 }
7469
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007470 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007471 final int N = mCategories.size();
7472 out.writeInt(N);
7473 for (int i=0; i<N; i++) {
7474 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007475 }
7476 } else {
7477 out.writeInt(0);
7478 }
7479
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007480 if (mSelector != null) {
7481 out.writeInt(1);
7482 mSelector.writeToParcel(out, flags);
7483 } else {
7484 out.writeInt(0);
7485 }
7486
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007487 if (mClipData != null) {
7488 out.writeInt(1);
7489 mClipData.writeToParcel(out, flags);
7490 } else {
7491 out.writeInt(0);
7492 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007493 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007494 out.writeBundle(mExtras);
7495 }
7496
7497 public static final Parcelable.Creator<Intent> CREATOR
7498 = new Parcelable.Creator<Intent>() {
7499 public Intent createFromParcel(Parcel in) {
7500 return new Intent(in);
7501 }
7502 public Intent[] newArray(int size) {
7503 return new Intent[size];
7504 }
7505 };
7506
Dianne Hackborneb034652009-09-07 00:49:58 -07007507 /** @hide */
7508 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007509 readFromParcel(in);
7510 }
7511
7512 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007513 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007514 mData = Uri.CREATOR.createFromParcel(in);
7515 mType = in.readString();
7516 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007517 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007518 mComponent = ComponentName.readFromParcel(in);
7519
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007520 if (in.readInt() != 0) {
7521 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7522 }
7523
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007524 int N = in.readInt();
7525 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007526 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007527 int i;
7528 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007529 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007530 }
7531 } else {
7532 mCategories = null;
7533 }
7534
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007535 if (in.readInt() != 0) {
7536 mSelector = new Intent(in);
7537 }
7538
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007539 if (in.readInt() != 0) {
7540 mClipData = new ClipData(in);
7541 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007542 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007543 mExtras = in.readBundle();
7544 }
7545
7546 /**
7547 * Parses the "intent" element (and its children) from XML and instantiates
7548 * an Intent object. The given XML parser should be located at the tag
7549 * where parsing should start (often named "intent"), from which the
7550 * basic action, data, type, and package and class name will be
7551 * retrieved. The function will then parse in to any child elements,
7552 * looking for <category android:name="xxx"> tags to add categories and
7553 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7554 * to the intent.
7555 *
7556 * @param resources The Resources to use when inflating resources.
7557 * @param parser The XML parser pointing at an "intent" tag.
7558 * @param attrs The AttributeSet interface for retrieving extended
7559 * attribute data at the current <var>parser</var> location.
7560 * @return An Intent object matching the XML data.
7561 * @throws XmlPullParserException If there was an XML parsing error.
7562 * @throws IOException If there was an I/O error.
7563 */
7564 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7565 throws XmlPullParserException, IOException {
7566 Intent intent = new Intent();
7567
7568 TypedArray sa = resources.obtainAttributes(attrs,
7569 com.android.internal.R.styleable.Intent);
7570
7571 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7572
7573 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7574 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7575 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7576
7577 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7578 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7579 if (packageName != null && className != null) {
7580 intent.setComponent(new ComponentName(packageName, className));
7581 }
7582
7583 sa.recycle();
7584
7585 int outerDepth = parser.getDepth();
7586 int type;
7587 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7588 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7589 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7590 continue;
7591 }
7592
7593 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007594 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007595 sa = resources.obtainAttributes(attrs,
7596 com.android.internal.R.styleable.IntentCategory);
7597 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7598 sa.recycle();
7599
7600 if (cat != null) {
7601 intent.addCategory(cat);
7602 }
7603 XmlUtils.skipCurrentTag(parser);
7604
Craig Mautner21d24a22014-04-23 11:45:37 -07007605 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007606 if (intent.mExtras == null) {
7607 intent.mExtras = new Bundle();
7608 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007609 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007610 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007611
7612 } else {
7613 XmlUtils.skipCurrentTag(parser);
7614 }
7615 }
7616
7617 return intent;
7618 }
Nick Pellyccae4122012-01-09 14:12:58 -08007619
Craig Mautner21d24a22014-04-23 11:45:37 -07007620 /** @hide */
7621 public void saveToXml(XmlSerializer out) throws IOException {
7622 if (mAction != null) {
7623 out.attribute(null, ATTR_ACTION, mAction);
7624 }
7625 if (mData != null) {
7626 out.attribute(null, ATTR_DATA, mData.toString());
7627 }
7628 if (mType != null) {
7629 out.attribute(null, ATTR_TYPE, mType);
7630 }
7631 if (mComponent != null) {
7632 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7633 }
7634 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7635
7636 if (mCategories != null) {
7637 out.startTag(null, TAG_CATEGORIES);
7638 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7639 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7640 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007641 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007642 }
7643 }
7644
7645 /** @hide */
7646 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7647 XmlPullParserException {
7648 Intent intent = new Intent();
7649 final int outerDepth = in.getDepth();
7650
7651 int attrCount = in.getAttributeCount();
7652 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7653 final String attrName = in.getAttributeName(attrNdx);
7654 final String attrValue = in.getAttributeValue(attrNdx);
7655 if (ATTR_ACTION.equals(attrName)) {
7656 intent.setAction(attrValue);
7657 } else if (ATTR_DATA.equals(attrName)) {
7658 intent.setData(Uri.parse(attrValue));
7659 } else if (ATTR_TYPE.equals(attrName)) {
7660 intent.setType(attrValue);
7661 } else if (ATTR_COMPONENT.equals(attrName)) {
7662 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7663 } else if (ATTR_FLAGS.equals(attrName)) {
7664 intent.setFlags(Integer.valueOf(attrValue, 16));
7665 } else {
7666 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7667 }
7668 }
7669
7670 int event;
7671 String name;
7672 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7673 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7674 if (event == XmlPullParser.START_TAG) {
7675 name = in.getName();
7676 if (TAG_CATEGORIES.equals(name)) {
7677 attrCount = in.getAttributeCount();
7678 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7679 intent.addCategory(in.getAttributeValue(attrNdx));
7680 }
7681 } else {
7682 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7683 XmlUtils.skipCurrentTag(in);
7684 }
7685 }
7686 }
7687
7688 return intent;
7689 }
7690
Nick Pellyccae4122012-01-09 14:12:58 -08007691 /**
7692 * Normalize a MIME data type.
7693 *
7694 * <p>A normalized MIME type has white-space trimmed,
7695 * content-type parameters removed, and is lower-case.
7696 * This aligns the type with Android best practices for
7697 * intent filtering.
7698 *
7699 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7700 * "text/x-vCard" becomes "text/x-vcard".
7701 *
7702 * <p>All MIME types received from outside Android (such as user input,
7703 * or external sources like Bluetooth, NFC, or the Internet) should
7704 * be normalized before they are used to create an Intent.
7705 *
7706 * @param type MIME data type to normalize
7707 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007708 * @see #setType
7709 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007710 */
7711 public static String normalizeMimeType(String type) {
7712 if (type == null) {
7713 return null;
7714 }
7715
Elliott Hughescb64d432013-08-02 10:00:44 -07007716 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007717
7718 final int semicolonIndex = type.indexOf(';');
7719 if (semicolonIndex != -1) {
7720 type = type.substring(0, semicolonIndex);
7721 }
7722 return type;
7723 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007724
7725 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007726 * Prepare this {@link Intent} to leave an app process.
7727 *
7728 * @hide
7729 */
7730 public void prepareToLeaveProcess() {
7731 setAllowFds(false);
7732
7733 if (mSelector != null) {
7734 mSelector.prepareToLeaveProcess();
7735 }
7736 if (mClipData != null) {
7737 mClipData.prepareToLeaveProcess();
7738 }
7739
7740 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
7741 // There are several ACTION_MEDIA_* broadcasts that send file://
7742 // Uris, so only check common actions.
7743 if (ACTION_VIEW.equals(mAction) ||
7744 ACTION_EDIT.equals(mAction) ||
7745 ACTION_ATTACH_DATA.equals(mAction)) {
7746 mData.checkFileUriExposed("Intent.getData()");
7747 }
7748 }
7749 }
7750
7751 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007752 * @hide
7753 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007754 public void prepareToEnterProcess() {
7755 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00007756 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
7757 fixUris(mContentUserHint);
7758 mContentUserHint = UserHandle.USER_CURRENT;
7759 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007760 }
7761 }
7762
7763 /**
7764 * @hide
7765 */
7766 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007767 Uri data = getData();
7768 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007769 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007770 }
7771 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007772 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007773 }
7774 String action = getAction();
7775 if (ACTION_SEND.equals(action)) {
7776 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7777 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007778 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007779 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007780 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007781 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7782 if (streams != null) {
7783 ArrayList<Uri> newStreams = new ArrayList<Uri>();
7784 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007785 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007786 }
7787 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
7788 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007789 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
7790 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
7791 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
7792 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
7793 if (output != null) {
7794 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
7795 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007796 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007797 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007798
7799 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007800 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007801 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
7802 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007803 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007804 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007805 * @hide
7806 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007807 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007808 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007809 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007810
7811 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007812 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007813
7814 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007815 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007816 // Inspect contained intents to see if we need to migrate extras. We
7817 // don't promote ClipData to the parent, since ChooserActivity will
7818 // already start the picked item as the caller, and we can't combine
7819 // the flags in a safe way.
7820
7821 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07007822 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007823 final Intent intent = getParcelableExtra(EXTRA_INTENT);
7824 if (intent != null) {
7825 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07007826 }
7827 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007828 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07007829 try {
7830 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
7831 if (intents != null) {
7832 for (int i = 0; i < intents.length; i++) {
7833 final Intent intent = (Intent) intents[i];
7834 if (intent != null) {
7835 migrated |= intent.migrateExtraStreamToClipData();
7836 }
7837 }
7838 }
7839 } catch (ClassCastException e) {
7840 }
7841 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007842
7843 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007844 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007845 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7846 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
7847 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
7848 if (stream != null || text != null || htmlText != null) {
7849 final ClipData clipData = new ClipData(
7850 null, new String[] { getType() },
7851 new ClipData.Item(text, htmlText, null, stream));
7852 setClipData(clipData);
7853 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007854 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007855 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007856 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007857 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007858
7859 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007860 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007861 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7862 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
7863 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
7864 int num = -1;
7865 if (streams != null) {
7866 num = streams.size();
7867 }
7868 if (texts != null) {
7869 if (num >= 0 && num != texts.size()) {
7870 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007871 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007872 }
7873 num = texts.size();
7874 }
7875 if (htmlTexts != null) {
7876 if (num >= 0 && num != htmlTexts.size()) {
7877 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007878 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007879 }
7880 num = htmlTexts.size();
7881 }
7882 if (num > 0) {
7883 final ClipData clipData = new ClipData(
7884 null, new String[] { getType() },
7885 makeClipItem(streams, texts, htmlTexts, 0));
7886
7887 for (int i = 1; i < num; i++) {
7888 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
7889 }
7890
7891 setClipData(clipData);
7892 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007893 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007894 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007895 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007896 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007897 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
7898 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
7899 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
7900 final Uri output;
7901 try {
7902 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
7903 } catch (ClassCastException e) {
7904 return false;
7905 }
7906 if (output != null) {
7907 setClipData(ClipData.newRawUri("", output));
7908 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
7909 return true;
7910 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007911 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007912
7913 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007914 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07007915
7916 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
7917 ArrayList<String> htmlTexts, int which) {
7918 Uri uri = streams != null ? streams.get(which) : null;
7919 CharSequence text = texts != null ? texts.get(which) : null;
7920 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
7921 return new ClipData.Item(text, htmlText, null, uri);
7922 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07007923
7924 /** @hide */
7925 public boolean isDocument() {
7926 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
7927 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007928}