blob: 71735917cc2f07253247159378da4dfb5942d7ba [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Dianne Hackborn221ea892013-08-04 16:50:16 -070019import android.content.pm.ApplicationInfo;
Adam Powell2ed547e2015-04-29 18:45:04 -070020import android.os.ResultReceiver;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010021import android.provider.MediaStore;
Dianne Hackbornadd005c2013-07-17 18:43:12 -070022import android.util.ArraySet;
Jeff Sharkey846318a2014-04-04 12:12:41 -070023
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import org.xmlpull.v1.XmlPullParser;
25import org.xmlpull.v1.XmlPullParserException;
26
Tor Norbye7b9c9122013-05-30 16:48:33 -070027import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070028import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070029import android.annotation.SdkConstant;
Jose Lima73915cf2014-07-29 17:16:31 -070030import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.annotation.SdkConstant.SdkConstantType;
32import android.content.pm.ActivityInfo;
Jose Lima73915cf2014-07-29 17:16:31 -070033
Nicolas Prevotd85fc722014-04-16 19:52:08 +010034import static android.content.ContentProvider.maybeAddUserId;
Jose Lima73915cf2014-07-29 17:16:31 -070035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070036import android.content.pm.PackageManager;
37import android.content.pm.ResolveInfo;
38import android.content.res.Resources;
39import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080040import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070041import android.net.Uri;
42import android.os.Bundle;
43import android.os.IBinder;
44import android.os.Parcel;
45import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000046import android.os.Process;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070047import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010048import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070049import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070050import android.provider.DocumentsProvider;
51import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070052import android.util.AttributeSet;
53import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080054
55import com.android.internal.util.XmlUtils;
Jose Lima73915cf2014-07-29 17:16:31 -070056
Craig Mautner21d24a22014-04-23 11:45:37 -070057import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058
59import java.io.IOException;
60import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070061import java.lang.annotation.Retention;
62import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070063import java.net.URISyntaxException;
64import java.util.ArrayList;
Dianne Hackborn221ea892013-08-04 16:50:16 -070065import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080066import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070067import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068import java.util.Set;
69
70/**
71 * An intent is an abstract description of an operation to be performed. It
72 * can be used with {@link Context#startActivity(Intent) startActivity} to
73 * launch an {@link android.app.Activity},
74 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
75 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
76 * and {@link android.content.Context#startService} or
77 * {@link android.content.Context#bindService} to communicate with a
78 * background {@link android.app.Service}.
79 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070080 * <p>An Intent provides a facility for performing late runtime binding between the code in
81 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070082 * can be thought of as the glue between activities. It is basically a passive data structure
83 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070084 *
85 * <div class="special reference">
86 * <h3>Developer Guides</h3>
87 * <p>For information about how to create and resolve intents, read the
88 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
89 * developer guide.</p>
90 * </div>
91 *
92 * <a name="IntentStructure"></a>
93 * <h3>Intent Structure</h3>
94 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 *
96 * <ul>
97 * <li> <p><b>action</b> -- The general action to be performed, such as
98 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
99 * etc.</p>
100 * </li>
101 * <li> <p><b>data</b> -- The data to operate on, such as a person record
102 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
103 * </li>
104 * </ul>
105 *
106 *
107 * <p>Some examples of action/data pairs are:</p>
108 *
109 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700110 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700111 * information about the person whose identifier is "1".</p>
112 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * the phone dialer with the person filled in.</p>
115 * </li>
116 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
117 * the phone dialer with the given number filled in. Note how the
118 * VIEW action does what what is considered the most reasonable thing for
119 * a particular URI.</p>
120 * </li>
121 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
122 * the phone dialer with the given number filled in.</p>
123 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700124 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700125 * information about the person whose identifier is "1".</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * a list of people, which the user can browse through. This example is a
129 * typical top-level entry into the Contacts application, showing you the
130 * list of people. Selecting a particular person to view would result in a
131 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
132 * being used to start an activity to display that person.</p>
133 * </li>
134 * </ul>
135 *
136 * <p>In addition to these primary attributes, there are a number of secondary
137 * attributes that you can also include with an intent:</p>
138 *
139 * <ul>
140 * <li> <p><b>category</b> -- Gives additional information about the action
141 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
142 * appear in the Launcher as a top-level application, while
143 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
144 * of alternative actions the user can perform on a piece of data.</p>
145 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
146 * intent data. Normally the type is inferred from the data itself.
147 * By setting this attribute, you disable that evaluation and force
148 * an explicit type.</p>
149 * <li> <p><b>component</b> -- Specifies an explicit name of a component
150 * class to use for the intent. Normally this is determined by looking
151 * at the other information in the intent (the action, data/type, and
152 * categories) and matching that with a component that can handle it.
153 * If this attribute is set then none of the evaluation is performed,
154 * and this component is used exactly as is. By specifying this attribute,
155 * all of the other Intent attributes become optional.</p>
156 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
157 * This can be used to provide extended information to the component.
158 * For example, if we have a action to send an e-mail message, we could
159 * also include extra pieces of data here to supply a subject, body,
160 * etc.</p>
161 * </ul>
162 *
163 * <p>Here are some examples of other operations you can specify as intents
164 * using these additional parameters:</p>
165 *
166 * <ul>
167 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
168 * Launch the home screen.</p>
169 * </li>
170 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
171 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
172 * vnd.android.cursor.item/phone}</i></b>
173 * -- Display the list of people's phone numbers, allowing the user to
174 * browse through them and pick one and return it to the parent activity.</p>
175 * </li>
176 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
177 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
178 * -- Display all pickers for data that can be opened with
179 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
180 * allowing the user to pick one of them and then some data inside of it
181 * and returning the resulting URI to the caller. This can be used,
182 * for example, in an e-mail application to allow the user to pick some
183 * data to include as an attachment.</p>
184 * </li>
185 * </ul>
186 *
187 * <p>There are a variety of standard Intent action and category constants
188 * defined in the Intent class, but applications can also define their own.
189 * These strings use java style scoping, to ensure they are unique -- for
190 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700191 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 *
193 * <p>Put together, the set of actions, data types, categories, and extra data
194 * defines a language for the system allowing for the expression of phrases
195 * such as "call john smith's cell". As applications are added to the system,
196 * they can extend this language by adding new actions, types, and categories, or
197 * they can modify the behavior of existing phrases by supplying their own
198 * activities that handle them.</p>
199 *
200 * <a name="IntentResolution"></a>
201 * <h3>Intent Resolution</h3>
202 *
203 * <p>There are two primary forms of intents you will use.
204 *
205 * <ul>
206 * <li> <p><b>Explicit Intents</b> have specified a component (via
207 * {@link #setComponent} or {@link #setClass}), which provides the exact
208 * class to be run. Often these will not include any other information,
209 * simply being a way for an application to launch various internal
210 * activities it has as the user interacts with the application.
211 *
212 * <li> <p><b>Implicit Intents</b> have not specified a component;
213 * instead, they must include enough information for the system to
214 * determine which of the available components is best to run for that
215 * intent.
216 * </ul>
217 *
218 * <p>When using implicit intents, given such an arbitrary intent we need to
219 * know what to do with it. This is handled by the process of <em>Intent
220 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
221 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
222 * more activities/receivers) that can handle it.</p>
223 *
224 * <p>The intent resolution mechanism basically revolves around matching an
225 * Intent against all of the &lt;intent-filter&gt; descriptions in the
226 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
227 * objects explicitly registered with {@link Context#registerReceiver}.) More
228 * details on this can be found in the documentation on the {@link
229 * IntentFilter} class.</p>
230 *
231 * <p>There are three pieces of information in the Intent that are used for
232 * resolution: the action, type, and category. Using this information, a query
233 * is done on the {@link PackageManager} for a component that can handle the
234 * intent. The appropriate component is determined based on the intent
235 * information supplied in the <code>AndroidManifest.xml</code> file as
236 * follows:</p>
237 *
238 * <ul>
239 * <li> <p>The <b>action</b>, if given, must be listed by the component as
240 * one it handles.</p>
241 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
242 * already supplied in the Intent. Like the action, if a type is
243 * included in the intent (either explicitly or implicitly in its
244 * data), then this must be listed by the component as one it handles.</p>
245 * <li> For data that is not a <code>content:</code> URI and where no explicit
246 * type is included in the Intent, instead the <b>scheme</b> of the
247 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
248 * considered. Again like the action, if we are matching a scheme it
249 * must be listed by the component as one it can handle.
250 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
251 * by the activity as categories it handles. That is, if you include
252 * the categories {@link #CATEGORY_LAUNCHER} and
253 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
254 * with an intent that lists <em>both</em> of those categories.
255 * Activities will very often need to support the
256 * {@link #CATEGORY_DEFAULT} so that they can be found by
257 * {@link Context#startActivity Context.startActivity()}.</p>
258 * </ul>
259 *
260 * <p>For example, consider the Note Pad sample application that
261 * allows user to browse through a list of notes data and view details about
262 * individual items. Text in italics indicate places were you would replace a
263 * name with one specific to your own package.</p>
264 *
265 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
266 * package="<i>com.android.notepad</i>"&gt;
267 * &lt;application android:icon="@drawable/app_notes"
268 * android:label="@string/app_name"&gt;
269 *
270 * &lt;provider class=".NotePadProvider"
271 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
272 *
273 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
274 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700275 * &lt;action android:name="android.intent.action.MAIN" /&gt;
276 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700277 * &lt;/intent-filter&gt;
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.VIEW" /&gt;
280 * &lt;action android:name="android.intent.action.EDIT" /&gt;
281 * &lt;action android:name="android.intent.action.PICK" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700284 * &lt;/intent-filter&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
287 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
288 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700289 * &lt;/intent-filter&gt;
290 * &lt;/activity&gt;
291 *
292 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
293 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700294 * &lt;action android:name="android.intent.action.VIEW" /&gt;
295 * &lt;action android:name="android.intent.action.EDIT" /&gt;
296 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
297 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700298 * &lt;/intent-filter&gt;
299 *
300 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700301 * &lt;action android:name="android.intent.action.INSERT" /&gt;
302 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
303 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700304 * &lt;/intent-filter&gt;
305 *
306 * &lt;/activity&gt;
307 *
308 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
309 * android:theme="@android:style/Theme.Dialog"&gt;
310 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700311 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
312 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
313 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
314 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
315 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700316 * &lt;/intent-filter&gt;
317 * &lt;/activity&gt;
318 *
319 * &lt;/application&gt;
320 * &lt;/manifest&gt;</pre>
321 *
322 * <p>The first activity,
323 * <code>com.android.notepad.NotesList</code>, serves as our main
324 * entry into the app. It can do three things as described by its three intent
325 * templates:
326 * <ol>
327 * <li><pre>
328 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700329 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
330 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700331 * &lt;/intent-filter&gt;</pre>
332 * <p>This provides a top-level entry into the NotePad application: the standard
333 * MAIN action is a main entry point (not requiring any other information in
334 * the Intent), and the LAUNCHER category says that this entry point should be
335 * listed in the application launcher.</p>
336 * <li><pre>
337 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700338 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
339 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
340 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
341 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
342 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700343 * &lt;/intent-filter&gt;</pre>
344 * <p>This declares the things that the activity can do on a directory of
345 * notes. The type being supported is given with the &lt;type&gt; tag, where
346 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
347 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
348 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
349 * The activity allows the user to view or edit the directory of data (via
350 * the VIEW and EDIT actions), or to pick a particular note and return it
351 * to the caller (via the PICK action). Note also the DEFAULT category
352 * supplied here: this is <em>required</em> for the
353 * {@link Context#startActivity Context.startActivity} method to resolve your
354 * activity when its component name is not explicitly specified.</p>
355 * <li><pre>
356 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700357 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
358 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
359 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700360 * &lt;/intent-filter&gt;</pre>
361 * <p>This filter describes the ability return to the caller a note selected by
362 * the user without needing to know where it came from. The data type
363 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
364 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
365 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
366 * The GET_CONTENT action is similar to the PICK action, where the activity
367 * will return to its caller a piece of data selected by the user. Here,
368 * however, the caller specifies the type of data they desire instead of
369 * the type of data the user will be picking from.</p>
370 * </ol>
371 *
372 * <p>Given these capabilities, the following intents will resolve to the
373 * NotesList activity:</p>
374 *
375 * <ul>
376 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
377 * activities that can be used as top-level entry points into an
378 * application.</p>
379 * <li> <p><b>{ action=android.app.action.MAIN,
380 * category=android.app.category.LAUNCHER }</b> is the actual intent
381 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700382 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700383 * data=content://com.google.provider.NotePad/notes }</b>
384 * displays a list of all the notes under
385 * "content://com.google.provider.NotePad/notes", which
386 * the user can browse through and see the details on.</p>
387 * <li> <p><b>{ action=android.app.action.PICK
388 * data=content://com.google.provider.NotePad/notes }</b>
389 * provides a list of the notes under
390 * "content://com.google.provider.NotePad/notes", from which
391 * the user can pick a note whose data URL is returned back to the caller.</p>
392 * <li> <p><b>{ action=android.app.action.GET_CONTENT
393 * type=vnd.android.cursor.item/vnd.google.note }</b>
394 * is similar to the pick action, but allows the caller to specify the
395 * kind of data they want back so that the system can find the appropriate
396 * activity to pick something of that data type.</p>
397 * </ul>
398 *
399 * <p>The second activity,
400 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
401 * note entry and allows them to edit it. It can do two things as described
402 * by its two intent templates:
403 * <ol>
404 * <li><pre>
405 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700406 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
407 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
408 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
409 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700410 * &lt;/intent-filter&gt;</pre>
411 * <p>The first, primary, purpose of this activity is to let the user interact
412 * with a single note, as decribed by the MIME type
413 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
414 * either VIEW a note or allow the user to EDIT it. Again we support the
415 * DEFAULT category to allow the activity to be launched without explicitly
416 * specifying its component.</p>
417 * <li><pre>
418 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700419 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
420 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
421 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700422 * &lt;/intent-filter&gt;</pre>
423 * <p>The secondary use of this activity is to insert a new note entry into
424 * an existing directory of notes. This is used when the user creates a new
425 * note: the INSERT action is executed on the directory of notes, causing
426 * this activity to run and have the user create the new note data which
427 * it then adds to the content provider.</p>
428 * </ol>
429 *
430 * <p>Given these capabilities, the following intents will resolve to the
431 * NoteEditor activity:</p>
432 *
433 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700434 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700435 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
436 * shows the user the content of note <var>{ID}</var>.</p>
437 * <li> <p><b>{ action=android.app.action.EDIT
438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * allows the user to edit the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.INSERT
441 * data=content://com.google.provider.NotePad/notes }</b>
442 * creates a new, empty note in the notes list at
443 * "content://com.google.provider.NotePad/notes"
444 * and allows the user to edit it. If they keep their changes, the URI
445 * of the newly created note is returned to the caller.</p>
446 * </ul>
447 *
448 * <p>The last activity,
449 * <code>com.android.notepad.TitleEditor</code>, allows the user to
450 * edit the title of a note. This could be implemented as a class that the
451 * application directly invokes (by explicitly setting its component in
452 * the Intent), but here we show a way you can publish alternative
453 * operations on existing data:</p>
454 *
455 * <pre>
456 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700457 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
458 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
459 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
461 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700462 * &lt;/intent-filter&gt;</pre>
463 *
464 * <p>In the single intent template here, we
465 * have created our own private action called
466 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
467 * edit the title of a note. It must be invoked on a specific note
468 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
469 * view and edit actions, but here displays and edits the title contained
470 * in the note data.
471 *
472 * <p>In addition to supporting the default category as usual, our title editor
473 * also supports two other standard categories: ALTERNATIVE and
474 * SELECTED_ALTERNATIVE. Implementing
475 * these categories allows others to find the special action it provides
476 * without directly knowing about it, through the
477 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
478 * more often to build dynamic menu items with
479 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
480 * template here was also supply an explicit name for the template
481 * (via <code>android:label="@string/resolve_title"</code>) to better control
482 * what the user sees when presented with this activity as an alternative
483 * action to the data they are viewing.
484 *
485 * <p>Given these capabilities, the following intent will resolve to the
486 * TitleEditor activity:</p>
487 *
488 * <ul>
489 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
490 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
491 * displays and allows the user to edit the title associated
492 * with note <var>{ID}</var>.</p>
493 * </ul>
494 *
495 * <h3>Standard Activity Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for launching
498 * activities (usually through {@link Context#startActivity}. The most
499 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
500 * {@link #ACTION_EDIT}.
501 *
502 * <ul>
503 * <li> {@link #ACTION_MAIN}
504 * <li> {@link #ACTION_VIEW}
505 * <li> {@link #ACTION_ATTACH_DATA}
506 * <li> {@link #ACTION_EDIT}
507 * <li> {@link #ACTION_PICK}
508 * <li> {@link #ACTION_CHOOSER}
509 * <li> {@link #ACTION_GET_CONTENT}
510 * <li> {@link #ACTION_DIAL}
511 * <li> {@link #ACTION_CALL}
512 * <li> {@link #ACTION_SEND}
513 * <li> {@link #ACTION_SENDTO}
514 * <li> {@link #ACTION_ANSWER}
515 * <li> {@link #ACTION_INSERT}
516 * <li> {@link #ACTION_DELETE}
517 * <li> {@link #ACTION_RUN}
518 * <li> {@link #ACTION_SYNC}
519 * <li> {@link #ACTION_PICK_ACTIVITY}
520 * <li> {@link #ACTION_SEARCH}
521 * <li> {@link #ACTION_WEB_SEARCH}
522 * <li> {@link #ACTION_FACTORY_TEST}
523 * </ul>
524 *
525 * <h3>Standard Broadcast Actions</h3>
526 *
527 * <p>These are the current standard actions that Intent defines for receiving
528 * broadcasts (usually through {@link Context#registerReceiver} or a
529 * &lt;receiver&gt; tag in a manifest).
530 *
531 * <ul>
532 * <li> {@link #ACTION_TIME_TICK}
533 * <li> {@link #ACTION_TIME_CHANGED}
534 * <li> {@link #ACTION_TIMEZONE_CHANGED}
535 * <li> {@link #ACTION_BOOT_COMPLETED}
536 * <li> {@link #ACTION_PACKAGE_ADDED}
537 * <li> {@link #ACTION_PACKAGE_CHANGED}
538 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 * <li> {@link #ACTION_PACKAGE_RESTARTED}
540 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700541 * <li> {@link #ACTION_UID_REMOVED}
542 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700543 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700544 * <li> {@link #ACTION_POWER_DISCONNECTED}
545 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * </ul>
547 *
548 * <h3>Standard Categories</h3>
549 *
550 * <p>These are the current standard categories that can be used to further
551 * clarify an Intent via {@link #addCategory}.
552 *
553 * <ul>
554 * <li> {@link #CATEGORY_DEFAULT}
555 * <li> {@link #CATEGORY_BROWSABLE}
556 * <li> {@link #CATEGORY_TAB}
557 * <li> {@link #CATEGORY_ALTERNATIVE}
558 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
559 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800560 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700561 * <li> {@link #CATEGORY_HOME}
562 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400564 * <li> {@link #CATEGORY_CAR_DOCK}
565 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500566 * <li> {@link #CATEGORY_LE_DESK_DOCK}
567 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200568 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700569 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * </ul>
571 *
572 * <h3>Standard Extra Data</h3>
573 *
574 * <p>These are the current standard fields that can be used as extra data via
575 * {@link #putExtra}.
576 *
577 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800578 * <li> {@link #EXTRA_ALARM_COUNT}
579 * <li> {@link #EXTRA_BCC}
580 * <li> {@link #EXTRA_CC}
581 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
582 * <li> {@link #EXTRA_DATA_REMOVED}
583 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500584 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
585 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800586 * <li> {@link #EXTRA_DOCK_STATE_CAR}
587 * <li> {@link #EXTRA_DOCK_STATE_DESK}
588 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
589 * <li> {@link #EXTRA_DONT_KILL_APP}
590 * <li> {@link #EXTRA_EMAIL}
591 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700592 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800593 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700594 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800595 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700596 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
598 * <li> {@link #EXTRA_REPLACING}
599 * <li> {@link #EXTRA_SHORTCUT_ICON}
600 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
601 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700602 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_SHORTCUT_NAME}
604 * <li> {@link #EXTRA_SUBJECT}
605 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_TITLE}
608 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * </ul>
610 *
611 * <h3>Flags</h3>
612 *
613 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800614 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
615 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800617public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700618 private static final String ATTR_ACTION = "action";
619 private static final String TAG_CATEGORIES = "categories";
620 private static final String ATTR_CATEGORY = "category";
621 private static final String TAG_EXTRA = "extra";
622 private static final String ATTR_TYPE = "type";
623 private static final String ATTR_COMPONENT = "component";
624 private static final String ATTR_DATA = "data";
625 private static final String ATTR_FLAGS = "flags";
626
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700627 // ---------------------------------------------------------------------
628 // ---------------------------------------------------------------------
629 // Standard intent activity actions (see action variable).
630
631 /**
632 * Activity Action: Start as a main entry point, does not expect to
633 * receive data.
634 * <p>Input: nothing
635 * <p>Output: nothing
636 */
637 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
638 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700640 /**
641 * Activity Action: Display the data to the user. This is the most common
642 * action performed on data -- it is the generic action you can use on
643 * a piece of data to get the most reasonable thing to occur. For example,
644 * when used on a contacts entry it will view the entry; when used on a
645 * mailto: URI it will bring up a compose window filled with the information
646 * supplied by the URI; when used with a tel: URI it will invoke the
647 * dialer.
648 * <p>Input: {@link #getData} is URI from which to retrieve data.
649 * <p>Output: nothing.
650 */
651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
652 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 /**
655 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
656 * performed on a piece of data.
657 */
658 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 /**
661 * Used to indicate that some piece of data should be attached to some other
662 * place. For example, image data could be attached to a contact. It is up
663 * to the recipient to decide where the data should be attached; the intent
664 * does not specify the ultimate destination.
665 * <p>Input: {@link #getData} is URI of data to be attached.
666 * <p>Output: nothing.
667 */
668 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
669 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800670
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700671 /**
672 * Activity Action: Provide explicit editable access to the given data.
673 * <p>Input: {@link #getData} is URI of data to be edited.
674 * <p>Output: nothing.
675 */
676 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
677 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800678
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700679 /**
680 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
681 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
682 * The extras can contain type specific data to pass through to the editing/creating
683 * activity.
684 * <p>Output: The URI of the item that was picked. This must be a content:
685 * URI so that any receiver can access it.
686 */
687 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
688 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800689
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700690 /**
691 * Activity Action: Pick an item from the data, returning what was selected.
692 * <p>Input: {@link #getData} is URI containing a directory of data
693 * (vnd.android.cursor.dir/*) from which to pick an item.
694 * <p>Output: The URI of the item that was picked.
695 */
696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
697 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800698
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700699 /**
700 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800701 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700702 * <p>Output: An Intent representing the shortcut. The intent must contain three
703 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
704 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800705 * (value: ShortcutIconResource).</p>
706 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700707 * @see #EXTRA_SHORTCUT_INTENT
708 * @see #EXTRA_SHORTCUT_NAME
709 * @see #EXTRA_SHORTCUT_ICON
710 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
711 * @see android.content.Intent.ShortcutIconResource
712 */
713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
715
716 /**
717 * The name of the extra used to define the Intent of a shortcut.
718 *
719 * @see #ACTION_CREATE_SHORTCUT
720 */
721 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
722 /**
723 * The name of the extra used to define the name of a shortcut.
724 *
725 * @see #ACTION_CREATE_SHORTCUT
726 */
727 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
728 /**
729 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
730 *
731 * @see #ACTION_CREATE_SHORTCUT
732 */
733 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
734 /**
735 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
736 *
737 * @see #ACTION_CREATE_SHORTCUT
738 * @see android.content.Intent.ShortcutIconResource
739 */
740 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
741 "android.intent.extra.shortcut.ICON_RESOURCE";
742
743 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800744 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700745 *
746 * @see Intent#ACTION_CREATE_SHORTCUT
747 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800748 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
749 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 */
751 public static class ShortcutIconResource implements Parcelable {
752 /**
753 * The package name of the application containing the icon.
754 */
755 public String packageName;
756
757 /**
758 * The resource name of the icon, including package, name and type.
759 */
760 public String resourceName;
761
762 /**
763 * Creates a new ShortcutIconResource for the specified context and resource
764 * identifier.
765 *
766 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700767 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700769 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700770 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700771 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700772 ShortcutIconResource icon = new ShortcutIconResource();
773 icon.packageName = context.getPackageName();
774 icon.resourceName = context.getResources().getResourceName(resourceId);
775 return icon;
776 }
777
778 /**
779 * Used to read a ShortcutIconResource from a Parcel.
780 */
781 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
782 new Parcelable.Creator<ShortcutIconResource>() {
783
784 public ShortcutIconResource createFromParcel(Parcel source) {
785 ShortcutIconResource icon = new ShortcutIconResource();
786 icon.packageName = source.readString();
787 icon.resourceName = source.readString();
788 return icon;
789 }
790
791 public ShortcutIconResource[] newArray(int size) {
792 return new ShortcutIconResource[size];
793 }
794 };
795
796 /**
797 * No special parcel contents.
798 */
799 public int describeContents() {
800 return 0;
801 }
802
803 public void writeToParcel(Parcel dest, int flags) {
804 dest.writeString(packageName);
805 dest.writeString(resourceName);
806 }
807
808 @Override
809 public String toString() {
810 return resourceName;
811 }
812 }
813
814 /**
815 * Activity Action: Display an activity chooser, allowing the user to pick
816 * what they want to before proceeding. This can be used as an alternative
817 * to the standard activity picker that is displayed by the system when
818 * you try to start an activity with multiple possible matches, with these
819 * differences in behavior:
820 * <ul>
821 * <li>You can specify the title that will appear in the activity chooser.
822 * <li>The user does not have the option to make one of the matching
823 * activities a preferred activity, and all possible activities will
824 * always be shown even if one of them is currently marked as the
825 * preferred activity.
826 * </ul>
827 * <p>
828 * This action should be used when the user will naturally expect to
829 * select an activity in order to proceed. An example if when not to use
830 * it is when the user clicks on a "mailto:" link. They would naturally
831 * expect to go directly to their mail app, so startActivity() should be
832 * called directly: it will
833 * either launch the current preferred app, or put up a dialog allowing the
834 * user to pick an app to use and optionally marking that as preferred.
835 * <p>
836 * In contrast, if the user is selecting a menu item to send a picture
837 * they are viewing to someone else, there are many different things they
838 * may want to do at this point: send it through e-mail, upload it to a
839 * web service, etc. In this case the CHOOSER action should be used, to
840 * always present to the user a list of the things they can do, with a
841 * nice title given by the caller such as "Send this photo with:".
842 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700843 * If you need to grant URI permissions through a chooser, you must specify
844 * the permissions to be granted on the ACTION_CHOOSER Intent
845 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
846 * {@link #setClipData} to specify the URIs to be granted as well as
847 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
848 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
849 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700850 * As a convenience, an Intent of this form can be created with the
851 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700852 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700853 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700854 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
855 * and can optionally have a {@link #EXTRA_TITLE} field containing the
856 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700857 * <p>
858 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700859 */
860 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
861 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
862
863 /**
864 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
865 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700866 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
867 * target intent, also optionally supplying a title. If the target
868 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
869 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
870 * set in the returned chooser intent, with its ClipData set appropriately:
871 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500872 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700873 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700874 * @param target The Intent that the user will be selecting an activity
875 * to perform.
876 * @param title Optional title that will be displayed in the chooser.
877 * @return Return a new Intent object that you can hand to
878 * {@link Context#startActivity(Intent) Context.startActivity()} and
879 * related methods.
880 */
881 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700882 return createChooser(target, title, null);
883 }
884
885 /**
886 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
887 *
888 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
889 * target intent, also optionally supplying a title. If the target
890 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
891 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
892 * set in the returned chooser intent, with its ClipData set appropriately:
893 * either a direct reflection of {@link #getClipData()} if that is non-null,
894 * or a new ClipData built from {@link #getData()}.</p>
895 *
896 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
897 * when the user makes a choice. This can be useful if the calling application wants
898 * to remember the last chosen target and surface it as a more prominent or one-touch
899 * affordance elsewhere in the UI for next time.</p>
900 *
901 * @param target The Intent that the user will be selecting an activity
902 * to perform.
903 * @param title Optional title that will be displayed in the chooser.
904 * @param sender Optional IntentSender to be called when a choice is made.
905 * @return Return a new Intent object that you can hand to
906 * {@link Context#startActivity(Intent) Context.startActivity()} and
907 * related methods.
908 */
909 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700910 Intent intent = new Intent(ACTION_CHOOSER);
911 intent.putExtra(EXTRA_INTENT, target);
912 if (title != null) {
913 intent.putExtra(EXTRA_TITLE, title);
914 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700915
Adam Powell0b3c1122014-10-09 12:50:14 -0700916 if (sender != null) {
917 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
918 }
919
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700920 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700921 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
922 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
923 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700924 if (permFlags != 0) {
925 ClipData targetClipData = target.getClipData();
926 if (targetClipData == null && target.getData() != null) {
927 ClipData.Item item = new ClipData.Item(target.getData());
928 String[] mimeTypes;
929 if (target.getType() != null) {
930 mimeTypes = new String[] { target.getType() };
931 } else {
932 mimeTypes = new String[] { };
933 }
934 targetClipData = new ClipData(null, mimeTypes, item);
935 }
936 if (targetClipData != null) {
937 intent.setClipData(targetClipData);
938 intent.addFlags(permFlags);
939 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700940 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700941
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700942 return intent;
943 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700944
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700945 /**
946 * Activity Action: Allow the user to select a particular kind of data and
947 * return it. This is different than {@link #ACTION_PICK} in that here we
948 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800949 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700950 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900951 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700952 * etc.
953 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900954 * 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 -0700955 * of data, such as a person contact, you set the MIME type to the kind of
956 * data you want and launch it with {@link Context#startActivity(Intent)}.
957 * The system will then launch the best application to select that kind
958 * of data for you.
959 * <p>
960 * You may also be interested in any of a set of types of content the user
961 * can pick. For example, an e-mail application that wants to allow the
962 * user to add an attachment to an e-mail message can use this action to
963 * bring up a list of all of the types of content the user can attach.
964 * <p>
965 * In this case, you should wrap the GET_CONTENT intent with a chooser
966 * (through {@link #createChooser}), which will give the proper interface
967 * for the user to pick how to send your data and allow you to specify
968 * a prompt indicating what they are doing. You will usually specify a
969 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
970 * broad range of content types the user can select from.
971 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900972 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700973 * only pick from data that can be represented as a stream. This is
974 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
975 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800976 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900977 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800978 * is locally available on the device. For example, if this extra is set
979 * to true then an image picker should not show any pictures that are available
980 * from a remote server but not already on the local device (thus requiring
981 * they be downloaded when opened).
982 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800983 * If the caller can handle multiple returned items (the user performing
984 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
985 * to indicate this.
986 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700987 * Input: {@link #getType} is the desired MIME type to retrieve. Note
988 * that no URI is supplied in the intent, as there are no constraints on
989 * where the returned data originally comes from. You may also include the
990 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800991 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800992 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
993 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700994 * <p>
995 * Output: The URI of the item that was picked. This must be a content:
996 * URI so that any receiver can access it.
997 */
998 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
999 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1000 /**
1001 * Activity Action: Dial a number as specified by the data. This shows a
1002 * UI with the number being dialed, allowing the user to explicitly
1003 * initiate the call.
1004 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1005 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1006 * number.
1007 * <p>Output: nothing.
1008 */
1009 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1010 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1011 /**
1012 * Activity Action: Perform a call to someone specified by the data.
1013 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1014 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1015 * number.
1016 * <p>Output: nothing.
1017 *
1018 * <p>Note: there will be restrictions on which applications can initiate a
1019 * call; most applications should use the {@link #ACTION_DIAL}.
1020 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1021 * numbers. Applications can <strong>dial</strong> emergency numbers using
1022 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001023 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001024 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001025 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001026 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001027 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001028 */
1029 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1030 public static final String ACTION_CALL = "android.intent.action.CALL";
1031 /**
1032 * Activity Action: Perform a call to an emergency number specified by the
1033 * data.
1034 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1035 * tel: URI of an explicit phone number.
1036 * <p>Output: nothing.
1037 * @hide
1038 */
1039 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1040 /**
1041 * Activity action: Perform a call to any number (emergency or not)
1042 * specified by the data.
1043 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1044 * tel: URI of an explicit phone number.
1045 * <p>Output: nothing.
1046 * @hide
1047 */
1048 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1049 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001050 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1051 * sending this intent is a no-op.
1052 * <p>Input: No data should be specified. get*Extra may have an optional
1053 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1054 * send the activation result.
1055 * <p>Output: nothing.
1056 * @hide
1057 */
1058 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1059 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1060 "android.intent.action.SIM_ACTIVATION_REQUEST";
1061 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001062 * Activity Action: Send a message to someone specified by the data.
1063 * <p>Input: {@link #getData} is URI describing the target.
1064 * <p>Output: nothing.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1068 /**
1069 * Activity Action: Deliver some data to someone else. Who the data is
1070 * being delivered to is not specified; it is up to the receiver of this
1071 * action to ask the user where the data should be sent.
1072 * <p>
1073 * When launching a SEND intent, you should usually wrap it in a chooser
1074 * (through {@link #createChooser}), which will give the proper interface
1075 * for the user to pick how to send your data and allow you to specify
1076 * a prompt indicating what they are doing.
1077 * <p>
1078 * Input: {@link #getType} is the MIME type of the data being sent.
1079 * get*Extra can have either a {@link #EXTRA_TEXT}
1080 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1081 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1082 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1083 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001084 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1085 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1086 * your text with HTML formatting.
1087 * <p>
1088 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1089 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1090 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1091 * content: URIs and other advanced features of {@link ClipData}. If
1092 * using this approach, you still must supply the same data through the
1093 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1094 * for compatibility with old applications. If you don't set a ClipData,
1095 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001096 * <p>
1097 * Optional standard extras, which may be interpreted by some recipients as
1098 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1099 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1100 * <p>
1101 * Output: nothing.
1102 */
1103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1104 public static final String ACTION_SEND = "android.intent.action.SEND";
1105 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001106 * Activity Action: Deliver multiple data to someone else.
1107 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001108 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001109 * <p>
1110 * Input: {@link #getType} is the MIME type of the data being sent.
1111 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001112 * #EXTRA_STREAM} field, containing the data to be sent. If using
1113 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1114 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001115 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001116 * Multiple types are supported, and receivers should handle mixed types
1117 * whenever possible. The right way for the receiver to check them is to
1118 * use the content resolver on each URI. The intent sender should try to
1119 * put the most concrete mime type in the intent type, but it can fall
1120 * back to {@literal <type>/*} or {@literal *}/* as needed.
1121 * <p>
1122 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1123 * be image/jpg, but if you are sending image/jpg and image/png, then the
1124 * intent's type should be image/*.
1125 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001126 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1127 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1128 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1129 * content: URIs and other advanced features of {@link ClipData}. If
1130 * using this approach, you still must supply the same data through the
1131 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1132 * for compatibility with old applications. If you don't set a ClipData,
1133 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1134 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001135 * Optional standard extras, which may be interpreted by some recipients as
1136 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1137 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1138 * <p>
1139 * Output: nothing.
1140 */
1141 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1142 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1143 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001144 * Activity Action: Handle an incoming phone call.
1145 * <p>Input: nothing.
1146 * <p>Output: nothing.
1147 */
1148 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1149 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1150 /**
1151 * Activity Action: Insert an empty item into the given container.
1152 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1153 * in which to place the data.
1154 * <p>Output: URI of the new data that was created.
1155 */
1156 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1157 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1158 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001159 * Activity Action: Create a new item in the given container, initializing it
1160 * from the current contents of the clipboard.
1161 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1162 * in which to place the data.
1163 * <p>Output: URI of the new data that was created.
1164 */
1165 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1166 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1167 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001168 * Activity Action: Delete the given data from its container.
1169 * <p>Input: {@link #getData} is URI of data to be deleted.
1170 * <p>Output: nothing.
1171 */
1172 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1173 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1174 /**
1175 * Activity Action: Run the data, whatever that means.
1176 * <p>Input: ? (Note: this is currently specific to the test harness.)
1177 * <p>Output: nothing.
1178 */
1179 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1180 public static final String ACTION_RUN = "android.intent.action.RUN";
1181 /**
1182 * Activity Action: Perform a data synchronization.
1183 * <p>Input: ?
1184 * <p>Output: ?
1185 */
1186 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1188 /**
1189 * Activity Action: Pick an activity given an intent, returning the class
1190 * selected.
1191 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1192 * used with {@link PackageManager#queryIntentActivities} to determine the
1193 * set of activities from which to pick.
1194 * <p>Output: Class name of the activity that was selected.
1195 */
1196 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1197 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1198 /**
1199 * Activity Action: Perform a search.
1200 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1201 * is the text to search for. If empty, simply
1202 * enter your search results Activity with the search UI activated.
1203 * <p>Output: nothing.
1204 */
1205 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1206 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1207 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001208 * Activity Action: Start the platform-defined tutorial
1209 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1210 * is the text to search for. If empty, simply
1211 * enter your search results Activity with the search UI activated.
1212 * <p>Output: nothing.
1213 */
1214 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1215 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1216 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001217 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001218 * <p>
1219 * Input: {@link android.app.SearchManager#QUERY
1220 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1221 * a url starts with http or https, the site will be opened. If it is plain
1222 * text, Google search will be applied.
1223 * <p>
1224 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001228
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001229 /**
Jim Miller07994402012-05-02 14:22:27 -07001230 * Activity Action: Perform assist action.
1231 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001232 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1233 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001234 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1235 * information.
Jim Miller07994402012-05-02 14:22:27 -07001236 * Output: nothing.
1237 */
1238 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1239 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001240
1241 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001242 * Activity Action: Perform voice assist action.
1243 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001244 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1245 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001246 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001247 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001248 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1252
1253 /**
Adam Skory7140a252013-09-11 12:04:58 +01001254 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1255 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001256 */
1257 public static final String EXTRA_ASSIST_PACKAGE
1258 = "android.intent.extra.ASSIST_PACKAGE";
1259
1260 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001261 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1262 * application package at the time the assist was invoked.
1263 */
1264 public static final String EXTRA_ASSIST_UID
1265 = "android.intent.extra.ASSIST_UID";
1266
1267 /**
Adam Skory7140a252013-09-11 12:04:58 +01001268 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1269 * information supplied by the current foreground app at the time of the assist request.
1270 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001271 */
1272 public static final String EXTRA_ASSIST_CONTEXT
1273 = "android.intent.extra.ASSIST_CONTEXT";
1274
Jim Miller07994402012-05-02 14:22:27 -07001275 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001276 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1277 * keyboard as the primary input device for assistance.
1278 */
1279 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1280 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1281
1282 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001283 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1284 * that was used to invoke the assist.
1285 */
1286 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1287 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1288
1289 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001290 * Activity Action: List all available applications
1291 * <p>Input: Nothing.
1292 * <p>Output: nothing.
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1296 /**
1297 * Activity Action: Show settings for choosing wallpaper
1298 * <p>Input: Nothing.
1299 * <p>Output: Nothing.
1300 */
1301 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1302 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1303
1304 /**
1305 * Activity Action: Show activity for reporting a bug.
1306 * <p>Input: Nothing.
1307 * <p>Output: Nothing.
1308 */
1309 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1310 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1311
1312 /**
1313 * Activity Action: Main entry point for factory tests. Only used when
1314 * the device is booting in factory test node. The implementing package
1315 * must be installed in the system image.
1316 * <p>Input: nothing
1317 * <p>Output: nothing
1318 */
1319 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1320
1321 /**
1322 * Activity Action: The user pressed the "call" button to go to the dialer
1323 * or other appropriate UI for placing a call.
1324 * <p>Input: Nothing.
1325 * <p>Output: Nothing.
1326 */
1327 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1328 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1329
1330 /**
1331 * Activity Action: Start Voice Command.
1332 * <p>Input: Nothing.
1333 * <p>Output: Nothing.
1334 */
1335 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1336 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001337
1338 /**
1339 * Activity Action: Start action associated with long pressing on the
1340 * search key.
1341 * <p>Input: Nothing.
1342 * <p>Output: Nothing.
1343 */
1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001346
Jacek Surazski86b6c532009-05-13 14:38:28 +02001347 /**
1348 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1349 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001350 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001351 * <p>Input: No data is specified. The bug report is passed in using
1352 * an {@link #EXTRA_BUG_REPORT} field.
1353 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001354 *
1355 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001356 */
1357 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1358 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001359
1360 /**
1361 * Activity Action: Show power usage information to the user.
1362 * <p>Input: Nothing.
1363 * <p>Output: Nothing.
1364 */
1365 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001367
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001368 /**
1369 * Activity Action: Setup wizard to launch after a platform update. This
1370 * activity should have a string meta-data field associated with it,
1371 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1372 * the platform for setup. The activity will be launched only if
1373 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1374 * same value.
1375 * <p>Input: Nothing.
1376 * <p>Output: Nothing.
1377 * @hide
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001381
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001382 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001383 * Activity Action: Show settings for managing network data usage of a
1384 * specific application. Applications should define an activity that offers
1385 * options to control data usage.
1386 */
1387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1388 public static final String ACTION_MANAGE_NETWORK_USAGE =
1389 "android.intent.action.MANAGE_NETWORK_USAGE";
1390
1391 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001392 * Activity Action: Launch application installer.
1393 * <p>
1394 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001395 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1396 * you can also use "package:<package-name>" to install an application for the
1397 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001398 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1399 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1400 * <p>
1401 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1402 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001403 * <p>
1404 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1405 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1406 * in order to launch the application installer.
1407 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001408 *
1409 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1410 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1411 * @see #EXTRA_RETURN_RESULT
1412 */
1413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1414 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1415
1416 /**
1417 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1418 * package. Specifies the installer package name; this package will receive the
1419 * {@link #ACTION_APP_ERROR} intent.
1420 */
1421 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1422 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1423
1424 /**
1425 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1426 * package. Specifies that the application being installed should not be
1427 * treated as coming from an unknown source, but as coming from the app
1428 * invoking the Intent. For this to work you must start the installer with
1429 * startActivityForResult().
1430 */
1431 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1432 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1433
1434 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001435 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1436 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001437 * data field originated from.
1438 */
rich cannings706e8ba2012-08-20 13:20:14 -07001439 public static final String EXTRA_ORIGINATING_URI
1440 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001441
1442 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001443 * This extra can be used with any Intent used to launch an activity, supplying information
1444 * about who is launching that activity. This field contains a {@link android.net.Uri}
1445 * object, typically an http: or https: URI of the web site that the referral came from;
1446 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1447 * a native application that it came from.
1448 *
1449 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1450 * instead of directly retrieving the extra. It is also valid for applications to
1451 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1452 * a string, not a Uri; the field here, if supplied, will always take precedence,
1453 * however.</p>
1454 *
1455 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001456 */
1457 public static final String EXTRA_REFERRER
1458 = "android.intent.extra.REFERRER";
1459
1460 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001461 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1462 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1463 * not be created, in particular when Intent extras are supplied through the
1464 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1465 * schemes.
1466 *
1467 * @see #EXTRA_REFERRER
1468 */
1469 public static final String EXTRA_REFERRER_NAME
1470 = "android.intent.extra.REFERRER_NAME";
1471
1472 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001473 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1474 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1475 * @hide
1476 */
1477 public static final String EXTRA_ORIGINATING_UID
1478 = "android.intent.extra.ORIGINATING_UID";
1479
1480 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001481 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1482 * package. Tells the installer UI to skip the confirmation with the user
1483 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001484 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1485 * will no longer show an interstitial message about updating existing
1486 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001487 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001488 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001489 public static final String EXTRA_ALLOW_REPLACE
1490 = "android.intent.extra.ALLOW_REPLACE";
1491
1492 /**
1493 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1494 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1495 * return to the application the result code of the install/uninstall. The returned result
1496 * code will be {@link android.app.Activity#RESULT_OK} on success or
1497 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1498 */
1499 public static final String EXTRA_RETURN_RESULT
1500 = "android.intent.extra.RETURN_RESULT";
1501
1502 /**
1503 * Package manager install result code. @hide because result codes are not
1504 * yet ready to be exposed.
1505 */
1506 public static final String EXTRA_INSTALL_RESULT
1507 = "android.intent.extra.INSTALL_RESULT";
1508
1509 /**
1510 * Activity Action: Launch application uninstaller.
1511 * <p>
1512 * Input: The data must be a package: URI whose scheme specific part is
1513 * the package name of the current installed package to be uninstalled.
1514 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1515 * <p>
1516 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1517 * succeeded.
1518 */
1519 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1520 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1521
1522 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001523 * Specify whether the package should be uninstalled for all users.
1524 * @hide because these should not be part of normal application flow.
1525 */
1526 public static final String EXTRA_UNINSTALL_ALL_USERS
1527 = "android.intent.extra.UNINSTALL_ALL_USERS";
1528
1529 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001530 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1531 * describing the last run version of the platform that was setup.
1532 * @hide
1533 */
1534 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1535
Svet Ganov3695b8a2015-03-24 16:30:25 -07001536 /**
1537 * Activity action: Launch UI to manage the permissions of an app.
1538 * <p>
1539 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1540 * will be managed by the launched UI.
1541 * </p>
1542 * <p>
1543 * Output: Nothing.
1544 * </p>
1545 *
1546 * @see #EXTRA_PACKAGE_NAME
1547 *
1548 * @hide
1549 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1551 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1552 "android.intent.action.MANAGE_APP_PERMISSIONS";
1553
1554 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001555 * Activity action: Launch UI to manage permissions.
1556 * <p>
1557 * Input: Nothing.
1558 * </p>
1559 * <p>
1560 * Output: Nothing.
1561 * </p>
1562 *
1563 * @hide
1564 */
Svet Ganov321f0152015-05-16 22:51:50 -07001565 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1566 public static final String ACTION_MANAGE_PERMISSIONS =
1567 "android.intent.action.MANAGE_PERMISSIONS";
1568
1569 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001570 * Intent extra: An app package name.
1571 * <p>
1572 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001573 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001574 *
1575 * @hide
1576 */
1577 @SystemApi
1578 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1579
1580 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001581 * Broadcast action that requests current permission granted information. It will respond
1582 * to the request by sending a broadcast with action defined by
1583 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001584 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1585 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1586 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001587 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001588 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1589 * number of permissions requested and the number of granted additional permissions
1590 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001591 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001592 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1593 * of localized permission group names that are granted in
1594 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001595 *
1596 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1597 * permissions and the total number of apps requesting runtime permissions will be the first
1598 * and second elements respectively of an int[] in the response as
1599 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1600 *
1601 * @hide
1602 */
1603 public static final String ACTION_GET_PERMISSIONS_COUNT
1604 = "android.intent.action.GET_PERMISSIONS_COUNT";
1605
1606 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001607 * Broadcast action that requests list of all apps that have runtime permissions. It will
1608 * respond to the request by sending a broadcast with action defined by
1609 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1610 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1611 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1612 * a null upon failure.
1613 *
1614 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1615 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1616 * will contain the list of app labels corresponding ot the apps in the first list.
1617 *
1618 * @hide
1619 */
1620 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1621 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1622
1623 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001624 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1625 * @hide
1626 */
1627 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1628 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1629
1630 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001631 * List of CharSequence of localized permission group labels.
1632 * @hide
1633 */
1634 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1635 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1636
1637 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001638 * String list of apps that have one or more runtime permissions.
1639 * @hide
1640 */
1641 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1642 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1643
1644 /**
1645 * String list of app labels for apps that have one or more runtime permissions.
1646 * @hide
1647 */
1648 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1649 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1650
1651 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001652 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001653 * @hide
1654 */
1655 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1656 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1657
1658 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001659 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1660 * @hide
1661 */
1662 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1663 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1664
1665 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001666 * Activity action: Launch UI to manage which apps have a given permission.
1667 * <p>
1668 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1669 * to which will be managed by the launched UI.
1670 * </p>
1671 * <p>
1672 * Output: Nothing.
1673 * </p>
1674 *
1675 * @see #EXTRA_PERMISSION_NAME
1676 *
1677 * @hide
1678 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001679 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1680 public static final String ACTION_MANAGE_PERMISSION_APPS =
1681 "android.intent.action.MANAGE_PERMISSION_APPS";
1682
1683 /**
1684 * Intent extra: The name of a permission.
1685 * <p>
1686 * Type: String
1687 * </p>
1688 *
1689 * @hide
1690 */
1691 @SystemApi
1692 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1693
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001694 // ---------------------------------------------------------------------
1695 // ---------------------------------------------------------------------
1696 // Standard intent broadcast actions (see action variable).
1697
1698 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001699 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1700 * <p>
1701 * For historical reasons, the name of this broadcast action refers to the power
1702 * state of the screen but it is actually sent in response to changes in the
1703 * overall interactive state of the device.
1704 * </p><p>
1705 * This broadcast is sent when the device becomes non-interactive which may have
1706 * nothing to do with the screen turning off. To determine the
1707 * actual state of the screen, use {@link android.view.Display#getState}.
1708 * </p><p>
1709 * See {@link android.os.PowerManager#isInteractive} for details.
1710 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001711 * You <em>cannot</em> receive this through components declared in
1712 * manifests, only by explicitly registering for it with
1713 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1714 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001715 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001716 * <p class="note">This is a protected intent that can only be sent
1717 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001718 */
1719 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1720 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001721
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001722 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001723 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1724 * <p>
1725 * For historical reasons, the name of this broadcast action refers to the power
1726 * state of the screen but it is actually sent in response to changes in the
1727 * overall interactive state of the device.
1728 * </p><p>
1729 * This broadcast is sent when the device becomes interactive which may have
1730 * nothing to do with the screen turning on. To determine the
1731 * actual state of the screen, use {@link android.view.Display#getState}.
1732 * </p><p>
1733 * See {@link android.os.PowerManager#isInteractive} for details.
1734 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001735 * You <em>cannot</em> receive this through components declared in
1736 * manifests, only by explicitly registering for it with
1737 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1738 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001739 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001740 * <p class="note">This is a protected intent that can only be sent
1741 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001742 */
1743 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1744 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001745
1746 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001747 * Broadcast Action: Sent after the system stops dreaming.
1748 *
1749 * <p class="note">This is a protected intent that can only be sent by the system.
1750 * It is only sent to registered receivers.</p>
1751 */
1752 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1753 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1754
1755 /**
1756 * Broadcast Action: Sent after the system starts dreaming.
1757 *
1758 * <p class="note">This is a protected intent that can only be sent by the system.
1759 * It is only sent to registered receivers.</p>
1760 */
1761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1762 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1763
1764 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001765 * 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 -07001766 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001767 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001768 * <p class="note">This is a protected intent that can only be sent
1769 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001770 */
1771 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001772 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001773
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001774 /**
1775 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001776 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001777 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001778 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1779 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001780 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001781 * <p class="note">This is a protected intent that can only be sent
1782 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001783 */
1784 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1785 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1786 /**
1787 * Broadcast Action: The time was set.
1788 */
1789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1790 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1791 /**
1792 * Broadcast Action: The date has changed.
1793 */
1794 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1795 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1796 /**
1797 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1798 * <ul>
1799 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1800 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001801 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001802 * <p class="note">This is a protected intent that can only be sent
1803 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001804 */
1805 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1806 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1807 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001808 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1809 * DNS entries should be tossed.
1810 * @hide
1811 */
1812 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1813 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1814 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001815 * Alarm Changed Action: This is broadcast when the AlarmClock
1816 * application's alarm is set or unset. It is used by the
1817 * AlarmClock application and the StatusBar service.
1818 * @hide
1819 */
1820 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1821 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1822 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001823 * Broadcast Action: This is broadcast once, after the system has finished
1824 * booting. It can be used to perform application-specific initialization,
1825 * such as installing alarms. You must hold the
1826 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1827 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001828 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001829 * <p class="note">This is a protected intent that can only be sent
1830 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001831 */
1832 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1833 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1834 /**
1835 * Broadcast Action: This is broadcast when a user action should request a
1836 * temporary system dialog to dismiss. Some examples of temporary system
1837 * dialogs are the notification window-shade and the recent tasks dialog.
1838 */
1839 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1840 /**
1841 * Broadcast Action: Trigger the download and eventual installation
1842 * of a package.
1843 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001844 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001845 * <p class="note">This is a protected intent that can only be sent
1846 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001847 *
1848 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001849 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001850 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001851 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1852 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1853 /**
1854 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001855 * device. The data contains the name of the package. Note that the
1856 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001857 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001858 * <ul>
1859 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1860 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1861 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1862 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001863 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001864 * <p class="note">This is a protected intent that can only be sent
1865 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001866 */
1867 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1868 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1869 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001870 * Broadcast Action: A new version of an application package has been
1871 * installed, replacing an existing version that was previously installed.
1872 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001873 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001874 * <ul>
1875 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1876 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001877 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001878 * <p class="note">This is a protected intent that can only be sent
1879 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001880 */
1881 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1882 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1883 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001884 * Broadcast Action: A new version of your application has been installed
1885 * over an existing one. This is only sent to the application that was
1886 * replaced. It does not contain any additional data; to receive it, just
1887 * use an intent filter for this action.
1888 *
1889 * <p class="note">This is a protected intent that can only be sent
1890 * by the system.
1891 */
1892 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1893 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1894 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001895 * Broadcast Action: An existing application package has been removed from
1896 * the device. The data contains the name of the package. The package
1897 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001898 * <ul>
1899 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1900 * to the package.
1901 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1902 * application -- data and code -- is being removed.
1903 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1904 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1905 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001906 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001907 * <p class="note">This is a protected intent that can only be sent
1908 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001909 */
1910 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1911 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1912 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001913 * Broadcast Action: An existing application package has been completely
1914 * removed from the device. The data contains the name of the package.
1915 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1916 * {@link #EXTRA_DATA_REMOVED} is true and
1917 * {@link #EXTRA_REPLACING} is false of that broadcast.
1918 *
1919 * <ul>
1920 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1921 * to the package.
1922 * </ul>
1923 *
1924 * <p class="note">This is a protected intent that can only be sent
1925 * by the system.
1926 */
1927 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1928 public static final String ACTION_PACKAGE_FULLY_REMOVED
1929 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1930 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001931 * Broadcast Action: An existing application package has been changed (e.g.
1932 * a component has been enabled or disabled). The data contains the name of
1933 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001934 * <ul>
1935 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001936 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001937 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001938 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1939 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001940 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001941 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001942 * <p class="note">This is a protected intent that can only be sent
1943 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001944 */
1945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1946 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1947 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001948 * @hide
1949 * Broadcast Action: Ask system services if there is any reason to
1950 * restart the given package. The data contains the name of the
1951 * package.
1952 * <ul>
1953 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1954 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1955 * </ul>
1956 *
1957 * <p class="note">This is a protected intent that can only be sent
1958 * by the system.
1959 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001960 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1962 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1963 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001964 * Broadcast Action: The user has restarted a package, and all of its
1965 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001966 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001967 * be removed. Note that the restarted package does <em>not</em>
1968 * receive this broadcast.
1969 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001970 * <ul>
1971 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1972 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001973 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001974 * <p class="note">This is a protected intent that can only be sent
1975 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001976 */
1977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1978 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1979 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001980 * Broadcast Action: The user has cleared the data of a package. This should
1981 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001982 * its persistent data is erased and this broadcast sent.
1983 * Note that the cleared package does <em>not</em>
1984 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001985 * <ul>
1986 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1987 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001988 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001989 * <p class="note">This is a protected intent that can only be sent
1990 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001991 */
1992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1993 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1994 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001995 * Broadcast Action: A user ID has been removed from the system. The user
1996 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001997 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001998 * <p class="note">This is a protected intent that can only be sent
1999 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002003
2004 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002005 * Broadcast Action: Sent to the installer package of an application
2006 * when that application is first launched (that is the first time it
2007 * is moved out of the stopped state). The data contains the name of the package.
2008 *
2009 * <p class="note">This is a protected intent that can only be sent
2010 * by the system.
2011 */
2012 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2013 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2014
2015 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002016 * Broadcast Action: Sent to the system package verifier when a package
2017 * needs to be verified. The data contains the package URI.
2018 * <p class="note">
2019 * This is a protected intent that can only be sent by the system.
2020 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002021 */
2022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2023 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2024
2025 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002026 * Broadcast Action: Sent to the system package verifier when a package is
2027 * verified. The data contains the package URI.
2028 * <p class="note">
2029 * This is a protected intent that can only be sent by the system.
2030 */
2031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2032 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2033
2034 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002035 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2036 * needs to be verified. The data contains the filter data hosts to be verified against.
2037 * <p class="note">
2038 * This is a protected intent that can only be sent by the system.
2039 * </p>
2040 *
2041 * @hide
2042 */
2043 @SystemApi
2044 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2045 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2046
2047 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002048 * Broadcast Action: Resources for a set of packages (which were
2049 * previously unavailable) are currently
2050 * available since the media on which they exist is available.
2051 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2052 * list of packages whose availability changed.
2053 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2054 * list of uids of packages whose availability changed.
2055 * Note that the
2056 * packages in this list do <em>not</em> receive this broadcast.
2057 * The specified set of packages are now available on the system.
2058 * <p>Includes the following extras:
2059 * <ul>
2060 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2061 * whose resources(were previously unavailable) are currently available.
2062 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2063 * packages whose resources(were previously unavailable)
2064 * are currently available.
2065 * </ul>
2066 *
2067 * <p class="note">This is a protected intent that can only be sent
2068 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002069 */
2070 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002071 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2072 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002073
2074 /**
2075 * Broadcast Action: Resources for a set of packages are currently
2076 * unavailable since the media on which they exist is unavailable.
2077 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2078 * list of packages whose availability changed.
2079 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2080 * list of uids of packages whose availability changed.
2081 * The specified set of packages can no longer be
2082 * launched and are practically unavailable on the system.
2083 * <p>Inclues the following extras:
2084 * <ul>
2085 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2086 * whose resources are no longer available.
2087 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2088 * whose resources are no longer available.
2089 * </ul>
2090 *
2091 * <p class="note">This is a protected intent that can only be sent
2092 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002093 */
2094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002095 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002096 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002097
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002098 /**
2099 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002100 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002101 * This should <em>only</em> be used to determine when the wallpaper
2102 * has changed to show the new wallpaper to the user. You should certainly
2103 * never, in response to this, change the wallpaper or other attributes of
2104 * it such as the suggested size. That would be crazy, right? You'd cause
2105 * all kinds of loops, especially if other apps are doing similar things,
2106 * right? Of course. So please don't do this.
2107 *
2108 * @deprecated Modern applications should use
2109 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2110 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2111 * shown behind their UI, rather than watching for this broadcast and
2112 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002113 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002114 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002115 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2116 /**
2117 * Broadcast Action: The current device {@link android.content.res.Configuration}
2118 * (orientation, locale, etc) has changed. When such a change happens, the
2119 * UIs (view hierarchy) will need to be rebuilt based on this new
2120 * information; for the most part, applications don't need to worry about
2121 * this, because the system will take care of stopping and restarting the
2122 * application to make sure it sees the new changes. Some system code that
2123 * can not be restarted will need to watch for this action and handle it
2124 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002125 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002126 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002127 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002128 * in manifests, only by explicitly registering for it with
2129 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2130 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002131 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002132 * <p class="note">This is a protected intent that can only be sent
2133 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002134 *
2135 * @see android.content.res.Configuration
2136 */
2137 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2138 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2139 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002140 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002141 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002142 * <p class="note">This is a protected intent that can only be sent
2143 * by the system.
2144 */
2145 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2146 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2147 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002148 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2149 * charging state, level, and other information about the battery.
2150 * See {@link android.os.BatteryManager} for documentation on the
2151 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002152 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002153 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002154 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002155 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002156 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002157 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2158 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2159 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2160 * broadcasts that are sent and can be received through manifest
2161 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002162 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002163 * <p class="note">This is a protected intent that can only be sent
2164 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002165 */
2166 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2167 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2168 /**
2169 * Broadcast Action: Indicates low battery condition on the device.
2170 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002171 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002172 * <p class="note">This is a protected intent that can only be sent
2173 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002174 */
2175 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2176 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2177 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002178 * Broadcast Action: Indicates the battery is now okay after being low.
2179 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2180 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002181 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002182 * <p class="note">This is a protected intent that can only be sent
2183 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002184 */
2185 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2186 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2187 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002188 * Broadcast Action: External power has been connected to the device.
2189 * This is intended for applications that wish to register specifically to this notification.
2190 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2191 * stay active to receive this notification. This action can be used to implement actions
2192 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002193 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002194 * <p class="note">This is a protected intent that can only be sent
2195 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002196 */
2197 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002198 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002199 /**
2200 * Broadcast Action: External power has been removed from the device.
2201 * This is intended for applications that wish to register specifically to this notification.
2202 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2203 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002204 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002205 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002206 * <p class="note">This is a protected intent that can only be sent
2207 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002208 */
2209 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002210 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002211 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002212 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002213 * Broadcast Action: Device is shutting down.
2214 * This is broadcast when the device is being shut down (completely turned
2215 * off, not sleeping). Once the broadcast is complete, the final shutdown
2216 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002217 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002218 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002219 * <p class="note">This is a protected intent that can only be sent
2220 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002221 * <p>May include the following extras:
2222 * <ul>
2223 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2224 * shutdown is only for userspace processes. If not set, assumed to be false.
2225 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002226 */
2227 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002228 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002229 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002230 * Activity Action: Start this activity to request system shutdown.
2231 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2232 * to request confirmation from the user before shutting down.
2233 *
2234 * <p class="note">This is a protected intent that can only be sent
2235 * by the system.
2236 *
2237 * {@hide}
2238 */
2239 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2240 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002241 * Broadcast Action: A sticky broadcast that indicates low memory
2242 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002243 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002244 * <p class="note">This is a protected intent that can only be sent
2245 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002246 */
2247 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2248 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2249 /**
2250 * Broadcast Action: Indicates low memory condition on the device no longer exists
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_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2257 /**
Jake Hambybb371632010-08-23 18:16:48 -07002258 * Broadcast Action: A sticky broadcast that indicates a memory full
2259 * condition on the device. This is intended for activities that want
2260 * to be able to fill the data partition completely, leaving only
2261 * enough free space to prevent system-wide SQLite failures.
2262 *
2263 * <p class="note">This is a protected intent that can only be sent
2264 * by the system.
2265 *
2266 * {@hide}
2267 */
2268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2269 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2270 /**
2271 * Broadcast Action: Indicates memory full condition on the device
2272 * no longer exists.
2273 *
2274 * <p class="note">This is a protected intent that can only be sent
2275 * by the system.
2276 *
2277 * {@hide}
2278 */
2279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2280 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2281 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002282 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2283 * and package management should be started.
2284 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2285 * notification.
2286 */
2287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2288 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2289 /**
2290 * Broadcast Action: The device has entered USB Mass Storage mode.
2291 * This is used mainly for the USB Settings panel.
2292 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2293 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002294 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002295 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002296 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002297 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2298
2299 /**
2300 * Broadcast Action: The device has exited USB Mass Storage mode.
2301 * This is used mainly for the USB Settings panel.
2302 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2303 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002304 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002305 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002306 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002307 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2308
2309 /**
2310 * Broadcast Action: External media has been removed.
2311 * The path to the mount point for the removed media is contained in the Intent.mData field.
2312 */
2313 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2314 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2315
2316 /**
2317 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002318 * 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 -07002319 */
2320 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2321 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2322
2323 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002324 * Broadcast Action: External media is present, and being disk-checked
2325 * 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 -08002326 */
2327 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2328 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2329
2330 /**
2331 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2332 * 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 -08002333 */
2334 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2335 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2336
2337 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002338 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002339 * 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 -07002340 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2341 * media was mounted read only.
2342 */
2343 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2344 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2345
2346 /**
2347 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002348 * 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 -07002349 */
2350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2351 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2352
2353 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002354 * Broadcast Action: External media is no longer being shared via USB mass storage.
2355 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2356 *
2357 * @hide
2358 */
2359 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2360
2361 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002362 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2363 * The path to the mount point for the removed media is contained in the Intent.mData field.
2364 */
2365 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2366 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2367
2368 /**
2369 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002370 * 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 -07002371 */
2372 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2373 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2374
2375 /**
2376 * Broadcast Action: User has expressed the desire to remove the external storage media.
2377 * Applications should close all files they have open within the mount point when they receive this intent.
2378 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2379 */
2380 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2381 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2382
2383 /**
2384 * Broadcast Action: The media scanner has started scanning a directory.
2385 * The path to the directory being scanned is contained in the Intent.mData field.
2386 */
2387 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2388 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2389
2390 /**
2391 * Broadcast Action: The media scanner has finished scanning a directory.
2392 * The path to the scanned directory is contained in the Intent.mData field.
2393 */
2394 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2395 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2396
2397 /**
2398 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2399 * The path to the file is contained in the Intent.mData field.
2400 */
2401 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2402 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2403
2404 /**
2405 * Broadcast Action: The "Media Button" was pressed. Includes a single
2406 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2407 * caused the broadcast.
2408 */
2409 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2410 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2411
2412 /**
2413 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2414 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2415 * caused the broadcast.
2416 */
2417 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2418 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2419
2420 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2421 // location; they are not general-purpose actions.
2422
2423 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002424 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002425 */
2426 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2427 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2428 "android.intent.action.GTALK_CONNECTED";
2429
2430 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002431 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002432 */
2433 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2434 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2435 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002436
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002437 /**
2438 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002439 */
2440 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2441 public static final String ACTION_INPUT_METHOD_CHANGED =
2442 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002443
2444 /**
2445 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2446 * more radios have been turned off or on. The intent will have the following extra value:</p>
2447 * <ul>
2448 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2449 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2450 * turned off</li>
2451 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002452 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002453 * <p class="note">This is a protected intent that can only be sent
2454 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002455 */
2456 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2457 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2458
2459 /**
2460 * Broadcast Action: Some content providers have parts of their namespace
2461 * where they publish new events or items that the user may be especially
2462 * interested in. For these things, they may broadcast this action when the
2463 * set of interesting items change.
2464 *
2465 * For example, GmailProvider sends this notification when the set of unread
2466 * mail in the inbox changes.
2467 *
2468 * <p>The data of the intent identifies which part of which provider
2469 * changed. When queried through the content resolver, the data URI will
2470 * return the data set in question.
2471 *
2472 * <p>The intent will have the following extra values:
2473 * <ul>
2474 * <li><em>count</em> - The number of items in the data set. This is the
2475 * same as the number of items in the cursor returned by querying the
2476 * data URI. </li>
2477 * </ul>
2478 *
2479 * This intent will be sent at boot (if the count is non-zero) and when the
2480 * data set changes. It is possible for the data set to change without the
2481 * count changing (for example, if a new unread message arrives in the same
2482 * sync operation in which a message is archived). The phone should still
2483 * ring/vibrate/etc as normal in this case.
2484 */
2485 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2486 public static final String ACTION_PROVIDER_CHANGED =
2487 "android.intent.action.PROVIDER_CHANGED";
2488
2489 /**
2490 * Broadcast Action: Wired Headset plugged in or unplugged.
2491 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002492 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2493 * and documentation.
2494 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002495 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002496 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002497 */
2498 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002499 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002500
2501 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002502 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2503 * <ul>
2504 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2505 * </ul>
2506 *
2507 * <p class="note">This is a protected intent that can only be sent
2508 * by the system.
2509 *
2510 * @hide
2511 */
2512 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2513 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2514 = "android.intent.action.ADVANCED_SETTINGS";
2515
2516 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002517 * Broadcast Action: Sent after application restrictions are changed.
2518 *
2519 * <p class="note">This is a protected intent that can only be sent
2520 * by the system.</p>
2521 */
2522 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2523 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2524 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2525
2526 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002527 * Broadcast Action: An outgoing call is about to be placed.
2528 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002529 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002530 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002531 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002532 * the phone number originally intended to be dialed.</li>
2533 * </ul>
2534 * <p>Once the broadcast is finished, the resultData is used as the actual
2535 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002536 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002537 * outgoing call in turn: for example, a parental control application
2538 * might verify that the user is authorized to place the call at that
2539 * time, then a number-rewriting application might add an area code if
2540 * one was not specified.</p>
2541 * <p>For consistency, any receiver whose purpose is to prohibit phone
2542 * calls should have a priority of 0, to ensure it will see the final
2543 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002544 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002545 * should have a positive priority.
2546 * Negative priorities are reserved for the system for this broadcast;
2547 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002548 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2549 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002550 * <p>Emergency calls cannot be intercepted using this mechanism, and
2551 * other calls cannot be modified to call emergency numbers using this
2552 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002553 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2554 * call to use their own service instead. Those apps should first prevent
2555 * the call from being placed by setting resultData to <code>null</code>
2556 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002557 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002558 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2559 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002560 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002561 * <p class="note">This is a protected intent that can only be sent
2562 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002563 */
2564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2565 public static final String ACTION_NEW_OUTGOING_CALL =
2566 "android.intent.action.NEW_OUTGOING_CALL";
2567
2568 /**
2569 * Broadcast Action: Have the device reboot. This is only for use by
2570 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002571 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002572 * <p class="note">This is a protected intent that can only be sent
2573 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002574 */
2575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2576 public static final String ACTION_REBOOT =
2577 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002578
Wei Huang97ecc9c2009-05-11 17:44:20 -07002579 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002580 * Broadcast Action: A sticky broadcast for changes in the physical
2581 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002582 *
2583 * <p>The intent will have the following extra values:
2584 * <ul>
2585 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002586 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002587 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002588 * <p>This is intended for monitoring the current physical dock state.
2589 * See {@link android.app.UiModeManager} for the normal API dealing with
2590 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002591 */
2592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2593 public static final String ACTION_DOCK_EVENT =
2594 "android.intent.action.DOCK_EVENT";
2595
2596 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002597 * Broadcast Action: A broadcast when idle maintenance can be started.
2598 * This means that the user is not interacting with the device and is
2599 * not expected to do so soon. Typical use of the idle maintenance is
2600 * to perform somehow expensive tasks that can be postponed at a moment
2601 * when they will not degrade user experience.
2602 * <p>
2603 * <p class="note">In order to keep the device responsive in case of an
2604 * unexpected user interaction, implementations of a maintenance task
2605 * should be interruptible. In such a scenario a broadcast with action
2606 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2607 * should not do the maintenance work in
2608 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2609 * maintenance service by {@link Context#startService(Intent)}. Also
2610 * you should hold a wake lock while your maintenance service is running
2611 * to prevent the device going to sleep.
2612 * </p>
2613 * <p>
2614 * <p class="note">This is a protected intent that can only be sent by
2615 * the system.
2616 * </p>
2617 *
2618 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002619 *
2620 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002621 */
2622 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2623 public static final String ACTION_IDLE_MAINTENANCE_START =
2624 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2625
2626 /**
2627 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2628 * This means that the user was not interacting with the device as a result
2629 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2630 * was sent and now the user started interacting with the device. Typical
2631 * use of the idle maintenance is to perform somehow expensive tasks that
2632 * can be postponed at a moment when they will not degrade user experience.
2633 * <p>
2634 * <p class="note">In order to keep the device responsive in case of an
2635 * unexpected user interaction, implementations of a maintenance task
2636 * should be interruptible. Hence, on receiving a broadcast with this
2637 * action, the maintenance task should be interrupted as soon as possible.
2638 * In other words, you should not do the maintenance work in
2639 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2640 * maintenance service that was started on receiving of
2641 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2642 * lock you acquired when your maintenance service started.
2643 * </p>
2644 * <p class="note">This is a protected intent that can only be sent
2645 * by the system.
2646 *
2647 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002648 *
2649 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002650 */
2651 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2652 public static final String ACTION_IDLE_MAINTENANCE_END =
2653 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2654
2655 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002656 * Broadcast Action: a remote intent is to be broadcasted.
2657 *
2658 * A remote intent is used for remote RPC between devices. The remote intent
2659 * is serialized and sent from one device to another device. The receiving
2660 * device parses the remote intent and broadcasts it. Note that anyone can
2661 * broadcast a remote intent. However, if the intent receiver of the remote intent
2662 * does not trust intent broadcasts from arbitrary intent senders, it should require
2663 * the sender to hold certain permissions so only trusted sender's broadcast will be
2664 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002665 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002666 */
2667 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002668 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002669
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002670 /**
2671 * Broadcast Action: hook for permforming cleanup after a system update.
2672 *
2673 * The broadcast is sent when the system is booting, before the
2674 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2675 * image. A receiver for this should do its work and then disable itself
2676 * so that it does not get run again at the next boot.
2677 * @hide
2678 */
2679 public static final String ACTION_PRE_BOOT_COMPLETED =
2680 "android.intent.action.PRE_BOOT_COMPLETED";
2681
Amith Yamasani13593602012-03-22 16:16:17 -07002682 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002683 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002684 * on restricted users. The broadcast intent contains an extra
2685 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2686 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2687 * String[] depending on the restriction type.<p/>
2688 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002689 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2690 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2691 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002692 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2693 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002694 * @see RestrictionEntry
2695 */
2696 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2697 "android.intent.action.GET_RESTRICTION_ENTRIES";
2698
2699 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002700 * Sent the first time a user is starting, to allow system apps to
2701 * perform one time initialization. (This will not be seen by third
2702 * party applications because a newly initialized user does not have any
2703 * third party applications installed for it.) This is sent early in
2704 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002705 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2706 * broadcast, since it is part of a visible user interaction; be as quick
2707 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002708 */
2709 public static final String ACTION_USER_INITIALIZE =
2710 "android.intent.action.USER_INITIALIZE";
2711
2712 /**
2713 * Sent when a user switch is happening, causing the process's user to be
2714 * brought to the foreground. This is only sent to receivers registered
2715 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2716 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002717 * foreground. This is sent as a foreground
2718 * broadcast, since it is part of a visible user interaction; be as quick
2719 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002720 */
2721 public static final String ACTION_USER_FOREGROUND =
2722 "android.intent.action.USER_FOREGROUND";
2723
2724 /**
2725 * Sent when a user switch is happening, causing the process's user to be
2726 * sent to the background. This is only sent to receivers registered
2727 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2728 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002729 * background. This is sent as a foreground
2730 * broadcast, since it is part of a visible user interaction; be as quick
2731 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002732 */
2733 public static final String ACTION_USER_BACKGROUND =
2734 "android.intent.action.USER_BACKGROUND";
2735
2736 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002737 * Broadcast sent to the system when a user is added. Carries an extra
2738 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2739 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002740 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002741 * @hide
2742 */
2743 public static final String ACTION_USER_ADDED =
2744 "android.intent.action.USER_ADDED";
2745
2746 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002747 * Broadcast sent by the system when a user is started. Carries an extra
2748 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002749 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002750 * that has been started. This is sent as a foreground
2751 * broadcast, since it is part of a visible user interaction; be as quick
2752 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002753 * @hide
2754 */
2755 public static final String ACTION_USER_STARTED =
2756 "android.intent.action.USER_STARTED";
2757
2758 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002759 * Broadcast sent when a user is in the process of starting. Carries an extra
2760 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2761 * sent to registered receivers, not manifest receivers. It is sent to all
2762 * users (including the one that is being started). You must hold
2763 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2764 * this broadcast. This is sent as a background broadcast, since
2765 * its result is not part of the primary UX flow; to safely keep track of
2766 * started/stopped state of a user you can use this in conjunction with
2767 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2768 * other user state broadcasts since those are foreground broadcasts so can
2769 * execute in a different order.
2770 * @hide
2771 */
2772 public static final String ACTION_USER_STARTING =
2773 "android.intent.action.USER_STARTING";
2774
2775 /**
2776 * Broadcast sent when a user is going to be stopped. Carries an extra
2777 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2778 * sent to registered receivers, not manifest receivers. It is sent to all
2779 * users (including the one that is being stopped). You must hold
2780 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2781 * this broadcast. The user will not stop until all receivers have
2782 * handled the broadcast. This is sent as a background broadcast, since
2783 * its result is not part of the primary UX flow; to safely keep track of
2784 * started/stopped state of a user you can use this in conjunction with
2785 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2786 * other user state broadcasts since those are foreground broadcasts so can
2787 * execute in a different order.
2788 * @hide
2789 */
2790 public static final String ACTION_USER_STOPPING =
2791 "android.intent.action.USER_STOPPING";
2792
2793 /**
2794 * Broadcast sent to the system when a user is stopped. Carries an extra
2795 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2796 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2797 * specific package. This is only sent to registered receivers, not manifest
2798 * receivers. It is sent to all running users <em>except</em> the one that
2799 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002800 * @hide
2801 */
2802 public static final String ACTION_USER_STOPPED =
2803 "android.intent.action.USER_STOPPED";
2804
2805 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002806 * 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 -07002807 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002808 * one that has been removed. The user will not be completely removed until all receivers have
2809 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002810 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002811 * @hide
2812 */
2813 public static final String ACTION_USER_REMOVED =
2814 "android.intent.action.USER_REMOVED";
2815
2816 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002817 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002818 * the userHandle of the user to become the current one. This is only sent to
2819 * registered receivers, not manifest receivers. It is sent to all running users.
2820 * You must hold
2821 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002822 * @hide
2823 */
2824 public static final String ACTION_USER_SWITCHED =
2825 "android.intent.action.USER_SWITCHED";
2826
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002827 /**
2828 * Broadcast sent to the system when a user's information changes. Carries an extra
2829 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002830 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002831 * @hide
2832 */
2833 public static final String ACTION_USER_INFO_CHANGED =
2834 "android.intent.action.USER_INFO_CHANGED";
2835
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002836 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002837 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2838 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002839 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2840 * that need to display merged content across both primary and managed profiles need to
2841 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002842 * not manifest receivers.
2843 */
2844 public static final String ACTION_MANAGED_PROFILE_ADDED =
2845 "android.intent.action.MANAGED_PROFILE_ADDED";
2846
2847 /**
2848 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002849 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2850 * Only applications (for example Launchers) that need to display merged content across both
2851 * primary and managed profiles need to worry about this broadcast. This is only sent to
2852 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002853 */
2854 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2855 "android.intent.action.MANAGED_PROFILE_REMOVED";
2856
2857 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002858 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2859 */
2860 public static final String ACTION_QUICK_CLOCK =
2861 "android.intent.action.QUICK_CLOCK";
2862
Michael Wright0087a142013-02-05 16:29:39 -08002863 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002864 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002865 * @hide
2866 */
2867 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2868 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2869
Justin Kohd378ad72013-04-01 12:18:26 -07002870 /**
2871 * Broadcast Action: A global button was pressed. Includes a single
2872 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2873 * caused the broadcast.
2874 * @hide
2875 */
2876 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2877
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002878 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002879 * Activity Action: Allow the user to select and return one or more existing
2880 * documents. When invoked, the system will display the various
2881 * {@link DocumentsProvider} instances installed on the device, letting the
2882 * user interactively navigate through them. These documents include local
2883 * media, such as photos and video, and documents provided by installed
2884 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002885 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002886 * Each document is represented as a {@code content://} URI backed by a
2887 * {@link DocumentsProvider}, which can be opened as a stream with
2888 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2889 * {@link android.provider.DocumentsContract.Document} metadata.
2890 * <p>
2891 * All selected documents are returned to the calling application with
2892 * persistable read and write permission grants. If you want to maintain
2893 * access to the documents across device reboots, you need to explicitly
2894 * take the persistable permissions using
2895 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2896 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002897 * Callers must indicate the acceptable document MIME types through
2898 * {@link #setType(String)}. For example, to select photos, use
2899 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2900 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2901 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002902 * <p>
2903 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002904 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2905 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002906 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002907 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2908 * returned URIs can be opened with
2909 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002910 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002911 * Output: The URI of the item that was picked, returned in
2912 * {@link #getData()}. This must be a {@code content://} URI so that any
2913 * receiver can access it. If multiple documents were selected, they are
2914 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002915 *
2916 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002917 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002918 * @see #ACTION_CREATE_DOCUMENT
2919 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002920 */
2921 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2922 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2923
2924 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002925 * Activity Action: Allow the user to create a new document. When invoked,
2926 * the system will display the various {@link DocumentsProvider} instances
2927 * installed on the device, letting the user navigate through them. The
2928 * returned document may be a newly created document with no content, or it
2929 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002930 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002931 * Each document is represented as a {@code content://} URI backed by a
2932 * {@link DocumentsProvider}, which can be opened as a stream with
2933 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2934 * {@link android.provider.DocumentsContract.Document} metadata.
2935 * <p>
2936 * Callers must indicate the concrete MIME type of the document being
2937 * created by setting {@link #setType(String)}. This MIME type cannot be
2938 * changed after the document is created.
2939 * <p>
2940 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2941 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002942 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002943 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2944 * returned URIs can be opened with
2945 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002946 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002947 * Output: The URI of the item that was created. This must be a
2948 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002949 *
2950 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002951 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002952 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002953 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002954 */
2955 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2956 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2957
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002958 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002959 * Activity Action: Allow the user to pick a directory subtree. When
2960 * invoked, the system will display the various {@link DocumentsProvider}
2961 * instances installed on the device, letting the user navigate through
2962 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002963 * <p>
2964 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002965 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2966 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2967 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002968 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002969 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002970 *
2971 * @see DocumentsContract
2972 */
2973 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002974 public static final String
2975 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002976
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002977 /** {@hide} */
2978 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2979
Christopher Tate6597e342015-02-17 12:15:25 -08002980 /**
2981 * Broadcast action: report that a settings element is being restored from backup. The intent
2982 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
2983 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
2984 * is the value of that settings entry prior to the restore operation. All of these values are
2985 * represented as strings.
2986 *
2987 * <p>This broadcast is sent only for settings provider entries known to require special handling
2988 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
2989 * the provider's backup agent implementation.
2990 *
2991 * @see #EXTRA_SETTING_NAME
2992 * @see #EXTRA_SETTING_PREVIOUS_VALUE
2993 * @see #EXTRA_SETTING_NEW_VALUE
2994 * {@hide}
2995 */
2996 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
2997
2998 /** {@hide} */
2999 public static final String EXTRA_SETTING_NAME = "setting_name";
3000 /** {@hide} */
3001 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3002 /** {@hide} */
3003 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3004
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003005 /**
3006 * Activity Action: Process a piece of text.
3007 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3008 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3009 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3010 */
3011 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3012 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3013 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003014 * The name of the extra used to define the text to be processed, as a
3015 * CharSequence. Note that this may be a styled CharSequence, so you must use
3016 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003017 */
3018 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3019 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003020 * The name of the boolean extra used to define if the processed text will be used as read-only.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003021 */
3022 public static final String EXTRA_PROCESS_TEXT_READONLY =
3023 "android.intent.extra.PROCESS_TEXT_READONLY";
3024
Bryce Leebc58f592015-09-25 16:43:01 -07003025 /**
3026 * Broadcast action: reports when a new thermal event has been reached. When the device
3027 * is reaching its maximum temperatue, the thermal level reported
3028 * {@hide}
3029 */
3030 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3031 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3032
3033 /** {@hide} */
3034 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3035
3036 /**
3037 * Thermal state when the device is normal. This state is sent in the
3038 * {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}.
3039 * {@hide}
3040 */
3041 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3042
3043 /**
3044 * Thermal state where the device is approaching its maximum threshold. This state is sent in
3045 * the {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}.
3046 * {@hide}
3047 */
3048 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3049
3050 /**
3051 * Thermal state where the device has reached its maximum threshold. This state is sent in the
3052 * {@link ACTION_THERMAL_EVENT} broadcast as {@link EXTRA_THERMAL_STATE}.
3053 * {@hide}
3054 */
3055 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3056
3057
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003058 // ---------------------------------------------------------------------
3059 // ---------------------------------------------------------------------
3060 // Standard intent categories (see addCategory()).
3061
3062 /**
3063 * Set if the activity should be an option for the default action
3064 * (center press) to perform on a piece of data. Setting this will
3065 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003066 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003067 * Intent when initiating an action -- it is for use in intent filters
3068 * specified in packages.
3069 */
3070 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3071 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3072 /**
3073 * Activities that can be safely invoked from a browser must support this
3074 * category. For example, if the user is viewing a web page or an e-mail
3075 * and clicks on a link in the text, the Intent generated execute that
3076 * link will require the BROWSABLE category, so that only activities
3077 * supporting this category will be considered as possible actions. By
3078 * supporting this category, you are promising that there is nothing
3079 * damaging (without user intervention) that can happen by invoking any
3080 * matching Intent.
3081 */
3082 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3083 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3084 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003085 * Categories for activities that can participate in voice interaction.
3086 * An activity that supports this category must be prepared to run with
3087 * no UI shown at all (though in some case it may have a UI shown), and
3088 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3089 */
3090 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3091 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3092 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003093 * Set if the activity should be considered as an alternative action to
3094 * the data the user is currently viewing. See also
3095 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3096 * applies to the selection in a list of items.
3097 *
3098 * <p>Supporting this category means that you would like your activity to be
3099 * displayed in the set of alternative things the user can do, usually as
3100 * part of the current activity's options menu. You will usually want to
3101 * include a specific label in the &lt;intent-filter&gt; of this action
3102 * describing to the user what it does.
3103 *
3104 * <p>The action of IntentFilter with this category is important in that it
3105 * describes the specific action the target will perform. This generally
3106 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3107 * a specific name such as "com.android.camera.action.CROP. Only one
3108 * alternative of any particular action will be shown to the user, so using
3109 * a specific action like this makes sure that your alternative will be
3110 * displayed while also allowing other applications to provide their own
3111 * overrides of that particular action.
3112 */
3113 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3114 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3115 /**
3116 * Set if the activity should be considered as an alternative selection
3117 * action to the data the user has currently selected. This is like
3118 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3119 * of items from which the user can select, giving them alternatives to the
3120 * default action that will be performed on it.
3121 */
3122 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3123 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3124 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003125 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003126 */
3127 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3128 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3129 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003130 * Should be displayed in the top-level launcher.
3131 */
3132 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3133 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3134 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003135 * Indicates an activity optimized for Leanback mode, and that should
3136 * be displayed in the Leanback launcher.
3137 */
3138 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3139 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3140 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003141 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3142 * @hide
3143 */
3144 @SystemApi
3145 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3146 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003147 * Provides information about the package it is in; typically used if
3148 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3149 * a front-door to the user without having to be shown in the all apps list.
3150 */
3151 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3152 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3153 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003154 * This is the home activity, that is the first activity that is displayed
3155 * when the device boots.
3156 */
3157 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3158 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3159 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003160 * This is the home activity that is displayed when the device is finished setting up and ready
3161 * for use.
3162 * @hide
3163 */
3164 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3165 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3166 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003167 * This is the setup wizard activity, that is the first activity that is displayed
3168 * when the user sets up the device for the first time.
3169 * @hide
3170 */
3171 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3172 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3173 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003174 * This activity is a preference panel.
3175 */
3176 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3177 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3178 /**
3179 * This activity is a development preference panel.
3180 */
3181 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3182 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3183 /**
3184 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003185 */
3186 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3187 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3188 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003189 * This activity allows the user to browse and download new applications.
3190 */
3191 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3192 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3193 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003194 * This activity may be exercised by the monkey or other automated test tools.
3195 */
3196 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3197 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3198 /**
3199 * To be used as a test (not part of the normal user experience).
3200 */
3201 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3202 /**
3203 * To be used as a unit test (run through the Test Harness).
3204 */
3205 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3206 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003207 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003208 * experience).
3209 */
3210 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003211
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003212 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003213 * Used to indicate that an intent only wants URIs that can be opened with
3214 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3215 * must support at least the columns defined in {@link OpenableColumns} when
3216 * queried.
3217 *
3218 * @see #ACTION_GET_CONTENT
3219 * @see #ACTION_OPEN_DOCUMENT
3220 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003221 */
3222 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3223 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3224
3225 /**
3226 * To be used as code under test for framework instrumentation tests.
3227 */
3228 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3229 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003230 /**
3231 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003232 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3233 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003234 */
3235 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3236 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3237 /**
3238 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003239 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3240 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003241 */
3242 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3243 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003244 /**
3245 * An activity to run when device is inserted into a analog (low end) dock.
3246 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3247 * information, see {@link android.app.UiModeManager}.
3248 */
3249 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3250 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3251
3252 /**
3253 * An activity to run when device is inserted into a digital (high end) dock.
3254 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3255 * information, see {@link android.app.UiModeManager}.
3256 */
3257 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3258 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003259
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003260 /**
3261 * Used to indicate that the activity can be used in a car environment.
3262 */
3263 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3264 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3265
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003266 // ---------------------------------------------------------------------
3267 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003268 // Application launch intent categories (see addCategory()).
3269
3270 /**
3271 * Used with {@link #ACTION_MAIN} to launch the browser application.
3272 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003273 * <p>NOTE: This should not be used as the primary key of an Intent,
3274 * since it will not result in the app launching with the correct
3275 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003276 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003277 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003278 */
3279 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3280 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3281
3282 /**
3283 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3284 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003285 * <p>NOTE: This should not be used as the primary key of an Intent,
3286 * since it will not result in the app launching with the correct
3287 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003288 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003289 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003290 */
3291 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3292 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3293
3294 /**
3295 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3296 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003297 * <p>NOTE: This should not be used as the primary key of an Intent,
3298 * since it will not result in the app launching with the correct
3299 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003300 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003301 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003302 */
3303 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3304 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3305
3306 /**
3307 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3308 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003309 * <p>NOTE: This should not be used as the primary key of an Intent,
3310 * since it will not result in the app launching with the correct
3311 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003312 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003313 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003314 */
3315 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3316 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3317
3318 /**
3319 * Used with {@link #ACTION_MAIN} to launch the email application.
3320 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003321 * <p>NOTE: This should not be used as the primary key of an Intent,
3322 * since it will not result in the app launching with the correct
3323 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003324 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003325 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003326 */
3327 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3328 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3329
3330 /**
3331 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3332 * The activity should be able to view and manipulate image and video files
3333 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003334 * <p>NOTE: This should not be used as the primary key of an Intent,
3335 * since it will not result in the app launching with the correct
3336 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003337 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003338 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003339 */
3340 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3341 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3342
3343 /**
3344 * Used with {@link #ACTION_MAIN} to launch the maps application.
3345 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003346 * <p>NOTE: This should not be used as the primary key of an Intent,
3347 * since it will not result in the app launching with the correct
3348 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003349 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003350 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003351 */
3352 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3353 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3354
3355 /**
3356 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3357 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003358 * <p>NOTE: This should not be used as the primary key of an Intent,
3359 * since it will not result in the app launching with the correct
3360 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003361 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003362 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003363 */
3364 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3365 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3366
3367 /**
3368 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003369 * The activity should be able to play, browse, or manipulate music files
3370 * stored on the device.
3371 * <p>NOTE: This should not be used as the primary key of an Intent,
3372 * since it will not result in the app launching with the correct
3373 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003374 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003375 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003376 */
3377 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3378 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3379
3380 // ---------------------------------------------------------------------
3381 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003382 // Standard extra data keys.
3383
3384 /**
3385 * The initial data to place in a newly created record. Use with
3386 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3387 * fields as would be given to the underlying ContentProvider.insert()
3388 * call.
3389 */
3390 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3391
3392 /**
3393 * A constant CharSequence that is associated with the Intent, used with
3394 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3395 * this may be a styled CharSequence, so you must use
3396 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3397 * retrieve it.
3398 */
3399 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3400
3401 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003402 * A constant String that is associated with the Intent, used with
3403 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3404 * as HTML formatted text. Note that you <em>must</em> also supply
3405 * {@link #EXTRA_TEXT}.
3406 */
3407 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3408
3409 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003410 * A content: URI holding a stream of data associated with the Intent,
3411 * used with {@link #ACTION_SEND} to supply the data being sent.
3412 */
3413 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3414
3415 /**
3416 * A String[] holding e-mail addresses that should be delivered to.
3417 */
3418 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3419
3420 /**
3421 * A String[] holding e-mail addresses that should be carbon copied.
3422 */
3423 public static final String EXTRA_CC = "android.intent.extra.CC";
3424
3425 /**
3426 * A String[] holding e-mail addresses that should be blind carbon copied.
3427 */
3428 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3429
3430 /**
3431 * A constant string holding the desired subject line of a message.
3432 */
3433 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3434
3435 /**
3436 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003437 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003438 */
3439 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3440
3441 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003442 * An Intent[] describing additional, alternate choices you would like shown with
3443 * {@link #ACTION_CHOOSER}.
3444 *
3445 * <p>An app may be capable of providing several different payload types to complete a
3446 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3447 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3448 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3449 * photo data or a hosted link where the photos can be viewed.</p>
3450 *
3451 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3452 * first/primary/preferred intent in the set. Additional intents specified in
3453 * this extra are ordered; by default intents that appear earlier in the array will be
3454 * preferred over intents that appear later in the array as matches for the same
3455 * target component. To alter this preference, a calling app may also supply
3456 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3457 */
3458 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3459
3460 /**
3461 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3462 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3463 *
3464 * <p>An app preparing an action for another app to complete may wish to allow the user to
3465 * disambiguate between several options for completing the action based on the chosen target
3466 * or otherwise refine the action before it is invoked.
3467 * </p>
3468 *
3469 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3470 * <ul>
3471 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3472 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3473 * chosen target beyond the first</li>
3474 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3475 * should fill in and send once the disambiguation is complete</li>
3476 * </ul>
3477 */
3478 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3479 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3480
3481 /**
3482 * A {@link ResultReceiver} used to return data back to the sender.
3483 *
3484 * <p>Used to complete an app-specific
3485 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3486 *
3487 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3488 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3489 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3490 * when the user selects a target component from the chooser. It is up to the recipient
3491 * to send a result to this ResultReceiver to signal that disambiguation is complete
3492 * and that the chooser should invoke the user's choice.</p>
3493 *
3494 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3495 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3496 * to match and fill in the final Intent or ChooserTarget before starting it.
3497 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3498 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3499 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3500 *
3501 * <p>The result code passed to the ResultReceiver should be
3502 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3503 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3504 * the chooser should finish without starting a target.</p>
3505 */
3506 public static final String EXTRA_RESULT_RECEIVER
3507 = "android.intent.extra.RESULT_RECEIVER";
3508
3509 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003510 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003511 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003512 */
3513 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3514
3515 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003516 * A Parcelable[] of {@link Intent} or
3517 * {@link android.content.pm.LabeledIntent} objects as set with
3518 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3519 * a the front of the list of choices, when shown to the user with a
3520 * {@link #ACTION_CHOOSER}.
3521 */
3522 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3523
3524 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003525 * A Bundle forming a mapping of potential target package names to different extras Bundles
3526 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3527 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3528 * be currently installed on the device.
3529 *
3530 * <p>An application may choose to provide alternate extras for the case where a user
3531 * selects an activity from a predetermined set of target packages. If the activity
3532 * the user selects from the chooser belongs to a package with its package name as
3533 * a key in this bundle, the corresponding extras for that package will be merged with
3534 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3535 * extra has the same key as an extra already present in the intent it will overwrite
3536 * the extra from the intent.</p>
3537 *
3538 * <p><em>Examples:</em>
3539 * <ul>
3540 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3541 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3542 * parameters for that target.</li>
3543 * <li>An application may offer additional metadata for known targets of a given intent
3544 * to pass along information only relevant to that target such as account or content
3545 * identifiers already known to that application.</li>
3546 * </ul></p>
3547 */
3548 public static final String EXTRA_REPLACEMENT_EXTRAS =
3549 "android.intent.extra.REPLACEMENT_EXTRAS";
3550
3551 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003552 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3553 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3554 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3555 * {@link ComponentName} of the chosen component.
3556 *
3557 * <p>In some situations this callback may never come, for example if the user abandons
3558 * the chooser, switches to another task or any number of other reasons. Apps should not
3559 * be written assuming that this callback will always occur.</p>
3560 */
3561 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3562 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3563
3564 /**
3565 * The {@link ComponentName} chosen by the user to complete an action.
3566 *
3567 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3568 */
3569 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3570
3571 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003572 * A {@link android.view.KeyEvent} object containing the event that
3573 * triggered the creation of the Intent it is in.
3574 */
3575 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3576
3577 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003578 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3579 * before shutting down.
3580 *
3581 * {@hide}
3582 */
3583 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3584
3585 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003586 * 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 -07003587 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3588 * of restarting the application.
3589 */
3590 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3591
3592 /**
3593 * A String holding the phone number originally entered in
3594 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3595 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3596 */
3597 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003598
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003599 /**
3600 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3601 * intents to supply the uid the package had been assigned. Also an optional
3602 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3603 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3604 * purpose.
3605 */
3606 public static final String EXTRA_UID = "android.intent.extra.UID";
3607
3608 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003609 * @hide String array of package names.
3610 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003611 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003612 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3613
3614 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003615 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3616 * intents to indicate whether this represents a full uninstall (removing
3617 * both the code and its data) or a partial uninstall (leaving its data,
3618 * implying that this is an update).
3619 */
3620 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003621
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003622 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003623 * @hide
3624 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3625 * intents to indicate that at this point the package has been removed for
3626 * all users on the device.
3627 */
3628 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3629 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3630
3631 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003632 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3633 * intents to indicate that this is a replacement of the package, so this
3634 * broadcast will immediately be followed by an add broadcast for a
3635 * different version of the same package.
3636 */
3637 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003638
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003639 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003640 * Used as an int extra field in {@link android.app.AlarmManager} intents
3641 * to tell the application being invoked how many pending alarms are being
3642 * delievered with the intent. For one-shot alarms this will always be 1.
3643 * For recurring alarms, this might be greater than 1 if the device was
3644 * asleep or powered off at the time an earlier alarm would have been
3645 * delivered.
3646 */
3647 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003648
Jacek Surazski86b6c532009-05-13 14:38:28 +02003649 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003650 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3651 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003652 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3653 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003654 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3655 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3656 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003657 */
3658 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3659
3660 /**
3661 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3662 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003663 */
3664 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3665
3666 /**
3667 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3668 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003669 */
3670 public static final int EXTRA_DOCK_STATE_DESK = 1;
3671
3672 /**
3673 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3674 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003675 */
3676 public static final int EXTRA_DOCK_STATE_CAR = 2;
3677
3678 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003679 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3680 * to represent that the phone is in a analog (low end) dock.
3681 */
3682 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3683
3684 /**
3685 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3686 * to represent that the phone is in a digital (high end) dock.
3687 */
3688 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3689
3690 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003691 * Boolean that can be supplied as meta-data with a dock activity, to
3692 * indicate that the dock should take over the home key when it is active.
3693 */
3694 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003695
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003696 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003697 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3698 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003699 */
3700 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3701
3702 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003703 * Used in the extra field in the remote intent. It's astring token passed with the
3704 * remote intent.
3705 */
3706 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3707 "android.intent.extra.remote_intent_token";
3708
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003709 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003710 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003711 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003712 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003713 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003714 "android.intent.extra.changed_component_name";
3715
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003716 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003717 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003718 * and contains a string array of all of the components that have changed. If
3719 * the state of the overall package has changed, then it will contain an entry
3720 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003721 */
3722 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3723 "android.intent.extra.changed_component_name_list";
3724
3725 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003726 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003727 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3728 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003729 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003730 */
3731 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3732 "android.intent.extra.changed_package_list";
3733
3734 /**
3735 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003736 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3737 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003738 * and contains an integer array of uids of all of the components
3739 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003740 */
3741 public static final String EXTRA_CHANGED_UID_LIST =
3742 "android.intent.extra.changed_uid_list";
3743
3744 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003745 * @hide
3746 * Magic extra system code can use when binding, to give a label for
3747 * who it is that has bound to a service. This is an integer giving
3748 * a framework string resource that can be displayed to the user.
3749 */
3750 public static final String EXTRA_CLIENT_LABEL =
3751 "android.intent.extra.client_label";
3752
3753 /**
3754 * @hide
3755 * Magic extra system code can use when binding, to give a PendingIntent object
3756 * that can be launched for the user to disable the system's use of this
3757 * service.
3758 */
3759 public static final String EXTRA_CLIENT_INTENT =
3760 "android.intent.extra.client_intent";
3761
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003762 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003763 * Extra used to indicate that an intent should only return data that is on
3764 * the local device. This is a boolean extra; the default is false. If true,
3765 * an implementation should only allow the user to select data that is
3766 * already on the device, not requiring it be downloaded from a remote
3767 * service when opened.
3768 *
3769 * @see #ACTION_GET_CONTENT
3770 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003771 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003772 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003773 */
3774 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003775 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003776
Amith Yamasani13593602012-03-22 16:16:17 -07003777 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003778 * Extra used to indicate that an intent can allow the user to select and
3779 * return multiple items. This is a boolean extra; the default is false. If
3780 * true, an implementation is allowed to present the user with a UI where
3781 * they can pick multiple items that are all returned to the caller. When
3782 * this happens, they should be returned as the {@link #getClipData()} part
3783 * of the result Intent.
3784 *
3785 * @see #ACTION_GET_CONTENT
3786 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003787 */
3788 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003789 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003790
3791 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003792 * The integer userHandle carried with broadcast intents related to addition, removal and
3793 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3794 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3795 *
Amith Yamasani13593602012-03-22 16:16:17 -07003796 * @hide
3797 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003798 public static final String EXTRA_USER_HANDLE =
3799 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003800
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003801 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003802 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3803 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3804 */
3805 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003806 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003807
3808 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003809 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003810 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3811 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003812 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003813 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3814
3815 /**
3816 * Extra sent in the intent to the BroadcastReceiver that handles
3817 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3818 * the restrictions as key/value pairs.
3819 */
3820 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3821 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003822
Amith Yamasani86118ba2013-03-28 14:33:16 -07003823 /**
3824 * Extra used in the response from a BroadcastReceiver that handles
3825 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3826 */
3827 public static final String EXTRA_RESTRICTIONS_INTENT =
3828 "android.intent.extra.restrictions_intent";
3829
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003830 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003831 * Extra used to communicate a set of acceptable MIME types. The type of the
3832 * extra is {@code String[]}. Values may be a combination of concrete MIME
3833 * types (such as "image/png") and/or partial MIME types (such as
3834 * "audio/*").
3835 *
3836 * @see #ACTION_GET_CONTENT
3837 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003838 */
3839 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3840
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003841 /**
3842 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3843 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003844 * When this is true, hardware devices can use this information to determine that
3845 * they shouldn't do a complete shutdown of their device since this is not a
3846 * complete shutdown down to the kernel, but only user space restarting.
3847 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003848 */
3849 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3850 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3851
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003852 /**
3853 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3854 * user has set their time format preferences to the 24 hour format.
3855 *
3856 * @hide for internal use only.
3857 */
3858 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3859 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3860
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003861 /** {@hide} */
3862 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3863
Rubin Xue8490f12015-06-25 12:17:48 +01003864 /** {@hide} */
3865 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
3866
Santos Cordon15a13782015-03-31 18:32:31 -07003867 /**
3868 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3869 * activation request.
3870 * TODO: Add information about the structure and response data used with the pending intent.
3871 * @hide
3872 */
3873 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3874 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3875
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003876 // ---------------------------------------------------------------------
3877 // ---------------------------------------------------------------------
3878 // Intent flags (see mFlags variable).
3879
Tor Norbyed9273d62013-05-30 15:59:53 -07003880 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003881 @IntDef(flag = true, value = {
3882 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3883 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003884 @Retention(RetentionPolicy.SOURCE)
3885 public @interface GrantUriMode {}
3886
Jeff Sharkey846318a2014-04-04 12:12:41 -07003887 /** @hide */
3888 @IntDef(flag = true, value = {
3889 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3890 @Retention(RetentionPolicy.SOURCE)
3891 public @interface AccessUriMode {}
3892
3893 /**
3894 * Test if given mode flags specify an access mode, which must be at least
3895 * read and/or write.
3896 *
3897 * @hide
3898 */
3899 public static boolean isAccessUriMode(int modeFlags) {
3900 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3901 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3902 }
3903
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003904 /**
3905 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003906 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003907 * specified in its ClipData. When applying to an Intent's ClipData,
3908 * all URIs as well as recursive traversals through data or other ClipData
3909 * in Intent items will be granted; only the grant flags of the top-level
3910 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003911 */
3912 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3913 /**
3914 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003915 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003916 * specified in its ClipData. When applying to an Intent's ClipData,
3917 * all URIs as well as recursive traversals through data or other ClipData
3918 * in Intent items will be granted; only the grant flags of the top-level
3919 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003920 */
3921 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3922 /**
3923 * Can be set by the caller to indicate that this Intent is coming from
3924 * a background operation, not from direct user interaction.
3925 */
3926 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3927 /**
3928 * A flag you can enable for debugging: when set, log messages will be
3929 * printed during the resolution of this intent to show you what has
3930 * been found to create the final resolved list.
3931 */
3932 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003933 /**
3934 * If set, this intent will not match any components in packages that
3935 * are currently stopped. If this is not set, then the default behavior
3936 * is to include such applications in the result.
3937 */
3938 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3939 /**
3940 * If set, this intent will always match any components in packages that
3941 * are currently stopped. This is the default behavior when
3942 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3943 * flags are set, this one wins (it allows overriding of exclude for
3944 * places where the framework may automatically set the exclude flag).
3945 */
3946 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003947
3948 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003949 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003950 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003951 * persisted across device reboots until explicitly revoked with
3952 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3953 * grant for possible persisting; the receiving application must call
3954 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3955 * actually persist.
3956 *
3957 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3958 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3959 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003960 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003961 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003962 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003963
3964 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003965 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3966 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3967 * applies to any URI that is a prefix match against the original granted
3968 * URI. (Without this flag, the URI must match exactly for access to be
3969 * granted.) Another URI is considered a prefix match only when scheme,
3970 * authority, and all path segments defined by the prefix are an exact
3971 * match.
3972 */
3973 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3974
3975 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003976 * If set, the new activity is not kept in the history stack. As soon as
3977 * the user navigates away from it, the activity is finished. This may also
3978 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3979 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003980 *
3981 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3982 * is never invoked when the current activity starts a new activity which
3983 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003984 */
3985 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3986 /**
3987 * If set, the activity will not be launched if it is already running
3988 * at the top of the history stack.
3989 */
3990 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3991 /**
3992 * If set, this activity will become the start of a new task on this
3993 * history stack. A task (from the activity that started it to the
3994 * next task activity) defines an atomic group of activities that the
3995 * user can move to. Tasks can be moved to the foreground and background;
3996 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003997 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003998 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3999 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004000 *
4001 * <p>This flag is generally used by activities that want
4002 * to present a "launcher" style behavior: they give the user a list of
4003 * separate things that can be done, which otherwise run completely
4004 * independently of the activity launching them.
4005 *
4006 * <p>When using this flag, if a task is already running for the activity
4007 * you are now starting, then a new activity will not be started; instead,
4008 * the current task will simply be brought to the front of the screen with
4009 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4010 * to disable this behavior.
4011 *
4012 * <p>This flag can not be used when the caller is requesting a result from
4013 * the activity being launched.
4014 */
4015 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4016 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004017 * This flag is used to create a new task and launch an activity into it.
4018 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4019 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4020 * search through existing tasks for ones matching this Intent. Only if no such
4021 * task is found would a new task be created. When paired with
4022 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4023 * the search for a matching task and unconditionally start a new task.
4024 *
4025 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4026 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004027 * top-level application launcher.</strong> Used in conjunction with
4028 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4029 * behavior of bringing an existing task to the foreground. When set,
4030 * a new task is <em>always</em> started to host the Activity for the
4031 * Intent, regardless of whether there is already an existing task running
4032 * the same thing.
4033 *
4034 * <p><strong>Because the default system does not include graphical task management,
4035 * you should not use this flag unless you provide some way for a user to
4036 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004037 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004038 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4039 * creating new document tasks.
4040 *
4041 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004042 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004043 *
Scott Main7aee61f2011-02-08 11:25:01 -08004044 * <p>See
4045 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4046 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004047 *
4048 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4049 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004050 */
4051 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4052 /**
4053 * If set, and the activity being launched is already running in the
4054 * current task, then instead of launching a new instance of that activity,
4055 * all of the other activities on top of it will be closed and this Intent
4056 * will be delivered to the (now on top) old activity as a new Intent.
4057 *
4058 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4059 * If D calls startActivity() with an Intent that resolves to the component
4060 * of activity B, then C and D will be finished and B receive the given
4061 * Intent, resulting in the stack now being: A, B.
4062 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004063 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004064 * either receive the new intent you are starting here in its
4065 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004066 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004067 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4068 * the same intent, then it will be finished and re-created; for all other
4069 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4070 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004071 *
4072 * <p>This launch mode can also be used to good effect in conjunction with
4073 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4074 * of a task, it will bring any currently running instance of that task
4075 * to the foreground, and then clear it to its root state. This is
4076 * especially useful, for example, when launching an activity from the
4077 * notification manager.
4078 *
Scott Main7aee61f2011-02-08 11:25:01 -08004079 * <p>See
4080 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4081 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004082 */
4083 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4084 /**
4085 * If set and this intent is being used to launch a new activity from an
4086 * existing one, then the reply target of the existing activity will be
4087 * transfered to the new activity. This way the new activity can call
4088 * {@link android.app.Activity#setResult} and have that result sent back to
4089 * the reply target of the original activity.
4090 */
4091 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4092 /**
4093 * If set and this intent is being used to launch a new activity from an
4094 * existing one, the current activity will not be counted as the top
4095 * activity for deciding whether the new intent should be delivered to
4096 * the top instead of starting a new one. The previous activity will
4097 * be used as the top, with the assumption being that the current activity
4098 * will finish itself immediately.
4099 */
4100 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4101 /**
4102 * If set, the new activity is not kept in the list of recently launched
4103 * activities.
4104 */
4105 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4106 /**
4107 * This flag is not normally set by application code, but set for you by
4108 * the system as described in the
4109 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4110 * launchMode} documentation for the singleTask mode.
4111 */
4112 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4113 /**
4114 * If set, and this activity is either being started in a new task or
4115 * bringing to the top an existing task, then it will be launched as
4116 * the front door of the task. This will result in the application of
4117 * any affinities needed to have that task in the proper state (either
4118 * moving activities to or from it), or simply resetting that task to
4119 * its initial state if needed.
4120 */
4121 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4122 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004123 * This flag is not normally set by application code, but set for you by
4124 * the system if this activity is being launched from history
4125 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004126 */
4127 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004128 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004129 * @deprecated As of API 21 this performs identically to
4130 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004131 */
4132 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004133 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004134 * This flag is used to open a document into a new task rooted at the activity launched
4135 * by this Intent. Through the use of this flag, or its equivalent attribute,
4136 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004137 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004138 *
Craig Mautner026596b2014-05-21 15:35:44 -07004139 * <p>The use of the activity attribute form of this,
4140 * {@link android.R.attr#documentLaunchMode}, is
4141 * preferred over the Intent flag described here. The attribute form allows the
4142 * Activity to specify multiple document behavior for all launchers of the Activity
4143 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004144 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004145 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4146 * it is kept after the activity is finished is different than the use of
4147 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4148 * this flag is being used to create a new recents entry, then by default that entry
4149 * will be removed once the activity is finished. You can modify this behavior with
4150 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4151 *
Craig Mautner026596b2014-05-21 15:35:44 -07004152 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4153 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4154 * equivalent of the Activity manifest specifying {@link
4155 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4156 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4157 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004158 *
Craig Mautner026596b2014-05-21 15:35:44 -07004159 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004160 *
Craig Mautner026596b2014-05-21 15:35:44 -07004161 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004162 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4163 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004164 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004165 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004166 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004167 * callback from occurring on the current frontmost activity before it is
4168 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004169 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004170 * <p>Typically, an activity can rely on that callback to indicate that an
4171 * explicit user action has caused their activity to be moved out of the
4172 * foreground. The callback marks an appropriate point in the activity's
4173 * lifecycle for it to dismiss any notifications that it intends to display
4174 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004175 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004176 * <p>If an activity is ever started via any non-user-driven events such as
4177 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4178 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004179 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004180 */
4181 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004182 /**
4183 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4184 * this flag will cause the launched activity to be brought to the front of its
4185 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004186 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004187 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4188 * If D calls startActivity() with an Intent that resolves to the component
4189 * of activity B, then B will be brought to the front of the history stack,
4190 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004191 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004192 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004193 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004194 */
4195 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004196 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004197 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4198 * this flag will prevent the system from applying an activity transition
4199 * animation to go to the next activity state. This doesn't mean an
4200 * animation will never run -- if another activity change happens that doesn't
4201 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004202 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004203 * when you are going to do a series of activity operations but the
4204 * animation seen by the user shouldn't be driven by the first activity
4205 * change but rather a later one.
4206 */
4207 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4208 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004209 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4210 * this flag will cause any existing task that would be associated with the
4211 * activity to be cleared before the activity is started. That is, the activity
4212 * becomes the new root of an otherwise empty task, and any old activities
4213 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4214 */
4215 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4216 /**
4217 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4218 * this flag will cause a newly launching task to be placed on top of the current
4219 * home activity task (if there is one). That is, pressing back from the task
4220 * will always return the user to home even if that was not the last activity they
4221 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4222 */
4223 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4224 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004225 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4226 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004227 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004228 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004229 * this flag. When set and the task's activity is finished, the recents
4230 * entry will remain in the interface for the user to re-launch it, like a
4231 * recents entry for a top-level application.
4232 * <p>
4233 * The receiving activity can override this request with
4234 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4235 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004236 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004237 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004238 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004239
4240 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004241 * If set, when sending a broadcast only registered receivers will be
4242 * called -- no BroadcastReceiver components will be launched.
4243 */
4244 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004245 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004246 * If set, when sending a broadcast the new broadcast will replace
4247 * any existing pending broadcast that matches it. Matching is defined
4248 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4249 * true for the intents of the two broadcasts. When a match is found,
4250 * the new broadcast (and receivers associated with it) will replace the
4251 * existing one in the pending broadcast list, remaining at the same
4252 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004253 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004254 * <p>This flag is most typically used with sticky broadcasts, which
4255 * only care about delivering the most recent values of the broadcast
4256 * to their receivers.
4257 */
4258 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4259 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004260 * If set, when sending a broadcast the recipient is allowed to run at
4261 * foreground priority, with a shorter timeout interval. During normal
4262 * broadcasts the receivers are not automatically hoisted out of the
4263 * background priority class.
4264 */
4265 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4266 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004267 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4268 * They can still propagate results through to later receivers, but they can not prevent
4269 * later receivers from seeing the broadcast.
4270 */
4271 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4272 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004273 * If set, when sending a broadcast <i>before boot has completed</i> only
4274 * registered receivers will be called -- no BroadcastReceiver components
4275 * will be launched. Sticky intent state will be recorded properly even
4276 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4277 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004278 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004279 * <p>This flag is only for use by system sevices as a convenience to
4280 * avoid having to implement a more complex mechanism around detection
4281 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004282 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004283 * @hide
4284 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004285 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004286 /**
4287 * Set when this broadcast is for a boot upgrade, a special mode that
4288 * allows the broadcast to be sent before the system is ready and launches
4289 * the app process with no providers running in it.
4290 * @hide
4291 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004292 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004293
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004294 /**
4295 * @hide Flags that can't be changed with PendingIntent.
4296 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004297 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4298 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4299 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004300
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004301 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004302 // ---------------------------------------------------------------------
4303 // toUri() and parseUri() options.
4304
4305 /**
4306 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4307 * always has the "intent:" scheme. This syntax can be used when you want
4308 * to later disambiguate between URIs that are intended to describe an
4309 * Intent vs. all others that should be treated as raw URIs. When used
4310 * with {@link #parseUri}, any other scheme will result in a generic
4311 * VIEW action for that raw URI.
4312 */
4313 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004314
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004315 /**
4316 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4317 * always has the "android-app:" scheme. This is a variation of
4318 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4319 * http/https URI being delivered to a specific package name. The format
4320 * is:
4321 *
4322 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004323 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004324 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004325 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4326 * you must also include a scheme; including a path also requires both a host and a scheme.
4327 * The final #Intent; fragment can be used without a scheme, host, or path.
4328 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004329 * used with intents that have a {@link #setSelector}, since the base intent
4330 * will always have an explicit package name.</p>
4331 *
4332 * <p>Some examples of how this scheme maps to Intent objects:</p>
4333 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4334 * <colgroup align="left" />
4335 * <colgroup align="left" />
4336 * <thead>
4337 * <tr><th>URI</th> <th>Intent</th></tr>
4338 * </thead>
4339 *
4340 * <tbody>
4341 * <tr><td><code>android-app://com.example.app</code></td>
4342 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4343 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4344 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4345 * </table></td>
4346 * </tr>
4347 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4348 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4349 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4350 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4351 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4352 * </table></td>
4353 * </tr>
4354 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4355 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4356 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4357 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4358 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4359 * </table></td>
4360 * </tr>
4361 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4362 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4363 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4364 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4365 * </table></td>
4366 * </tr>
4367 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4368 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4369 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4370 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4371 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4372 * </table></td>
4373 * </tr>
4374 * <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>
4375 * <td><table border="" style="margin:0" >
4376 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4377 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4378 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4379 * </table></td>
4380 * </tr>
4381 * </tbody>
4382 * </table>
4383 */
4384 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4385
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004386 /**
4387 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4388 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4389 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4390 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4391 * generated Intent can not cause unexpected data access to happen.
4392 *
4393 * <p>If you do not trust the source of the URI being parsed, you should still do further
4394 * processing to protect yourself from it. In particular, when using it to start an
4395 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4396 * that can handle it.</p>
4397 */
4398 public static final int URI_ALLOW_UNSAFE = 1<<2;
4399
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004400 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004401
4402 private String mAction;
4403 private Uri mData;
4404 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004405 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004406 private ComponentName mComponent;
4407 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004408 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004409 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004410 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004411 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004412 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004413 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004414
4415 // ---------------------------------------------------------------------
4416
4417 /**
4418 * Create an empty intent.
4419 */
4420 public Intent() {
4421 }
4422
4423 /**
4424 * Copy constructor.
4425 */
4426 public Intent(Intent o) {
4427 this.mAction = o.mAction;
4428 this.mData = o.mData;
4429 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004430 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004431 this.mComponent = o.mComponent;
4432 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004433 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004434 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004435 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004436 }
4437 if (o.mExtras != null) {
4438 this.mExtras = new Bundle(o.mExtras);
4439 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004440 if (o.mSourceBounds != null) {
4441 this.mSourceBounds = new Rect(o.mSourceBounds);
4442 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004443 if (o.mSelector != null) {
4444 this.mSelector = new Intent(o.mSelector);
4445 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004446 if (o.mClipData != null) {
4447 this.mClipData = new ClipData(o.mClipData);
4448 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004449 }
4450
4451 @Override
4452 public Object clone() {
4453 return new Intent(this);
4454 }
4455
4456 private Intent(Intent o, boolean all) {
4457 this.mAction = o.mAction;
4458 this.mData = o.mData;
4459 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004460 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004461 this.mComponent = o.mComponent;
4462 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004463 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004464 }
4465 }
4466
4467 /**
4468 * Make a clone of only the parts of the Intent that are relevant for
4469 * filter matching: the action, data, type, component, and categories.
4470 */
4471 public Intent cloneFilter() {
4472 return new Intent(this, false);
4473 }
4474
4475 /**
4476 * Create an intent with a given action. All other fields (data, type,
4477 * class) are null. Note that the action <em>must</em> be in a
4478 * namespace because Intents are used globally in the system -- for
4479 * example the system VIEW action is android.intent.action.VIEW; an
4480 * application's custom action would be something like
4481 * com.google.app.myapp.CUSTOM_ACTION.
4482 *
4483 * @param action The Intent action, such as ACTION_VIEW.
4484 */
4485 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004486 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004487 }
4488
4489 /**
4490 * Create an intent with a given action and for a given data url. Note
4491 * that the action <em>must</em> be in a namespace because Intents are
4492 * used globally in the system -- for example the system VIEW action is
4493 * android.intent.action.VIEW; an application's custom action would be
4494 * something like com.google.app.myapp.CUSTOM_ACTION.
4495 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004496 * <p><em>Note: scheme and host name matching in the Android framework is
4497 * case-sensitive, unlike the formal RFC. As a result,
4498 * you should always ensure that you write your Uri with these elements
4499 * using lower case letters, and normalize any Uris you receive from
4500 * outside of Android to ensure the scheme and host is lower case.</em></p>
4501 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004502 * @param action The Intent action, such as ACTION_VIEW.
4503 * @param uri The Intent data URI.
4504 */
4505 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004506 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004507 mData = uri;
4508 }
4509
4510 /**
4511 * Create an intent for a specific component. All other fields (action, data,
4512 * type, class) are null, though they can be modified later with explicit
4513 * calls. This provides a convenient way to create an intent that is
4514 * intended to execute a hard-coded class name, rather than relying on the
4515 * system to find an appropriate class for you; see {@link #setComponent}
4516 * for more information on the repercussions of this.
4517 *
4518 * @param packageContext A Context of the application package implementing
4519 * this class.
4520 * @param cls The component class that is to be used for the intent.
4521 *
4522 * @see #setClass
4523 * @see #setComponent
4524 * @see #Intent(String, android.net.Uri , Context, Class)
4525 */
4526 public Intent(Context packageContext, Class<?> cls) {
4527 mComponent = new ComponentName(packageContext, cls);
4528 }
4529
4530 /**
4531 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004532 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004533 * construct the Intent and then calling {@link #setClass} to set its
4534 * class.
4535 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004536 * <p><em>Note: scheme and host name matching in the Android framework is
4537 * case-sensitive, unlike the formal RFC. As a result,
4538 * you should always ensure that you write your Uri with these elements
4539 * using lower case letters, and normalize any Uris you receive from
4540 * outside of Android to ensure the scheme and host is lower case.</em></p>
4541 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004542 * @param action The Intent action, such as ACTION_VIEW.
4543 * @param uri The Intent data URI.
4544 * @param packageContext A Context of the application package implementing
4545 * this class.
4546 * @param cls The component class that is to be used for the intent.
4547 *
4548 * @see #Intent(String, android.net.Uri)
4549 * @see #Intent(Context, Class)
4550 * @see #setClass
4551 * @see #setComponent
4552 */
4553 public Intent(String action, Uri uri,
4554 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004555 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004556 mData = uri;
4557 mComponent = new ComponentName(packageContext, cls);
4558 }
4559
4560 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004561 * Create an intent to launch the main (root) activity of a task. This
4562 * is the Intent that is started when the application's is launched from
4563 * Home. For anything else that wants to launch an application in the
4564 * same way, it is important that they use an Intent structured the same
4565 * way, and can use this function to ensure this is the case.
4566 *
4567 * <p>The returned Intent has the given Activity component as its explicit
4568 * component, {@link #ACTION_MAIN} as its action, and includes the
4569 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4570 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4571 * to do that through {@link #addFlags(int)} on the returned Intent.
4572 *
4573 * @param mainActivity The main activity component that this Intent will
4574 * launch.
4575 * @return Returns a newly created Intent that can be used to launch the
4576 * activity as a main application entry.
4577 *
4578 * @see #setClass
4579 * @see #setComponent
4580 */
4581 public static Intent makeMainActivity(ComponentName mainActivity) {
4582 Intent intent = new Intent(ACTION_MAIN);
4583 intent.setComponent(mainActivity);
4584 intent.addCategory(CATEGORY_LAUNCHER);
4585 return intent;
4586 }
4587
4588 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004589 * Make an Intent for the main activity of an application, without
4590 * specifying a specific activity to run but giving a selector to find
4591 * the activity. This results in a final Intent that is structured
4592 * the same as when the application is launched from
4593 * Home. For anything else that wants to launch an application in the
4594 * same way, it is important that they use an Intent structured the same
4595 * way, and can use this function to ensure this is the case.
4596 *
4597 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4598 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4599 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4600 * to do that through {@link #addFlags(int)} on the returned Intent.
4601 *
4602 * @param selectorAction The action name of the Intent's selector.
4603 * @param selectorCategory The name of a category to add to the Intent's
4604 * selector.
4605 * @return Returns a newly created Intent that can be used to launch the
4606 * activity as a main application entry.
4607 *
4608 * @see #setSelector(Intent)
4609 */
4610 public static Intent makeMainSelectorActivity(String selectorAction,
4611 String selectorCategory) {
4612 Intent intent = new Intent(ACTION_MAIN);
4613 intent.addCategory(CATEGORY_LAUNCHER);
4614 Intent selector = new Intent();
4615 selector.setAction(selectorAction);
4616 selector.addCategory(selectorCategory);
4617 intent.setSelector(selector);
4618 return intent;
4619 }
4620
4621 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004622 * Make an Intent that can be used to re-launch an application's task
4623 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4624 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4625 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4626 *
4627 * @param mainActivity The activity component that is the root of the
4628 * task; this is the activity that has been published in the application's
4629 * manifest as the main launcher icon.
4630 *
4631 * @return Returns a newly created Intent that can be used to relaunch the
4632 * activity's task in its root state.
4633 */
4634 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4635 Intent intent = makeMainActivity(mainActivity);
4636 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4637 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4638 return intent;
4639 }
4640
4641 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004642 * Call {@link #parseUri} with 0 flags.
4643 * @deprecated Use {@link #parseUri} instead.
4644 */
4645 @Deprecated
4646 public static Intent getIntent(String uri) throws URISyntaxException {
4647 return parseUri(uri, 0);
4648 }
Tom Taylord4a47292009-12-21 13:59:18 -08004649
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004650 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004651 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004652 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004653 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004654 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004655 *
4656 * <p>The URI given here must not be relative -- that is, it must include
4657 * the scheme and full path.
4658 *
4659 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004660 * @param flags Additional processing flags. Either 0,
4661 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004662 *
4663 * @return Intent The newly created Intent object.
4664 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004665 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4666 * it bad (as parsed by the Uri class) or the Intent data within the
4667 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004668 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004669 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004670 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004671 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004672 int i = 0;
4673 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004674 final boolean androidApp = uri.startsWith("android-app:");
4675
4676 // Validate intent scheme if requested.
4677 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4678 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004679 Intent intent = new Intent(ACTION_VIEW);
4680 try {
4681 intent.setData(Uri.parse(uri));
4682 } catch (IllegalArgumentException e) {
4683 throw new URISyntaxException(uri, e.getMessage());
4684 }
4685 return intent;
4686 }
4687 }
Tom Taylord4a47292009-12-21 13:59:18 -08004688
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004689 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004690 // simple case
4691 if (i == -1) {
4692 if (!androidApp) {
4693 return new Intent(ACTION_VIEW, Uri.parse(uri));
4694 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004695
4696 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004697 } else if (!uri.startsWith("#Intent;", i)) {
4698 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004699 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004700 } else {
4701 i = -1;
4702 }
4703 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004704
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004705 // new format
4706 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004707 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004708 boolean explicitAction = false;
4709 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004710
4711 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004712 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004713 String data;
4714 if (i >= 0) {
4715 data = uri.substring(0, i);
4716 i += 8; // length of "#Intent;"
4717 } else {
4718 data = uri;
4719 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004720
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004721 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004722 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004723 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004724 if (eq < 0) eq = i-1;
4725 int semi = uri.indexOf(';', i);
4726 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004727
4728 // action
4729 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004730 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004731 if (!inSelector) {
4732 explicitAction = true;
4733 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004734 }
4735
4736 // categories
4737 else if (uri.startsWith("category=", i)) {
4738 intent.addCategory(value);
4739 }
4740
4741 // type
4742 else if (uri.startsWith("type=", i)) {
4743 intent.mType = value;
4744 }
4745
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004746 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004747 else if (uri.startsWith("launchFlags=", i)) {
4748 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004749 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4750 intent.mFlags &= ~IMMUTABLE_FLAGS;
4751 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004752 }
4753
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004754 // package
4755 else if (uri.startsWith("package=", i)) {
4756 intent.mPackage = value;
4757 }
4758
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004759 // component
4760 else if (uri.startsWith("component=", i)) {
4761 intent.mComponent = ComponentName.unflattenFromString(value);
4762 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004763
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004764 // scheme
4765 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004766 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004767 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004768 } else {
4769 scheme = value;
4770 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004771 }
4772
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004773 // source bounds
4774 else if (uri.startsWith("sourceBounds=", i)) {
4775 intent.mSourceBounds = Rect.unflattenFromString(value);
4776 }
4777
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004778 // selector
4779 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4780 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004781 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004782 }
4783
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004784 // extra
4785 else {
4786 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004787 // create Bundle if it doesn't already exist
4788 if (intent.mExtras == null) intent.mExtras = new Bundle();
4789 Bundle b = intent.mExtras;
4790 // add EXTRA
4791 if (uri.startsWith("S.", i)) b.putString(key, value);
4792 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4793 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4794 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4795 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4796 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4797 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4798 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4799 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4800 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4801 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004802
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004803 // move to the next item
4804 i = semi + 1;
4805 }
4806
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004807 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004808 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004809 if (baseIntent.mPackage == null) {
4810 baseIntent.setSelector(intent);
4811 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004812 intent = baseIntent;
4813 }
4814
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004815 if (data != null) {
4816 if (data.startsWith("intent:")) {
4817 data = data.substring(7);
4818 if (scheme != null) {
4819 data = scheme + ':' + data;
4820 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004821 } else if (data.startsWith("android-app:")) {
4822 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4823 // Correctly formed android-app, first part is package name.
4824 int end = data.indexOf('/', 14);
4825 if (end < 0) {
4826 // All we have is a package name.
4827 intent.mPackage = data.substring(14);
4828 if (!explicitAction) {
4829 intent.setAction(ACTION_MAIN);
4830 }
4831 data = "";
4832 } else {
4833 // Target the Intent at the given package name always.
4834 String authority = null;
4835 intent.mPackage = data.substring(14, end);
4836 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004837 if ((end+1) < data.length()) {
4838 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4839 // Found a scheme, remember it.
4840 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004841 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004842 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4843 // Found a authority, remember it.
4844 authority = data.substring(end+1, newEnd);
4845 end = newEnd;
4846 }
4847 } else {
4848 // All we have is a scheme.
4849 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004850 }
4851 }
4852 if (scheme == null) {
4853 // If there was no scheme, then this just targets the package.
4854 if (!explicitAction) {
4855 intent.setAction(ACTION_MAIN);
4856 }
4857 data = "";
4858 } else if (authority == null) {
4859 data = scheme + ":";
4860 } else {
4861 data = scheme + "://" + authority + data.substring(end);
4862 }
4863 }
4864 } else {
4865 data = "";
4866 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004867 }
Tom Taylord4a47292009-12-21 13:59:18 -08004868
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004869 if (data.length() > 0) {
4870 try {
4871 intent.mData = Uri.parse(data);
4872 } catch (IllegalArgumentException e) {
4873 throw new URISyntaxException(uri, e.getMessage());
4874 }
4875 }
4876 }
Tom Taylord4a47292009-12-21 13:59:18 -08004877
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004878 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004879
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004880 } catch (IndexOutOfBoundsException e) {
4881 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4882 }
4883 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004884
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004885 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004886 return getIntentOld(uri, 0);
4887 }
4888
4889 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004890 Intent intent;
4891
4892 int i = uri.lastIndexOf('#');
4893 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004894 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004895 final int intentFragmentStart = i;
4896 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004897
4898 i++;
4899
4900 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004901 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004902 i += 7;
4903 int j = uri.indexOf(')', i);
4904 action = uri.substring(i, j);
4905 i = j + 1;
4906 }
4907
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004908 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004909
4910 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004911 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004912 i += 11;
4913 int j = uri.indexOf(')', i);
4914 while (i < j) {
4915 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004916 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004917 if (i < sep) {
4918 intent.addCategory(uri.substring(i, sep));
4919 }
4920 i = sep + 1;
4921 }
4922 i = j + 1;
4923 }
4924
4925 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004926 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004927 i += 5;
4928 int j = uri.indexOf(')', i);
4929 intent.mType = uri.substring(i, j);
4930 i = j + 1;
4931 }
4932
4933 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004934 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004935 i += 12;
4936 int j = uri.indexOf(')', i);
4937 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004938 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4939 intent.mFlags &= ~IMMUTABLE_FLAGS;
4940 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004941 i = j + 1;
4942 }
4943
4944 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004945 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004946 i += 10;
4947 int j = uri.indexOf(')', i);
4948 int sep = uri.indexOf('!', i);
4949 if (sep >= 0 && sep < j) {
4950 String pkg = uri.substring(i, sep);
4951 String cls = uri.substring(sep + 1, j);
4952 intent.mComponent = new ComponentName(pkg, cls);
4953 }
4954 i = j + 1;
4955 }
4956
4957 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004958 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004959 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004960
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004961 final int closeParen = uri.indexOf(')', i);
4962 if (closeParen == -1) throw new URISyntaxException(uri,
4963 "EXTRA missing trailing ')'", i);
4964
4965 while (i < closeParen) {
4966 // fetch the key value
4967 int j = uri.indexOf('=', i);
4968 if (j <= i + 1 || i >= closeParen) {
4969 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4970 }
4971 char type = uri.charAt(i);
4972 i++;
4973 String key = uri.substring(i, j);
4974 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004976 // get type-value
4977 j = uri.indexOf('!', i);
4978 if (j == -1 || j >= closeParen) j = closeParen;
4979 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4980 String value = uri.substring(i, j);
4981 i = j;
4982
4983 // create Bundle if it doesn't already exist
4984 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004985
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004986 // add item to bundle
4987 try {
4988 switch (type) {
4989 case 'S':
4990 intent.mExtras.putString(key, Uri.decode(value));
4991 break;
4992 case 'B':
4993 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4994 break;
4995 case 'b':
4996 intent.mExtras.putByte(key, Byte.parseByte(value));
4997 break;
4998 case 'c':
4999 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5000 break;
5001 case 'd':
5002 intent.mExtras.putDouble(key, Double.parseDouble(value));
5003 break;
5004 case 'f':
5005 intent.mExtras.putFloat(key, Float.parseFloat(value));
5006 break;
5007 case 'i':
5008 intent.mExtras.putInt(key, Integer.parseInt(value));
5009 break;
5010 case 'l':
5011 intent.mExtras.putLong(key, Long.parseLong(value));
5012 break;
5013 case 's':
5014 intent.mExtras.putShort(key, Short.parseShort(value));
5015 break;
5016 default:
5017 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5018 }
5019 } catch (NumberFormatException e) {
5020 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5021 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005022
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005023 char ch = uri.charAt(i);
5024 if (ch == ')') break;
5025 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5026 i++;
5027 }
5028 }
5029
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005030 if (isIntentFragment) {
5031 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5032 } else {
5033 intent.mData = Uri.parse(uri);
5034 }
Tom Taylord4a47292009-12-21 13:59:18 -08005035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005036 if (intent.mAction == null) {
5037 // By default, if no action is specified, then use VIEW.
5038 intent.mAction = ACTION_VIEW;
5039 }
5040
5041 } else {
5042 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5043 }
5044
5045 return intent;
5046 }
5047
5048 /**
5049 * Retrieve the general action to be performed, such as
5050 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5051 * the information in the intent should be interpreted -- most importantly,
5052 * what to do with the data returned by {@link #getData}.
5053 *
5054 * @return The action of this intent or null if none is specified.
5055 *
5056 * @see #setAction
5057 */
5058 public String getAction() {
5059 return mAction;
5060 }
5061
5062 /**
5063 * Retrieve data this intent is operating on. This URI specifies the name
5064 * of the data; often it uses the content: scheme, specifying data in a
5065 * content provider. Other schemes may be handled by specific activities,
5066 * such as http: by the web browser.
5067 *
5068 * @return The URI of the data this intent is targeting or null.
5069 *
5070 * @see #getScheme
5071 * @see #setData
5072 */
5073 public Uri getData() {
5074 return mData;
5075 }
5076
5077 /**
5078 * The same as {@link #getData()}, but returns the URI as an encoded
5079 * String.
5080 */
5081 public String getDataString() {
5082 return mData != null ? mData.toString() : null;
5083 }
5084
5085 /**
5086 * Return the scheme portion of the intent's data. If the data is null or
5087 * does not include a scheme, null is returned. Otherwise, the scheme
5088 * prefix without the final ':' is returned, i.e. "http".
5089 *
5090 * <p>This is the same as calling getData().getScheme() (and checking for
5091 * null data).
5092 *
5093 * @return The scheme of this intent.
5094 *
5095 * @see #getData
5096 */
5097 public String getScheme() {
5098 return mData != null ? mData.getScheme() : null;
5099 }
5100
5101 /**
5102 * Retrieve any explicit MIME type included in the intent. This is usually
5103 * null, as the type is determined by the intent data.
5104 *
5105 * @return If a type was manually set, it is returned; else null is
5106 * returned.
5107 *
5108 * @see #resolveType(ContentResolver)
5109 * @see #setType
5110 */
5111 public String getType() {
5112 return mType;
5113 }
5114
5115 /**
5116 * Return the MIME data type of this intent. If the type field is
5117 * explicitly set, that is simply returned. Otherwise, if the data is set,
5118 * the type of that data is returned. If neither fields are set, a null is
5119 * returned.
5120 *
5121 * @return The MIME type of this intent.
5122 *
5123 * @see #getType
5124 * @see #resolveType(ContentResolver)
5125 */
5126 public String resolveType(Context context) {
5127 return resolveType(context.getContentResolver());
5128 }
5129
5130 /**
5131 * Return the MIME data type of this intent. If the type field is
5132 * explicitly set, that is simply returned. Otherwise, if the data is set,
5133 * the type of that data is returned. If neither fields are set, a null is
5134 * returned.
5135 *
5136 * @param resolver A ContentResolver that can be used to determine the MIME
5137 * type of the intent's data.
5138 *
5139 * @return The MIME type of this intent.
5140 *
5141 * @see #getType
5142 * @see #resolveType(Context)
5143 */
5144 public String resolveType(ContentResolver resolver) {
5145 if (mType != null) {
5146 return mType;
5147 }
5148 if (mData != null) {
5149 if ("content".equals(mData.getScheme())) {
5150 return resolver.getType(mData);
5151 }
5152 }
5153 return null;
5154 }
5155
5156 /**
5157 * Return the MIME data type of this intent, only if it will be needed for
5158 * intent resolution. This is not generally useful for application code;
5159 * it is used by the frameworks for communicating with back-end system
5160 * services.
5161 *
5162 * @param resolver A ContentResolver that can be used to determine the MIME
5163 * type of the intent's data.
5164 *
5165 * @return The MIME type of this intent, or null if it is unknown or not
5166 * needed.
5167 */
5168 public String resolveTypeIfNeeded(ContentResolver resolver) {
5169 if (mComponent != null) {
5170 return mType;
5171 }
5172 return resolveType(resolver);
5173 }
5174
5175 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005176 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005177 *
5178 * @param category The category to check.
5179 *
5180 * @return boolean True if the intent contains the category, else false.
5181 *
5182 * @see #getCategories
5183 * @see #addCategory
5184 */
5185 public boolean hasCategory(String category) {
5186 return mCategories != null && mCategories.contains(category);
5187 }
5188
5189 /**
5190 * Return the set of all categories in the intent. If there are no categories,
5191 * returns NULL.
5192 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005193 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005194 *
5195 * @see #hasCategory
5196 * @see #addCategory
5197 */
5198 public Set<String> getCategories() {
5199 return mCategories;
5200 }
5201
5202 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005203 * Return the specific selector associated with this Intent. If there is
5204 * none, returns null. See {@link #setSelector} for more information.
5205 *
5206 * @see #setSelector
5207 */
5208 public Intent getSelector() {
5209 return mSelector;
5210 }
5211
5212 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005213 * Return the {@link ClipData} associated with this Intent. If there is
5214 * none, returns null. See {@link #setClipData} for more information.
5215 *
John Spurlock125d1332013-11-25 11:58:37 -05005216 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005217 */
5218 public ClipData getClipData() {
5219 return mClipData;
5220 }
5221
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005222 /** @hide */
5223 public int getContentUserHint() {
5224 return mContentUserHint;
5225 }
5226
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005227 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005228 * Sets the ClassLoader that will be used when unmarshalling
5229 * any Parcelable values from the extras of this Intent.
5230 *
5231 * @param loader a ClassLoader, or null to use the default loader
5232 * at the time of unmarshalling.
5233 */
5234 public void setExtrasClassLoader(ClassLoader loader) {
5235 if (mExtras != null) {
5236 mExtras.setClassLoader(loader);
5237 }
5238 }
5239
5240 /**
5241 * Returns true if an extra value is associated with the given name.
5242 * @param name the extra's name
5243 * @return true if the given extra is present.
5244 */
5245 public boolean hasExtra(String name) {
5246 return mExtras != null && mExtras.containsKey(name);
5247 }
5248
5249 /**
5250 * Returns true if the Intent's extras contain a parcelled file descriptor.
5251 * @return true if the Intent contains a parcelled file descriptor.
5252 */
5253 public boolean hasFileDescriptors() {
5254 return mExtras != null && mExtras.hasFileDescriptors();
5255 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005256
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005257 /** @hide */
5258 public void setAllowFds(boolean allowFds) {
5259 if (mExtras != null) {
5260 mExtras.setAllowFds(allowFds);
5261 }
5262 }
5263
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005264 /**
5265 * Retrieve extended data from the intent.
5266 *
5267 * @param name The name of the desired item.
5268 *
5269 * @return the value of an item that previously added with putExtra()
5270 * or null if none was found.
5271 *
5272 * @deprecated
5273 * @hide
5274 */
5275 @Deprecated
5276 public Object getExtra(String name) {
5277 return getExtra(name, null);
5278 }
5279
5280 /**
5281 * Retrieve extended data from the intent.
5282 *
5283 * @param name The name of the desired item.
5284 * @param defaultValue the value to be returned if no value of the desired
5285 * type is stored with the given name.
5286 *
5287 * @return the value of an item that previously added with putExtra()
5288 * or the default value if none was found.
5289 *
5290 * @see #putExtra(String, boolean)
5291 */
5292 public boolean getBooleanExtra(String name, boolean defaultValue) {
5293 return mExtras == null ? defaultValue :
5294 mExtras.getBoolean(name, defaultValue);
5295 }
5296
5297 /**
5298 * Retrieve extended data from the intent.
5299 *
5300 * @param name The name of the desired item.
5301 * @param defaultValue the value to be returned if no value of the desired
5302 * type is stored with the given name.
5303 *
5304 * @return the value of an item that previously added with putExtra()
5305 * or the default value if none was found.
5306 *
5307 * @see #putExtra(String, byte)
5308 */
5309 public byte getByteExtra(String name, byte defaultValue) {
5310 return mExtras == null ? defaultValue :
5311 mExtras.getByte(name, defaultValue);
5312 }
5313
5314 /**
5315 * Retrieve extended data from the intent.
5316 *
5317 * @param name The name of the desired item.
5318 * @param defaultValue the value to be returned if no value of the desired
5319 * type is stored with the given name.
5320 *
5321 * @return the value of an item that previously added with putExtra()
5322 * or the default value if none was found.
5323 *
5324 * @see #putExtra(String, short)
5325 */
5326 public short getShortExtra(String name, short defaultValue) {
5327 return mExtras == null ? defaultValue :
5328 mExtras.getShort(name, defaultValue);
5329 }
5330
5331 /**
5332 * Retrieve extended data from the intent.
5333 *
5334 * @param name The name of the desired item.
5335 * @param defaultValue the value to be returned if no value of the desired
5336 * type is stored with the given name.
5337 *
5338 * @return the value of an item that previously added with putExtra()
5339 * or the default value if none was found.
5340 *
5341 * @see #putExtra(String, char)
5342 */
5343 public char getCharExtra(String name, char defaultValue) {
5344 return mExtras == null ? defaultValue :
5345 mExtras.getChar(name, defaultValue);
5346 }
5347
5348 /**
5349 * Retrieve extended data from the intent.
5350 *
5351 * @param name The name of the desired item.
5352 * @param defaultValue the value to be returned if no value of the desired
5353 * type is stored with the given name.
5354 *
5355 * @return the value of an item that previously added with putExtra()
5356 * or the default value if none was found.
5357 *
5358 * @see #putExtra(String, int)
5359 */
5360 public int getIntExtra(String name, int defaultValue) {
5361 return mExtras == null ? defaultValue :
5362 mExtras.getInt(name, defaultValue);
5363 }
5364
5365 /**
5366 * Retrieve extended data from the intent.
5367 *
5368 * @param name The name of the desired item.
5369 * @param defaultValue the value to be returned if no value of the desired
5370 * type is stored with the given name.
5371 *
5372 * @return the value of an item that previously added with putExtra()
5373 * or the default value if none was found.
5374 *
5375 * @see #putExtra(String, long)
5376 */
5377 public long getLongExtra(String name, long defaultValue) {
5378 return mExtras == null ? defaultValue :
5379 mExtras.getLong(name, defaultValue);
5380 }
5381
5382 /**
5383 * Retrieve extended data from the intent.
5384 *
5385 * @param name The name of the desired item.
5386 * @param defaultValue the value to be returned if no value of the desired
5387 * type is stored with the given name.
5388 *
5389 * @return the value of an item that previously added with putExtra(),
5390 * or the default value if no such item is present
5391 *
5392 * @see #putExtra(String, float)
5393 */
5394 public float getFloatExtra(String name, float defaultValue) {
5395 return mExtras == null ? defaultValue :
5396 mExtras.getFloat(name, defaultValue);
5397 }
5398
5399 /**
5400 * Retrieve extended data from the intent.
5401 *
5402 * @param name The name of the desired item.
5403 * @param defaultValue the value to be returned if no value of the desired
5404 * type is stored with the given name.
5405 *
5406 * @return the value of an item that previously added with putExtra()
5407 * or the default value if none was found.
5408 *
5409 * @see #putExtra(String, double)
5410 */
5411 public double getDoubleExtra(String name, double defaultValue) {
5412 return mExtras == null ? defaultValue :
5413 mExtras.getDouble(name, defaultValue);
5414 }
5415
5416 /**
5417 * Retrieve extended data from the intent.
5418 *
5419 * @param name The name of the desired item.
5420 *
5421 * @return the value of an item that previously added with putExtra()
5422 * or null if no String value was found.
5423 *
5424 * @see #putExtra(String, String)
5425 */
5426 public String getStringExtra(String name) {
5427 return mExtras == null ? null : mExtras.getString(name);
5428 }
5429
5430 /**
5431 * Retrieve extended data from the intent.
5432 *
5433 * @param name The name of the desired item.
5434 *
5435 * @return the value of an item that previously added with putExtra()
5436 * or null if no CharSequence value was found.
5437 *
5438 * @see #putExtra(String, CharSequence)
5439 */
5440 public CharSequence getCharSequenceExtra(String name) {
5441 return mExtras == null ? null : mExtras.getCharSequence(name);
5442 }
5443
5444 /**
5445 * Retrieve extended data from the intent.
5446 *
5447 * @param name The name of the desired item.
5448 *
5449 * @return the value of an item that previously added with putExtra()
5450 * or null if no Parcelable value was found.
5451 *
5452 * @see #putExtra(String, Parcelable)
5453 */
5454 public <T extends Parcelable> T getParcelableExtra(String name) {
5455 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5456 }
5457
5458 /**
5459 * Retrieve extended data from the intent.
5460 *
5461 * @param name The name of the desired item.
5462 *
5463 * @return the value of an item that previously added with putExtra()
5464 * or null if no Parcelable[] value was found.
5465 *
5466 * @see #putExtra(String, Parcelable[])
5467 */
5468 public Parcelable[] getParcelableArrayExtra(String name) {
5469 return mExtras == null ? null : mExtras.getParcelableArray(name);
5470 }
5471
5472 /**
5473 * Retrieve extended data from the intent.
5474 *
5475 * @param name The name of the desired item.
5476 *
5477 * @return the value of an item that previously added with putExtra()
5478 * or null if no ArrayList<Parcelable> value was found.
5479 *
5480 * @see #putParcelableArrayListExtra(String, ArrayList)
5481 */
5482 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5483 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5484 }
5485
5486 /**
5487 * Retrieve extended data from the intent.
5488 *
5489 * @param name The name of the desired item.
5490 *
5491 * @return the value of an item that previously added with putExtra()
5492 * or null if no Serializable value was found.
5493 *
5494 * @see #putExtra(String, Serializable)
5495 */
5496 public Serializable getSerializableExtra(String name) {
5497 return mExtras == null ? null : mExtras.getSerializable(name);
5498 }
5499
5500 /**
5501 * Retrieve extended data from the intent.
5502 *
5503 * @param name The name of the desired item.
5504 *
5505 * @return the value of an item that previously added with putExtra()
5506 * or null if no ArrayList<Integer> value was found.
5507 *
5508 * @see #putIntegerArrayListExtra(String, ArrayList)
5509 */
5510 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5511 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5512 }
5513
5514 /**
5515 * Retrieve extended data from the intent.
5516 *
5517 * @param name The name of the desired item.
5518 *
5519 * @return the value of an item that previously added with putExtra()
5520 * or null if no ArrayList<String> value was found.
5521 *
5522 * @see #putStringArrayListExtra(String, ArrayList)
5523 */
5524 public ArrayList<String> getStringArrayListExtra(String name) {
5525 return mExtras == null ? null : mExtras.getStringArrayList(name);
5526 }
5527
5528 /**
5529 * Retrieve extended data from the intent.
5530 *
5531 * @param name The name of the desired item.
5532 *
5533 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005534 * or null if no ArrayList<CharSequence> value was found.
5535 *
5536 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5537 */
5538 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5539 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5540 }
5541
5542 /**
5543 * Retrieve extended data from the intent.
5544 *
5545 * @param name The name of the desired item.
5546 *
5547 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005548 * or null if no boolean array value was found.
5549 *
5550 * @see #putExtra(String, boolean[])
5551 */
5552 public boolean[] getBooleanArrayExtra(String name) {
5553 return mExtras == null ? null : mExtras.getBooleanArray(name);
5554 }
5555
5556 /**
5557 * Retrieve extended data from the intent.
5558 *
5559 * @param name The name of the desired item.
5560 *
5561 * @return the value of an item that previously added with putExtra()
5562 * or null if no byte array value was found.
5563 *
5564 * @see #putExtra(String, byte[])
5565 */
5566 public byte[] getByteArrayExtra(String name) {
5567 return mExtras == null ? null : mExtras.getByteArray(name);
5568 }
5569
5570 /**
5571 * Retrieve extended data from the intent.
5572 *
5573 * @param name The name of the desired item.
5574 *
5575 * @return the value of an item that previously added with putExtra()
5576 * or null if no short array value was found.
5577 *
5578 * @see #putExtra(String, short[])
5579 */
5580 public short[] getShortArrayExtra(String name) {
5581 return mExtras == null ? null : mExtras.getShortArray(name);
5582 }
5583
5584 /**
5585 * Retrieve extended data from the intent.
5586 *
5587 * @param name The name of the desired item.
5588 *
5589 * @return the value of an item that previously added with putExtra()
5590 * or null if no char array value was found.
5591 *
5592 * @see #putExtra(String, char[])
5593 */
5594 public char[] getCharArrayExtra(String name) {
5595 return mExtras == null ? null : mExtras.getCharArray(name);
5596 }
5597
5598 /**
5599 * Retrieve extended data from the intent.
5600 *
5601 * @param name The name of the desired item.
5602 *
5603 * @return the value of an item that previously added with putExtra()
5604 * or null if no int array value was found.
5605 *
5606 * @see #putExtra(String, int[])
5607 */
5608 public int[] getIntArrayExtra(String name) {
5609 return mExtras == null ? null : mExtras.getIntArray(name);
5610 }
5611
5612 /**
5613 * Retrieve extended data from the intent.
5614 *
5615 * @param name The name of the desired item.
5616 *
5617 * @return the value of an item that previously added with putExtra()
5618 * or null if no long array value was found.
5619 *
5620 * @see #putExtra(String, long[])
5621 */
5622 public long[] getLongArrayExtra(String name) {
5623 return mExtras == null ? null : mExtras.getLongArray(name);
5624 }
5625
5626 /**
5627 * Retrieve extended data from the intent.
5628 *
5629 * @param name The name of the desired item.
5630 *
5631 * @return the value of an item that previously added with putExtra()
5632 * or null if no float array value was found.
5633 *
5634 * @see #putExtra(String, float[])
5635 */
5636 public float[] getFloatArrayExtra(String name) {
5637 return mExtras == null ? null : mExtras.getFloatArray(name);
5638 }
5639
5640 /**
5641 * Retrieve extended data from the intent.
5642 *
5643 * @param name The name of the desired item.
5644 *
5645 * @return the value of an item that previously added with putExtra()
5646 * or null if no double array value was found.
5647 *
5648 * @see #putExtra(String, double[])
5649 */
5650 public double[] getDoubleArrayExtra(String name) {
5651 return mExtras == null ? null : mExtras.getDoubleArray(name);
5652 }
5653
5654 /**
5655 * Retrieve extended data from the intent.
5656 *
5657 * @param name The name of the desired item.
5658 *
5659 * @return the value of an item that previously added with putExtra()
5660 * or null if no String array value was found.
5661 *
5662 * @see #putExtra(String, String[])
5663 */
5664 public String[] getStringArrayExtra(String name) {
5665 return mExtras == null ? null : mExtras.getStringArray(name);
5666 }
5667
5668 /**
5669 * Retrieve extended data from the intent.
5670 *
5671 * @param name The name of the desired item.
5672 *
5673 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005674 * or null if no CharSequence array value was found.
5675 *
5676 * @see #putExtra(String, CharSequence[])
5677 */
5678 public CharSequence[] getCharSequenceArrayExtra(String name) {
5679 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5680 }
5681
5682 /**
5683 * Retrieve extended data from the intent.
5684 *
5685 * @param name The name of the desired item.
5686 *
5687 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005688 * or null if no Bundle value was found.
5689 *
5690 * @see #putExtra(String, Bundle)
5691 */
5692 public Bundle getBundleExtra(String name) {
5693 return mExtras == null ? null : mExtras.getBundle(name);
5694 }
5695
5696 /**
5697 * Retrieve extended data from the intent.
5698 *
5699 * @param name The name of the desired item.
5700 *
5701 * @return the value of an item that previously added with putExtra()
5702 * or null if no IBinder value was found.
5703 *
5704 * @see #putExtra(String, IBinder)
5705 *
5706 * @deprecated
5707 * @hide
5708 */
5709 @Deprecated
5710 public IBinder getIBinderExtra(String name) {
5711 return mExtras == null ? null : mExtras.getIBinder(name);
5712 }
5713
5714 /**
5715 * Retrieve extended data from the intent.
5716 *
5717 * @param name The name of the desired item.
5718 * @param defaultValue The default value to return in case no item is
5719 * associated with the key 'name'
5720 *
5721 * @return the value of an item that previously added with putExtra()
5722 * or defaultValue if none was found.
5723 *
5724 * @see #putExtra
5725 *
5726 * @deprecated
5727 * @hide
5728 */
5729 @Deprecated
5730 public Object getExtra(String name, Object defaultValue) {
5731 Object result = defaultValue;
5732 if (mExtras != null) {
5733 Object result2 = mExtras.get(name);
5734 if (result2 != null) {
5735 result = result2;
5736 }
5737 }
5738
5739 return result;
5740 }
5741
5742 /**
5743 * Retrieves a map of extended data from the intent.
5744 *
5745 * @return the map of all extras previously added with putExtra(),
5746 * or null if none have been added.
5747 */
5748 public Bundle getExtras() {
5749 return (mExtras != null)
5750 ? new Bundle(mExtras)
5751 : null;
5752 }
5753
5754 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005755 * Filter extras to only basic types.
5756 * @hide
5757 */
5758 public void removeUnsafeExtras() {
5759 if (mExtras != null) {
5760 mExtras.filterValues();
5761 }
5762 }
5763
5764 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005765 * Retrieve any special flags associated with this intent. You will
5766 * normally just set them with {@link #setFlags} and let the system
5767 * take the appropriate action with them.
5768 *
5769 * @return int The currently set flags.
5770 *
5771 * @see #setFlags
5772 */
5773 public int getFlags() {
5774 return mFlags;
5775 }
5776
Dianne Hackborne7f97212011-02-24 14:40:20 -08005777 /** @hide */
5778 public boolean isExcludingStopped() {
5779 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5780 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5781 }
5782
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005783 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005784 * Retrieve the application package name this Intent is limited to. When
5785 * resolving an Intent, if non-null this limits the resolution to only
5786 * components in the given application package.
5787 *
5788 * @return The name of the application package for the Intent.
5789 *
5790 * @see #resolveActivity
5791 * @see #setPackage
5792 */
5793 public String getPackage() {
5794 return mPackage;
5795 }
5796
5797 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005798 * Retrieve the concrete component associated with the intent. When receiving
5799 * an intent, this is the component that was found to best handle it (that is,
5800 * yourself) and will always be non-null; in all other cases it will be
5801 * null unless explicitly set.
5802 *
5803 * @return The name of the application component to handle the intent.
5804 *
5805 * @see #resolveActivity
5806 * @see #setComponent
5807 */
5808 public ComponentName getComponent() {
5809 return mComponent;
5810 }
5811
5812 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005813 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5814 * used as a hint to the receiver for animations and the like. Null means that there
5815 * is no source bounds.
5816 */
5817 public Rect getSourceBounds() {
5818 return mSourceBounds;
5819 }
5820
5821 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005822 * Return the Activity component that should be used to handle this intent.
5823 * The appropriate component is determined based on the information in the
5824 * intent, evaluated as follows:
5825 *
5826 * <p>If {@link #getComponent} returns an explicit class, that is returned
5827 * without any further consideration.
5828 *
5829 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5830 * category to be considered.
5831 *
5832 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5833 * action.
5834 *
5835 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5836 * this type.
5837 *
5838 * <p>If {@link #addCategory} has added any categories, the activity must
5839 * handle ALL of the categories specified.
5840 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005841 * <p>If {@link #getPackage} is non-NULL, only activity components in
5842 * that application package will be considered.
5843 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005844 * <p>If there are no activities that satisfy all of these conditions, a
5845 * null string is returned.
5846 *
5847 * <p>If multiple activities are found to satisfy the intent, the one with
5848 * the highest priority will be used. If there are multiple activities
5849 * with the same priority, the system will either pick the best activity
5850 * based on user preference, or resolve to a system class that will allow
5851 * the user to pick an activity and forward from there.
5852 *
5853 * <p>This method is implemented simply by calling
5854 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5855 * true.</p>
5856 * <p> This API is called for you as part of starting an activity from an
5857 * intent. You do not normally need to call it yourself.</p>
5858 *
5859 * @param pm The package manager with which to resolve the Intent.
5860 *
5861 * @return Name of the component implementing an activity that can
5862 * display the intent.
5863 *
5864 * @see #setComponent
5865 * @see #getComponent
5866 * @see #resolveActivityInfo
5867 */
5868 public ComponentName resolveActivity(PackageManager pm) {
5869 if (mComponent != null) {
5870 return mComponent;
5871 }
5872
5873 ResolveInfo info = pm.resolveActivity(
5874 this, PackageManager.MATCH_DEFAULT_ONLY);
5875 if (info != null) {
5876 return new ComponentName(
5877 info.activityInfo.applicationInfo.packageName,
5878 info.activityInfo.name);
5879 }
5880
5881 return null;
5882 }
5883
5884 /**
5885 * Resolve the Intent into an {@link ActivityInfo}
5886 * describing the activity that should execute the intent. Resolution
5887 * follows the same rules as described for {@link #resolveActivity}, but
5888 * you get back the completely information about the resolved activity
5889 * instead of just its class name.
5890 *
5891 * @param pm The package manager with which to resolve the Intent.
5892 * @param flags Addition information to retrieve as per
5893 * {@link PackageManager#getActivityInfo(ComponentName, int)
5894 * PackageManager.getActivityInfo()}.
5895 *
5896 * @return PackageManager.ActivityInfo
5897 *
5898 * @see #resolveActivity
5899 */
5900 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5901 ActivityInfo ai = null;
5902 if (mComponent != null) {
5903 try {
5904 ai = pm.getActivityInfo(mComponent, flags);
5905 } catch (PackageManager.NameNotFoundException e) {
5906 // ignore
5907 }
5908 } else {
5909 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005910 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005911 if (info != null) {
5912 ai = info.activityInfo;
5913 }
5914 }
5915
5916 return ai;
5917 }
5918
5919 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005920 * Special function for use by the system to resolve service
5921 * intents to system apps. Throws an exception if there are
5922 * multiple potential matches to the Intent. Returns null if
5923 * there are no matches.
5924 * @hide
5925 */
5926 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5927 if (mComponent != null) {
5928 return mComponent;
5929 }
5930
5931 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5932 if (results == null) {
5933 return null;
5934 }
5935 ComponentName comp = null;
5936 for (int i=0; i<results.size(); i++) {
5937 ResolveInfo ri = results.get(i);
5938 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5939 continue;
5940 }
5941 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5942 ri.serviceInfo.name);
5943 if (comp != null) {
5944 throw new IllegalStateException("Multiple system services handle " + this
5945 + ": " + comp + ", " + foundComp);
5946 }
5947 comp = foundComp;
5948 }
5949 return comp;
5950 }
5951
5952 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005953 * Set the general action to be performed.
5954 *
5955 * @param action An action name, such as ACTION_VIEW. Application-specific
5956 * actions should be prefixed with the vendor's package name.
5957 *
5958 * @return Returns the same Intent object, for chaining multiple calls
5959 * into a single statement.
5960 *
5961 * @see #getAction
5962 */
5963 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005964 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005965 return this;
5966 }
5967
5968 /**
5969 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005970 * clears any type that was previously set by {@link #setType} or
5971 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005972 *
Nick Pellyccae4122012-01-09 14:12:58 -08005973 * <p><em>Note: scheme matching in the Android framework is
5974 * case-sensitive, unlike the formal RFC. As a result,
5975 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005976 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005977 * {@link #setDataAndNormalize}
5978 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005979 *
Nick Pellyccae4122012-01-09 14:12:58 -08005980 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005981 *
5982 * @return Returns the same Intent object, for chaining multiple calls
5983 * into a single statement.
5984 *
5985 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005986 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005987 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005988 */
5989 public Intent setData(Uri data) {
5990 mData = data;
5991 mType = null;
5992 return this;
5993 }
5994
5995 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005996 * Normalize and set the data this intent is operating on.
5997 *
5998 * <p>This method automatically clears any type that was
5999 * previously set (for example, by {@link #setType}).
6000 *
6001 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006002 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006003 * so really this is just a convenience method for
6004 * <pre>
6005 * setData(data.normalize())
6006 * </pre>
6007 *
6008 * @param data The Uri of the data this intent is now targeting.
6009 *
6010 * @return Returns the same Intent object, for chaining multiple calls
6011 * into a single statement.
6012 *
6013 * @see #getData
6014 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006015 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006016 */
6017 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006018 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006019 }
6020
6021 /**
6022 * Set an explicit MIME data type.
6023 *
6024 * <p>This is used to create intents that only specify a type and not data,
6025 * for example to indicate the type of data to return.
6026 *
6027 * <p>This method automatically clears any data that was
6028 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006029 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006030 * <p><em>Note: MIME type matching in the Android framework is
6031 * case-sensitive, unlike formal RFC MIME types. As a result,
6032 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006033 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6034 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006035 *
6036 * @param type The MIME type of the data being handled by this intent.
6037 *
6038 * @return Returns the same Intent object, for chaining multiple calls
6039 * into a single statement.
6040 *
6041 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006042 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006043 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006044 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006045 */
6046 public Intent setType(String type) {
6047 mData = null;
6048 mType = type;
6049 return this;
6050 }
6051
6052 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006053 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006054 *
Nick Pellyccae4122012-01-09 14:12:58 -08006055 * <p>This is used to create intents that only specify a type and not data,
6056 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006057 *
Nick Pellyccae4122012-01-09 14:12:58 -08006058 * <p>This method automatically clears any data that was
6059 * previously set (for example by {@link #setData}).
6060 *
6061 * <p>The MIME type is normalized using
6062 * {@link #normalizeMimeType} before it is set,
6063 * so really this is just a convenience method for
6064 * <pre>
6065 * setType(Intent.normalizeMimeType(type))
6066 * </pre>
6067 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006068 * @param type The MIME type of the data being handled by this intent.
6069 *
6070 * @return Returns the same Intent object, for chaining multiple calls
6071 * into a single statement.
6072 *
Nick Pellyccae4122012-01-09 14:12:58 -08006073 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006074 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006075 * @see #normalizeMimeType
6076 */
6077 public Intent setTypeAndNormalize(String type) {
6078 return setType(normalizeMimeType(type));
6079 }
6080
6081 /**
6082 * (Usually optional) Set the data for the intent along with an explicit
6083 * MIME data type. This method should very rarely be used -- it allows you
6084 * to override the MIME type that would ordinarily be inferred from the
6085 * data with your own type given here.
6086 *
6087 * <p><em>Note: MIME type and Uri scheme matching in the
6088 * Android framework is case-sensitive, unlike the formal RFC definitions.
6089 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006090 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006091 * {@link #setDataAndTypeAndNormalize}
6092 * to ensure that they are converted to lower case.</em>
6093 *
6094 * @param data The Uri of the data this intent is now targeting.
6095 * @param type The MIME type of the data being handled by this intent.
6096 *
6097 * @return Returns the same Intent object, for chaining multiple calls
6098 * into a single statement.
6099 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006100 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006101 * @see #setData
6102 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006103 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006104 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006105 */
6106 public Intent setDataAndType(Uri data, String type) {
6107 mData = data;
6108 mType = type;
6109 return this;
6110 }
6111
6112 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006113 * (Usually optional) Normalize and set both the data Uri and an explicit
6114 * MIME data type. This method should very rarely be used -- it allows you
6115 * to override the MIME type that would ordinarily be inferred from the
6116 * data with your own type given here.
6117 *
6118 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006119 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006120 * before they are set, so really this is just a convenience method for
6121 * <pre>
6122 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6123 * </pre>
6124 *
6125 * @param data The Uri of the data this intent is now targeting.
6126 * @param type The MIME type of the data being handled by this intent.
6127 *
6128 * @return Returns the same Intent object, for chaining multiple calls
6129 * into a single statement.
6130 *
6131 * @see #setType
6132 * @see #setData
6133 * @see #setDataAndType
6134 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006135 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006136 */
6137 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006138 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006139 }
6140
6141 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006142 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006143 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006144 * activities that provide <em>all</em> of the requested categories will be
6145 * used.
6146 *
6147 * @param category The desired category. This can be either one of the
6148 * predefined Intent categories, or a custom category in your own
6149 * namespace.
6150 *
6151 * @return Returns the same Intent object, for chaining multiple calls
6152 * into a single statement.
6153 *
6154 * @see #hasCategory
6155 * @see #removeCategory
6156 */
6157 public Intent addCategory(String category) {
6158 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006159 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006160 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006161 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006162 return this;
6163 }
6164
6165 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006166 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006167 *
6168 * @param category The category to remove.
6169 *
6170 * @see #addCategory
6171 */
6172 public void removeCategory(String category) {
6173 if (mCategories != null) {
6174 mCategories.remove(category);
6175 if (mCategories.size() == 0) {
6176 mCategories = null;
6177 }
6178 }
6179 }
6180
6181 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006182 * Set a selector for this Intent. This is a modification to the kinds of
6183 * things the Intent will match. If the selector is set, it will be used
6184 * when trying to find entities that can handle the Intent, instead of the
6185 * main contents of the Intent. This allows you build an Intent containing
6186 * a generic protocol while targeting it more specifically.
6187 *
6188 * <p>An example of where this may be used is with things like
6189 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6190 * Intent that will launch the Browser application. However, the correct
6191 * main entry point of an application is actually {@link #ACTION_MAIN}
6192 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6193 * used to specify the actual Activity to launch. If you launch the browser
6194 * with something different, undesired behavior may happen if the user has
6195 * previously or later launches it the normal way, since they do not match.
6196 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6197 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6198 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6199 *
6200 * <p>Setting a selector does not impact the behavior of
6201 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6202 * desired behavior of a selector -- it does not impact the base meaning
6203 * of the Intent, just what kinds of things will be matched against it
6204 * when determining who can handle it.</p>
6205 *
6206 * <p>You can not use both a selector and {@link #setPackage(String)} on
6207 * the same base Intent.</p>
6208 *
6209 * @param selector The desired selector Intent; set to null to not use
6210 * a special selector.
6211 */
6212 public void setSelector(Intent selector) {
6213 if (selector == this) {
6214 throw new IllegalArgumentException(
6215 "Intent being set as a selector of itself");
6216 }
6217 if (selector != null && mPackage != null) {
6218 throw new IllegalArgumentException(
6219 "Can't set selector when package name is already set");
6220 }
6221 mSelector = selector;
6222 }
6223
6224 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006225 * Set a {@link ClipData} associated with this Intent. This replaces any
6226 * previously set ClipData.
6227 *
6228 * <p>The ClipData in an intent is not used for Intent matching or other
6229 * such operations. Semantically it is like extras, used to transmit
6230 * additional data with the Intent. The main feature of using this over
6231 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6232 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6233 * items included in the clip data. This is useful, in particular, if
6234 * you want to transmit an Intent containing multiple <code>content:</code>
6235 * URIs for which the recipient may not have global permission to access the
6236 * content provider.
6237 *
6238 * <p>If the ClipData contains items that are themselves Intents, any
6239 * grant flags in those Intents will be ignored. Only the top-level flags
6240 * of the main Intent are respected, and will be applied to all Uri or
6241 * Intent items in the clip (or sub-items of the clip).
6242 *
6243 * <p>The MIME type, label, and icon in the ClipData object are not
6244 * directly used by Intent. Applications should generally rely on the
6245 * MIME type of the Intent itself, not what it may find in the ClipData.
6246 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006247 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006248 *
6249 * @param clip The new clip to set. May be null to clear the current clip.
6250 */
6251 public void setClipData(ClipData clip) {
6252 mClipData = clip;
6253 }
6254
6255 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006256 * This is NOT a secure mechanism to identify the user who sent the intent.
6257 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6258 * who sent the intent.
6259 * @hide
6260 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01006261 public void prepareToLeaveUser(int userId) {
6262 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
6263 // We want mContentUserHint to refer to the original user, so don't do anything.
6264 if (mContentUserHint == UserHandle.USER_CURRENT) {
6265 mContentUserHint = userId;
6266 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006267 }
6268
6269 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006270 * Add extended data to the intent. The name must include a package
6271 * prefix, for example the app com.android.contacts would use names
6272 * like "com.android.contacts.ShowAll".
6273 *
6274 * @param name The name of the extra data, with package prefix.
6275 * @param value The boolean data value.
6276 *
6277 * @return Returns the same Intent object, for chaining multiple calls
6278 * into a single statement.
6279 *
6280 * @see #putExtras
6281 * @see #removeExtra
6282 * @see #getBooleanExtra(String, boolean)
6283 */
6284 public Intent putExtra(String name, boolean value) {
6285 if (mExtras == null) {
6286 mExtras = new Bundle();
6287 }
6288 mExtras.putBoolean(name, value);
6289 return this;
6290 }
6291
6292 /**
6293 * Add extended data to the intent. The name must include a package
6294 * prefix, for example the app com.android.contacts would use names
6295 * like "com.android.contacts.ShowAll".
6296 *
6297 * @param name The name of the extra data, with package prefix.
6298 * @param value The byte data value.
6299 *
6300 * @return Returns the same Intent object, for chaining multiple calls
6301 * into a single statement.
6302 *
6303 * @see #putExtras
6304 * @see #removeExtra
6305 * @see #getByteExtra(String, byte)
6306 */
6307 public Intent putExtra(String name, byte value) {
6308 if (mExtras == null) {
6309 mExtras = new Bundle();
6310 }
6311 mExtras.putByte(name, value);
6312 return this;
6313 }
6314
6315 /**
6316 * Add extended data to the intent. The name must include a package
6317 * prefix, for example the app com.android.contacts would use names
6318 * like "com.android.contacts.ShowAll".
6319 *
6320 * @param name The name of the extra data, with package prefix.
6321 * @param value The char data value.
6322 *
6323 * @return Returns the same Intent object, for chaining multiple calls
6324 * into a single statement.
6325 *
6326 * @see #putExtras
6327 * @see #removeExtra
6328 * @see #getCharExtra(String, char)
6329 */
6330 public Intent putExtra(String name, char value) {
6331 if (mExtras == null) {
6332 mExtras = new Bundle();
6333 }
6334 mExtras.putChar(name, value);
6335 return this;
6336 }
6337
6338 /**
6339 * Add extended data to the intent. The name must include a package
6340 * prefix, for example the app com.android.contacts would use names
6341 * like "com.android.contacts.ShowAll".
6342 *
6343 * @param name The name of the extra data, with package prefix.
6344 * @param value The short data value.
6345 *
6346 * @return Returns the same Intent object, for chaining multiple calls
6347 * into a single statement.
6348 *
6349 * @see #putExtras
6350 * @see #removeExtra
6351 * @see #getShortExtra(String, short)
6352 */
6353 public Intent putExtra(String name, short value) {
6354 if (mExtras == null) {
6355 mExtras = new Bundle();
6356 }
6357 mExtras.putShort(name, value);
6358 return this;
6359 }
6360
6361 /**
6362 * Add extended data to the intent. The name must include a package
6363 * prefix, for example the app com.android.contacts would use names
6364 * like "com.android.contacts.ShowAll".
6365 *
6366 * @param name The name of the extra data, with package prefix.
6367 * @param value The integer data value.
6368 *
6369 * @return Returns the same Intent object, for chaining multiple calls
6370 * into a single statement.
6371 *
6372 * @see #putExtras
6373 * @see #removeExtra
6374 * @see #getIntExtra(String, int)
6375 */
6376 public Intent putExtra(String name, int value) {
6377 if (mExtras == null) {
6378 mExtras = new Bundle();
6379 }
6380 mExtras.putInt(name, value);
6381 return this;
6382 }
6383
6384 /**
6385 * Add extended data to the intent. The name must include a package
6386 * prefix, for example the app com.android.contacts would use names
6387 * like "com.android.contacts.ShowAll".
6388 *
6389 * @param name The name of the extra data, with package prefix.
6390 * @param value The long data value.
6391 *
6392 * @return Returns the same Intent object, for chaining multiple calls
6393 * into a single statement.
6394 *
6395 * @see #putExtras
6396 * @see #removeExtra
6397 * @see #getLongExtra(String, long)
6398 */
6399 public Intent putExtra(String name, long value) {
6400 if (mExtras == null) {
6401 mExtras = new Bundle();
6402 }
6403 mExtras.putLong(name, value);
6404 return this;
6405 }
6406
6407 /**
6408 * Add extended data to the intent. The name must include a package
6409 * prefix, for example the app com.android.contacts would use names
6410 * like "com.android.contacts.ShowAll".
6411 *
6412 * @param name The name of the extra data, with package prefix.
6413 * @param value The float data value.
6414 *
6415 * @return Returns the same Intent object, for chaining multiple calls
6416 * into a single statement.
6417 *
6418 * @see #putExtras
6419 * @see #removeExtra
6420 * @see #getFloatExtra(String, float)
6421 */
6422 public Intent putExtra(String name, float value) {
6423 if (mExtras == null) {
6424 mExtras = new Bundle();
6425 }
6426 mExtras.putFloat(name, value);
6427 return this;
6428 }
6429
6430 /**
6431 * Add extended data to the intent. The name must include a package
6432 * prefix, for example the app com.android.contacts would use names
6433 * like "com.android.contacts.ShowAll".
6434 *
6435 * @param name The name of the extra data, with package prefix.
6436 * @param value The double data value.
6437 *
6438 * @return Returns the same Intent object, for chaining multiple calls
6439 * into a single statement.
6440 *
6441 * @see #putExtras
6442 * @see #removeExtra
6443 * @see #getDoubleExtra(String, double)
6444 */
6445 public Intent putExtra(String name, double value) {
6446 if (mExtras == null) {
6447 mExtras = new Bundle();
6448 }
6449 mExtras.putDouble(name, value);
6450 return this;
6451 }
6452
6453 /**
6454 * Add extended data to the intent. The name must include a package
6455 * prefix, for example the app com.android.contacts would use names
6456 * like "com.android.contacts.ShowAll".
6457 *
6458 * @param name The name of the extra data, with package prefix.
6459 * @param value The String data value.
6460 *
6461 * @return Returns the same Intent object, for chaining multiple calls
6462 * into a single statement.
6463 *
6464 * @see #putExtras
6465 * @see #removeExtra
6466 * @see #getStringExtra(String)
6467 */
6468 public Intent putExtra(String name, String value) {
6469 if (mExtras == null) {
6470 mExtras = new Bundle();
6471 }
6472 mExtras.putString(name, value);
6473 return this;
6474 }
6475
6476 /**
6477 * Add extended data to the intent. The name must include a package
6478 * prefix, for example the app com.android.contacts would use names
6479 * like "com.android.contacts.ShowAll".
6480 *
6481 * @param name The name of the extra data, with package prefix.
6482 * @param value The CharSequence data value.
6483 *
6484 * @return Returns the same Intent object, for chaining multiple calls
6485 * into a single statement.
6486 *
6487 * @see #putExtras
6488 * @see #removeExtra
6489 * @see #getCharSequenceExtra(String)
6490 */
6491 public Intent putExtra(String name, CharSequence value) {
6492 if (mExtras == null) {
6493 mExtras = new Bundle();
6494 }
6495 mExtras.putCharSequence(name, value);
6496 return this;
6497 }
6498
6499 /**
6500 * Add extended data to the intent. The name must include a package
6501 * prefix, for example the app com.android.contacts would use names
6502 * like "com.android.contacts.ShowAll".
6503 *
6504 * @param name The name of the extra data, with package prefix.
6505 * @param value The Parcelable data value.
6506 *
6507 * @return Returns the same Intent object, for chaining multiple calls
6508 * into a single statement.
6509 *
6510 * @see #putExtras
6511 * @see #removeExtra
6512 * @see #getParcelableExtra(String)
6513 */
6514 public Intent putExtra(String name, Parcelable value) {
6515 if (mExtras == null) {
6516 mExtras = new Bundle();
6517 }
6518 mExtras.putParcelable(name, value);
6519 return this;
6520 }
6521
6522 /**
6523 * Add extended data to the intent. The name must include a package
6524 * prefix, for example the app com.android.contacts would use names
6525 * like "com.android.contacts.ShowAll".
6526 *
6527 * @param name The name of the extra data, with package prefix.
6528 * @param value The Parcelable[] data value.
6529 *
6530 * @return Returns the same Intent object, for chaining multiple calls
6531 * into a single statement.
6532 *
6533 * @see #putExtras
6534 * @see #removeExtra
6535 * @see #getParcelableArrayExtra(String)
6536 */
6537 public Intent putExtra(String name, Parcelable[] value) {
6538 if (mExtras == null) {
6539 mExtras = new Bundle();
6540 }
6541 mExtras.putParcelableArray(name, value);
6542 return this;
6543 }
6544
6545 /**
6546 * Add extended data to the intent. The name must include a package
6547 * prefix, for example the app com.android.contacts would use names
6548 * like "com.android.contacts.ShowAll".
6549 *
6550 * @param name The name of the extra data, with package prefix.
6551 * @param value The ArrayList<Parcelable> data value.
6552 *
6553 * @return Returns the same Intent object, for chaining multiple calls
6554 * into a single statement.
6555 *
6556 * @see #putExtras
6557 * @see #removeExtra
6558 * @see #getParcelableArrayListExtra(String)
6559 */
6560 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6561 if (mExtras == null) {
6562 mExtras = new Bundle();
6563 }
6564 mExtras.putParcelableArrayList(name, value);
6565 return this;
6566 }
6567
6568 /**
6569 * Add extended data to the intent. The name must include a package
6570 * prefix, for example the app com.android.contacts would use names
6571 * like "com.android.contacts.ShowAll".
6572 *
6573 * @param name The name of the extra data, with package prefix.
6574 * @param value The ArrayList<Integer> data value.
6575 *
6576 * @return Returns the same Intent object, for chaining multiple calls
6577 * into a single statement.
6578 *
6579 * @see #putExtras
6580 * @see #removeExtra
6581 * @see #getIntegerArrayListExtra(String)
6582 */
6583 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6584 if (mExtras == null) {
6585 mExtras = new Bundle();
6586 }
6587 mExtras.putIntegerArrayList(name, value);
6588 return this;
6589 }
6590
6591 /**
6592 * Add extended data to the intent. The name must include a package
6593 * prefix, for example the app com.android.contacts would use names
6594 * like "com.android.contacts.ShowAll".
6595 *
6596 * @param name The name of the extra data, with package prefix.
6597 * @param value The ArrayList<String> data value.
6598 *
6599 * @return Returns the same Intent object, for chaining multiple calls
6600 * into a single statement.
6601 *
6602 * @see #putExtras
6603 * @see #removeExtra
6604 * @see #getStringArrayListExtra(String)
6605 */
6606 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6607 if (mExtras == null) {
6608 mExtras = new Bundle();
6609 }
6610 mExtras.putStringArrayList(name, value);
6611 return this;
6612 }
6613
6614 /**
6615 * Add extended data to the intent. The name must include a package
6616 * prefix, for example the app com.android.contacts would use names
6617 * like "com.android.contacts.ShowAll".
6618 *
6619 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006620 * @param value The ArrayList<CharSequence> data value.
6621 *
6622 * @return Returns the same Intent object, for chaining multiple calls
6623 * into a single statement.
6624 *
6625 * @see #putExtras
6626 * @see #removeExtra
6627 * @see #getCharSequenceArrayListExtra(String)
6628 */
6629 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6630 if (mExtras == null) {
6631 mExtras = new Bundle();
6632 }
6633 mExtras.putCharSequenceArrayList(name, value);
6634 return this;
6635 }
6636
6637 /**
6638 * Add extended data to the intent. The name must include a package
6639 * prefix, for example the app com.android.contacts would use names
6640 * like "com.android.contacts.ShowAll".
6641 *
6642 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006643 * @param value The Serializable data value.
6644 *
6645 * @return Returns the same Intent object, for chaining multiple calls
6646 * into a single statement.
6647 *
6648 * @see #putExtras
6649 * @see #removeExtra
6650 * @see #getSerializableExtra(String)
6651 */
6652 public Intent putExtra(String name, Serializable value) {
6653 if (mExtras == null) {
6654 mExtras = new Bundle();
6655 }
6656 mExtras.putSerializable(name, value);
6657 return this;
6658 }
6659
6660 /**
6661 * Add extended data to the intent. The name must include a package
6662 * prefix, for example the app com.android.contacts would use names
6663 * like "com.android.contacts.ShowAll".
6664 *
6665 * @param name The name of the extra data, with package prefix.
6666 * @param value The boolean array data value.
6667 *
6668 * @return Returns the same Intent object, for chaining multiple calls
6669 * into a single statement.
6670 *
6671 * @see #putExtras
6672 * @see #removeExtra
6673 * @see #getBooleanArrayExtra(String)
6674 */
6675 public Intent putExtra(String name, boolean[] value) {
6676 if (mExtras == null) {
6677 mExtras = new Bundle();
6678 }
6679 mExtras.putBooleanArray(name, value);
6680 return this;
6681 }
6682
6683 /**
6684 * Add extended data to the intent. The name must include a package
6685 * prefix, for example the app com.android.contacts would use names
6686 * like "com.android.contacts.ShowAll".
6687 *
6688 * @param name The name of the extra data, with package prefix.
6689 * @param value The byte array data value.
6690 *
6691 * @return Returns the same Intent object, for chaining multiple calls
6692 * into a single statement.
6693 *
6694 * @see #putExtras
6695 * @see #removeExtra
6696 * @see #getByteArrayExtra(String)
6697 */
6698 public Intent putExtra(String name, byte[] value) {
6699 if (mExtras == null) {
6700 mExtras = new Bundle();
6701 }
6702 mExtras.putByteArray(name, value);
6703 return this;
6704 }
6705
6706 /**
6707 * Add extended data to the intent. The name must include a package
6708 * prefix, for example the app com.android.contacts would use names
6709 * like "com.android.contacts.ShowAll".
6710 *
6711 * @param name The name of the extra data, with package prefix.
6712 * @param value The short array data value.
6713 *
6714 * @return Returns the same Intent object, for chaining multiple calls
6715 * into a single statement.
6716 *
6717 * @see #putExtras
6718 * @see #removeExtra
6719 * @see #getShortArrayExtra(String)
6720 */
6721 public Intent putExtra(String name, short[] value) {
6722 if (mExtras == null) {
6723 mExtras = new Bundle();
6724 }
6725 mExtras.putShortArray(name, value);
6726 return this;
6727 }
6728
6729 /**
6730 * Add extended data to the intent. The name must include a package
6731 * prefix, for example the app com.android.contacts would use names
6732 * like "com.android.contacts.ShowAll".
6733 *
6734 * @param name The name of the extra data, with package prefix.
6735 * @param value The char array data value.
6736 *
6737 * @return Returns the same Intent object, for chaining multiple calls
6738 * into a single statement.
6739 *
6740 * @see #putExtras
6741 * @see #removeExtra
6742 * @see #getCharArrayExtra(String)
6743 */
6744 public Intent putExtra(String name, char[] value) {
6745 if (mExtras == null) {
6746 mExtras = new Bundle();
6747 }
6748 mExtras.putCharArray(name, value);
6749 return this;
6750 }
6751
6752 /**
6753 * Add extended data to the intent. The name must include a package
6754 * prefix, for example the app com.android.contacts would use names
6755 * like "com.android.contacts.ShowAll".
6756 *
6757 * @param name The name of the extra data, with package prefix.
6758 * @param value The int array data value.
6759 *
6760 * @return Returns the same Intent object, for chaining multiple calls
6761 * into a single statement.
6762 *
6763 * @see #putExtras
6764 * @see #removeExtra
6765 * @see #getIntArrayExtra(String)
6766 */
6767 public Intent putExtra(String name, int[] value) {
6768 if (mExtras == null) {
6769 mExtras = new Bundle();
6770 }
6771 mExtras.putIntArray(name, value);
6772 return this;
6773 }
6774
6775 /**
6776 * Add extended data to the intent. The name must include a package
6777 * prefix, for example the app com.android.contacts would use names
6778 * like "com.android.contacts.ShowAll".
6779 *
6780 * @param name The name of the extra data, with package prefix.
6781 * @param value The byte array data value.
6782 *
6783 * @return Returns the same Intent object, for chaining multiple calls
6784 * into a single statement.
6785 *
6786 * @see #putExtras
6787 * @see #removeExtra
6788 * @see #getLongArrayExtra(String)
6789 */
6790 public Intent putExtra(String name, long[] value) {
6791 if (mExtras == null) {
6792 mExtras = new Bundle();
6793 }
6794 mExtras.putLongArray(name, value);
6795 return this;
6796 }
6797
6798 /**
6799 * Add extended data to the intent. The name must include a package
6800 * prefix, for example the app com.android.contacts would use names
6801 * like "com.android.contacts.ShowAll".
6802 *
6803 * @param name The name of the extra data, with package prefix.
6804 * @param value The float array data value.
6805 *
6806 * @return Returns the same Intent object, for chaining multiple calls
6807 * into a single statement.
6808 *
6809 * @see #putExtras
6810 * @see #removeExtra
6811 * @see #getFloatArrayExtra(String)
6812 */
6813 public Intent putExtra(String name, float[] value) {
6814 if (mExtras == null) {
6815 mExtras = new Bundle();
6816 }
6817 mExtras.putFloatArray(name, value);
6818 return this;
6819 }
6820
6821 /**
6822 * Add extended data to the intent. The name must include a package
6823 * prefix, for example the app com.android.contacts would use names
6824 * like "com.android.contacts.ShowAll".
6825 *
6826 * @param name The name of the extra data, with package prefix.
6827 * @param value The double array data value.
6828 *
6829 * @return Returns the same Intent object, for chaining multiple calls
6830 * into a single statement.
6831 *
6832 * @see #putExtras
6833 * @see #removeExtra
6834 * @see #getDoubleArrayExtra(String)
6835 */
6836 public Intent putExtra(String name, double[] value) {
6837 if (mExtras == null) {
6838 mExtras = new Bundle();
6839 }
6840 mExtras.putDoubleArray(name, value);
6841 return this;
6842 }
6843
6844 /**
6845 * Add extended data to the intent. The name must include a package
6846 * prefix, for example the app com.android.contacts would use names
6847 * like "com.android.contacts.ShowAll".
6848 *
6849 * @param name The name of the extra data, with package prefix.
6850 * @param value The String array data value.
6851 *
6852 * @return Returns the same Intent object, for chaining multiple calls
6853 * into a single statement.
6854 *
6855 * @see #putExtras
6856 * @see #removeExtra
6857 * @see #getStringArrayExtra(String)
6858 */
6859 public Intent putExtra(String name, String[] value) {
6860 if (mExtras == null) {
6861 mExtras = new Bundle();
6862 }
6863 mExtras.putStringArray(name, value);
6864 return this;
6865 }
6866
6867 /**
6868 * Add extended data to the intent. The name must include a package
6869 * prefix, for example the app com.android.contacts would use names
6870 * like "com.android.contacts.ShowAll".
6871 *
6872 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006873 * @param value The CharSequence array data value.
6874 *
6875 * @return Returns the same Intent object, for chaining multiple calls
6876 * into a single statement.
6877 *
6878 * @see #putExtras
6879 * @see #removeExtra
6880 * @see #getCharSequenceArrayExtra(String)
6881 */
6882 public Intent putExtra(String name, CharSequence[] value) {
6883 if (mExtras == null) {
6884 mExtras = new Bundle();
6885 }
6886 mExtras.putCharSequenceArray(name, value);
6887 return this;
6888 }
6889
6890 /**
6891 * Add extended data to the intent. The name must include a package
6892 * prefix, for example the app com.android.contacts would use names
6893 * like "com.android.contacts.ShowAll".
6894 *
6895 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006896 * @param value The Bundle data value.
6897 *
6898 * @return Returns the same Intent object, for chaining multiple calls
6899 * into a single statement.
6900 *
6901 * @see #putExtras
6902 * @see #removeExtra
6903 * @see #getBundleExtra(String)
6904 */
6905 public Intent putExtra(String name, Bundle value) {
6906 if (mExtras == null) {
6907 mExtras = new Bundle();
6908 }
6909 mExtras.putBundle(name, value);
6910 return this;
6911 }
6912
6913 /**
6914 * Add extended data to the intent. The name must include a package
6915 * prefix, for example the app com.android.contacts would use names
6916 * like "com.android.contacts.ShowAll".
6917 *
6918 * @param name The name of the extra data, with package prefix.
6919 * @param value The IBinder data value.
6920 *
6921 * @return Returns the same Intent object, for chaining multiple calls
6922 * into a single statement.
6923 *
6924 * @see #putExtras
6925 * @see #removeExtra
6926 * @see #getIBinderExtra(String)
6927 *
6928 * @deprecated
6929 * @hide
6930 */
6931 @Deprecated
6932 public Intent putExtra(String name, IBinder value) {
6933 if (mExtras == null) {
6934 mExtras = new Bundle();
6935 }
6936 mExtras.putIBinder(name, value);
6937 return this;
6938 }
6939
6940 /**
6941 * Copy all extras in 'src' in to this intent.
6942 *
6943 * @param src Contains the extras to copy.
6944 *
6945 * @see #putExtra
6946 */
6947 public Intent putExtras(Intent src) {
6948 if (src.mExtras != null) {
6949 if (mExtras == null) {
6950 mExtras = new Bundle(src.mExtras);
6951 } else {
6952 mExtras.putAll(src.mExtras);
6953 }
6954 }
6955 return this;
6956 }
6957
6958 /**
6959 * Add a set of extended data to the intent. The keys must include a package
6960 * prefix, for example the app com.android.contacts would use names
6961 * like "com.android.contacts.ShowAll".
6962 *
6963 * @param extras The Bundle of extras to add to this intent.
6964 *
6965 * @see #putExtra
6966 * @see #removeExtra
6967 */
6968 public Intent putExtras(Bundle extras) {
6969 if (mExtras == null) {
6970 mExtras = new Bundle();
6971 }
6972 mExtras.putAll(extras);
6973 return this;
6974 }
6975
6976 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006977 * Completely replace the extras in the Intent with the extras in the
6978 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006979 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006980 * @param src The exact extras contained in this Intent are copied
6981 * into the target intent, replacing any that were previously there.
6982 */
6983 public Intent replaceExtras(Intent src) {
6984 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6985 return this;
6986 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006987
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006988 /**
6989 * Completely replace the extras in the Intent with the given Bundle of
6990 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006991 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006992 * @param extras The new set of extras in the Intent, or null to erase
6993 * all extras.
6994 */
6995 public Intent replaceExtras(Bundle extras) {
6996 mExtras = extras != null ? new Bundle(extras) : null;
6997 return this;
6998 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006999
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007000 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007001 * Remove extended data from the intent.
7002 *
7003 * @see #putExtra
7004 */
7005 public void removeExtra(String name) {
7006 if (mExtras != null) {
7007 mExtras.remove(name);
7008 if (mExtras.size() == 0) {
7009 mExtras = null;
7010 }
7011 }
7012 }
7013
7014 /**
7015 * Set special flags controlling how this intent is handled. Most values
7016 * here depend on the type of component being executed by the Intent,
7017 * specifically the FLAG_ACTIVITY_* flags are all for use with
7018 * {@link Context#startActivity Context.startActivity()} and the
7019 * FLAG_RECEIVER_* flags are all for use with
7020 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7021 *
Scott Main7aee61f2011-02-08 11:25:01 -08007022 * <p>See the
7023 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7024 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007025 * the behavior of your application.
7026 *
7027 * @param flags The desired flags.
7028 *
7029 * @return Returns the same Intent object, for chaining multiple calls
7030 * into a single statement.
7031 *
7032 * @see #getFlags
7033 * @see #addFlags
7034 *
7035 * @see #FLAG_GRANT_READ_URI_PERMISSION
7036 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007037 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7038 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007039 * @see #FLAG_DEBUG_LOG_RESOLUTION
7040 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007041 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007042 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007043 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007044 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007045 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7046 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007047 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007048 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007049 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007050 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007051 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007052 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007053 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007054 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7055 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007056 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007057 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007058 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007059 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7060 */
7061 public Intent setFlags(int flags) {
7062 mFlags = flags;
7063 return this;
7064 }
7065
7066 /**
7067 * Add additional flags to the intent (or with existing flags
7068 * value).
7069 *
7070 * @param flags The new flags to set.
7071 *
7072 * @return Returns the same Intent object, for chaining multiple calls
7073 * into a single statement.
7074 *
7075 * @see #setFlags
7076 */
7077 public Intent addFlags(int flags) {
7078 mFlags |= flags;
7079 return this;
7080 }
7081
7082 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007083 * (Usually optional) Set an explicit application package name that limits
7084 * the components this Intent will resolve to. If left to the default
7085 * value of null, all components in all applications will considered.
7086 * If non-null, the Intent can only match the components in the given
7087 * application package.
7088 *
7089 * @param packageName The name of the application package to handle the
7090 * intent, or null to allow any application package.
7091 *
7092 * @return Returns the same Intent object, for chaining multiple calls
7093 * into a single statement.
7094 *
7095 * @see #getPackage
7096 * @see #resolveActivity
7097 */
7098 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007099 if (packageName != null && mSelector != null) {
7100 throw new IllegalArgumentException(
7101 "Can't set package name when selector is already set");
7102 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007103 mPackage = packageName;
7104 return this;
7105 }
7106
7107 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007108 * (Usually optional) Explicitly set the component to handle the intent.
7109 * If left with the default value of null, the system will determine the
7110 * appropriate class to use based on the other fields (action, data,
7111 * type, categories) in the Intent. If this class is defined, the
7112 * specified class will always be used regardless of the other fields. You
7113 * should only set this value when you know you absolutely want a specific
7114 * class to be used; otherwise it is better to let the system find the
7115 * appropriate class so that you will respect the installed applications
7116 * and user preferences.
7117 *
7118 * @param component The name of the application component to handle the
7119 * intent, or null to let the system find one for you.
7120 *
7121 * @return Returns the same Intent object, for chaining multiple calls
7122 * into a single statement.
7123 *
7124 * @see #setClass
7125 * @see #setClassName(Context, String)
7126 * @see #setClassName(String, String)
7127 * @see #getComponent
7128 * @see #resolveActivity
7129 */
7130 public Intent setComponent(ComponentName component) {
7131 mComponent = component;
7132 return this;
7133 }
7134
7135 /**
7136 * Convenience for calling {@link #setComponent} with an
7137 * explicit class name.
7138 *
7139 * @param packageContext A Context of the application package implementing
7140 * this class.
7141 * @param className The name of a class inside of the application package
7142 * that will be used as the component for this Intent.
7143 *
7144 * @return Returns the same Intent object, for chaining multiple calls
7145 * into a single statement.
7146 *
7147 * @see #setComponent
7148 * @see #setClass
7149 */
7150 public Intent setClassName(Context packageContext, String className) {
7151 mComponent = new ComponentName(packageContext, className);
7152 return this;
7153 }
7154
7155 /**
7156 * Convenience for calling {@link #setComponent} with an
7157 * explicit application package name and class name.
7158 *
7159 * @param packageName The name of the package implementing the desired
7160 * component.
7161 * @param className The name of a class inside of the application package
7162 * that will be used as the component for this Intent.
7163 *
7164 * @return Returns the same Intent object, for chaining multiple calls
7165 * into a single statement.
7166 *
7167 * @see #setComponent
7168 * @see #setClass
7169 */
7170 public Intent setClassName(String packageName, String className) {
7171 mComponent = new ComponentName(packageName, className);
7172 return this;
7173 }
7174
7175 /**
7176 * Convenience for calling {@link #setComponent(ComponentName)} with the
7177 * name returned by a {@link Class} object.
7178 *
7179 * @param packageContext A Context of the application package implementing
7180 * this class.
7181 * @param cls The class name to set, equivalent to
7182 * <code>setClassName(context, cls.getName())</code>.
7183 *
7184 * @return Returns the same Intent object, for chaining multiple calls
7185 * into a single statement.
7186 *
7187 * @see #setComponent
7188 */
7189 public Intent setClass(Context packageContext, Class<?> cls) {
7190 mComponent = new ComponentName(packageContext, cls);
7191 return this;
7192 }
7193
7194 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007195 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7196 * used as a hint to the receiver for animations and the like. Null means that there
7197 * is no source bounds.
7198 */
7199 public void setSourceBounds(Rect r) {
7200 if (r != null) {
7201 mSourceBounds = new Rect(r);
7202 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007203 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007204 }
7205 }
7206
Tor Norbyed9273d62013-05-30 15:59:53 -07007207 /** @hide */
7208 @IntDef(flag = true,
7209 value = {
7210 FILL_IN_ACTION,
7211 FILL_IN_DATA,
7212 FILL_IN_CATEGORIES,
7213 FILL_IN_COMPONENT,
7214 FILL_IN_PACKAGE,
7215 FILL_IN_SOURCE_BOUNDS,
7216 FILL_IN_SELECTOR,
7217 FILL_IN_CLIP_DATA
7218 })
7219 @Retention(RetentionPolicy.SOURCE)
7220 public @interface FillInFlags {}
7221
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007222 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007223 * Use with {@link #fillIn} to allow the current action value to be
7224 * overwritten, even if it is already set.
7225 */
7226 public static final int FILL_IN_ACTION = 1<<0;
7227
7228 /**
7229 * Use with {@link #fillIn} to allow the current data or type value
7230 * overwritten, even if it is already set.
7231 */
7232 public static final int FILL_IN_DATA = 1<<1;
7233
7234 /**
7235 * Use with {@link #fillIn} to allow the current categories to be
7236 * overwritten, even if they are already set.
7237 */
7238 public static final int FILL_IN_CATEGORIES = 1<<2;
7239
7240 /**
7241 * Use with {@link #fillIn} to allow the current component value to be
7242 * overwritten, even if it is already set.
7243 */
7244 public static final int FILL_IN_COMPONENT = 1<<3;
7245
7246 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007247 * Use with {@link #fillIn} to allow the current package value to be
7248 * overwritten, even if it is already set.
7249 */
7250 public static final int FILL_IN_PACKAGE = 1<<4;
7251
7252 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007253 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007254 * overwritten, even if it is already set.
7255 */
7256 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7257
7258 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007259 * Use with {@link #fillIn} to allow the current selector to be
7260 * overwritten, even if it is already set.
7261 */
7262 public static final int FILL_IN_SELECTOR = 1<<6;
7263
7264 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007265 * Use with {@link #fillIn} to allow the current ClipData to be
7266 * overwritten, even if it is already set.
7267 */
7268 public static final int FILL_IN_CLIP_DATA = 1<<7;
7269
7270 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007271 * Copy the contents of <var>other</var> in to this object, but only
7272 * where fields are not defined by this object. For purposes of a field
7273 * being defined, the following pieces of data in the Intent are
7274 * considered to be separate fields:
7275 *
7276 * <ul>
7277 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007278 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007279 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7280 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007281 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007282 * <li> component, as set by {@link #setComponent(ComponentName)} or
7283 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007284 * <li> source bounds, as set by {@link #setSourceBounds}.
7285 * <li> selector, as set by {@link #setSelector(Intent)}.
7286 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007287 * <li> each top-level name in the associated extras.
7288 * </ul>
7289 *
7290 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007291 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007292 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7293 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7294 * the restriction where the corresponding field will not be replaced if
7295 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007296 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007297 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7298 * is explicitly specified. The selector will only be copied if
7299 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007300 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007301 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7302 * and Intent B with {action="gotit", data-type="some/thing",
7303 * categories="one","two"}.
7304 *
7305 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7306 * containing: {action="gotit", data-type="some/thing",
7307 * categories="bar"}.
7308 *
7309 * @param other Another Intent whose values are to be used to fill in
7310 * the current one.
7311 * @param flags Options to control which fields can be filled in.
7312 *
7313 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007314 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007315 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7316 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7317 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007318 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007319 @FillInFlags
7320 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007321 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007322 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007323 if (other.mAction != null
7324 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007325 mAction = other.mAction;
7326 changes |= FILL_IN_ACTION;
7327 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007328 if ((other.mData != null || other.mType != null)
7329 && ((mData == null && mType == null)
7330 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007331 mData = other.mData;
7332 mType = other.mType;
7333 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007334 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007335 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007336 if (other.mCategories != null
7337 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007338 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007339 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007340 }
7341 changes |= FILL_IN_CATEGORIES;
7342 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007343 if (other.mPackage != null
7344 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007345 // Only do this if mSelector is not set.
7346 if (mSelector == null) {
7347 mPackage = other.mPackage;
7348 changes |= FILL_IN_PACKAGE;
7349 }
7350 }
7351 // Selector is special: it can only be set if explicitly allowed,
7352 // for the same reason as the component name.
7353 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7354 if (mPackage == null) {
7355 mSelector = new Intent(other.mSelector);
7356 mPackage = null;
7357 changes |= FILL_IN_SELECTOR;
7358 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007359 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007360 if (other.mClipData != null
7361 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7362 mClipData = other.mClipData;
7363 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007364 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007365 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007366 // Component is special: it can -only- be set if explicitly allowed,
7367 // since otherwise the sender could force the intent somewhere the
7368 // originator didn't intend.
7369 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007370 mComponent = other.mComponent;
7371 changes |= FILL_IN_COMPONENT;
7372 }
7373 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007374 if (other.mSourceBounds != null
7375 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7376 mSourceBounds = new Rect(other.mSourceBounds);
7377 changes |= FILL_IN_SOURCE_BOUNDS;
7378 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007379 if (mExtras == null) {
7380 if (other.mExtras != null) {
7381 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007382 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007383 }
7384 } else if (other.mExtras != null) {
7385 try {
7386 Bundle newb = new Bundle(other.mExtras);
7387 newb.putAll(mExtras);
7388 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007389 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007390 } catch (RuntimeException e) {
7391 // Modifying the extras can cause us to unparcel the contents
7392 // of the bundle, and if we do this in the system process that
7393 // may fail. We really should handle this (i.e., the Bundle
7394 // impl shouldn't be on top of a plain map), but for now just
7395 // ignore it and keep the original contents. :(
7396 Log.w("Intent", "Failure filling in extras", e);
7397 }
7398 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007399 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7400 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7401 mContentUserHint = other.mContentUserHint;
7402 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007403 return changes;
7404 }
7405
7406 /**
7407 * Wrapper class holding an Intent and implementing comparisons on it for
7408 * the purpose of filtering. The class implements its
7409 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7410 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7411 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7412 * on the wrapped Intent.
7413 */
7414 public static final class FilterComparison {
7415 private final Intent mIntent;
7416 private final int mHashCode;
7417
7418 public FilterComparison(Intent intent) {
7419 mIntent = intent;
7420 mHashCode = intent.filterHashCode();
7421 }
7422
7423 /**
7424 * Return the Intent that this FilterComparison represents.
7425 * @return Returns the Intent held by the FilterComparison. Do
7426 * not modify!
7427 */
7428 public Intent getIntent() {
7429 return mIntent;
7430 }
7431
7432 @Override
7433 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007434 if (obj instanceof FilterComparison) {
7435 Intent other = ((FilterComparison)obj).mIntent;
7436 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007437 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007438 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007439 }
7440
7441 @Override
7442 public int hashCode() {
7443 return mHashCode;
7444 }
7445 }
7446
7447 /**
7448 * Determine if two intents are the same for the purposes of intent
7449 * resolution (filtering). That is, if their action, data, type,
7450 * class, and categories are the same. This does <em>not</em> compare
7451 * any extra data included in the intents.
7452 *
7453 * @param other The other Intent to compare against.
7454 *
7455 * @return Returns true if action, data, type, class, and categories
7456 * are the same.
7457 */
7458 public boolean filterEquals(Intent other) {
7459 if (other == null) {
7460 return false;
7461 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007462 if (!Objects.equals(this.mAction, other.mAction)) return false;
7463 if (!Objects.equals(this.mData, other.mData)) return false;
7464 if (!Objects.equals(this.mType, other.mType)) return false;
7465 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7466 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7467 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007468
7469 return true;
7470 }
7471
7472 /**
7473 * Generate hash code that matches semantics of filterEquals().
7474 *
7475 * @return Returns the hash value of the action, data, type, class, and
7476 * categories.
7477 *
7478 * @see #filterEquals
7479 */
7480 public int filterHashCode() {
7481 int code = 0;
7482 if (mAction != null) {
7483 code += mAction.hashCode();
7484 }
7485 if (mData != null) {
7486 code += mData.hashCode();
7487 }
7488 if (mType != null) {
7489 code += mType.hashCode();
7490 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007491 if (mPackage != null) {
7492 code += mPackage.hashCode();
7493 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007494 if (mComponent != null) {
7495 code += mComponent.hashCode();
7496 }
7497 if (mCategories != null) {
7498 code += mCategories.hashCode();
7499 }
7500 return code;
7501 }
7502
7503 @Override
7504 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007505 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007506
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007507 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007508 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007509 b.append(" }");
7510
7511 return b.toString();
7512 }
7513
7514 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007515 public String toInsecureString() {
7516 StringBuilder b = new StringBuilder(128);
7517
7518 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007519 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007520 b.append(" }");
7521
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007522 return b.toString();
7523 }
Romain Guy4969af72009-06-17 10:53:19 -07007524
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007525 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007526 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007527 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007528
7529 b.append("Intent { ");
7530 toShortString(b, false, true, true, true);
7531 b.append(" }");
7532
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007533 return b.toString();
7534 }
7535
7536 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007537 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7538 StringBuilder b = new StringBuilder(128);
7539 toShortString(b, secure, comp, extras, clip);
7540 return b.toString();
7541 }
7542
7543 /** @hide */
7544 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7545 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007546 boolean first = true;
7547 if (mAction != null) {
7548 b.append("act=").append(mAction);
7549 first = false;
7550 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007551 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007552 if (!first) {
7553 b.append(' ');
7554 }
7555 first = false;
7556 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007557 for (int i=0; i<mCategories.size(); i++) {
7558 if (i > 0) b.append(',');
7559 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007560 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007561 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007562 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007563 if (mData != null) {
7564 if (!first) {
7565 b.append(' ');
7566 }
7567 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007568 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007569 if (secure) {
7570 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007571 } else {
7572 b.append(mData);
7573 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007574 }
7575 if (mType != null) {
7576 if (!first) {
7577 b.append(' ');
7578 }
7579 first = false;
7580 b.append("typ=").append(mType);
7581 }
7582 if (mFlags != 0) {
7583 if (!first) {
7584 b.append(' ');
7585 }
7586 first = false;
7587 b.append("flg=0x").append(Integer.toHexString(mFlags));
7588 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007589 if (mPackage != null) {
7590 if (!first) {
7591 b.append(' ');
7592 }
7593 first = false;
7594 b.append("pkg=").append(mPackage);
7595 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007596 if (comp && mComponent != null) {
7597 if (!first) {
7598 b.append(' ');
7599 }
7600 first = false;
7601 b.append("cmp=").append(mComponent.flattenToShortString());
7602 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007603 if (mSourceBounds != null) {
7604 if (!first) {
7605 b.append(' ');
7606 }
7607 first = false;
7608 b.append("bnds=").append(mSourceBounds.toShortString());
7609 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007610 if (mClipData != null) {
7611 if (!first) {
7612 b.append(' ');
7613 }
Dianne Hackbornae498722015-08-14 13:29:47 -07007614 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007615 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007616 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007617 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07007618 if (mClipData.getDescription() != null) {
7619 first = !mClipData.getDescription().toShortStringTypesOnly(b);
7620 } else {
7621 first = true;
7622 }
7623 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007624 }
Dianne Hackbornae498722015-08-14 13:29:47 -07007625 first = false;
7626 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007627 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007628 if (extras && mExtras != null) {
7629 if (!first) {
7630 b.append(' ');
7631 }
7632 first = false;
7633 b.append("(has extras)");
7634 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007635 if (mContentUserHint != UserHandle.USER_CURRENT) {
7636 if (!first) {
7637 b.append(' ');
7638 }
7639 first = false;
7640 b.append("u=").append(mContentUserHint);
7641 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007642 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007643 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007644 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007645 b.append("}");
7646 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007647 }
7648
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007649 /**
7650 * Call {@link #toUri} with 0 flags.
7651 * @deprecated Use {@link #toUri} instead.
7652 */
7653 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007654 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007655 return toUri(0);
7656 }
7657
7658 /**
7659 * Convert this Intent into a String holding a URI representation of it.
7660 * The returned URI string has been properly URI encoded, so it can be
7661 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7662 * Intent's data as the base URI, with an additional fragment describing
7663 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007664 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007665 * <p>You can convert the returned string back to an Intent with
7666 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007667 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007668 * @param flags Additional operating flags. Either 0,
7669 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007670 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007671 * @return Returns a URI encoding URI string describing the entire contents
7672 * of the Intent.
7673 */
7674 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007675 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007676 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7677 if (mPackage == null) {
7678 throw new IllegalArgumentException(
7679 "Intent must include an explicit package name to build an android-app: "
7680 + this);
7681 }
7682 uri.append("android-app://");
7683 uri.append(mPackage);
7684 String scheme = null;
7685 if (mData != null) {
7686 scheme = mData.getScheme();
7687 if (scheme != null) {
7688 uri.append('/');
7689 uri.append(scheme);
7690 String authority = mData.getEncodedAuthority();
7691 if (authority != null) {
7692 uri.append('/');
7693 uri.append(authority);
7694 String path = mData.getEncodedPath();
7695 if (path != null) {
7696 uri.append(path);
7697 }
7698 String queryParams = mData.getEncodedQuery();
7699 if (queryParams != null) {
7700 uri.append('?');
7701 uri.append(queryParams);
7702 }
7703 String fragment = mData.getEncodedFragment();
7704 if (fragment != null) {
7705 uri.append('#');
7706 uri.append(fragment);
7707 }
7708 }
7709 }
7710 }
7711 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7712 mPackage, flags);
7713 return uri.toString();
7714 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007715 String scheme = null;
7716 if (mData != null) {
7717 String data = mData.toString();
7718 if ((flags&URI_INTENT_SCHEME) != 0) {
7719 final int N = data.length();
7720 for (int i=0; i<N; i++) {
7721 char c = data.charAt(i);
7722 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7723 || c == '.' || c == '-') {
7724 continue;
7725 }
7726 if (c == ':' && i > 0) {
7727 // Valid scheme.
7728 scheme = data.substring(0, i);
7729 uri.append("intent:");
7730 data = data.substring(i+1);
7731 break;
7732 }
Tom Taylord4a47292009-12-21 13:59:18 -08007733
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007734 // No scheme.
7735 break;
7736 }
7737 }
7738 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007739
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007740 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7741 uri.append("intent:");
7742 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007743
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007744 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007745
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007746 return uri.toString();
7747 }
7748
7749 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7750 String defPackage, int flags) {
7751 StringBuilder frag = new StringBuilder(128);
7752
7753 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007754 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007755 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007756 // Note that for now we are not going to try to handle the
7757 // data part; not clear how to represent this as a URI, and
7758 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007759 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7760 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007761 }
7762
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007763 if (frag.length() > 0) {
7764 uri.append("#Intent;");
7765 uri.append(frag);
7766 uri.append("end");
7767 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007768 }
7769
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007770 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7771 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007772 if (scheme != null) {
7773 uri.append("scheme=").append(scheme).append(';');
7774 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007775 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007776 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007777 }
7778 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007779 for (int i=0; i<mCategories.size(); i++) {
7780 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007781 }
7782 }
7783 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007784 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007785 }
7786 if (mFlags != 0) {
7787 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7788 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007789 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007790 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7791 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007792 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007793 uri.append("component=").append(Uri.encode(
7794 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007796 if (mSourceBounds != null) {
7797 uri.append("sourceBounds=")
7798 .append(Uri.encode(mSourceBounds.flattenToString()))
7799 .append(';');
7800 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007801 if (mExtras != null) {
7802 for (String key : mExtras.keySet()) {
7803 final Object value = mExtras.get(key);
7804 char entryType =
7805 value instanceof String ? 'S' :
7806 value instanceof Boolean ? 'B' :
7807 value instanceof Byte ? 'b' :
7808 value instanceof Character ? 'c' :
7809 value instanceof Double ? 'd' :
7810 value instanceof Float ? 'f' :
7811 value instanceof Integer ? 'i' :
7812 value instanceof Long ? 'l' :
7813 value instanceof Short ? 's' :
7814 '\0';
7815
7816 if (entryType != '\0') {
7817 uri.append(entryType);
7818 uri.append('.');
7819 uri.append(Uri.encode(key));
7820 uri.append('=');
7821 uri.append(Uri.encode(value.toString()));
7822 uri.append(';');
7823 }
7824 }
7825 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007826 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007827
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007828 public int describeContents() {
7829 return (mExtras != null) ? mExtras.describeContents() : 0;
7830 }
7831
7832 public void writeToParcel(Parcel out, int flags) {
7833 out.writeString(mAction);
7834 Uri.writeToParcel(out, mData);
7835 out.writeString(mType);
7836 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007837 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 ComponentName.writeToParcel(mComponent, out);
7839
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007840 if (mSourceBounds != null) {
7841 out.writeInt(1);
7842 mSourceBounds.writeToParcel(out, flags);
7843 } else {
7844 out.writeInt(0);
7845 }
7846
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007847 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007848 final int N = mCategories.size();
7849 out.writeInt(N);
7850 for (int i=0; i<N; i++) {
7851 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007852 }
7853 } else {
7854 out.writeInt(0);
7855 }
7856
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007857 if (mSelector != null) {
7858 out.writeInt(1);
7859 mSelector.writeToParcel(out, flags);
7860 } else {
7861 out.writeInt(0);
7862 }
7863
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007864 if (mClipData != null) {
7865 out.writeInt(1);
7866 mClipData.writeToParcel(out, flags);
7867 } else {
7868 out.writeInt(0);
7869 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007870 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007871 out.writeBundle(mExtras);
7872 }
7873
7874 public static final Parcelable.Creator<Intent> CREATOR
7875 = new Parcelable.Creator<Intent>() {
7876 public Intent createFromParcel(Parcel in) {
7877 return new Intent(in);
7878 }
7879 public Intent[] newArray(int size) {
7880 return new Intent[size];
7881 }
7882 };
7883
Dianne Hackborneb034652009-09-07 00:49:58 -07007884 /** @hide */
7885 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007886 readFromParcel(in);
7887 }
7888
7889 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007890 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007891 mData = Uri.CREATOR.createFromParcel(in);
7892 mType = in.readString();
7893 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007894 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007895 mComponent = ComponentName.readFromParcel(in);
7896
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007897 if (in.readInt() != 0) {
7898 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7899 }
7900
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007901 int N = in.readInt();
7902 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007903 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007904 int i;
7905 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007906 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007907 }
7908 } else {
7909 mCategories = null;
7910 }
7911
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007912 if (in.readInt() != 0) {
7913 mSelector = new Intent(in);
7914 }
7915
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007916 if (in.readInt() != 0) {
7917 mClipData = new ClipData(in);
7918 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007919 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007920 mExtras = in.readBundle();
7921 }
7922
7923 /**
7924 * Parses the "intent" element (and its children) from XML and instantiates
7925 * an Intent object. The given XML parser should be located at the tag
7926 * where parsing should start (often named "intent"), from which the
7927 * basic action, data, type, and package and class name will be
7928 * retrieved. The function will then parse in to any child elements,
7929 * looking for <category android:name="xxx"> tags to add categories and
7930 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7931 * to the intent.
7932 *
7933 * @param resources The Resources to use when inflating resources.
7934 * @param parser The XML parser pointing at an "intent" tag.
7935 * @param attrs The AttributeSet interface for retrieving extended
7936 * attribute data at the current <var>parser</var> location.
7937 * @return An Intent object matching the XML data.
7938 * @throws XmlPullParserException If there was an XML parsing error.
7939 * @throws IOException If there was an I/O error.
7940 */
7941 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7942 throws XmlPullParserException, IOException {
7943 Intent intent = new Intent();
7944
7945 TypedArray sa = resources.obtainAttributes(attrs,
7946 com.android.internal.R.styleable.Intent);
7947
7948 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7949
7950 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7951 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7952 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7953
7954 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7955 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7956 if (packageName != null && className != null) {
7957 intent.setComponent(new ComponentName(packageName, className));
7958 }
7959
7960 sa.recycle();
7961
7962 int outerDepth = parser.getDepth();
7963 int type;
7964 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7965 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7966 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7967 continue;
7968 }
7969
7970 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007971 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007972 sa = resources.obtainAttributes(attrs,
7973 com.android.internal.R.styleable.IntentCategory);
7974 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7975 sa.recycle();
7976
7977 if (cat != null) {
7978 intent.addCategory(cat);
7979 }
7980 XmlUtils.skipCurrentTag(parser);
7981
Craig Mautner21d24a22014-04-23 11:45:37 -07007982 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007983 if (intent.mExtras == null) {
7984 intent.mExtras = new Bundle();
7985 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007986 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007987 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007988
7989 } else {
7990 XmlUtils.skipCurrentTag(parser);
7991 }
7992 }
7993
7994 return intent;
7995 }
Nick Pellyccae4122012-01-09 14:12:58 -08007996
Craig Mautner21d24a22014-04-23 11:45:37 -07007997 /** @hide */
7998 public void saveToXml(XmlSerializer out) throws IOException {
7999 if (mAction != null) {
8000 out.attribute(null, ATTR_ACTION, mAction);
8001 }
8002 if (mData != null) {
8003 out.attribute(null, ATTR_DATA, mData.toString());
8004 }
8005 if (mType != null) {
8006 out.attribute(null, ATTR_TYPE, mType);
8007 }
8008 if (mComponent != null) {
8009 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8010 }
8011 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8012
8013 if (mCategories != null) {
8014 out.startTag(null, TAG_CATEGORIES);
8015 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8016 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8017 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008018 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008019 }
8020 }
8021
8022 /** @hide */
8023 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8024 XmlPullParserException {
8025 Intent intent = new Intent();
8026 final int outerDepth = in.getDepth();
8027
8028 int attrCount = in.getAttributeCount();
8029 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8030 final String attrName = in.getAttributeName(attrNdx);
8031 final String attrValue = in.getAttributeValue(attrNdx);
8032 if (ATTR_ACTION.equals(attrName)) {
8033 intent.setAction(attrValue);
8034 } else if (ATTR_DATA.equals(attrName)) {
8035 intent.setData(Uri.parse(attrValue));
8036 } else if (ATTR_TYPE.equals(attrName)) {
8037 intent.setType(attrValue);
8038 } else if (ATTR_COMPONENT.equals(attrName)) {
8039 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8040 } else if (ATTR_FLAGS.equals(attrName)) {
8041 intent.setFlags(Integer.valueOf(attrValue, 16));
8042 } else {
8043 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8044 }
8045 }
8046
8047 int event;
8048 String name;
8049 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8050 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8051 if (event == XmlPullParser.START_TAG) {
8052 name = in.getName();
8053 if (TAG_CATEGORIES.equals(name)) {
8054 attrCount = in.getAttributeCount();
8055 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8056 intent.addCategory(in.getAttributeValue(attrNdx));
8057 }
8058 } else {
8059 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8060 XmlUtils.skipCurrentTag(in);
8061 }
8062 }
8063 }
8064
8065 return intent;
8066 }
8067
Nick Pellyccae4122012-01-09 14:12:58 -08008068 /**
8069 * Normalize a MIME data type.
8070 *
8071 * <p>A normalized MIME type has white-space trimmed,
8072 * content-type parameters removed, and is lower-case.
8073 * This aligns the type with Android best practices for
8074 * intent filtering.
8075 *
8076 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8077 * "text/x-vCard" becomes "text/x-vcard".
8078 *
8079 * <p>All MIME types received from outside Android (such as user input,
8080 * or external sources like Bluetooth, NFC, or the Internet) should
8081 * be normalized before they are used to create an Intent.
8082 *
8083 * @param type MIME data type to normalize
8084 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008085 * @see #setType
8086 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008087 */
8088 public static String normalizeMimeType(String type) {
8089 if (type == null) {
8090 return null;
8091 }
8092
Elliott Hughescb64d432013-08-02 10:00:44 -07008093 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008094
8095 final int semicolonIndex = type.indexOf(';');
8096 if (semicolonIndex != -1) {
8097 type = type.substring(0, semicolonIndex);
8098 }
8099 return type;
8100 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008101
8102 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008103 * Prepare this {@link Intent} to leave an app process.
8104 *
8105 * @hide
8106 */
8107 public void prepareToLeaveProcess() {
8108 setAllowFds(false);
8109
8110 if (mSelector != null) {
8111 mSelector.prepareToLeaveProcess();
8112 }
8113 if (mClipData != null) {
8114 mClipData.prepareToLeaveProcess();
8115 }
8116
8117 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8118 // There are several ACTION_MEDIA_* broadcasts that send file://
8119 // Uris, so only check common actions.
8120 if (ACTION_VIEW.equals(mAction) ||
8121 ACTION_EDIT.equals(mAction) ||
8122 ACTION_ATTACH_DATA.equals(mAction)) {
8123 mData.checkFileUriExposed("Intent.getData()");
8124 }
8125 }
8126 }
8127
8128 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008129 * @hide
8130 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008131 public void prepareToEnterProcess() {
8132 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008133 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8134 fixUris(mContentUserHint);
8135 mContentUserHint = UserHandle.USER_CURRENT;
8136 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008137 }
8138 }
8139
8140 /**
8141 * @hide
8142 */
8143 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008144 Uri data = getData();
8145 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008146 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008147 }
8148 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008149 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008150 }
8151 String action = getAction();
8152 if (ACTION_SEND.equals(action)) {
8153 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8154 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008155 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008156 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008157 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008158 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8159 if (streams != null) {
8160 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8161 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008162 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008163 }
8164 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8165 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008166 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8167 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8168 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8169 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8170 if (output != null) {
8171 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8172 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008173 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008174 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008175
8176 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008177 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008178 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8179 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008180 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008181 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008182 * @hide
8183 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008184 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008185 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008186 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008187
8188 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008189 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008190
8191 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008192 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008193 // Inspect contained intents to see if we need to migrate extras. We
8194 // don't promote ClipData to the parent, since ChooserActivity will
8195 // already start the picked item as the caller, and we can't combine
8196 // the flags in a safe way.
8197
8198 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008199 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008200 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8201 if (intent != null) {
8202 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008203 }
8204 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008205 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008206 try {
8207 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8208 if (intents != null) {
8209 for (int i = 0; i < intents.length; i++) {
8210 final Intent intent = (Intent) intents[i];
8211 if (intent != null) {
8212 migrated |= intent.migrateExtraStreamToClipData();
8213 }
8214 }
8215 }
8216 } catch (ClassCastException e) {
8217 }
8218 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008219
8220 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008221 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008222 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8223 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8224 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8225 if (stream != null || text != null || htmlText != null) {
8226 final ClipData clipData = new ClipData(
8227 null, new String[] { getType() },
8228 new ClipData.Item(text, htmlText, null, stream));
8229 setClipData(clipData);
8230 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008231 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008232 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008233 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008234 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008235
8236 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008237 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008238 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8239 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8240 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8241 int num = -1;
8242 if (streams != null) {
8243 num = streams.size();
8244 }
8245 if (texts != null) {
8246 if (num >= 0 && num != texts.size()) {
8247 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008248 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008249 }
8250 num = texts.size();
8251 }
8252 if (htmlTexts != null) {
8253 if (num >= 0 && num != htmlTexts.size()) {
8254 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008255 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008256 }
8257 num = htmlTexts.size();
8258 }
8259 if (num > 0) {
8260 final ClipData clipData = new ClipData(
8261 null, new String[] { getType() },
8262 makeClipItem(streams, texts, htmlTexts, 0));
8263
8264 for (int i = 1; i < num; i++) {
8265 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8266 }
8267
8268 setClipData(clipData);
8269 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008270 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008271 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008272 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008273 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008274 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8275 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8276 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8277 final Uri output;
8278 try {
8279 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8280 } catch (ClassCastException e) {
8281 return false;
8282 }
8283 if (output != null) {
8284 setClipData(ClipData.newRawUri("", output));
8285 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8286 return true;
8287 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008288 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008289
8290 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008291 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008292
8293 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8294 ArrayList<String> htmlTexts, int which) {
8295 Uri uri = streams != null ? streams.get(which) : null;
8296 CharSequence text = texts != null ? texts.get(which) : null;
8297 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8298 return new ClipData.Item(text, htmlText, null, uri);
8299 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008300
8301 /** @hide */
8302 public boolean isDocument() {
8303 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8304 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008305}