blob: 5c23204aeebabfc780ed3e15c1d33548dbcf1196 [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.
1023 */
1024 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1025 public static final String ACTION_CALL = "android.intent.action.CALL";
1026 /**
1027 * Activity Action: Perform a call to an emergency number specified by the
1028 * data.
1029 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1030 * tel: URI of an explicit phone number.
1031 * <p>Output: nothing.
1032 * @hide
1033 */
1034 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1035 /**
1036 * Activity action: Perform a call to any number (emergency or not)
1037 * specified by the data.
1038 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1039 * tel: URI of an explicit phone number.
1040 * <p>Output: nothing.
1041 * @hide
1042 */
1043 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1044 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001045 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1046 * sending this intent is a no-op.
1047 * <p>Input: No data should be specified. get*Extra may have an optional
1048 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1049 * send the activation result.
1050 * <p>Output: nothing.
1051 * @hide
1052 */
1053 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1054 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1055 "android.intent.action.SIM_ACTIVATION_REQUEST";
1056 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001057 * Activity Action: Send a message to someone specified by the data.
1058 * <p>Input: {@link #getData} is URI describing the target.
1059 * <p>Output: nothing.
1060 */
1061 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1062 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1063 /**
1064 * Activity Action: Deliver some data to someone else. Who the data is
1065 * being delivered to is not specified; it is up to the receiver of this
1066 * action to ask the user where the data should be sent.
1067 * <p>
1068 * When launching a SEND intent, you should usually wrap it in a chooser
1069 * (through {@link #createChooser}), which will give the proper interface
1070 * for the user to pick how to send your data and allow you to specify
1071 * a prompt indicating what they are doing.
1072 * <p>
1073 * Input: {@link #getType} is the MIME type of the data being sent.
1074 * get*Extra can have either a {@link #EXTRA_TEXT}
1075 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1076 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1077 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1078 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001079 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1080 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1081 * your text with HTML formatting.
1082 * <p>
1083 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1084 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1085 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1086 * content: URIs and other advanced features of {@link ClipData}. If
1087 * using this approach, you still must supply the same data through the
1088 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1089 * for compatibility with old applications. If you don't set a ClipData,
1090 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001091 * <p>
1092 * Optional standard extras, which may be interpreted by some recipients as
1093 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1094 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1095 * <p>
1096 * Output: nothing.
1097 */
1098 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1099 public static final String ACTION_SEND = "android.intent.action.SEND";
1100 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001101 * Activity Action: Deliver multiple data to someone else.
1102 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001103 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001104 * <p>
1105 * Input: {@link #getType} is the MIME type of the data being sent.
1106 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001107 * #EXTRA_STREAM} field, containing the data to be sent. If using
1108 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1109 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001110 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001111 * Multiple types are supported, and receivers should handle mixed types
1112 * whenever possible. The right way for the receiver to check them is to
1113 * use the content resolver on each URI. The intent sender should try to
1114 * put the most concrete mime type in the intent type, but it can fall
1115 * back to {@literal <type>/*} or {@literal *}/* as needed.
1116 * <p>
1117 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1118 * be image/jpg, but if you are sending image/jpg and image/png, then the
1119 * intent's type should be image/*.
1120 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001121 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1122 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1123 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1124 * content: URIs and other advanced features of {@link ClipData}. If
1125 * using this approach, you still must supply the same data through the
1126 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1127 * for compatibility with old applications. If you don't set a ClipData,
1128 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1129 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001130 * Optional standard extras, which may be interpreted by some recipients as
1131 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1132 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1133 * <p>
1134 * Output: nothing.
1135 */
1136 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1137 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1138 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001139 * Activity Action: Handle an incoming phone call.
1140 * <p>Input: nothing.
1141 * <p>Output: nothing.
1142 */
1143 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1144 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1145 /**
1146 * Activity Action: Insert an empty item into the given container.
1147 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1148 * in which to place the data.
1149 * <p>Output: URI of the new data that was created.
1150 */
1151 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1152 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1153 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001154 * Activity Action: Create a new item in the given container, initializing it
1155 * from the current contents of the clipboard.
1156 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1157 * in which to place the data.
1158 * <p>Output: URI of the new data that was created.
1159 */
1160 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1161 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1162 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001163 * Activity Action: Delete the given data from its container.
1164 * <p>Input: {@link #getData} is URI of data to be deleted.
1165 * <p>Output: nothing.
1166 */
1167 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1168 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1169 /**
1170 * Activity Action: Run the data, whatever that means.
1171 * <p>Input: ? (Note: this is currently specific to the test harness.)
1172 * <p>Output: nothing.
1173 */
1174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1175 public static final String ACTION_RUN = "android.intent.action.RUN";
1176 /**
1177 * Activity Action: Perform a data synchronization.
1178 * <p>Input: ?
1179 * <p>Output: ?
1180 */
1181 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1182 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1183 /**
1184 * Activity Action: Pick an activity given an intent, returning the class
1185 * selected.
1186 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1187 * used with {@link PackageManager#queryIntentActivities} to determine the
1188 * set of activities from which to pick.
1189 * <p>Output: Class name of the activity that was selected.
1190 */
1191 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1192 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1193 /**
1194 * Activity Action: Perform a search.
1195 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1196 * is the text to search for. If empty, simply
1197 * enter your search results Activity with the search UI activated.
1198 * <p>Output: nothing.
1199 */
1200 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1201 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1202 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001203 * Activity Action: Start the platform-defined tutorial
1204 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1205 * is the text to search for. If empty, simply
1206 * enter your search results Activity with the search UI activated.
1207 * <p>Output: nothing.
1208 */
1209 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1210 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1211 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001212 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001213 * <p>
1214 * Input: {@link android.app.SearchManager#QUERY
1215 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1216 * a url starts with http or https, the site will be opened. If it is plain
1217 * text, Google search will be applied.
1218 * <p>
1219 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001220 */
1221 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1222 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001223
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001224 /**
Jim Miller07994402012-05-02 14:22:27 -07001225 * Activity Action: Perform assist action.
1226 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001227 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1228 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001229 * requested the assist.
Jim Miller07994402012-05-02 14:22:27 -07001230 * Output: nothing.
1231 */
1232 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1233 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001234
1235 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001236 * Activity Action: Perform voice assist action.
1237 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001238 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1239 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001240 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001241 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001242 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001243 */
1244 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1245 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1246
1247 /**
Adam Skory7140a252013-09-11 12:04:58 +01001248 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1249 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001250 */
1251 public static final String EXTRA_ASSIST_PACKAGE
1252 = "android.intent.extra.ASSIST_PACKAGE";
1253
1254 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001255 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1256 * application package at the time the assist was invoked.
1257 */
1258 public static final String EXTRA_ASSIST_UID
1259 = "android.intent.extra.ASSIST_UID";
1260
1261 /**
Adam Skory7140a252013-09-11 12:04:58 +01001262 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1263 * information supplied by the current foreground app at the time of the assist request.
1264 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001265 */
1266 public static final String EXTRA_ASSIST_CONTEXT
1267 = "android.intent.extra.ASSIST_CONTEXT";
1268
Jim Miller07994402012-05-02 14:22:27 -07001269 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001270 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1271 * keyboard as the primary input device for assistance.
1272 */
1273 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1274 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1275
1276 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001277 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1278 * that was used to invoke the assist.
1279 */
1280 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1281 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1282
1283 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001284 * Activity Action: List all available applications
1285 * <p>Input: Nothing.
1286 * <p>Output: nothing.
1287 */
1288 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1289 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1290 /**
1291 * Activity Action: Show settings for choosing wallpaper
1292 * <p>Input: Nothing.
1293 * <p>Output: Nothing.
1294 */
1295 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1296 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1297
1298 /**
1299 * Activity Action: Show activity for reporting a bug.
1300 * <p>Input: Nothing.
1301 * <p>Output: Nothing.
1302 */
1303 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1304 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1305
1306 /**
1307 * Activity Action: Main entry point for factory tests. Only used when
1308 * the device is booting in factory test node. The implementing package
1309 * must be installed in the system image.
1310 * <p>Input: nothing
1311 * <p>Output: nothing
1312 */
1313 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1314
1315 /**
1316 * Activity Action: The user pressed the "call" button to go to the dialer
1317 * or other appropriate UI for placing a call.
1318 * <p>Input: Nothing.
1319 * <p>Output: Nothing.
1320 */
1321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1323
1324 /**
1325 * Activity Action: Start Voice Command.
1326 * <p>Input: Nothing.
1327 * <p>Output: Nothing.
1328 */
1329 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1330 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001331
1332 /**
1333 * Activity Action: Start action associated with long pressing on the
1334 * search key.
1335 * <p>Input: Nothing.
1336 * <p>Output: Nothing.
1337 */
1338 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1339 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001340
Jacek Surazski86b6c532009-05-13 14:38:28 +02001341 /**
1342 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1343 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001344 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001345 * <p>Input: No data is specified. The bug report is passed in using
1346 * an {@link #EXTRA_BUG_REPORT} field.
1347 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001348 *
1349 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001350 */
1351 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1352 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001353
1354 /**
1355 * Activity Action: Show power usage information to the user.
1356 * <p>Input: Nothing.
1357 * <p>Output: Nothing.
1358 */
1359 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1360 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001361
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001362 /**
1363 * Activity Action: Setup wizard to launch after a platform update. This
1364 * activity should have a string meta-data field associated with it,
1365 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1366 * the platform for setup. The activity will be launched only if
1367 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1368 * same value.
1369 * <p>Input: Nothing.
1370 * <p>Output: Nothing.
1371 * @hide
1372 */
1373 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1374 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001375
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001376 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001377 * Activity Action: Show settings for managing network data usage of a
1378 * specific application. Applications should define an activity that offers
1379 * options to control data usage.
1380 */
1381 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1382 public static final String ACTION_MANAGE_NETWORK_USAGE =
1383 "android.intent.action.MANAGE_NETWORK_USAGE";
1384
1385 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001386 * Activity Action: Launch application installer.
1387 * <p>
1388 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001389 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1390 * you can also use "package:<package-name>" to install an application for the
1391 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001392 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1393 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1394 * <p>
1395 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1396 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001397 * <p>
1398 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1399 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1400 * in order to launch the application installer.
1401 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001402 *
1403 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1404 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1405 * @see #EXTRA_RETURN_RESULT
1406 */
1407 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1408 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1409
1410 /**
1411 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1412 * package. Specifies the installer package name; this package will receive the
1413 * {@link #ACTION_APP_ERROR} intent.
1414 */
1415 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1416 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1417
1418 /**
1419 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1420 * package. Specifies that the application being installed should not be
1421 * treated as coming from an unknown source, but as coming from the app
1422 * invoking the Intent. For this to work you must start the installer with
1423 * startActivityForResult().
1424 */
1425 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1426 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1427
1428 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001429 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1430 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001431 * data field originated from.
1432 */
rich cannings706e8ba2012-08-20 13:20:14 -07001433 public static final String EXTRA_ORIGINATING_URI
1434 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001435
1436 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001437 * This extra can be used with any Intent used to launch an activity, supplying information
1438 * about who is launching that activity. This field contains a {@link android.net.Uri}
1439 * object, typically an http: or https: URI of the web site that the referral came from;
1440 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1441 * a native application that it came from.
1442 *
1443 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1444 * instead of directly retrieving the extra. It is also valid for applications to
1445 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1446 * a string, not a Uri; the field here, if supplied, will always take precedence,
1447 * however.</p>
1448 *
1449 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001450 */
1451 public static final String EXTRA_REFERRER
1452 = "android.intent.extra.REFERRER";
1453
1454 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001455 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1456 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1457 * not be created, in particular when Intent extras are supplied through the
1458 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1459 * schemes.
1460 *
1461 * @see #EXTRA_REFERRER
1462 */
1463 public static final String EXTRA_REFERRER_NAME
1464 = "android.intent.extra.REFERRER_NAME";
1465
1466 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001467 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1468 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1469 * @hide
1470 */
1471 public static final String EXTRA_ORIGINATING_UID
1472 = "android.intent.extra.ORIGINATING_UID";
1473
1474 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001475 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1476 * package. Tells the installer UI to skip the confirmation with the user
1477 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001478 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1479 * will no longer show an interstitial message about updating existing
1480 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001481 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001482 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001483 public static final String EXTRA_ALLOW_REPLACE
1484 = "android.intent.extra.ALLOW_REPLACE";
1485
1486 /**
1487 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1488 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1489 * return to the application the result code of the install/uninstall. The returned result
1490 * code will be {@link android.app.Activity#RESULT_OK} on success or
1491 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1492 */
1493 public static final String EXTRA_RETURN_RESULT
1494 = "android.intent.extra.RETURN_RESULT";
1495
1496 /**
1497 * Package manager install result code. @hide because result codes are not
1498 * yet ready to be exposed.
1499 */
1500 public static final String EXTRA_INSTALL_RESULT
1501 = "android.intent.extra.INSTALL_RESULT";
1502
1503 /**
1504 * Activity Action: Launch application uninstaller.
1505 * <p>
1506 * Input: The data must be a package: URI whose scheme specific part is
1507 * the package name of the current installed package to be uninstalled.
1508 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1509 * <p>
1510 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1511 * succeeded.
1512 */
1513 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1514 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1515
1516 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001517 * Specify whether the package should be uninstalled for all users.
1518 * @hide because these should not be part of normal application flow.
1519 */
1520 public static final String EXTRA_UNINSTALL_ALL_USERS
1521 = "android.intent.extra.UNINSTALL_ALL_USERS";
1522
1523 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001524 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1525 * describing the last run version of the platform that was setup.
1526 * @hide
1527 */
1528 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1529
Svet Ganov3695b8a2015-03-24 16:30:25 -07001530 /**
1531 * Activity action: Launch UI to manage the permissions of an app.
1532 * <p>
1533 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1534 * will be managed by the launched UI.
1535 * </p>
1536 * <p>
1537 * Output: Nothing.
1538 * </p>
1539 *
1540 * @see #EXTRA_PACKAGE_NAME
1541 *
1542 * @hide
1543 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001544 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1545 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1546 "android.intent.action.MANAGE_APP_PERMISSIONS";
1547
1548 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001549 * Activity action: Launch UI to manage permissions.
1550 * <p>
1551 * Input: Nothing.
1552 * </p>
1553 * <p>
1554 * Output: Nothing.
1555 * </p>
1556 *
1557 * @hide
1558 */
Svet Ganov321f0152015-05-16 22:51:50 -07001559 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1560 public static final String ACTION_MANAGE_PERMISSIONS =
1561 "android.intent.action.MANAGE_PERMISSIONS";
1562
1563 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001564 * Intent extra: An app package name.
1565 * <p>
1566 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001567 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001568 *
1569 * @hide
1570 */
1571 @SystemApi
1572 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1573
1574 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001575 * Broadcast action that requests current permission granted information. It will respond
1576 * to the request by sending a broadcast with action defined by
1577 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
1578 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT} with contents described below or a null upon
1579 * failure.
1580 *
1581 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted and the
1582 * number of permissions requested by that package will be calculated and included as the first
1583 * and second elements respectively of an int[] in the response as
1584 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1585 *
1586 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1587 * permissions and the total number of apps requesting runtime permissions will be the first
1588 * and second elements respectively of an int[] in the response as
1589 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1590 *
1591 * @hide
1592 */
1593 public static final String ACTION_GET_PERMISSIONS_COUNT
1594 = "android.intent.action.GET_PERMISSIONS_COUNT";
1595
1596 /**
1597 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1598 * @hide
1599 */
1600 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1601 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1602
1603 /**
1604 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcast.
1605 * @hide
1606 */
1607 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1608 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1609
1610 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001611 * Activity action: Launch UI to manage which apps have a given permission.
1612 * <p>
1613 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1614 * to which will be managed by the launched UI.
1615 * </p>
1616 * <p>
1617 * Output: Nothing.
1618 * </p>
1619 *
1620 * @see #EXTRA_PERMISSION_NAME
1621 *
1622 * @hide
1623 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001624 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1625 public static final String ACTION_MANAGE_PERMISSION_APPS =
1626 "android.intent.action.MANAGE_PERMISSION_APPS";
1627
1628 /**
1629 * Intent extra: The name of a permission.
1630 * <p>
1631 * Type: String
1632 * </p>
1633 *
1634 * @hide
1635 */
1636 @SystemApi
1637 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1638
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001639 // ---------------------------------------------------------------------
1640 // ---------------------------------------------------------------------
1641 // Standard intent broadcast actions (see action variable).
1642
1643 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001644 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1645 * <p>
1646 * For historical reasons, the name of this broadcast action refers to the power
1647 * state of the screen but it is actually sent in response to changes in the
1648 * overall interactive state of the device.
1649 * </p><p>
1650 * This broadcast is sent when the device becomes non-interactive which may have
1651 * nothing to do with the screen turning off. To determine the
1652 * actual state of the screen, use {@link android.view.Display#getState}.
1653 * </p><p>
1654 * See {@link android.os.PowerManager#isInteractive} for details.
1655 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001656 * You <em>cannot</em> receive this through components declared in
1657 * manifests, only by explicitly registering for it with
1658 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1659 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001660 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001661 * <p class="note">This is a protected intent that can only be sent
1662 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001663 */
1664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1665 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001666
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001667 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001668 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1669 * <p>
1670 * For historical reasons, the name of this broadcast action refers to the power
1671 * state of the screen but it is actually sent in response to changes in the
1672 * overall interactive state of the device.
1673 * </p><p>
1674 * This broadcast is sent when the device becomes interactive which may have
1675 * nothing to do with the screen turning on. To determine the
1676 * actual state of the screen, use {@link android.view.Display#getState}.
1677 * </p><p>
1678 * See {@link android.os.PowerManager#isInteractive} for details.
1679 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001680 * You <em>cannot</em> receive this through components declared in
1681 * manifests, only by explicitly registering for it with
1682 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1683 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001684 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001685 * <p class="note">This is a protected intent that can only be sent
1686 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001687 */
1688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1689 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001690
1691 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001692 * Broadcast Action: Sent after the system stops dreaming.
1693 *
1694 * <p class="note">This is a protected intent that can only be sent by the system.
1695 * It is only sent to registered receivers.</p>
1696 */
1697 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1698 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1699
1700 /**
1701 * Broadcast Action: Sent after the system starts dreaming.
1702 *
1703 * <p class="note">This is a protected intent that can only be sent by the system.
1704 * It is only sent to registered receivers.</p>
1705 */
1706 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1707 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1708
1709 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001710 * 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 -07001711 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001712 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001713 * <p class="note">This is a protected intent that can only be sent
1714 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001715 */
1716 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001717 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001718
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001719 /**
1720 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001721 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001722 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001723 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1724 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001725 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001726 * <p class="note">This is a protected intent that can only be sent
1727 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001728 */
1729 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1730 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1731 /**
1732 * Broadcast Action: The time was set.
1733 */
1734 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1735 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1736 /**
1737 * Broadcast Action: The date has changed.
1738 */
1739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1740 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1741 /**
1742 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1743 * <ul>
1744 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1745 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001746 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001747 * <p class="note">This is a protected intent that can only be sent
1748 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001749 */
1750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1751 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1752 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001753 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1754 * DNS entries should be tossed.
1755 * @hide
1756 */
1757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1758 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1759 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001760 * Alarm Changed Action: This is broadcast when the AlarmClock
1761 * application's alarm is set or unset. It is used by the
1762 * AlarmClock application and the StatusBar service.
1763 * @hide
1764 */
1765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1766 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1767 /**
1768 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1769 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1770 * @hide
1771 */
1772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1773 public static final String ACTION_SYNC_STATE_CHANGED
1774 = "android.intent.action.SYNC_STATE_CHANGED";
1775 /**
1776 * Broadcast Action: This is broadcast once, after the system has finished
1777 * booting. It can be used to perform application-specific initialization,
1778 * such as installing alarms. You must hold the
1779 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1780 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001781 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001782 * <p class="note">This is a protected intent that can only be sent
1783 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001784 */
1785 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1786 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1787 /**
1788 * Broadcast Action: This is broadcast when a user action should request a
1789 * temporary system dialog to dismiss. Some examples of temporary system
1790 * dialogs are the notification window-shade and the recent tasks dialog.
1791 */
1792 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1793 /**
1794 * Broadcast Action: Trigger the download and eventual installation
1795 * of a package.
1796 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001797 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001798 * <p class="note">This is a protected intent that can only be sent
1799 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001800 *
1801 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001802 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001803 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001804 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1805 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1806 /**
1807 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001808 * device. The data contains the name of the package. Note that the
1809 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001810 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001811 * <ul>
1812 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1813 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1814 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1815 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001816 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001817 * <p class="note">This is a protected intent that can only be sent
1818 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001819 */
1820 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1821 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1822 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001823 * Broadcast Action: A new version of an application package has been
1824 * installed, replacing an existing version that was previously installed.
1825 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001826 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001827 * <ul>
1828 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1829 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001830 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001831 * <p class="note">This is a protected intent that can only be sent
1832 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001833 */
1834 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1835 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1836 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001837 * Broadcast Action: A new version of your application has been installed
1838 * over an existing one. This is only sent to the application that was
1839 * replaced. It does not contain any additional data; to receive it, just
1840 * use an intent filter for this action.
1841 *
1842 * <p class="note">This is a protected intent that can only be sent
1843 * by the system.
1844 */
1845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1846 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1847 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001848 * Broadcast Action: An existing application package has been removed from
1849 * the device. The data contains the name of the package. The package
1850 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001851 * <ul>
1852 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1853 * to the package.
1854 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1855 * application -- data and code -- is being removed.
1856 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1857 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1858 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001859 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001860 * <p class="note">This is a protected intent that can only be sent
1861 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001862 */
1863 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1864 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1865 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001866 * Broadcast Action: An existing application package has been completely
1867 * removed from the device. The data contains the name of the package.
1868 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1869 * {@link #EXTRA_DATA_REMOVED} is true and
1870 * {@link #EXTRA_REPLACING} is false of that broadcast.
1871 *
1872 * <ul>
1873 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1874 * to the package.
1875 * </ul>
1876 *
1877 * <p class="note">This is a protected intent that can only be sent
1878 * by the system.
1879 */
1880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1881 public static final String ACTION_PACKAGE_FULLY_REMOVED
1882 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1883 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001884 * Broadcast Action: An existing application package has been changed (e.g.
1885 * a component has been enabled or disabled). The data contains the name of
1886 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001887 * <ul>
1888 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001889 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001890 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001891 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1892 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001893 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001894 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001895 * <p class="note">This is a protected intent that can only be sent
1896 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001897 */
1898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1899 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1900 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001901 * @hide
1902 * Broadcast Action: Ask system services if there is any reason to
1903 * restart the given package. The data contains the name of the
1904 * package.
1905 * <ul>
1906 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1907 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1908 * </ul>
1909 *
1910 * <p class="note">This is a protected intent that can only be sent
1911 * by the system.
1912 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001913 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001914 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1915 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1916 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001917 * Broadcast Action: The user has restarted a package, and all of its
1918 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001919 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001920 * be removed. Note that the restarted package does <em>not</em>
1921 * receive this broadcast.
1922 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001923 * <ul>
1924 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1925 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001926 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001927 * <p class="note">This is a protected intent that can only be sent
1928 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001929 */
1930 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1931 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1932 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001933 * Broadcast Action: The user has cleared the data of a package. This should
1934 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001935 * its persistent data is erased and this broadcast sent.
1936 * Note that the cleared package does <em>not</em>
1937 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001938 * <ul>
1939 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1940 * </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 Project9066cfe2009-03-03 19:31:44 -08001944 */
1945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1946 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1947 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001948 * Broadcast Action: A user ID has been removed from the system. The user
1949 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001950 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001951 * <p class="note">This is a protected intent that can only be sent
1952 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001953 */
1954 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1955 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001956
1957 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001958 * Broadcast Action: Sent to the installer package of an application
1959 * when that application is first launched (that is the first time it
1960 * is moved out of the stopped state). The data contains the name of the package.
1961 *
1962 * <p class="note">This is a protected intent that can only be sent
1963 * by the system.
1964 */
1965 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1966 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1967
1968 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001969 * Broadcast Action: Sent to the system package verifier when a package
1970 * needs to be verified. The data contains the package URI.
1971 * <p class="note">
1972 * This is a protected intent that can only be sent by the system.
1973 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001974 */
1975 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1976 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1977
1978 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001979 * Broadcast Action: Sent to the system package verifier when a package is
1980 * verified. The data contains the package URI.
1981 * <p class="note">
1982 * This is a protected intent that can only be sent by the system.
1983 */
1984 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1985 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1986
1987 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001988 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
1989 * needs to be verified. The data contains the filter data hosts to be verified against.
1990 * <p class="note">
1991 * This is a protected intent that can only be sent by the system.
1992 * </p>
1993 *
1994 * @hide
1995 */
1996 @SystemApi
1997 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1998 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
1999
2000 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002001 * Broadcast Action: Resources for a set of packages (which were
2002 * previously unavailable) are currently
2003 * available since the media on which they exist is available.
2004 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2005 * list of packages whose availability changed.
2006 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2007 * list of uids of packages whose availability changed.
2008 * Note that the
2009 * packages in this list do <em>not</em> receive this broadcast.
2010 * The specified set of packages are now available on the system.
2011 * <p>Includes the following extras:
2012 * <ul>
2013 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2014 * whose resources(were previously unavailable) are currently available.
2015 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2016 * packages whose resources(were previously unavailable)
2017 * are currently available.
2018 * </ul>
2019 *
2020 * <p class="note">This is a protected intent that can only be sent
2021 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002022 */
2023 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002024 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2025 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002026
2027 /**
2028 * Broadcast Action: Resources for a set of packages are currently
2029 * unavailable since the media on which they exist is unavailable.
2030 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2031 * list of packages whose availability changed.
2032 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2033 * list of uids of packages whose availability changed.
2034 * The specified set of packages can no longer be
2035 * launched and are practically unavailable on the system.
2036 * <p>Inclues the following extras:
2037 * <ul>
2038 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2039 * whose resources are no longer available.
2040 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2041 * whose resources are no longer available.
2042 * </ul>
2043 *
2044 * <p class="note">This is a protected intent that can only be sent
2045 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002046 */
2047 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002048 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002049 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002050
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002051 /**
2052 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002053 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002054 * This should <em>only</em> be used to determine when the wallpaper
2055 * has changed to show the new wallpaper to the user. You should certainly
2056 * never, in response to this, change the wallpaper or other attributes of
2057 * it such as the suggested size. That would be crazy, right? You'd cause
2058 * all kinds of loops, especially if other apps are doing similar things,
2059 * right? Of course. So please don't do this.
2060 *
2061 * @deprecated Modern applications should use
2062 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2063 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2064 * shown behind their UI, rather than watching for this broadcast and
2065 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002066 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002067 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002068 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2069 /**
2070 * Broadcast Action: The current device {@link android.content.res.Configuration}
2071 * (orientation, locale, etc) has changed. When such a change happens, the
2072 * UIs (view hierarchy) will need to be rebuilt based on this new
2073 * information; for the most part, applications don't need to worry about
2074 * this, because the system will take care of stopping and restarting the
2075 * application to make sure it sees the new changes. Some system code that
2076 * can not be restarted will need to watch for this action and handle it
2077 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002078 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002079 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002080 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002081 * in manifests, only by explicitly registering for it with
2082 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2083 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002084 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002085 * <p class="note">This is a protected intent that can only be sent
2086 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002087 *
2088 * @see android.content.res.Configuration
2089 */
2090 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2091 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2092 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002093 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002094 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002095 * <p class="note">This is a protected intent that can only be sent
2096 * by the system.
2097 */
2098 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2099 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2100 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002101 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2102 * charging state, level, and other information about the battery.
2103 * See {@link android.os.BatteryManager} for documentation on the
2104 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002105 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002106 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002107 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002108 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002109 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002110 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2111 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2112 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2113 * broadcasts that are sent and can be received through manifest
2114 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002115 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002116 * <p class="note">This is a protected intent that can only be sent
2117 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002118 */
2119 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2120 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2121 /**
2122 * Broadcast Action: Indicates low battery condition on the device.
2123 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002124 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002125 * <p class="note">This is a protected intent that can only be sent
2126 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002127 */
2128 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2129 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2130 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002131 * Broadcast Action: Indicates the battery is now okay after being low.
2132 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2133 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002134 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002135 * <p class="note">This is a protected intent that can only be sent
2136 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002137 */
2138 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2139 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2140 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002141 * Broadcast Action: External power has been connected to the device.
2142 * This is intended for applications that wish to register specifically to this notification.
2143 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2144 * stay active to receive this notification. This action can be used to implement actions
2145 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002146 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002147 * <p class="note">This is a protected intent that can only be sent
2148 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002149 */
2150 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002151 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002152 /**
2153 * Broadcast Action: External power has been removed from the device.
2154 * This is intended for applications that wish to register specifically to this notification.
2155 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2156 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002157 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002158 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002159 * <p class="note">This is a protected intent that can only be sent
2160 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002161 */
2162 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002163 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002164 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002165 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002166 * Broadcast Action: Device is shutting down.
2167 * This is broadcast when the device is being shut down (completely turned
2168 * off, not sleeping). Once the broadcast is complete, the final shutdown
2169 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002170 * to handle this, since the foreground activity will be paused as well.
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.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002174 * <p>May include the following extras:
2175 * <ul>
2176 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2177 * shutdown is only for userspace processes. If not set, assumed to be false.
2178 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002179 */
2180 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002181 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002182 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002183 * Activity Action: Start this activity to request system shutdown.
2184 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2185 * to request confirmation from the user before shutting down.
2186 *
2187 * <p class="note">This is a protected intent that can only be sent
2188 * by the system.
2189 *
2190 * {@hide}
2191 */
2192 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2193 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002194 * Broadcast Action: A sticky broadcast that indicates low memory
2195 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002196 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002197 * <p class="note">This is a protected intent that can only be sent
2198 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002199 */
2200 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2201 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2202 /**
2203 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002204 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002205 * <p class="note">This is a protected intent that can only be sent
2206 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002207 */
2208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2209 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2210 /**
Jake Hambybb371632010-08-23 18:16:48 -07002211 * Broadcast Action: A sticky broadcast that indicates a memory full
2212 * condition on the device. This is intended for activities that want
2213 * to be able to fill the data partition completely, leaving only
2214 * enough free space to prevent system-wide SQLite failures.
2215 *
2216 * <p class="note">This is a protected intent that can only be sent
2217 * by the system.
2218 *
2219 * {@hide}
2220 */
2221 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2222 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2223 /**
2224 * Broadcast Action: Indicates memory full condition on the device
2225 * no longer exists.
2226 *
2227 * <p class="note">This is a protected intent that can only be sent
2228 * by the system.
2229 *
2230 * {@hide}
2231 */
2232 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2233 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2234 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002235 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2236 * and package management should be started.
2237 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2238 * notification.
2239 */
2240 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2241 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2242 /**
2243 * Broadcast Action: The device has entered USB Mass Storage mode.
2244 * This is used mainly for the USB Settings panel.
2245 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2246 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002247 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002248 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002249 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002250 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2251
2252 /**
2253 * Broadcast Action: The device has exited USB Mass Storage mode.
2254 * This is used mainly for the USB Settings panel.
2255 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2256 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002257 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002258 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002259 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002260 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2261
2262 /**
2263 * Broadcast Action: External media has been removed.
2264 * The path to the mount point for the removed media is contained in the Intent.mData field.
2265 */
2266 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2267 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2268
2269 /**
2270 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002271 * 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 -07002272 */
2273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2274 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2275
2276 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002277 * Broadcast Action: External media is present, and being disk-checked
2278 * 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 -08002279 */
2280 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2281 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2282
2283 /**
2284 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2285 * 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 -08002286 */
2287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2288 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2289
2290 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002291 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002292 * 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 -07002293 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2294 * media was mounted read only.
2295 */
2296 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2297 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2298
2299 /**
2300 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002301 * 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 -07002302 */
2303 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2304 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2305
2306 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002307 * Broadcast Action: External media is no longer being shared via USB mass storage.
2308 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2309 *
2310 * @hide
2311 */
2312 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2313
2314 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002315 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2316 * The path to the mount point for the removed media is contained in the Intent.mData field.
2317 */
2318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2319 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2320
2321 /**
2322 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002323 * 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 -07002324 */
2325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2326 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2327
2328 /**
2329 * Broadcast Action: User has expressed the desire to remove the external storage media.
2330 * Applications should close all files they have open within the mount point when they receive this intent.
2331 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2332 */
2333 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2334 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2335
2336 /**
2337 * Broadcast Action: The media scanner has started scanning a directory.
2338 * The path to the directory being scanned is contained in the Intent.mData field.
2339 */
2340 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2341 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2342
2343 /**
2344 * Broadcast Action: The media scanner has finished scanning a directory.
2345 * The path to the scanned directory is contained in the Intent.mData field.
2346 */
2347 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2348 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2349
2350 /**
2351 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2352 * The path to the file is contained in the Intent.mData field.
2353 */
2354 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2355 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2356
2357 /**
2358 * Broadcast Action: The "Media Button" was pressed. Includes a single
2359 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2360 * caused the broadcast.
2361 */
2362 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2363 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2364
2365 /**
2366 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2367 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2368 * caused the broadcast.
2369 */
2370 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2371 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2372
2373 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2374 // location; they are not general-purpose actions.
2375
2376 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002377 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002378 */
2379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2380 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2381 "android.intent.action.GTALK_CONNECTED";
2382
2383 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002384 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002385 */
2386 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2387 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2388 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002389
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002390 /**
2391 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002392 */
2393 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2394 public static final String ACTION_INPUT_METHOD_CHANGED =
2395 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002396
2397 /**
2398 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2399 * more radios have been turned off or on. The intent will have the following extra value:</p>
2400 * <ul>
2401 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2402 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2403 * turned off</li>
2404 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002405 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002406 * <p class="note">This is a protected intent that can only be sent
2407 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002408 */
2409 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2410 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2411
2412 /**
2413 * Broadcast Action: Some content providers have parts of their namespace
2414 * where they publish new events or items that the user may be especially
2415 * interested in. For these things, they may broadcast this action when the
2416 * set of interesting items change.
2417 *
2418 * For example, GmailProvider sends this notification when the set of unread
2419 * mail in the inbox changes.
2420 *
2421 * <p>The data of the intent identifies which part of which provider
2422 * changed. When queried through the content resolver, the data URI will
2423 * return the data set in question.
2424 *
2425 * <p>The intent will have the following extra values:
2426 * <ul>
2427 * <li><em>count</em> - The number of items in the data set. This is the
2428 * same as the number of items in the cursor returned by querying the
2429 * data URI. </li>
2430 * </ul>
2431 *
2432 * This intent will be sent at boot (if the count is non-zero) and when the
2433 * data set changes. It is possible for the data set to change without the
2434 * count changing (for example, if a new unread message arrives in the same
2435 * sync operation in which a message is archived). The phone should still
2436 * ring/vibrate/etc as normal in this case.
2437 */
2438 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2439 public static final String ACTION_PROVIDER_CHANGED =
2440 "android.intent.action.PROVIDER_CHANGED";
2441
2442 /**
2443 * Broadcast Action: Wired Headset plugged in or unplugged.
2444 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002445 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2446 * and documentation.
2447 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002448 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002449 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002450 */
2451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002452 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002453
2454 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002455 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2456 * <ul>
2457 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2458 * </ul>
2459 *
2460 * <p class="note">This is a protected intent that can only be sent
2461 * by the system.
2462 *
2463 * @hide
2464 */
2465 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2466 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2467 = "android.intent.action.ADVANCED_SETTINGS";
2468
2469 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002470 * Broadcast Action: Sent after application restrictions are changed.
2471 *
2472 * <p class="note">This is a protected intent that can only be sent
2473 * by the system.</p>
2474 */
2475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2476 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2477 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2478
2479 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002480 * Broadcast Action: An outgoing call is about to be placed.
2481 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002482 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002483 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002484 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002485 * the phone number originally intended to be dialed.</li>
2486 * </ul>
2487 * <p>Once the broadcast is finished, the resultData is used as the actual
2488 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002489 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002490 * outgoing call in turn: for example, a parental control application
2491 * might verify that the user is authorized to place the call at that
2492 * time, then a number-rewriting application might add an area code if
2493 * one was not specified.</p>
2494 * <p>For consistency, any receiver whose purpose is to prohibit phone
2495 * calls should have a priority of 0, to ensure it will see the final
2496 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002497 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002498 * should have a positive priority.
2499 * Negative priorities are reserved for the system for this broadcast;
2500 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002501 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2502 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002503 * <p>Emergency calls cannot be intercepted using this mechanism, and
2504 * other calls cannot be modified to call emergency numbers using this
2505 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002506 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2507 * call to use their own service instead. Those apps should first prevent
2508 * the call from being placed by setting resultData to <code>null</code>
2509 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002510 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002511 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2512 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002513 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002514 * <p class="note">This is a protected intent that can only be sent
2515 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002516 */
2517 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2518 public static final String ACTION_NEW_OUTGOING_CALL =
2519 "android.intent.action.NEW_OUTGOING_CALL";
2520
2521 /**
2522 * Broadcast Action: Have the device reboot. This is only for use by
2523 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002524 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002525 * <p class="note">This is a protected intent that can only be sent
2526 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002527 */
2528 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2529 public static final String ACTION_REBOOT =
2530 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002531
Wei Huang97ecc9c2009-05-11 17:44:20 -07002532 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002533 * Broadcast Action: A sticky broadcast for changes in the physical
2534 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002535 *
2536 * <p>The intent will have the following extra values:
2537 * <ul>
2538 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002539 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002540 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002541 * <p>This is intended for monitoring the current physical dock state.
2542 * See {@link android.app.UiModeManager} for the normal API dealing with
2543 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2546 public static final String ACTION_DOCK_EVENT =
2547 "android.intent.action.DOCK_EVENT";
2548
2549 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002550 * Broadcast Action: A broadcast when idle maintenance can be started.
2551 * This means that the user is not interacting with the device and is
2552 * not expected to do so soon. Typical use of the idle maintenance is
2553 * to perform somehow expensive tasks that can be postponed at a moment
2554 * when they will not degrade user experience.
2555 * <p>
2556 * <p class="note">In order to keep the device responsive in case of an
2557 * unexpected user interaction, implementations of a maintenance task
2558 * should be interruptible. In such a scenario a broadcast with action
2559 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2560 * should not do the maintenance work in
2561 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2562 * maintenance service by {@link Context#startService(Intent)}. Also
2563 * you should hold a wake lock while your maintenance service is running
2564 * to prevent the device going to sleep.
2565 * </p>
2566 * <p>
2567 * <p class="note">This is a protected intent that can only be sent by
2568 * the system.
2569 * </p>
2570 *
2571 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002572 *
2573 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002574 */
2575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2576 public static final String ACTION_IDLE_MAINTENANCE_START =
2577 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2578
2579 /**
2580 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2581 * This means that the user was not interacting with the device as a result
2582 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2583 * was sent and now the user started interacting with the device. Typical
2584 * use of the idle maintenance is to perform somehow expensive tasks that
2585 * can be postponed at a moment when they will not degrade user experience.
2586 * <p>
2587 * <p class="note">In order to keep the device responsive in case of an
2588 * unexpected user interaction, implementations of a maintenance task
2589 * should be interruptible. Hence, on receiving a broadcast with this
2590 * action, the maintenance task should be interrupted as soon as possible.
2591 * In other words, you should not do the maintenance work in
2592 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2593 * maintenance service that was started on receiving of
2594 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2595 * lock you acquired when your maintenance service started.
2596 * </p>
2597 * <p class="note">This is a protected intent that can only be sent
2598 * by the system.
2599 *
2600 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002601 *
2602 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002603 */
2604 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2605 public static final String ACTION_IDLE_MAINTENANCE_END =
2606 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2607
2608 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002609 * Broadcast Action: a remote intent is to be broadcasted.
2610 *
2611 * A remote intent is used for remote RPC between devices. The remote intent
2612 * is serialized and sent from one device to another device. The receiving
2613 * device parses the remote intent and broadcasts it. Note that anyone can
2614 * broadcast a remote intent. However, if the intent receiver of the remote intent
2615 * does not trust intent broadcasts from arbitrary intent senders, it should require
2616 * the sender to hold certain permissions so only trusted sender's broadcast will be
2617 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002618 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002619 */
2620 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002621 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002622
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002623 /**
2624 * Broadcast Action: hook for permforming cleanup after a system update.
2625 *
2626 * The broadcast is sent when the system is booting, before the
2627 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2628 * image. A receiver for this should do its work and then disable itself
2629 * so that it does not get run again at the next boot.
2630 * @hide
2631 */
2632 public static final String ACTION_PRE_BOOT_COMPLETED =
2633 "android.intent.action.PRE_BOOT_COMPLETED";
2634
Amith Yamasani13593602012-03-22 16:16:17 -07002635 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002636 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002637 * on restricted users. The broadcast intent contains an extra
2638 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2639 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2640 * String[] depending on the restriction type.<p/>
2641 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002642 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2643 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2644 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002645 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2646 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002647 * @see RestrictionEntry
2648 */
2649 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2650 "android.intent.action.GET_RESTRICTION_ENTRIES";
2651
2652 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002653 * Sent the first time a user is starting, to allow system apps to
2654 * perform one time initialization. (This will not be seen by third
2655 * party applications because a newly initialized user does not have any
2656 * third party applications installed for it.) This is sent early in
2657 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002658 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2659 * broadcast, since it is part of a visible user interaction; be as quick
2660 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002661 */
2662 public static final String ACTION_USER_INITIALIZE =
2663 "android.intent.action.USER_INITIALIZE";
2664
2665 /**
2666 * Sent when a user switch is happening, causing the process's user to be
2667 * brought to the foreground. This is only sent to receivers registered
2668 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2669 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002670 * foreground. This is sent as a foreground
2671 * broadcast, since it is part of a visible user interaction; be as quick
2672 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002673 */
2674 public static final String ACTION_USER_FOREGROUND =
2675 "android.intent.action.USER_FOREGROUND";
2676
2677 /**
2678 * Sent when a user switch is happening, causing the process's user to be
2679 * sent to the background. This is only sent to receivers registered
2680 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2681 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002682 * background. This is sent as a foreground
2683 * broadcast, since it is part of a visible user interaction; be as quick
2684 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002685 */
2686 public static final String ACTION_USER_BACKGROUND =
2687 "android.intent.action.USER_BACKGROUND";
2688
2689 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002690 * Broadcast sent to the system when a user is added. Carries an extra
2691 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2692 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002693 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002694 * @hide
2695 */
2696 public static final String ACTION_USER_ADDED =
2697 "android.intent.action.USER_ADDED";
2698
2699 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002700 * Broadcast sent by the system when a user is started. Carries an extra
2701 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002702 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002703 * that has been started. This is sent as a foreground
2704 * broadcast, since it is part of a visible user interaction; be as quick
2705 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002706 * @hide
2707 */
2708 public static final String ACTION_USER_STARTED =
2709 "android.intent.action.USER_STARTED";
2710
2711 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002712 * Broadcast sent when a user is in the process of starting. Carries an extra
2713 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2714 * sent to registered receivers, not manifest receivers. It is sent to all
2715 * users (including the one that is being started). You must hold
2716 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2717 * this broadcast. This is sent as a background broadcast, since
2718 * its result is not part of the primary UX flow; to safely keep track of
2719 * started/stopped state of a user you can use this in conjunction with
2720 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2721 * other user state broadcasts since those are foreground broadcasts so can
2722 * execute in a different order.
2723 * @hide
2724 */
2725 public static final String ACTION_USER_STARTING =
2726 "android.intent.action.USER_STARTING";
2727
2728 /**
2729 * Broadcast sent when a user is going to be stopped. Carries an extra
2730 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2731 * sent to registered receivers, not manifest receivers. It is sent to all
2732 * users (including the one that is being stopped). You must hold
2733 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2734 * this broadcast. The user will not stop until all receivers have
2735 * handled the broadcast. This is sent as a background broadcast, since
2736 * its result is not part of the primary UX flow; to safely keep track of
2737 * started/stopped state of a user you can use this in conjunction with
2738 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2739 * other user state broadcasts since those are foreground broadcasts so can
2740 * execute in a different order.
2741 * @hide
2742 */
2743 public static final String ACTION_USER_STOPPING =
2744 "android.intent.action.USER_STOPPING";
2745
2746 /**
2747 * Broadcast sent to the system when a user is stopped. Carries an extra
2748 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2749 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2750 * specific package. This is only sent to registered receivers, not manifest
2751 * receivers. It is sent to all running users <em>except</em> the one that
2752 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002753 * @hide
2754 */
2755 public static final String ACTION_USER_STOPPED =
2756 "android.intent.action.USER_STOPPED";
2757
2758 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002759 * 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 -07002760 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002761 * one that has been removed. The user will not be completely removed until all receivers have
2762 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002763 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002764 * @hide
2765 */
2766 public static final String ACTION_USER_REMOVED =
2767 "android.intent.action.USER_REMOVED";
2768
2769 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002770 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002771 * the userHandle of the user to become the current one. This is only sent to
2772 * registered receivers, not manifest receivers. It is sent to all running users.
2773 * You must hold
2774 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002775 * @hide
2776 */
2777 public static final String ACTION_USER_SWITCHED =
2778 "android.intent.action.USER_SWITCHED";
2779
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002780 /**
2781 * Broadcast sent to the system when a user's information changes. Carries an extra
2782 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002783 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002784 * @hide
2785 */
2786 public static final String ACTION_USER_INFO_CHANGED =
2787 "android.intent.action.USER_INFO_CHANGED";
2788
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002789 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002790 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2791 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002792 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2793 * that need to display merged content across both primary and managed profiles need to
2794 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002795 * not manifest receivers.
2796 */
2797 public static final String ACTION_MANAGED_PROFILE_ADDED =
2798 "android.intent.action.MANAGED_PROFILE_ADDED";
2799
2800 /**
2801 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002802 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2803 * Only applications (for example Launchers) that need to display merged content across both
2804 * primary and managed profiles need to worry about this broadcast. This is only sent to
2805 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002806 */
2807 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2808 "android.intent.action.MANAGED_PROFILE_REMOVED";
2809
2810 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002811 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2812 */
2813 public static final String ACTION_QUICK_CLOCK =
2814 "android.intent.action.QUICK_CLOCK";
2815
Michael Wright0087a142013-02-05 16:29:39 -08002816 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002817 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002818 * @hide
2819 */
2820 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2821 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2822
Justin Kohd378ad72013-04-01 12:18:26 -07002823 /**
2824 * Broadcast Action: A global button was pressed. Includes a single
2825 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2826 * caused the broadcast.
2827 * @hide
2828 */
2829 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2830
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002831 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002832 * Activity Action: Allow the user to select and return one or more existing
2833 * documents. When invoked, the system will display the various
2834 * {@link DocumentsProvider} instances installed on the device, letting the
2835 * user interactively navigate through them. These documents include local
2836 * media, such as photos and video, and documents provided by installed
2837 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002838 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002839 * Each document is represented as a {@code content://} URI backed by a
2840 * {@link DocumentsProvider}, which can be opened as a stream with
2841 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2842 * {@link android.provider.DocumentsContract.Document} metadata.
2843 * <p>
2844 * All selected documents are returned to the calling application with
2845 * persistable read and write permission grants. If you want to maintain
2846 * access to the documents across device reboots, you need to explicitly
2847 * take the persistable permissions using
2848 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2849 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002850 * Callers must indicate the acceptable document MIME types through
2851 * {@link #setType(String)}. For example, to select photos, use
2852 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2853 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2854 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002855 * <p>
2856 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002857 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2858 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002859 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002860 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2861 * returned URIs can be opened with
2862 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002863 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002864 * Output: The URI of the item that was picked, returned in
2865 * {@link #getData()}. This must be a {@code content://} URI so that any
2866 * receiver can access it. If multiple documents were selected, they are
2867 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002868 *
2869 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002870 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002871 * @see #ACTION_CREATE_DOCUMENT
2872 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002873 */
2874 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2875 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2876
2877 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002878 * Activity Action: Allow the user to create a new document. When invoked,
2879 * the system will display the various {@link DocumentsProvider} instances
2880 * installed on the device, letting the user navigate through them. The
2881 * returned document may be a newly created document with no content, or it
2882 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002883 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002884 * Each document is represented as a {@code content://} URI backed by a
2885 * {@link DocumentsProvider}, which can be opened as a stream with
2886 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2887 * {@link android.provider.DocumentsContract.Document} metadata.
2888 * <p>
2889 * Callers must indicate the concrete MIME type of the document being
2890 * created by setting {@link #setType(String)}. This MIME type cannot be
2891 * changed after the document is created.
2892 * <p>
2893 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2894 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002895 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002896 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2897 * returned URIs can be opened with
2898 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002899 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002900 * Output: The URI of the item that was created. This must be a
2901 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002902 *
2903 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002904 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002905 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002906 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002907 */
2908 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2909 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2910
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002911 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002912 * Activity Action: Allow the user to pick a directory subtree. When
2913 * invoked, the system will display the various {@link DocumentsProvider}
2914 * instances installed on the device, letting the user navigate through
2915 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002916 * <p>
2917 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002918 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2919 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2920 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002921 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002922 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002923 *
2924 * @see DocumentsContract
2925 */
2926 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002927 public static final String
2928 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002929
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002930 /** {@hide} */
2931 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2932
Christopher Tate6597e342015-02-17 12:15:25 -08002933 /**
2934 * Broadcast action: report that a settings element is being restored from backup. The intent
2935 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
2936 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
2937 * is the value of that settings entry prior to the restore operation. All of these values are
2938 * represented as strings.
2939 *
2940 * <p>This broadcast is sent only for settings provider entries known to require special handling
2941 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
2942 * the provider's backup agent implementation.
2943 *
2944 * @see #EXTRA_SETTING_NAME
2945 * @see #EXTRA_SETTING_PREVIOUS_VALUE
2946 * @see #EXTRA_SETTING_NEW_VALUE
2947 * {@hide}
2948 */
2949 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
2950
2951 /** {@hide} */
2952 public static final String EXTRA_SETTING_NAME = "setting_name";
2953 /** {@hide} */
2954 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
2955 /** {@hide} */
2956 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
2957
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002958 /**
2959 * Activity Action: Process a piece of text.
2960 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
2961 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
2962 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
2963 */
2964 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2965 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
2966 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01002967 * The name of the extra used to define the text to be processed, as a
2968 * CharSequence. Note that this may be a styled CharSequence, so you must use
2969 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002970 */
2971 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
2972 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01002973 * 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 +00002974 */
2975 public static final String EXTRA_PROCESS_TEXT_READONLY =
2976 "android.intent.extra.PROCESS_TEXT_READONLY";
2977
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002978 // ---------------------------------------------------------------------
2979 // ---------------------------------------------------------------------
2980 // Standard intent categories (see addCategory()).
2981
2982 /**
2983 * Set if the activity should be an option for the default action
2984 * (center press) to perform on a piece of data. Setting this will
2985 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002986 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002987 * Intent when initiating an action -- it is for use in intent filters
2988 * specified in packages.
2989 */
2990 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2991 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2992 /**
2993 * Activities that can be safely invoked from a browser must support this
2994 * category. For example, if the user is viewing a web page or an e-mail
2995 * and clicks on a link in the text, the Intent generated execute that
2996 * link will require the BROWSABLE category, so that only activities
2997 * supporting this category will be considered as possible actions. By
2998 * supporting this category, you are promising that there is nothing
2999 * damaging (without user intervention) that can happen by invoking any
3000 * matching Intent.
3001 */
3002 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3003 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3004 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003005 * Categories for activities that can participate in voice interaction.
3006 * An activity that supports this category must be prepared to run with
3007 * no UI shown at all (though in some case it may have a UI shown), and
3008 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3009 */
3010 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3011 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3012 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003013 * Set if the activity should be considered as an alternative action to
3014 * the data the user is currently viewing. See also
3015 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3016 * applies to the selection in a list of items.
3017 *
3018 * <p>Supporting this category means that you would like your activity to be
3019 * displayed in the set of alternative things the user can do, usually as
3020 * part of the current activity's options menu. You will usually want to
3021 * include a specific label in the &lt;intent-filter&gt; of this action
3022 * describing to the user what it does.
3023 *
3024 * <p>The action of IntentFilter with this category is important in that it
3025 * describes the specific action the target will perform. This generally
3026 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3027 * a specific name such as "com.android.camera.action.CROP. Only one
3028 * alternative of any particular action will be shown to the user, so using
3029 * a specific action like this makes sure that your alternative will be
3030 * displayed while also allowing other applications to provide their own
3031 * overrides of that particular action.
3032 */
3033 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3034 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3035 /**
3036 * Set if the activity should be considered as an alternative selection
3037 * action to the data the user has currently selected. This is like
3038 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3039 * of items from which the user can select, giving them alternatives to the
3040 * default action that will be performed on it.
3041 */
3042 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3043 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3044 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003045 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003046 */
3047 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3048 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3049 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003050 * Should be displayed in the top-level launcher.
3051 */
3052 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3053 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3054 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003055 * Indicates an activity optimized for Leanback mode, and that should
3056 * be displayed in the Leanback launcher.
3057 */
3058 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3059 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3060 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003061 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3062 * @hide
3063 */
3064 @SystemApi
3065 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3066 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003067 * Provides information about the package it is in; typically used if
3068 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3069 * a front-door to the user without having to be shown in the all apps list.
3070 */
3071 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3072 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3073 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003074 * This is the home activity, that is the first activity that is displayed
3075 * when the device boots.
3076 */
3077 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3078 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3079 /**
3080 * This activity is a preference panel.
3081 */
3082 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3083 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3084 /**
3085 * This activity is a development preference panel.
3086 */
3087 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3088 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3089 /**
3090 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003091 */
3092 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3093 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3094 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003095 * This activity allows the user to browse and download new applications.
3096 */
3097 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3098 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3099 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003100 * This activity may be exercised by the monkey or other automated test tools.
3101 */
3102 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3103 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3104 /**
3105 * To be used as a test (not part of the normal user experience).
3106 */
3107 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3108 /**
3109 * To be used as a unit test (run through the Test Harness).
3110 */
3111 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3112 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003113 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003114 * experience).
3115 */
3116 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003117
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003118 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003119 * Used to indicate that an intent only wants URIs that can be opened with
3120 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3121 * must support at least the columns defined in {@link OpenableColumns} when
3122 * queried.
3123 *
3124 * @see #ACTION_GET_CONTENT
3125 * @see #ACTION_OPEN_DOCUMENT
3126 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003127 */
3128 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3129 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3130
3131 /**
3132 * To be used as code under test for framework instrumentation tests.
3133 */
3134 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3135 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003136 /**
3137 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003138 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3139 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003140 */
3141 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3142 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3143 /**
3144 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003145 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3146 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003147 */
3148 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3149 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003150 /**
3151 * An activity to run when device is inserted into a analog (low end) dock.
3152 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3153 * information, see {@link android.app.UiModeManager}.
3154 */
3155 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3156 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3157
3158 /**
3159 * An activity to run when device is inserted into a digital (high end) dock.
3160 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3161 * information, see {@link android.app.UiModeManager}.
3162 */
3163 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3164 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003165
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003166 /**
3167 * Used to indicate that the activity can be used in a car environment.
3168 */
3169 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3170 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3171
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003172 // ---------------------------------------------------------------------
3173 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003174 // Application launch intent categories (see addCategory()).
3175
3176 /**
3177 * Used with {@link #ACTION_MAIN} to launch the browser application.
3178 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003179 * <p>NOTE: This should not be used as the primary key of an Intent,
3180 * since it will not result in the app launching with the correct
3181 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003182 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003183 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003184 */
3185 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3186 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3187
3188 /**
3189 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3190 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003191 * <p>NOTE: This should not be used as the primary key of an Intent,
3192 * since it will not result in the app launching with the correct
3193 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003194 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003195 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003196 */
3197 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3198 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3199
3200 /**
3201 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3202 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003203 * <p>NOTE: This should not be used as the primary key of an Intent,
3204 * since it will not result in the app launching with the correct
3205 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003206 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003207 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003208 */
3209 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3210 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3211
3212 /**
3213 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3214 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003215 * <p>NOTE: This should not be used as the primary key of an Intent,
3216 * since it will not result in the app launching with the correct
3217 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003218 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003219 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003220 */
3221 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3222 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3223
3224 /**
3225 * Used with {@link #ACTION_MAIN} to launch the email application.
3226 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003227 * <p>NOTE: This should not be used as the primary key of an Intent,
3228 * since it will not result in the app launching with the correct
3229 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003230 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003231 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003232 */
3233 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3234 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3235
3236 /**
3237 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3238 * The activity should be able to view and manipulate image and video files
3239 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003240 * <p>NOTE: This should not be used as the primary key of an Intent,
3241 * since it will not result in the app launching with the correct
3242 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003243 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003244 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003245 */
3246 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3247 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3248
3249 /**
3250 * Used with {@link #ACTION_MAIN} to launch the maps application.
3251 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003252 * <p>NOTE: This should not be used as the primary key of an Intent,
3253 * since it will not result in the app launching with the correct
3254 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003255 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003256 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003257 */
3258 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3259 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3260
3261 /**
3262 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3263 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003264 * <p>NOTE: This should not be used as the primary key of an Intent,
3265 * since it will not result in the app launching with the correct
3266 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003267 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003268 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003269 */
3270 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3271 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3272
3273 /**
3274 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003275 * The activity should be able to play, browse, or manipulate music files
3276 * stored on the device.
3277 * <p>NOTE: This should not be used as the primary key of an Intent,
3278 * since it will not result in the app launching with the correct
3279 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003280 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003281 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003282 */
3283 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3284 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3285
3286 // ---------------------------------------------------------------------
3287 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003288 // Standard extra data keys.
3289
3290 /**
3291 * The initial data to place in a newly created record. Use with
3292 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3293 * fields as would be given to the underlying ContentProvider.insert()
3294 * call.
3295 */
3296 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3297
3298 /**
3299 * A constant CharSequence that is associated with the Intent, used with
3300 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3301 * this may be a styled CharSequence, so you must use
3302 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3303 * retrieve it.
3304 */
3305 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3306
3307 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003308 * A constant String that is associated with the Intent, used with
3309 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3310 * as HTML formatted text. Note that you <em>must</em> also supply
3311 * {@link #EXTRA_TEXT}.
3312 */
3313 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3314
3315 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003316 * A content: URI holding a stream of data associated with the Intent,
3317 * used with {@link #ACTION_SEND} to supply the data being sent.
3318 */
3319 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3320
3321 /**
3322 * A String[] holding e-mail addresses that should be delivered to.
3323 */
3324 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3325
3326 /**
3327 * A String[] holding e-mail addresses that should be carbon copied.
3328 */
3329 public static final String EXTRA_CC = "android.intent.extra.CC";
3330
3331 /**
3332 * A String[] holding e-mail addresses that should be blind carbon copied.
3333 */
3334 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3335
3336 /**
3337 * A constant string holding the desired subject line of a message.
3338 */
3339 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3340
3341 /**
3342 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003343 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003344 */
3345 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3346
3347 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003348 * An Intent[] describing additional, alternate choices you would like shown with
3349 * {@link #ACTION_CHOOSER}.
3350 *
3351 * <p>An app may be capable of providing several different payload types to complete a
3352 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3353 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3354 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3355 * photo data or a hosted link where the photos can be viewed.</p>
3356 *
3357 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3358 * first/primary/preferred intent in the set. Additional intents specified in
3359 * this extra are ordered; by default intents that appear earlier in the array will be
3360 * preferred over intents that appear later in the array as matches for the same
3361 * target component. To alter this preference, a calling app may also supply
3362 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3363 */
3364 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3365
3366 /**
3367 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3368 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3369 *
3370 * <p>An app preparing an action for another app to complete may wish to allow the user to
3371 * disambiguate between several options for completing the action based on the chosen target
3372 * or otherwise refine the action before it is invoked.
3373 * </p>
3374 *
3375 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3376 * <ul>
3377 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3378 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3379 * chosen target beyond the first</li>
3380 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3381 * should fill in and send once the disambiguation is complete</li>
3382 * </ul>
3383 */
3384 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3385 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3386
3387 /**
3388 * A {@link ResultReceiver} used to return data back to the sender.
3389 *
3390 * <p>Used to complete an app-specific
3391 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3392 *
3393 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3394 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3395 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3396 * when the user selects a target component from the chooser. It is up to the recipient
3397 * to send a result to this ResultReceiver to signal that disambiguation is complete
3398 * and that the chooser should invoke the user's choice.</p>
3399 *
3400 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3401 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3402 * to match and fill in the final Intent or ChooserTarget before starting it.
3403 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3404 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3405 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3406 *
3407 * <p>The result code passed to the ResultReceiver should be
3408 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3409 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3410 * the chooser should finish without starting a target.</p>
3411 */
3412 public static final String EXTRA_RESULT_RECEIVER
3413 = "android.intent.extra.RESULT_RECEIVER";
3414
3415 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003416 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003417 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003418 */
3419 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3420
3421 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003422 * A Parcelable[] of {@link Intent} or
3423 * {@link android.content.pm.LabeledIntent} objects as set with
3424 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3425 * a the front of the list of choices, when shown to the user with a
3426 * {@link #ACTION_CHOOSER}.
3427 */
3428 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3429
3430 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003431 * A Bundle forming a mapping of potential target package names to different extras Bundles
3432 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3433 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3434 * be currently installed on the device.
3435 *
3436 * <p>An application may choose to provide alternate extras for the case where a user
3437 * selects an activity from a predetermined set of target packages. If the activity
3438 * the user selects from the chooser belongs to a package with its package name as
3439 * a key in this bundle, the corresponding extras for that package will be merged with
3440 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3441 * extra has the same key as an extra already present in the intent it will overwrite
3442 * the extra from the intent.</p>
3443 *
3444 * <p><em>Examples:</em>
3445 * <ul>
3446 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3447 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3448 * parameters for that target.</li>
3449 * <li>An application may offer additional metadata for known targets of a given intent
3450 * to pass along information only relevant to that target such as account or content
3451 * identifiers already known to that application.</li>
3452 * </ul></p>
3453 */
3454 public static final String EXTRA_REPLACEMENT_EXTRAS =
3455 "android.intent.extra.REPLACEMENT_EXTRAS";
3456
3457 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003458 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3459 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3460 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3461 * {@link ComponentName} of the chosen component.
3462 *
3463 * <p>In some situations this callback may never come, for example if the user abandons
3464 * the chooser, switches to another task or any number of other reasons. Apps should not
3465 * be written assuming that this callback will always occur.</p>
3466 */
3467 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3468 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3469
3470 /**
3471 * The {@link ComponentName} chosen by the user to complete an action.
3472 *
3473 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3474 */
3475 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3476
3477 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003478 * A {@link android.view.KeyEvent} object containing the event that
3479 * triggered the creation of the Intent it is in.
3480 */
3481 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3482
3483 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003484 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3485 * before shutting down.
3486 *
3487 * {@hide}
3488 */
3489 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3490
3491 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003492 * 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 -07003493 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3494 * of restarting the application.
3495 */
3496 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3497
3498 /**
3499 * A String holding the phone number originally entered in
3500 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3501 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3502 */
3503 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003504
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003505 /**
3506 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3507 * intents to supply the uid the package had been assigned. Also an optional
3508 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3509 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3510 * purpose.
3511 */
3512 public static final String EXTRA_UID = "android.intent.extra.UID";
3513
3514 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003515 * @hide String array of package names.
3516 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003517 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003518 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3519
3520 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003521 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3522 * intents to indicate whether this represents a full uninstall (removing
3523 * both the code and its data) or a partial uninstall (leaving its data,
3524 * implying that this is an update).
3525 */
3526 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003527
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003528 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003529 * @hide
3530 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3531 * intents to indicate that at this point the package has been removed for
3532 * all users on the device.
3533 */
3534 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3535 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3536
3537 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003538 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3539 * intents to indicate that this is a replacement of the package, so this
3540 * broadcast will immediately be followed by an add broadcast for a
3541 * different version of the same package.
3542 */
3543 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003544
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003545 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003546 * Used as an int extra field in {@link android.app.AlarmManager} intents
3547 * to tell the application being invoked how many pending alarms are being
3548 * delievered with the intent. For one-shot alarms this will always be 1.
3549 * For recurring alarms, this might be greater than 1 if the device was
3550 * asleep or powered off at the time an earlier alarm would have been
3551 * delivered.
3552 */
3553 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003554
Jacek Surazski86b6c532009-05-13 14:38:28 +02003555 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003556 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3557 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003558 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3559 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003560 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3561 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3562 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003563 */
3564 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3565
3566 /**
3567 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3568 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003569 */
3570 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3571
3572 /**
3573 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3574 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003575 */
3576 public static final int EXTRA_DOCK_STATE_DESK = 1;
3577
3578 /**
3579 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3580 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003581 */
3582 public static final int EXTRA_DOCK_STATE_CAR = 2;
3583
3584 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003585 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3586 * to represent that the phone is in a analog (low end) dock.
3587 */
3588 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3589
3590 /**
3591 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3592 * to represent that the phone is in a digital (high end) dock.
3593 */
3594 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3595
3596 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003597 * Boolean that can be supplied as meta-data with a dock activity, to
3598 * indicate that the dock should take over the home key when it is active.
3599 */
3600 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003601
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003602 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003603 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3604 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003605 */
3606 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3607
3608 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003609 * Used in the extra field in the remote intent. It's astring token passed with the
3610 * remote intent.
3611 */
3612 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3613 "android.intent.extra.remote_intent_token";
3614
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003615 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003616 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003617 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003618 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003619 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003620 "android.intent.extra.changed_component_name";
3621
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003622 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003623 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003624 * and contains a string array of all of the components that have changed. If
3625 * the state of the overall package has changed, then it will contain an entry
3626 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003627 */
3628 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3629 "android.intent.extra.changed_component_name_list";
3630
3631 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003632 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003633 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3634 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003635 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003636 */
3637 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3638 "android.intent.extra.changed_package_list";
3639
3640 /**
3641 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003642 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3643 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003644 * and contains an integer array of uids of all of the components
3645 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003646 */
3647 public static final String EXTRA_CHANGED_UID_LIST =
3648 "android.intent.extra.changed_uid_list";
3649
3650 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003651 * @hide
3652 * Magic extra system code can use when binding, to give a label for
3653 * who it is that has bound to a service. This is an integer giving
3654 * a framework string resource that can be displayed to the user.
3655 */
3656 public static final String EXTRA_CLIENT_LABEL =
3657 "android.intent.extra.client_label";
3658
3659 /**
3660 * @hide
3661 * Magic extra system code can use when binding, to give a PendingIntent object
3662 * that can be launched for the user to disable the system's use of this
3663 * service.
3664 */
3665 public static final String EXTRA_CLIENT_INTENT =
3666 "android.intent.extra.client_intent";
3667
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003668 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003669 * Extra used to indicate that an intent should only return data that is on
3670 * the local device. This is a boolean extra; the default is false. If true,
3671 * an implementation should only allow the user to select data that is
3672 * already on the device, not requiring it be downloaded from a remote
3673 * service when opened.
3674 *
3675 * @see #ACTION_GET_CONTENT
3676 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003677 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003678 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003679 */
3680 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003681 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003682
Amith Yamasani13593602012-03-22 16:16:17 -07003683 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003684 * Extra used to indicate that an intent can allow the user to select and
3685 * return multiple items. This is a boolean extra; the default is false. If
3686 * true, an implementation is allowed to present the user with a UI where
3687 * they can pick multiple items that are all returned to the caller. When
3688 * this happens, they should be returned as the {@link #getClipData()} part
3689 * of the result Intent.
3690 *
3691 * @see #ACTION_GET_CONTENT
3692 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003693 */
3694 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003695 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003696
3697 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003698 * The integer userHandle carried with broadcast intents related to addition, removal and
3699 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3700 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3701 *
Amith Yamasani13593602012-03-22 16:16:17 -07003702 * @hide
3703 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003704 public static final String EXTRA_USER_HANDLE =
3705 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003706
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003707 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003708 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3709 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3710 */
3711 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003712 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003713
3714 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003715 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003716 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3717 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003718 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003719 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3720
3721 /**
3722 * Extra sent in the intent to the BroadcastReceiver that handles
3723 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3724 * the restrictions as key/value pairs.
3725 */
3726 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3727 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003728
Amith Yamasani86118ba2013-03-28 14:33:16 -07003729 /**
3730 * Extra used in the response from a BroadcastReceiver that handles
3731 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3732 */
3733 public static final String EXTRA_RESTRICTIONS_INTENT =
3734 "android.intent.extra.restrictions_intent";
3735
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003736 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003737 * Extra used to communicate a set of acceptable MIME types. The type of the
3738 * extra is {@code String[]}. Values may be a combination of concrete MIME
3739 * types (such as "image/png") and/or partial MIME types (such as
3740 * "audio/*").
3741 *
3742 * @see #ACTION_GET_CONTENT
3743 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003744 */
3745 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3746
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003747 /**
3748 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3749 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003750 * When this is true, hardware devices can use this information to determine that
3751 * they shouldn't do a complete shutdown of their device since this is not a
3752 * complete shutdown down to the kernel, but only user space restarting.
3753 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003754 */
3755 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3756 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3757
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003758 /**
3759 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3760 * user has set their time format preferences to the 24 hour format.
3761 *
3762 * @hide for internal use only.
3763 */
3764 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3765 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3766
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003767 /** {@hide} */
3768 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3769
Santos Cordon15a13782015-03-31 18:32:31 -07003770 /**
3771 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3772 * activation request.
3773 * TODO: Add information about the structure and response data used with the pending intent.
3774 * @hide
3775 */
3776 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3777 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3778
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003779 // ---------------------------------------------------------------------
3780 // ---------------------------------------------------------------------
3781 // Intent flags (see mFlags variable).
3782
Tor Norbyed9273d62013-05-30 15:59:53 -07003783 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003784 @IntDef(flag = true, value = {
3785 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3786 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003787 @Retention(RetentionPolicy.SOURCE)
3788 public @interface GrantUriMode {}
3789
Jeff Sharkey846318a2014-04-04 12:12:41 -07003790 /** @hide */
3791 @IntDef(flag = true, value = {
3792 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3793 @Retention(RetentionPolicy.SOURCE)
3794 public @interface AccessUriMode {}
3795
3796 /**
3797 * Test if given mode flags specify an access mode, which must be at least
3798 * read and/or write.
3799 *
3800 * @hide
3801 */
3802 public static boolean isAccessUriMode(int modeFlags) {
3803 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3804 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3805 }
3806
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003807 /**
3808 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003809 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003810 * specified in its ClipData. When applying to an Intent's ClipData,
3811 * all URIs as well as recursive traversals through data or other ClipData
3812 * in Intent items will be granted; only the grant flags of the top-level
3813 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003814 */
3815 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3816 /**
3817 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003818 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003819 * specified in its ClipData. When applying to an Intent's ClipData,
3820 * all URIs as well as recursive traversals through data or other ClipData
3821 * in Intent items will be granted; only the grant flags of the top-level
3822 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003823 */
3824 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3825 /**
3826 * Can be set by the caller to indicate that this Intent is coming from
3827 * a background operation, not from direct user interaction.
3828 */
3829 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3830 /**
3831 * A flag you can enable for debugging: when set, log messages will be
3832 * printed during the resolution of this intent to show you what has
3833 * been found to create the final resolved list.
3834 */
3835 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003836 /**
3837 * If set, this intent will not match any components in packages that
3838 * are currently stopped. If this is not set, then the default behavior
3839 * is to include such applications in the result.
3840 */
3841 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3842 /**
3843 * If set, this intent will always match any components in packages that
3844 * are currently stopped. This is the default behavior when
3845 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3846 * flags are set, this one wins (it allows overriding of exclude for
3847 * places where the framework may automatically set the exclude flag).
3848 */
3849 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003850
3851 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003852 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003853 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003854 * persisted across device reboots until explicitly revoked with
3855 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3856 * grant for possible persisting; the receiving application must call
3857 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3858 * actually persist.
3859 *
3860 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3861 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3862 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003863 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003864 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003865 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003866
3867 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003868 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3869 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3870 * applies to any URI that is a prefix match against the original granted
3871 * URI. (Without this flag, the URI must match exactly for access to be
3872 * granted.) Another URI is considered a prefix match only when scheme,
3873 * authority, and all path segments defined by the prefix are an exact
3874 * match.
3875 */
3876 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3877
3878 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003879 * If set, the new activity is not kept in the history stack. As soon as
3880 * the user navigates away from it, the activity is finished. This may also
3881 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3882 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003883 *
3884 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3885 * is never invoked when the current activity starts a new activity which
3886 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003887 */
3888 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3889 /**
3890 * If set, the activity will not be launched if it is already running
3891 * at the top of the history stack.
3892 */
3893 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3894 /**
3895 * If set, this activity will become the start of a new task on this
3896 * history stack. A task (from the activity that started it to the
3897 * next task activity) defines an atomic group of activities that the
3898 * user can move to. Tasks can be moved to the foreground and background;
3899 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003900 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003901 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3902 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003903 *
3904 * <p>This flag is generally used by activities that want
3905 * to present a "launcher" style behavior: they give the user a list of
3906 * separate things that can be done, which otherwise run completely
3907 * independently of the activity launching them.
3908 *
3909 * <p>When using this flag, if a task is already running for the activity
3910 * you are now starting, then a new activity will not be started; instead,
3911 * the current task will simply be brought to the front of the screen with
3912 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3913 * to disable this behavior.
3914 *
3915 * <p>This flag can not be used when the caller is requesting a result from
3916 * the activity being launched.
3917 */
3918 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3919 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003920 * This flag is used to create a new task and launch an activity into it.
3921 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3922 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3923 * search through existing tasks for ones matching this Intent. Only if no such
3924 * task is found would a new task be created. When paired with
3925 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3926 * the search for a matching task and unconditionally start a new task.
3927 *
3928 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3929 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003930 * top-level application launcher.</strong> Used in conjunction with
3931 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3932 * behavior of bringing an existing task to the foreground. When set,
3933 * a new task is <em>always</em> started to host the Activity for the
3934 * Intent, regardless of whether there is already an existing task running
3935 * the same thing.
3936 *
3937 * <p><strong>Because the default system does not include graphical task management,
3938 * you should not use this flag unless you provide some way for a user to
3939 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003940 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003941 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3942 * creating new document tasks.
3943 *
3944 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003945 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003946 *
Scott Main7aee61f2011-02-08 11:25:01 -08003947 * <p>See
3948 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3949 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003950 *
3951 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3952 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003953 */
3954 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3955 /**
3956 * If set, and the activity being launched is already running in the
3957 * current task, then instead of launching a new instance of that activity,
3958 * all of the other activities on top of it will be closed and this Intent
3959 * will be delivered to the (now on top) old activity as a new Intent.
3960 *
3961 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3962 * If D calls startActivity() with an Intent that resolves to the component
3963 * of activity B, then C and D will be finished and B receive the given
3964 * Intent, resulting in the stack now being: A, B.
3965 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003966 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003967 * either receive the new intent you are starting here in its
3968 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003969 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003970 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3971 * the same intent, then it will be finished and re-created; for all other
3972 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3973 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003974 *
3975 * <p>This launch mode can also be used to good effect in conjunction with
3976 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3977 * of a task, it will bring any currently running instance of that task
3978 * to the foreground, and then clear it to its root state. This is
3979 * especially useful, for example, when launching an activity from the
3980 * notification manager.
3981 *
Scott Main7aee61f2011-02-08 11:25:01 -08003982 * <p>See
3983 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3984 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003985 */
3986 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3987 /**
3988 * If set and this intent is being used to launch a new activity from an
3989 * existing one, then the reply target of the existing activity will be
3990 * transfered to the new activity. This way the new activity can call
3991 * {@link android.app.Activity#setResult} and have that result sent back to
3992 * the reply target of the original activity.
3993 */
3994 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3995 /**
3996 * If set and this intent is being used to launch a new activity from an
3997 * existing one, the current activity will not be counted as the top
3998 * activity for deciding whether the new intent should be delivered to
3999 * the top instead of starting a new one. The previous activity will
4000 * be used as the top, with the assumption being that the current activity
4001 * will finish itself immediately.
4002 */
4003 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4004 /**
4005 * If set, the new activity is not kept in the list of recently launched
4006 * activities.
4007 */
4008 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4009 /**
4010 * This flag is not normally set by application code, but set for you by
4011 * the system as described in the
4012 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4013 * launchMode} documentation for the singleTask mode.
4014 */
4015 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4016 /**
4017 * If set, and this activity is either being started in a new task or
4018 * bringing to the top an existing task, then it will be launched as
4019 * the front door of the task. This will result in the application of
4020 * any affinities needed to have that task in the proper state (either
4021 * moving activities to or from it), or simply resetting that task to
4022 * its initial state if needed.
4023 */
4024 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4025 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004026 * This flag is not normally set by application code, but set for you by
4027 * the system if this activity is being launched from history
4028 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004029 */
4030 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004031 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004032 * @deprecated As of API 21 this performs identically to
4033 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004034 */
4035 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004036 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004037 * This flag is used to open a document into a new task rooted at the activity launched
4038 * by this Intent. Through the use of this flag, or its equivalent attribute,
4039 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004040 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004041 *
Craig Mautner026596b2014-05-21 15:35:44 -07004042 * <p>The use of the activity attribute form of this,
4043 * {@link android.R.attr#documentLaunchMode}, is
4044 * preferred over the Intent flag described here. The attribute form allows the
4045 * Activity to specify multiple document behavior for all launchers of the Activity
4046 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004047 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004048 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4049 * it is kept after the activity is finished is different than the use of
4050 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4051 * this flag is being used to create a new recents entry, then by default that entry
4052 * will be removed once the activity is finished. You can modify this behavior with
4053 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4054 *
Craig Mautner026596b2014-05-21 15:35:44 -07004055 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4056 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4057 * equivalent of the Activity manifest specifying {@link
4058 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4059 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4060 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004061 *
Craig Mautner026596b2014-05-21 15:35:44 -07004062 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004063 *
Craig Mautner026596b2014-05-21 15:35:44 -07004064 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004065 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4066 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004067 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004068 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004069 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004070 * callback from occurring on the current frontmost activity before it is
4071 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004072 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004073 * <p>Typically, an activity can rely on that callback to indicate that an
4074 * explicit user action has caused their activity to be moved out of the
4075 * foreground. The callback marks an appropriate point in the activity's
4076 * lifecycle for it to dismiss any notifications that it intends to display
4077 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004078 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004079 * <p>If an activity is ever started via any non-user-driven events such as
4080 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4081 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004082 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004083 */
4084 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004085 /**
4086 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4087 * this flag will cause the launched activity to be brought to the front of its
4088 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004089 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004090 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4091 * If D calls startActivity() with an Intent that resolves to the component
4092 * of activity B, then B will be brought to the front of the history stack,
4093 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004094 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004095 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004096 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004097 */
4098 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004099 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004100 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4101 * this flag will prevent the system from applying an activity transition
4102 * animation to go to the next activity state. This doesn't mean an
4103 * animation will never run -- if another activity change happens that doesn't
4104 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004105 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004106 * when you are going to do a series of activity operations but the
4107 * animation seen by the user shouldn't be driven by the first activity
4108 * change but rather a later one.
4109 */
4110 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4111 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004112 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4113 * this flag will cause any existing task that would be associated with the
4114 * activity to be cleared before the activity is started. That is, the activity
4115 * becomes the new root of an otherwise empty task, and any old activities
4116 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4117 */
4118 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4119 /**
4120 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4121 * this flag will cause a newly launching task to be placed on top of the current
4122 * home activity task (if there is one). That is, pressing back from the task
4123 * will always return the user to home even if that was not the last activity they
4124 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4125 */
4126 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4127 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004128 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4129 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004130 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004131 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004132 * this flag. When set and the task's activity is finished, the recents
4133 * entry will remain in the interface for the user to re-launch it, like a
4134 * recents entry for a top-level application.
4135 * <p>
4136 * The receiving activity can override this request with
4137 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4138 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004139 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004140 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004141 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004142
4143 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004144 * If set, when sending a broadcast only registered receivers will be
4145 * called -- no BroadcastReceiver components will be launched.
4146 */
4147 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004148 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004149 * If set, when sending a broadcast the new broadcast will replace
4150 * any existing pending broadcast that matches it. Matching is defined
4151 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4152 * true for the intents of the two broadcasts. When a match is found,
4153 * the new broadcast (and receivers associated with it) will replace the
4154 * existing one in the pending broadcast list, remaining at the same
4155 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004156 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004157 * <p>This flag is most typically used with sticky broadcasts, which
4158 * only care about delivering the most recent values of the broadcast
4159 * to their receivers.
4160 */
4161 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4162 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004163 * If set, when sending a broadcast the recipient is allowed to run at
4164 * foreground priority, with a shorter timeout interval. During normal
4165 * broadcasts the receivers are not automatically hoisted out of the
4166 * background priority class.
4167 */
4168 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4169 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004170 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4171 * They can still propagate results through to later receivers, but they can not prevent
4172 * later receivers from seeing the broadcast.
4173 */
4174 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4175 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004176 * If set, when sending a broadcast <i>before boot has completed</i> only
4177 * registered receivers will be called -- no BroadcastReceiver components
4178 * will be launched. Sticky intent state will be recorded properly even
4179 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4180 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004181 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004182 * <p>This flag is only for use by system sevices as a convenience to
4183 * avoid having to implement a more complex mechanism around detection
4184 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004185 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004186 * @hide
4187 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004188 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004189 /**
4190 * Set when this broadcast is for a boot upgrade, a special mode that
4191 * allows the broadcast to be sent before the system is ready and launches
4192 * the app process with no providers running in it.
4193 * @hide
4194 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004195 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004196
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004197 /**
4198 * @hide Flags that can't be changed with PendingIntent.
4199 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004200 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4201 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4202 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004204 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004205 // ---------------------------------------------------------------------
4206 // toUri() and parseUri() options.
4207
4208 /**
4209 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4210 * always has the "intent:" scheme. This syntax can be used when you want
4211 * to later disambiguate between URIs that are intended to describe an
4212 * Intent vs. all others that should be treated as raw URIs. When used
4213 * with {@link #parseUri}, any other scheme will result in a generic
4214 * VIEW action for that raw URI.
4215 */
4216 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004217
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004218 /**
4219 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4220 * always has the "android-app:" scheme. This is a variation of
4221 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4222 * http/https URI being delivered to a specific package name. The format
4223 * is:
4224 *
4225 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004226 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004227 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004228 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4229 * you must also include a scheme; including a path also requires both a host and a scheme.
4230 * The final #Intent; fragment can be used without a scheme, host, or path.
4231 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004232 * used with intents that have a {@link #setSelector}, since the base intent
4233 * will always have an explicit package name.</p>
4234 *
4235 * <p>Some examples of how this scheme maps to Intent objects:</p>
4236 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4237 * <colgroup align="left" />
4238 * <colgroup align="left" />
4239 * <thead>
4240 * <tr><th>URI</th> <th>Intent</th></tr>
4241 * </thead>
4242 *
4243 * <tbody>
4244 * <tr><td><code>android-app://com.example.app</code></td>
4245 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4246 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4247 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4248 * </table></td>
4249 * </tr>
4250 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4251 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4252 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4253 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4254 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4255 * </table></td>
4256 * </tr>
4257 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4258 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4259 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4260 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4261 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4262 * </table></td>
4263 * </tr>
4264 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4265 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4266 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4267 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4268 * </table></td>
4269 * </tr>
4270 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4271 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4272 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4273 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4274 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4275 * </table></td>
4276 * </tr>
4277 * <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>
4278 * <td><table border="" style="margin:0" >
4279 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4280 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4281 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4282 * </table></td>
4283 * </tr>
4284 * </tbody>
4285 * </table>
4286 */
4287 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4288
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004289 /**
4290 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4291 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4292 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4293 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4294 * generated Intent can not cause unexpected data access to happen.
4295 *
4296 * <p>If you do not trust the source of the URI being parsed, you should still do further
4297 * processing to protect yourself from it. In particular, when using it to start an
4298 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4299 * that can handle it.</p>
4300 */
4301 public static final int URI_ALLOW_UNSAFE = 1<<2;
4302
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004303 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004304
4305 private String mAction;
4306 private Uri mData;
4307 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004308 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004309 private ComponentName mComponent;
4310 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004311 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004312 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004313 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004314 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004315 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004316 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004317
4318 // ---------------------------------------------------------------------
4319
4320 /**
4321 * Create an empty intent.
4322 */
4323 public Intent() {
4324 }
4325
4326 /**
4327 * Copy constructor.
4328 */
4329 public Intent(Intent o) {
4330 this.mAction = o.mAction;
4331 this.mData = o.mData;
4332 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004333 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004334 this.mComponent = o.mComponent;
4335 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004336 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004337 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004338 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004339 }
4340 if (o.mExtras != null) {
4341 this.mExtras = new Bundle(o.mExtras);
4342 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004343 if (o.mSourceBounds != null) {
4344 this.mSourceBounds = new Rect(o.mSourceBounds);
4345 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004346 if (o.mSelector != null) {
4347 this.mSelector = new Intent(o.mSelector);
4348 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004349 if (o.mClipData != null) {
4350 this.mClipData = new ClipData(o.mClipData);
4351 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004352 }
4353
4354 @Override
4355 public Object clone() {
4356 return new Intent(this);
4357 }
4358
4359 private Intent(Intent o, boolean all) {
4360 this.mAction = o.mAction;
4361 this.mData = o.mData;
4362 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004363 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004364 this.mComponent = o.mComponent;
4365 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004366 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004367 }
4368 }
4369
4370 /**
4371 * Make a clone of only the parts of the Intent that are relevant for
4372 * filter matching: the action, data, type, component, and categories.
4373 */
4374 public Intent cloneFilter() {
4375 return new Intent(this, false);
4376 }
4377
4378 /**
4379 * Create an intent with a given action. All other fields (data, type,
4380 * class) are null. Note that the action <em>must</em> be in a
4381 * namespace because Intents are used globally in the system -- for
4382 * example the system VIEW action is android.intent.action.VIEW; an
4383 * application's custom action would be something like
4384 * com.google.app.myapp.CUSTOM_ACTION.
4385 *
4386 * @param action The Intent action, such as ACTION_VIEW.
4387 */
4388 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004389 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004390 }
4391
4392 /**
4393 * Create an intent with a given action and for a given data url. Note
4394 * that the action <em>must</em> be in a namespace because Intents are
4395 * used globally in the system -- for example the system VIEW action is
4396 * android.intent.action.VIEW; an application's custom action would be
4397 * something like com.google.app.myapp.CUSTOM_ACTION.
4398 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004399 * <p><em>Note: scheme and host name matching in the Android framework is
4400 * case-sensitive, unlike the formal RFC. As a result,
4401 * you should always ensure that you write your Uri with these elements
4402 * using lower case letters, and normalize any Uris you receive from
4403 * outside of Android to ensure the scheme and host is lower case.</em></p>
4404 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004405 * @param action The Intent action, such as ACTION_VIEW.
4406 * @param uri The Intent data URI.
4407 */
4408 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004409 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004410 mData = uri;
4411 }
4412
4413 /**
4414 * Create an intent for a specific component. All other fields (action, data,
4415 * type, class) are null, though they can be modified later with explicit
4416 * calls. This provides a convenient way to create an intent that is
4417 * intended to execute a hard-coded class name, rather than relying on the
4418 * system to find an appropriate class for you; see {@link #setComponent}
4419 * for more information on the repercussions of this.
4420 *
4421 * @param packageContext A Context of the application package implementing
4422 * this class.
4423 * @param cls The component class that is to be used for the intent.
4424 *
4425 * @see #setClass
4426 * @see #setComponent
4427 * @see #Intent(String, android.net.Uri , Context, Class)
4428 */
4429 public Intent(Context packageContext, Class<?> cls) {
4430 mComponent = new ComponentName(packageContext, cls);
4431 }
4432
4433 /**
4434 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004435 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004436 * construct the Intent and then calling {@link #setClass} to set its
4437 * class.
4438 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004439 * <p><em>Note: scheme and host name matching in the Android framework is
4440 * case-sensitive, unlike the formal RFC. As a result,
4441 * you should always ensure that you write your Uri with these elements
4442 * using lower case letters, and normalize any Uris you receive from
4443 * outside of Android to ensure the scheme and host is lower case.</em></p>
4444 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004445 * @param action The Intent action, such as ACTION_VIEW.
4446 * @param uri The Intent data URI.
4447 * @param packageContext A Context of the application package implementing
4448 * this class.
4449 * @param cls The component class that is to be used for the intent.
4450 *
4451 * @see #Intent(String, android.net.Uri)
4452 * @see #Intent(Context, Class)
4453 * @see #setClass
4454 * @see #setComponent
4455 */
4456 public Intent(String action, Uri uri,
4457 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004458 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004459 mData = uri;
4460 mComponent = new ComponentName(packageContext, cls);
4461 }
4462
4463 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004464 * Create an intent to launch the main (root) activity of a task. This
4465 * is the Intent that is started when the application's is launched from
4466 * Home. For anything else that wants to launch an application in the
4467 * same way, it is important that they use an Intent structured the same
4468 * way, and can use this function to ensure this is the case.
4469 *
4470 * <p>The returned Intent has the given Activity component as its explicit
4471 * component, {@link #ACTION_MAIN} as its action, and includes the
4472 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4473 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4474 * to do that through {@link #addFlags(int)} on the returned Intent.
4475 *
4476 * @param mainActivity The main activity component that this Intent will
4477 * launch.
4478 * @return Returns a newly created Intent that can be used to launch the
4479 * activity as a main application entry.
4480 *
4481 * @see #setClass
4482 * @see #setComponent
4483 */
4484 public static Intent makeMainActivity(ComponentName mainActivity) {
4485 Intent intent = new Intent(ACTION_MAIN);
4486 intent.setComponent(mainActivity);
4487 intent.addCategory(CATEGORY_LAUNCHER);
4488 return intent;
4489 }
4490
4491 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004492 * Make an Intent for the main activity of an application, without
4493 * specifying a specific activity to run but giving a selector to find
4494 * the activity. This results in a final Intent that is structured
4495 * the same as when the application is launched from
4496 * Home. For anything else that wants to launch an application in the
4497 * same way, it is important that they use an Intent structured the same
4498 * way, and can use this function to ensure this is the case.
4499 *
4500 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4501 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4502 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4503 * to do that through {@link #addFlags(int)} on the returned Intent.
4504 *
4505 * @param selectorAction The action name of the Intent's selector.
4506 * @param selectorCategory The name of a category to add to the Intent's
4507 * selector.
4508 * @return Returns a newly created Intent that can be used to launch the
4509 * activity as a main application entry.
4510 *
4511 * @see #setSelector(Intent)
4512 */
4513 public static Intent makeMainSelectorActivity(String selectorAction,
4514 String selectorCategory) {
4515 Intent intent = new Intent(ACTION_MAIN);
4516 intent.addCategory(CATEGORY_LAUNCHER);
4517 Intent selector = new Intent();
4518 selector.setAction(selectorAction);
4519 selector.addCategory(selectorCategory);
4520 intent.setSelector(selector);
4521 return intent;
4522 }
4523
4524 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004525 * Make an Intent that can be used to re-launch an application's task
4526 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4527 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4528 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4529 *
4530 * @param mainActivity The activity component that is the root of the
4531 * task; this is the activity that has been published in the application's
4532 * manifest as the main launcher icon.
4533 *
4534 * @return Returns a newly created Intent that can be used to relaunch the
4535 * activity's task in its root state.
4536 */
4537 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4538 Intent intent = makeMainActivity(mainActivity);
4539 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4540 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4541 return intent;
4542 }
4543
4544 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004545 * Call {@link #parseUri} with 0 flags.
4546 * @deprecated Use {@link #parseUri} instead.
4547 */
4548 @Deprecated
4549 public static Intent getIntent(String uri) throws URISyntaxException {
4550 return parseUri(uri, 0);
4551 }
Tom Taylord4a47292009-12-21 13:59:18 -08004552
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004553 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004554 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004555 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004556 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004557 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004558 *
4559 * <p>The URI given here must not be relative -- that is, it must include
4560 * the scheme and full path.
4561 *
4562 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004563 * @param flags Additional processing flags. Either 0,
4564 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004565 *
4566 * @return Intent The newly created Intent object.
4567 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004568 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4569 * it bad (as parsed by the Uri class) or the Intent data within the
4570 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004571 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004572 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004573 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004574 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004575 int i = 0;
4576 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004577 final boolean androidApp = uri.startsWith("android-app:");
4578
4579 // Validate intent scheme if requested.
4580 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4581 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004582 Intent intent = new Intent(ACTION_VIEW);
4583 try {
4584 intent.setData(Uri.parse(uri));
4585 } catch (IllegalArgumentException e) {
4586 throw new URISyntaxException(uri, e.getMessage());
4587 }
4588 return intent;
4589 }
4590 }
Tom Taylord4a47292009-12-21 13:59:18 -08004591
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004592 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004593 // simple case
4594 if (i == -1) {
4595 if (!androidApp) {
4596 return new Intent(ACTION_VIEW, Uri.parse(uri));
4597 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004598
4599 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004600 } else if (!uri.startsWith("#Intent;", i)) {
4601 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004602 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004603 } else {
4604 i = -1;
4605 }
4606 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004607
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004608 // new format
4609 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004610 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004611 boolean explicitAction = false;
4612 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004613
4614 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004615 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004616 String data;
4617 if (i >= 0) {
4618 data = uri.substring(0, i);
4619 i += 8; // length of "#Intent;"
4620 } else {
4621 data = uri;
4622 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004623
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004624 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004625 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004626 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004627 if (eq < 0) eq = i-1;
4628 int semi = uri.indexOf(';', i);
4629 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004630
4631 // action
4632 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004633 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004634 if (!inSelector) {
4635 explicitAction = true;
4636 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004637 }
4638
4639 // categories
4640 else if (uri.startsWith("category=", i)) {
4641 intent.addCategory(value);
4642 }
4643
4644 // type
4645 else if (uri.startsWith("type=", i)) {
4646 intent.mType = value;
4647 }
4648
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004649 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004650 else if (uri.startsWith("launchFlags=", i)) {
4651 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004652 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4653 intent.mFlags &= ~IMMUTABLE_FLAGS;
4654 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004655 }
4656
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004657 // package
4658 else if (uri.startsWith("package=", i)) {
4659 intent.mPackage = value;
4660 }
4661
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004662 // component
4663 else if (uri.startsWith("component=", i)) {
4664 intent.mComponent = ComponentName.unflattenFromString(value);
4665 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004666
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004667 // scheme
4668 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004669 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004670 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004671 } else {
4672 scheme = value;
4673 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004674 }
4675
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004676 // source bounds
4677 else if (uri.startsWith("sourceBounds=", i)) {
4678 intent.mSourceBounds = Rect.unflattenFromString(value);
4679 }
4680
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004681 // selector
4682 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4683 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004684 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004685 }
4686
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004687 // extra
4688 else {
4689 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004690 // create Bundle if it doesn't already exist
4691 if (intent.mExtras == null) intent.mExtras = new Bundle();
4692 Bundle b = intent.mExtras;
4693 // add EXTRA
4694 if (uri.startsWith("S.", i)) b.putString(key, value);
4695 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4696 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4697 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4698 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4699 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4700 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4701 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4702 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4703 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4704 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004706 // move to the next item
4707 i = semi + 1;
4708 }
4709
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004710 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004711 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004712 if (baseIntent.mPackage == null) {
4713 baseIntent.setSelector(intent);
4714 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004715 intent = baseIntent;
4716 }
4717
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004718 if (data != null) {
4719 if (data.startsWith("intent:")) {
4720 data = data.substring(7);
4721 if (scheme != null) {
4722 data = scheme + ':' + data;
4723 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004724 } else if (data.startsWith("android-app:")) {
4725 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4726 // Correctly formed android-app, first part is package name.
4727 int end = data.indexOf('/', 14);
4728 if (end < 0) {
4729 // All we have is a package name.
4730 intent.mPackage = data.substring(14);
4731 if (!explicitAction) {
4732 intent.setAction(ACTION_MAIN);
4733 }
4734 data = "";
4735 } else {
4736 // Target the Intent at the given package name always.
4737 String authority = null;
4738 intent.mPackage = data.substring(14, end);
4739 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004740 if ((end+1) < data.length()) {
4741 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4742 // Found a scheme, remember it.
4743 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004744 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004745 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4746 // Found a authority, remember it.
4747 authority = data.substring(end+1, newEnd);
4748 end = newEnd;
4749 }
4750 } else {
4751 // All we have is a scheme.
4752 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004753 }
4754 }
4755 if (scheme == null) {
4756 // If there was no scheme, then this just targets the package.
4757 if (!explicitAction) {
4758 intent.setAction(ACTION_MAIN);
4759 }
4760 data = "";
4761 } else if (authority == null) {
4762 data = scheme + ":";
4763 } else {
4764 data = scheme + "://" + authority + data.substring(end);
4765 }
4766 }
4767 } else {
4768 data = "";
4769 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004770 }
Tom Taylord4a47292009-12-21 13:59:18 -08004771
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004772 if (data.length() > 0) {
4773 try {
4774 intent.mData = Uri.parse(data);
4775 } catch (IllegalArgumentException e) {
4776 throw new URISyntaxException(uri, e.getMessage());
4777 }
4778 }
4779 }
Tom Taylord4a47292009-12-21 13:59:18 -08004780
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004781 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004782
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004783 } catch (IndexOutOfBoundsException e) {
4784 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4785 }
4786 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004787
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004788 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004789 return getIntentOld(uri, 0);
4790 }
4791
4792 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004793 Intent intent;
4794
4795 int i = uri.lastIndexOf('#');
4796 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004797 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004798 final int intentFragmentStart = i;
4799 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004800
4801 i++;
4802
4803 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004804 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004805 i += 7;
4806 int j = uri.indexOf(')', i);
4807 action = uri.substring(i, j);
4808 i = j + 1;
4809 }
4810
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004811 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004812
4813 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004814 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004815 i += 11;
4816 int j = uri.indexOf(')', i);
4817 while (i < j) {
4818 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004819 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004820 if (i < sep) {
4821 intent.addCategory(uri.substring(i, sep));
4822 }
4823 i = sep + 1;
4824 }
4825 i = j + 1;
4826 }
4827
4828 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004829 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004830 i += 5;
4831 int j = uri.indexOf(')', i);
4832 intent.mType = uri.substring(i, j);
4833 i = j + 1;
4834 }
4835
4836 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004837 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004838 i += 12;
4839 int j = uri.indexOf(')', i);
4840 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004841 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4842 intent.mFlags &= ~IMMUTABLE_FLAGS;
4843 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004844 i = j + 1;
4845 }
4846
4847 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004848 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004849 i += 10;
4850 int j = uri.indexOf(')', i);
4851 int sep = uri.indexOf('!', i);
4852 if (sep >= 0 && sep < j) {
4853 String pkg = uri.substring(i, sep);
4854 String cls = uri.substring(sep + 1, j);
4855 intent.mComponent = new ComponentName(pkg, cls);
4856 }
4857 i = j + 1;
4858 }
4859
4860 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004861 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004862 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004863
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004864 final int closeParen = uri.indexOf(')', i);
4865 if (closeParen == -1) throw new URISyntaxException(uri,
4866 "EXTRA missing trailing ')'", i);
4867
4868 while (i < closeParen) {
4869 // fetch the key value
4870 int j = uri.indexOf('=', i);
4871 if (j <= i + 1 || i >= closeParen) {
4872 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4873 }
4874 char type = uri.charAt(i);
4875 i++;
4876 String key = uri.substring(i, j);
4877 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004878
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004879 // get type-value
4880 j = uri.indexOf('!', i);
4881 if (j == -1 || j >= closeParen) j = closeParen;
4882 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4883 String value = uri.substring(i, j);
4884 i = j;
4885
4886 // create Bundle if it doesn't already exist
4887 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004888
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004889 // add item to bundle
4890 try {
4891 switch (type) {
4892 case 'S':
4893 intent.mExtras.putString(key, Uri.decode(value));
4894 break;
4895 case 'B':
4896 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4897 break;
4898 case 'b':
4899 intent.mExtras.putByte(key, Byte.parseByte(value));
4900 break;
4901 case 'c':
4902 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4903 break;
4904 case 'd':
4905 intent.mExtras.putDouble(key, Double.parseDouble(value));
4906 break;
4907 case 'f':
4908 intent.mExtras.putFloat(key, Float.parseFloat(value));
4909 break;
4910 case 'i':
4911 intent.mExtras.putInt(key, Integer.parseInt(value));
4912 break;
4913 case 'l':
4914 intent.mExtras.putLong(key, Long.parseLong(value));
4915 break;
4916 case 's':
4917 intent.mExtras.putShort(key, Short.parseShort(value));
4918 break;
4919 default:
4920 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4921 }
4922 } catch (NumberFormatException e) {
4923 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4924 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004925
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004926 char ch = uri.charAt(i);
4927 if (ch == ')') break;
4928 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4929 i++;
4930 }
4931 }
4932
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004933 if (isIntentFragment) {
4934 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4935 } else {
4936 intent.mData = Uri.parse(uri);
4937 }
Tom Taylord4a47292009-12-21 13:59:18 -08004938
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004939 if (intent.mAction == null) {
4940 // By default, if no action is specified, then use VIEW.
4941 intent.mAction = ACTION_VIEW;
4942 }
4943
4944 } else {
4945 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4946 }
4947
4948 return intent;
4949 }
4950
4951 /**
4952 * Retrieve the general action to be performed, such as
4953 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4954 * the information in the intent should be interpreted -- most importantly,
4955 * what to do with the data returned by {@link #getData}.
4956 *
4957 * @return The action of this intent or null if none is specified.
4958 *
4959 * @see #setAction
4960 */
4961 public String getAction() {
4962 return mAction;
4963 }
4964
4965 /**
4966 * Retrieve data this intent is operating on. This URI specifies the name
4967 * of the data; often it uses the content: scheme, specifying data in a
4968 * content provider. Other schemes may be handled by specific activities,
4969 * such as http: by the web browser.
4970 *
4971 * @return The URI of the data this intent is targeting or null.
4972 *
4973 * @see #getScheme
4974 * @see #setData
4975 */
4976 public Uri getData() {
4977 return mData;
4978 }
4979
4980 /**
4981 * The same as {@link #getData()}, but returns the URI as an encoded
4982 * String.
4983 */
4984 public String getDataString() {
4985 return mData != null ? mData.toString() : null;
4986 }
4987
4988 /**
4989 * Return the scheme portion of the intent's data. If the data is null or
4990 * does not include a scheme, null is returned. Otherwise, the scheme
4991 * prefix without the final ':' is returned, i.e. "http".
4992 *
4993 * <p>This is the same as calling getData().getScheme() (and checking for
4994 * null data).
4995 *
4996 * @return The scheme of this intent.
4997 *
4998 * @see #getData
4999 */
5000 public String getScheme() {
5001 return mData != null ? mData.getScheme() : null;
5002 }
5003
5004 /**
5005 * Retrieve any explicit MIME type included in the intent. This is usually
5006 * null, as the type is determined by the intent data.
5007 *
5008 * @return If a type was manually set, it is returned; else null is
5009 * returned.
5010 *
5011 * @see #resolveType(ContentResolver)
5012 * @see #setType
5013 */
5014 public String getType() {
5015 return mType;
5016 }
5017
5018 /**
5019 * Return the MIME data type of this intent. If the type field is
5020 * explicitly set, that is simply returned. Otherwise, if the data is set,
5021 * the type of that data is returned. If neither fields are set, a null is
5022 * returned.
5023 *
5024 * @return The MIME type of this intent.
5025 *
5026 * @see #getType
5027 * @see #resolveType(ContentResolver)
5028 */
5029 public String resolveType(Context context) {
5030 return resolveType(context.getContentResolver());
5031 }
5032
5033 /**
5034 * Return the MIME data type of this intent. If the type field is
5035 * explicitly set, that is simply returned. Otherwise, if the data is set,
5036 * the type of that data is returned. If neither fields are set, a null is
5037 * returned.
5038 *
5039 * @param resolver A ContentResolver that can be used to determine the MIME
5040 * type of the intent's data.
5041 *
5042 * @return The MIME type of this intent.
5043 *
5044 * @see #getType
5045 * @see #resolveType(Context)
5046 */
5047 public String resolveType(ContentResolver resolver) {
5048 if (mType != null) {
5049 return mType;
5050 }
5051 if (mData != null) {
5052 if ("content".equals(mData.getScheme())) {
5053 return resolver.getType(mData);
5054 }
5055 }
5056 return null;
5057 }
5058
5059 /**
5060 * Return the MIME data type of this intent, only if it will be needed for
5061 * intent resolution. This is not generally useful for application code;
5062 * it is used by the frameworks for communicating with back-end system
5063 * services.
5064 *
5065 * @param resolver A ContentResolver that can be used to determine the MIME
5066 * type of the intent's data.
5067 *
5068 * @return The MIME type of this intent, or null if it is unknown or not
5069 * needed.
5070 */
5071 public String resolveTypeIfNeeded(ContentResolver resolver) {
5072 if (mComponent != null) {
5073 return mType;
5074 }
5075 return resolveType(resolver);
5076 }
5077
5078 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005079 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005080 *
5081 * @param category The category to check.
5082 *
5083 * @return boolean True if the intent contains the category, else false.
5084 *
5085 * @see #getCategories
5086 * @see #addCategory
5087 */
5088 public boolean hasCategory(String category) {
5089 return mCategories != null && mCategories.contains(category);
5090 }
5091
5092 /**
5093 * Return the set of all categories in the intent. If there are no categories,
5094 * returns NULL.
5095 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005096 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005097 *
5098 * @see #hasCategory
5099 * @see #addCategory
5100 */
5101 public Set<String> getCategories() {
5102 return mCategories;
5103 }
5104
5105 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005106 * Return the specific selector associated with this Intent. If there is
5107 * none, returns null. See {@link #setSelector} for more information.
5108 *
5109 * @see #setSelector
5110 */
5111 public Intent getSelector() {
5112 return mSelector;
5113 }
5114
5115 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005116 * Return the {@link ClipData} associated with this Intent. If there is
5117 * none, returns null. See {@link #setClipData} for more information.
5118 *
John Spurlock125d1332013-11-25 11:58:37 -05005119 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005120 */
5121 public ClipData getClipData() {
5122 return mClipData;
5123 }
5124
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005125 /** @hide */
5126 public int getContentUserHint() {
5127 return mContentUserHint;
5128 }
5129
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005130 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005131 * Sets the ClassLoader that will be used when unmarshalling
5132 * any Parcelable values from the extras of this Intent.
5133 *
5134 * @param loader a ClassLoader, or null to use the default loader
5135 * at the time of unmarshalling.
5136 */
5137 public void setExtrasClassLoader(ClassLoader loader) {
5138 if (mExtras != null) {
5139 mExtras.setClassLoader(loader);
5140 }
5141 }
5142
5143 /**
5144 * Returns true if an extra value is associated with the given name.
5145 * @param name the extra's name
5146 * @return true if the given extra is present.
5147 */
5148 public boolean hasExtra(String name) {
5149 return mExtras != null && mExtras.containsKey(name);
5150 }
5151
5152 /**
5153 * Returns true if the Intent's extras contain a parcelled file descriptor.
5154 * @return true if the Intent contains a parcelled file descriptor.
5155 */
5156 public boolean hasFileDescriptors() {
5157 return mExtras != null && mExtras.hasFileDescriptors();
5158 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005159
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005160 /** @hide */
5161 public void setAllowFds(boolean allowFds) {
5162 if (mExtras != null) {
5163 mExtras.setAllowFds(allowFds);
5164 }
5165 }
5166
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005167 /**
5168 * Retrieve extended data from the intent.
5169 *
5170 * @param name The name of the desired item.
5171 *
5172 * @return the value of an item that previously added with putExtra()
5173 * or null if none was found.
5174 *
5175 * @deprecated
5176 * @hide
5177 */
5178 @Deprecated
5179 public Object getExtra(String name) {
5180 return getExtra(name, null);
5181 }
5182
5183 /**
5184 * Retrieve extended data from the intent.
5185 *
5186 * @param name The name of the desired item.
5187 * @param defaultValue the value to be returned if no value of the desired
5188 * type is stored with the given name.
5189 *
5190 * @return the value of an item that previously added with putExtra()
5191 * or the default value if none was found.
5192 *
5193 * @see #putExtra(String, boolean)
5194 */
5195 public boolean getBooleanExtra(String name, boolean defaultValue) {
5196 return mExtras == null ? defaultValue :
5197 mExtras.getBoolean(name, defaultValue);
5198 }
5199
5200 /**
5201 * Retrieve extended data from the intent.
5202 *
5203 * @param name The name of the desired item.
5204 * @param defaultValue the value to be returned if no value of the desired
5205 * type is stored with the given name.
5206 *
5207 * @return the value of an item that previously added with putExtra()
5208 * or the default value if none was found.
5209 *
5210 * @see #putExtra(String, byte)
5211 */
5212 public byte getByteExtra(String name, byte defaultValue) {
5213 return mExtras == null ? defaultValue :
5214 mExtras.getByte(name, defaultValue);
5215 }
5216
5217 /**
5218 * Retrieve extended data from the intent.
5219 *
5220 * @param name The name of the desired item.
5221 * @param defaultValue the value to be returned if no value of the desired
5222 * type is stored with the given name.
5223 *
5224 * @return the value of an item that previously added with putExtra()
5225 * or the default value if none was found.
5226 *
5227 * @see #putExtra(String, short)
5228 */
5229 public short getShortExtra(String name, short defaultValue) {
5230 return mExtras == null ? defaultValue :
5231 mExtras.getShort(name, defaultValue);
5232 }
5233
5234 /**
5235 * Retrieve extended data from the intent.
5236 *
5237 * @param name The name of the desired item.
5238 * @param defaultValue the value to be returned if no value of the desired
5239 * type is stored with the given name.
5240 *
5241 * @return the value of an item that previously added with putExtra()
5242 * or the default value if none was found.
5243 *
5244 * @see #putExtra(String, char)
5245 */
5246 public char getCharExtra(String name, char defaultValue) {
5247 return mExtras == null ? defaultValue :
5248 mExtras.getChar(name, defaultValue);
5249 }
5250
5251 /**
5252 * Retrieve extended data from the intent.
5253 *
5254 * @param name The name of the desired item.
5255 * @param defaultValue the value to be returned if no value of the desired
5256 * type is stored with the given name.
5257 *
5258 * @return the value of an item that previously added with putExtra()
5259 * or the default value if none was found.
5260 *
5261 * @see #putExtra(String, int)
5262 */
5263 public int getIntExtra(String name, int defaultValue) {
5264 return mExtras == null ? defaultValue :
5265 mExtras.getInt(name, defaultValue);
5266 }
5267
5268 /**
5269 * Retrieve extended data from the intent.
5270 *
5271 * @param name The name of the desired item.
5272 * @param defaultValue the value to be returned if no value of the desired
5273 * type is stored with the given name.
5274 *
5275 * @return the value of an item that previously added with putExtra()
5276 * or the default value if none was found.
5277 *
5278 * @see #putExtra(String, long)
5279 */
5280 public long getLongExtra(String name, long defaultValue) {
5281 return mExtras == null ? defaultValue :
5282 mExtras.getLong(name, defaultValue);
5283 }
5284
5285 /**
5286 * Retrieve extended data from the intent.
5287 *
5288 * @param name The name of the desired item.
5289 * @param defaultValue the value to be returned if no value of the desired
5290 * type is stored with the given name.
5291 *
5292 * @return the value of an item that previously added with putExtra(),
5293 * or the default value if no such item is present
5294 *
5295 * @see #putExtra(String, float)
5296 */
5297 public float getFloatExtra(String name, float defaultValue) {
5298 return mExtras == null ? defaultValue :
5299 mExtras.getFloat(name, defaultValue);
5300 }
5301
5302 /**
5303 * Retrieve extended data from the intent.
5304 *
5305 * @param name The name of the desired item.
5306 * @param defaultValue the value to be returned if no value of the desired
5307 * type is stored with the given name.
5308 *
5309 * @return the value of an item that previously added with putExtra()
5310 * or the default value if none was found.
5311 *
5312 * @see #putExtra(String, double)
5313 */
5314 public double getDoubleExtra(String name, double defaultValue) {
5315 return mExtras == null ? defaultValue :
5316 mExtras.getDouble(name, defaultValue);
5317 }
5318
5319 /**
5320 * Retrieve extended data from the intent.
5321 *
5322 * @param name The name of the desired item.
5323 *
5324 * @return the value of an item that previously added with putExtra()
5325 * or null if no String value was found.
5326 *
5327 * @see #putExtra(String, String)
5328 */
5329 public String getStringExtra(String name) {
5330 return mExtras == null ? null : mExtras.getString(name);
5331 }
5332
5333 /**
5334 * Retrieve extended data from the intent.
5335 *
5336 * @param name The name of the desired item.
5337 *
5338 * @return the value of an item that previously added with putExtra()
5339 * or null if no CharSequence value was found.
5340 *
5341 * @see #putExtra(String, CharSequence)
5342 */
5343 public CharSequence getCharSequenceExtra(String name) {
5344 return mExtras == null ? null : mExtras.getCharSequence(name);
5345 }
5346
5347 /**
5348 * Retrieve extended data from the intent.
5349 *
5350 * @param name The name of the desired item.
5351 *
5352 * @return the value of an item that previously added with putExtra()
5353 * or null if no Parcelable value was found.
5354 *
5355 * @see #putExtra(String, Parcelable)
5356 */
5357 public <T extends Parcelable> T getParcelableExtra(String name) {
5358 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5359 }
5360
5361 /**
5362 * Retrieve extended data from the intent.
5363 *
5364 * @param name The name of the desired item.
5365 *
5366 * @return the value of an item that previously added with putExtra()
5367 * or null if no Parcelable[] value was found.
5368 *
5369 * @see #putExtra(String, Parcelable[])
5370 */
5371 public Parcelable[] getParcelableArrayExtra(String name) {
5372 return mExtras == null ? null : mExtras.getParcelableArray(name);
5373 }
5374
5375 /**
5376 * Retrieve extended data from the intent.
5377 *
5378 * @param name The name of the desired item.
5379 *
5380 * @return the value of an item that previously added with putExtra()
5381 * or null if no ArrayList<Parcelable> value was found.
5382 *
5383 * @see #putParcelableArrayListExtra(String, ArrayList)
5384 */
5385 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5386 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5387 }
5388
5389 /**
5390 * Retrieve extended data from the intent.
5391 *
5392 * @param name The name of the desired item.
5393 *
5394 * @return the value of an item that previously added with putExtra()
5395 * or null if no Serializable value was found.
5396 *
5397 * @see #putExtra(String, Serializable)
5398 */
5399 public Serializable getSerializableExtra(String name) {
5400 return mExtras == null ? null : mExtras.getSerializable(name);
5401 }
5402
5403 /**
5404 * Retrieve extended data from the intent.
5405 *
5406 * @param name The name of the desired item.
5407 *
5408 * @return the value of an item that previously added with putExtra()
5409 * or null if no ArrayList<Integer> value was found.
5410 *
5411 * @see #putIntegerArrayListExtra(String, ArrayList)
5412 */
5413 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5414 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5415 }
5416
5417 /**
5418 * Retrieve extended data from the intent.
5419 *
5420 * @param name The name of the desired item.
5421 *
5422 * @return the value of an item that previously added with putExtra()
5423 * or null if no ArrayList<String> value was found.
5424 *
5425 * @see #putStringArrayListExtra(String, ArrayList)
5426 */
5427 public ArrayList<String> getStringArrayListExtra(String name) {
5428 return mExtras == null ? null : mExtras.getStringArrayList(name);
5429 }
5430
5431 /**
5432 * Retrieve extended data from the intent.
5433 *
5434 * @param name The name of the desired item.
5435 *
5436 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005437 * or null if no ArrayList<CharSequence> value was found.
5438 *
5439 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5440 */
5441 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5442 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5443 }
5444
5445 /**
5446 * Retrieve extended data from the intent.
5447 *
5448 * @param name The name of the desired item.
5449 *
5450 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005451 * or null if no boolean array value was found.
5452 *
5453 * @see #putExtra(String, boolean[])
5454 */
5455 public boolean[] getBooleanArrayExtra(String name) {
5456 return mExtras == null ? null : mExtras.getBooleanArray(name);
5457 }
5458
5459 /**
5460 * Retrieve extended data from the intent.
5461 *
5462 * @param name The name of the desired item.
5463 *
5464 * @return the value of an item that previously added with putExtra()
5465 * or null if no byte array value was found.
5466 *
5467 * @see #putExtra(String, byte[])
5468 */
5469 public byte[] getByteArrayExtra(String name) {
5470 return mExtras == null ? null : mExtras.getByteArray(name);
5471 }
5472
5473 /**
5474 * Retrieve extended data from the intent.
5475 *
5476 * @param name The name of the desired item.
5477 *
5478 * @return the value of an item that previously added with putExtra()
5479 * or null if no short array value was found.
5480 *
5481 * @see #putExtra(String, short[])
5482 */
5483 public short[] getShortArrayExtra(String name) {
5484 return mExtras == null ? null : mExtras.getShortArray(name);
5485 }
5486
5487 /**
5488 * Retrieve extended data from the intent.
5489 *
5490 * @param name The name of the desired item.
5491 *
5492 * @return the value of an item that previously added with putExtra()
5493 * or null if no char array value was found.
5494 *
5495 * @see #putExtra(String, char[])
5496 */
5497 public char[] getCharArrayExtra(String name) {
5498 return mExtras == null ? null : mExtras.getCharArray(name);
5499 }
5500
5501 /**
5502 * Retrieve extended data from the intent.
5503 *
5504 * @param name The name of the desired item.
5505 *
5506 * @return the value of an item that previously added with putExtra()
5507 * or null if no int array value was found.
5508 *
5509 * @see #putExtra(String, int[])
5510 */
5511 public int[] getIntArrayExtra(String name) {
5512 return mExtras == null ? null : mExtras.getIntArray(name);
5513 }
5514
5515 /**
5516 * Retrieve extended data from the intent.
5517 *
5518 * @param name The name of the desired item.
5519 *
5520 * @return the value of an item that previously added with putExtra()
5521 * or null if no long array value was found.
5522 *
5523 * @see #putExtra(String, long[])
5524 */
5525 public long[] getLongArrayExtra(String name) {
5526 return mExtras == null ? null : mExtras.getLongArray(name);
5527 }
5528
5529 /**
5530 * Retrieve extended data from the intent.
5531 *
5532 * @param name The name of the desired item.
5533 *
5534 * @return the value of an item that previously added with putExtra()
5535 * or null if no float array value was found.
5536 *
5537 * @see #putExtra(String, float[])
5538 */
5539 public float[] getFloatArrayExtra(String name) {
5540 return mExtras == null ? null : mExtras.getFloatArray(name);
5541 }
5542
5543 /**
5544 * Retrieve extended data from the intent.
5545 *
5546 * @param name The name of the desired item.
5547 *
5548 * @return the value of an item that previously added with putExtra()
5549 * or null if no double array value was found.
5550 *
5551 * @see #putExtra(String, double[])
5552 */
5553 public double[] getDoubleArrayExtra(String name) {
5554 return mExtras == null ? null : mExtras.getDoubleArray(name);
5555 }
5556
5557 /**
5558 * Retrieve extended data from the intent.
5559 *
5560 * @param name The name of the desired item.
5561 *
5562 * @return the value of an item that previously added with putExtra()
5563 * or null if no String array value was found.
5564 *
5565 * @see #putExtra(String, String[])
5566 */
5567 public String[] getStringArrayExtra(String name) {
5568 return mExtras == null ? null : mExtras.getStringArray(name);
5569 }
5570
5571 /**
5572 * Retrieve extended data from the intent.
5573 *
5574 * @param name The name of the desired item.
5575 *
5576 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005577 * or null if no CharSequence array value was found.
5578 *
5579 * @see #putExtra(String, CharSequence[])
5580 */
5581 public CharSequence[] getCharSequenceArrayExtra(String name) {
5582 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5583 }
5584
5585 /**
5586 * Retrieve extended data from the intent.
5587 *
5588 * @param name The name of the desired item.
5589 *
5590 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005591 * or null if no Bundle value was found.
5592 *
5593 * @see #putExtra(String, Bundle)
5594 */
5595 public Bundle getBundleExtra(String name) {
5596 return mExtras == null ? null : mExtras.getBundle(name);
5597 }
5598
5599 /**
5600 * Retrieve extended data from the intent.
5601 *
5602 * @param name The name of the desired item.
5603 *
5604 * @return the value of an item that previously added with putExtra()
5605 * or null if no IBinder value was found.
5606 *
5607 * @see #putExtra(String, IBinder)
5608 *
5609 * @deprecated
5610 * @hide
5611 */
5612 @Deprecated
5613 public IBinder getIBinderExtra(String name) {
5614 return mExtras == null ? null : mExtras.getIBinder(name);
5615 }
5616
5617 /**
5618 * Retrieve extended data from the intent.
5619 *
5620 * @param name The name of the desired item.
5621 * @param defaultValue The default value to return in case no item is
5622 * associated with the key 'name'
5623 *
5624 * @return the value of an item that previously added with putExtra()
5625 * or defaultValue if none was found.
5626 *
5627 * @see #putExtra
5628 *
5629 * @deprecated
5630 * @hide
5631 */
5632 @Deprecated
5633 public Object getExtra(String name, Object defaultValue) {
5634 Object result = defaultValue;
5635 if (mExtras != null) {
5636 Object result2 = mExtras.get(name);
5637 if (result2 != null) {
5638 result = result2;
5639 }
5640 }
5641
5642 return result;
5643 }
5644
5645 /**
5646 * Retrieves a map of extended data from the intent.
5647 *
5648 * @return the map of all extras previously added with putExtra(),
5649 * or null if none have been added.
5650 */
5651 public Bundle getExtras() {
5652 return (mExtras != null)
5653 ? new Bundle(mExtras)
5654 : null;
5655 }
5656
5657 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005658 * Filter extras to only basic types.
5659 * @hide
5660 */
5661 public void removeUnsafeExtras() {
5662 if (mExtras != null) {
5663 mExtras.filterValues();
5664 }
5665 }
5666
5667 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005668 * Retrieve any special flags associated with this intent. You will
5669 * normally just set them with {@link #setFlags} and let the system
5670 * take the appropriate action with them.
5671 *
5672 * @return int The currently set flags.
5673 *
5674 * @see #setFlags
5675 */
5676 public int getFlags() {
5677 return mFlags;
5678 }
5679
Dianne Hackborne7f97212011-02-24 14:40:20 -08005680 /** @hide */
5681 public boolean isExcludingStopped() {
5682 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5683 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5684 }
5685
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005686 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005687 * Retrieve the application package name this Intent is limited to. When
5688 * resolving an Intent, if non-null this limits the resolution to only
5689 * components in the given application package.
5690 *
5691 * @return The name of the application package for the Intent.
5692 *
5693 * @see #resolveActivity
5694 * @see #setPackage
5695 */
5696 public String getPackage() {
5697 return mPackage;
5698 }
5699
5700 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005701 * Retrieve the concrete component associated with the intent. When receiving
5702 * an intent, this is the component that was found to best handle it (that is,
5703 * yourself) and will always be non-null; in all other cases it will be
5704 * null unless explicitly set.
5705 *
5706 * @return The name of the application component to handle the intent.
5707 *
5708 * @see #resolveActivity
5709 * @see #setComponent
5710 */
5711 public ComponentName getComponent() {
5712 return mComponent;
5713 }
5714
5715 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005716 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5717 * used as a hint to the receiver for animations and the like. Null means that there
5718 * is no source bounds.
5719 */
5720 public Rect getSourceBounds() {
5721 return mSourceBounds;
5722 }
5723
5724 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005725 * Return the Activity component that should be used to handle this intent.
5726 * The appropriate component is determined based on the information in the
5727 * intent, evaluated as follows:
5728 *
5729 * <p>If {@link #getComponent} returns an explicit class, that is returned
5730 * without any further consideration.
5731 *
5732 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5733 * category to be considered.
5734 *
5735 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5736 * action.
5737 *
5738 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5739 * this type.
5740 *
5741 * <p>If {@link #addCategory} has added any categories, the activity must
5742 * handle ALL of the categories specified.
5743 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005744 * <p>If {@link #getPackage} is non-NULL, only activity components in
5745 * that application package will be considered.
5746 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005747 * <p>If there are no activities that satisfy all of these conditions, a
5748 * null string is returned.
5749 *
5750 * <p>If multiple activities are found to satisfy the intent, the one with
5751 * the highest priority will be used. If there are multiple activities
5752 * with the same priority, the system will either pick the best activity
5753 * based on user preference, or resolve to a system class that will allow
5754 * the user to pick an activity and forward from there.
5755 *
5756 * <p>This method is implemented simply by calling
5757 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5758 * true.</p>
5759 * <p> This API is called for you as part of starting an activity from an
5760 * intent. You do not normally need to call it yourself.</p>
5761 *
5762 * @param pm The package manager with which to resolve the Intent.
5763 *
5764 * @return Name of the component implementing an activity that can
5765 * display the intent.
5766 *
5767 * @see #setComponent
5768 * @see #getComponent
5769 * @see #resolveActivityInfo
5770 */
5771 public ComponentName resolveActivity(PackageManager pm) {
5772 if (mComponent != null) {
5773 return mComponent;
5774 }
5775
5776 ResolveInfo info = pm.resolveActivity(
5777 this, PackageManager.MATCH_DEFAULT_ONLY);
5778 if (info != null) {
5779 return new ComponentName(
5780 info.activityInfo.applicationInfo.packageName,
5781 info.activityInfo.name);
5782 }
5783
5784 return null;
5785 }
5786
5787 /**
5788 * Resolve the Intent into an {@link ActivityInfo}
5789 * describing the activity that should execute the intent. Resolution
5790 * follows the same rules as described for {@link #resolveActivity}, but
5791 * you get back the completely information about the resolved activity
5792 * instead of just its class name.
5793 *
5794 * @param pm The package manager with which to resolve the Intent.
5795 * @param flags Addition information to retrieve as per
5796 * {@link PackageManager#getActivityInfo(ComponentName, int)
5797 * PackageManager.getActivityInfo()}.
5798 *
5799 * @return PackageManager.ActivityInfo
5800 *
5801 * @see #resolveActivity
5802 */
5803 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5804 ActivityInfo ai = null;
5805 if (mComponent != null) {
5806 try {
5807 ai = pm.getActivityInfo(mComponent, flags);
5808 } catch (PackageManager.NameNotFoundException e) {
5809 // ignore
5810 }
5811 } else {
5812 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005813 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005814 if (info != null) {
5815 ai = info.activityInfo;
5816 }
5817 }
5818
5819 return ai;
5820 }
5821
5822 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005823 * Special function for use by the system to resolve service
5824 * intents to system apps. Throws an exception if there are
5825 * multiple potential matches to the Intent. Returns null if
5826 * there are no matches.
5827 * @hide
5828 */
5829 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5830 if (mComponent != null) {
5831 return mComponent;
5832 }
5833
5834 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5835 if (results == null) {
5836 return null;
5837 }
5838 ComponentName comp = null;
5839 for (int i=0; i<results.size(); i++) {
5840 ResolveInfo ri = results.get(i);
5841 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5842 continue;
5843 }
5844 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5845 ri.serviceInfo.name);
5846 if (comp != null) {
5847 throw new IllegalStateException("Multiple system services handle " + this
5848 + ": " + comp + ", " + foundComp);
5849 }
5850 comp = foundComp;
5851 }
5852 return comp;
5853 }
5854
5855 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005856 * Set the general action to be performed.
5857 *
5858 * @param action An action name, such as ACTION_VIEW. Application-specific
5859 * actions should be prefixed with the vendor's package name.
5860 *
5861 * @return Returns the same Intent object, for chaining multiple calls
5862 * into a single statement.
5863 *
5864 * @see #getAction
5865 */
5866 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005867 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005868 return this;
5869 }
5870
5871 /**
5872 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005873 * clears any type that was previously set by {@link #setType} or
5874 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005875 *
Nick Pellyccae4122012-01-09 14:12:58 -08005876 * <p><em>Note: scheme matching in the Android framework is
5877 * case-sensitive, unlike the formal RFC. As a result,
5878 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005879 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005880 * {@link #setDataAndNormalize}
5881 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005882 *
Nick Pellyccae4122012-01-09 14:12:58 -08005883 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005884 *
5885 * @return Returns the same Intent object, for chaining multiple calls
5886 * into a single statement.
5887 *
5888 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005889 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005890 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005891 */
5892 public Intent setData(Uri data) {
5893 mData = data;
5894 mType = null;
5895 return this;
5896 }
5897
5898 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005899 * Normalize and set the data this intent is operating on.
5900 *
5901 * <p>This method automatically clears any type that was
5902 * previously set (for example, by {@link #setType}).
5903 *
5904 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005905 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005906 * so really this is just a convenience method for
5907 * <pre>
5908 * setData(data.normalize())
5909 * </pre>
5910 *
5911 * @param data The Uri of the data this intent is now targeting.
5912 *
5913 * @return Returns the same Intent object, for chaining multiple calls
5914 * into a single statement.
5915 *
5916 * @see #getData
5917 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005918 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005919 */
5920 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005921 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005922 }
5923
5924 /**
5925 * Set an explicit MIME data type.
5926 *
5927 * <p>This is used to create intents that only specify a type and not data,
5928 * for example to indicate the type of data to return.
5929 *
5930 * <p>This method automatically clears any data that was
5931 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005932 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005933 * <p><em>Note: MIME type matching in the Android framework is
5934 * case-sensitive, unlike formal RFC MIME types. As a result,
5935 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005936 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5937 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005938 *
5939 * @param type The MIME type of the data being handled by this intent.
5940 *
5941 * @return Returns the same Intent object, for chaining multiple calls
5942 * into a single statement.
5943 *
5944 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005945 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005946 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005947 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005948 */
5949 public Intent setType(String type) {
5950 mData = null;
5951 mType = type;
5952 return this;
5953 }
5954
5955 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005956 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005957 *
Nick Pellyccae4122012-01-09 14:12:58 -08005958 * <p>This is used to create intents that only specify a type and not data,
5959 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005960 *
Nick Pellyccae4122012-01-09 14:12:58 -08005961 * <p>This method automatically clears any data that was
5962 * previously set (for example by {@link #setData}).
5963 *
5964 * <p>The MIME type is normalized using
5965 * {@link #normalizeMimeType} before it is set,
5966 * so really this is just a convenience method for
5967 * <pre>
5968 * setType(Intent.normalizeMimeType(type))
5969 * </pre>
5970 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005971 * @param type The MIME type of the data being handled by this intent.
5972 *
5973 * @return Returns the same Intent object, for chaining multiple calls
5974 * into a single statement.
5975 *
Nick Pellyccae4122012-01-09 14:12:58 -08005976 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005977 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005978 * @see #normalizeMimeType
5979 */
5980 public Intent setTypeAndNormalize(String type) {
5981 return setType(normalizeMimeType(type));
5982 }
5983
5984 /**
5985 * (Usually optional) Set the data for the intent along with an explicit
5986 * MIME data type. This method should very rarely be used -- it allows you
5987 * to override the MIME type that would ordinarily be inferred from the
5988 * data with your own type given here.
5989 *
5990 * <p><em>Note: MIME type and Uri scheme matching in the
5991 * Android framework is case-sensitive, unlike the formal RFC definitions.
5992 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005993 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005994 * {@link #setDataAndTypeAndNormalize}
5995 * to ensure that they are converted to lower case.</em>
5996 *
5997 * @param data The Uri of the data this intent is now targeting.
5998 * @param type The MIME type of the data being handled by this intent.
5999 *
6000 * @return Returns the same Intent object, for chaining multiple calls
6001 * into a single statement.
6002 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006003 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006004 * @see #setData
6005 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006006 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006007 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006008 */
6009 public Intent setDataAndType(Uri data, String type) {
6010 mData = data;
6011 mType = type;
6012 return this;
6013 }
6014
6015 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006016 * (Usually optional) Normalize and set both the data Uri and an explicit
6017 * MIME data type. This method should very rarely be used -- it allows you
6018 * to override the MIME type that would ordinarily be inferred from the
6019 * data with your own type given here.
6020 *
6021 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006022 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006023 * before they are set, so really this is just a convenience method for
6024 * <pre>
6025 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6026 * </pre>
6027 *
6028 * @param data The Uri of the data this intent is now targeting.
6029 * @param type The MIME type of the data being handled by this intent.
6030 *
6031 * @return Returns the same Intent object, for chaining multiple calls
6032 * into a single statement.
6033 *
6034 * @see #setType
6035 * @see #setData
6036 * @see #setDataAndType
6037 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006038 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006039 */
6040 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006041 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006042 }
6043
6044 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006045 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006046 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006047 * activities that provide <em>all</em> of the requested categories will be
6048 * used.
6049 *
6050 * @param category The desired category. This can be either one of the
6051 * predefined Intent categories, or a custom category in your own
6052 * namespace.
6053 *
6054 * @return Returns the same Intent object, for chaining multiple calls
6055 * into a single statement.
6056 *
6057 * @see #hasCategory
6058 * @see #removeCategory
6059 */
6060 public Intent addCategory(String category) {
6061 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006062 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006063 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006064 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006065 return this;
6066 }
6067
6068 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006069 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006070 *
6071 * @param category The category to remove.
6072 *
6073 * @see #addCategory
6074 */
6075 public void removeCategory(String category) {
6076 if (mCategories != null) {
6077 mCategories.remove(category);
6078 if (mCategories.size() == 0) {
6079 mCategories = null;
6080 }
6081 }
6082 }
6083
6084 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006085 * Set a selector for this Intent. This is a modification to the kinds of
6086 * things the Intent will match. If the selector is set, it will be used
6087 * when trying to find entities that can handle the Intent, instead of the
6088 * main contents of the Intent. This allows you build an Intent containing
6089 * a generic protocol while targeting it more specifically.
6090 *
6091 * <p>An example of where this may be used is with things like
6092 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6093 * Intent that will launch the Browser application. However, the correct
6094 * main entry point of an application is actually {@link #ACTION_MAIN}
6095 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6096 * used to specify the actual Activity to launch. If you launch the browser
6097 * with something different, undesired behavior may happen if the user has
6098 * previously or later launches it the normal way, since they do not match.
6099 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6100 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6101 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6102 *
6103 * <p>Setting a selector does not impact the behavior of
6104 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6105 * desired behavior of a selector -- it does not impact the base meaning
6106 * of the Intent, just what kinds of things will be matched against it
6107 * when determining who can handle it.</p>
6108 *
6109 * <p>You can not use both a selector and {@link #setPackage(String)} on
6110 * the same base Intent.</p>
6111 *
6112 * @param selector The desired selector Intent; set to null to not use
6113 * a special selector.
6114 */
6115 public void setSelector(Intent selector) {
6116 if (selector == this) {
6117 throw new IllegalArgumentException(
6118 "Intent being set as a selector of itself");
6119 }
6120 if (selector != null && mPackage != null) {
6121 throw new IllegalArgumentException(
6122 "Can't set selector when package name is already set");
6123 }
6124 mSelector = selector;
6125 }
6126
6127 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006128 * Set a {@link ClipData} associated with this Intent. This replaces any
6129 * previously set ClipData.
6130 *
6131 * <p>The ClipData in an intent is not used for Intent matching or other
6132 * such operations. Semantically it is like extras, used to transmit
6133 * additional data with the Intent. The main feature of using this over
6134 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6135 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6136 * items included in the clip data. This is useful, in particular, if
6137 * you want to transmit an Intent containing multiple <code>content:</code>
6138 * URIs for which the recipient may not have global permission to access the
6139 * content provider.
6140 *
6141 * <p>If the ClipData contains items that are themselves Intents, any
6142 * grant flags in those Intents will be ignored. Only the top-level flags
6143 * of the main Intent are respected, and will be applied to all Uri or
6144 * Intent items in the clip (or sub-items of the clip).
6145 *
6146 * <p>The MIME type, label, and icon in the ClipData object are not
6147 * directly used by Intent. Applications should generally rely on the
6148 * MIME type of the Intent itself, not what it may find in the ClipData.
6149 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006150 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006151 *
6152 * @param clip The new clip to set. May be null to clear the current clip.
6153 */
6154 public void setClipData(ClipData clip) {
6155 mClipData = clip;
6156 }
6157
6158 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006159 * This is NOT a secure mechanism to identify the user who sent the intent.
6160 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6161 * who sent the intent.
6162 * @hide
6163 */
6164 public void setContentUserHint(int contentUserHint) {
6165 mContentUserHint = contentUserHint;
6166 }
6167
6168 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006169 * Add extended data to the intent. The name must include a package
6170 * prefix, for example the app com.android.contacts would use names
6171 * like "com.android.contacts.ShowAll".
6172 *
6173 * @param name The name of the extra data, with package prefix.
6174 * @param value The boolean data value.
6175 *
6176 * @return Returns the same Intent object, for chaining multiple calls
6177 * into a single statement.
6178 *
6179 * @see #putExtras
6180 * @see #removeExtra
6181 * @see #getBooleanExtra(String, boolean)
6182 */
6183 public Intent putExtra(String name, boolean value) {
6184 if (mExtras == null) {
6185 mExtras = new Bundle();
6186 }
6187 mExtras.putBoolean(name, value);
6188 return this;
6189 }
6190
6191 /**
6192 * Add extended data to the intent. The name must include a package
6193 * prefix, for example the app com.android.contacts would use names
6194 * like "com.android.contacts.ShowAll".
6195 *
6196 * @param name The name of the extra data, with package prefix.
6197 * @param value The byte data value.
6198 *
6199 * @return Returns the same Intent object, for chaining multiple calls
6200 * into a single statement.
6201 *
6202 * @see #putExtras
6203 * @see #removeExtra
6204 * @see #getByteExtra(String, byte)
6205 */
6206 public Intent putExtra(String name, byte value) {
6207 if (mExtras == null) {
6208 mExtras = new Bundle();
6209 }
6210 mExtras.putByte(name, value);
6211 return this;
6212 }
6213
6214 /**
6215 * Add extended data to the intent. The name must include a package
6216 * prefix, for example the app com.android.contacts would use names
6217 * like "com.android.contacts.ShowAll".
6218 *
6219 * @param name The name of the extra data, with package prefix.
6220 * @param value The char data value.
6221 *
6222 * @return Returns the same Intent object, for chaining multiple calls
6223 * into a single statement.
6224 *
6225 * @see #putExtras
6226 * @see #removeExtra
6227 * @see #getCharExtra(String, char)
6228 */
6229 public Intent putExtra(String name, char value) {
6230 if (mExtras == null) {
6231 mExtras = new Bundle();
6232 }
6233 mExtras.putChar(name, value);
6234 return this;
6235 }
6236
6237 /**
6238 * Add extended data to the intent. The name must include a package
6239 * prefix, for example the app com.android.contacts would use names
6240 * like "com.android.contacts.ShowAll".
6241 *
6242 * @param name The name of the extra data, with package prefix.
6243 * @param value The short data value.
6244 *
6245 * @return Returns the same Intent object, for chaining multiple calls
6246 * into a single statement.
6247 *
6248 * @see #putExtras
6249 * @see #removeExtra
6250 * @see #getShortExtra(String, short)
6251 */
6252 public Intent putExtra(String name, short value) {
6253 if (mExtras == null) {
6254 mExtras = new Bundle();
6255 }
6256 mExtras.putShort(name, value);
6257 return this;
6258 }
6259
6260 /**
6261 * Add extended data to the intent. The name must include a package
6262 * prefix, for example the app com.android.contacts would use names
6263 * like "com.android.contacts.ShowAll".
6264 *
6265 * @param name The name of the extra data, with package prefix.
6266 * @param value The integer data value.
6267 *
6268 * @return Returns the same Intent object, for chaining multiple calls
6269 * into a single statement.
6270 *
6271 * @see #putExtras
6272 * @see #removeExtra
6273 * @see #getIntExtra(String, int)
6274 */
6275 public Intent putExtra(String name, int value) {
6276 if (mExtras == null) {
6277 mExtras = new Bundle();
6278 }
6279 mExtras.putInt(name, value);
6280 return this;
6281 }
6282
6283 /**
6284 * Add extended data to the intent. The name must include a package
6285 * prefix, for example the app com.android.contacts would use names
6286 * like "com.android.contacts.ShowAll".
6287 *
6288 * @param name The name of the extra data, with package prefix.
6289 * @param value The long data value.
6290 *
6291 * @return Returns the same Intent object, for chaining multiple calls
6292 * into a single statement.
6293 *
6294 * @see #putExtras
6295 * @see #removeExtra
6296 * @see #getLongExtra(String, long)
6297 */
6298 public Intent putExtra(String name, long value) {
6299 if (mExtras == null) {
6300 mExtras = new Bundle();
6301 }
6302 mExtras.putLong(name, value);
6303 return this;
6304 }
6305
6306 /**
6307 * Add extended data to the intent. The name must include a package
6308 * prefix, for example the app com.android.contacts would use names
6309 * like "com.android.contacts.ShowAll".
6310 *
6311 * @param name The name of the extra data, with package prefix.
6312 * @param value The float data value.
6313 *
6314 * @return Returns the same Intent object, for chaining multiple calls
6315 * into a single statement.
6316 *
6317 * @see #putExtras
6318 * @see #removeExtra
6319 * @see #getFloatExtra(String, float)
6320 */
6321 public Intent putExtra(String name, float value) {
6322 if (mExtras == null) {
6323 mExtras = new Bundle();
6324 }
6325 mExtras.putFloat(name, value);
6326 return this;
6327 }
6328
6329 /**
6330 * Add extended data to the intent. The name must include a package
6331 * prefix, for example the app com.android.contacts would use names
6332 * like "com.android.contacts.ShowAll".
6333 *
6334 * @param name The name of the extra data, with package prefix.
6335 * @param value The double data value.
6336 *
6337 * @return Returns the same Intent object, for chaining multiple calls
6338 * into a single statement.
6339 *
6340 * @see #putExtras
6341 * @see #removeExtra
6342 * @see #getDoubleExtra(String, double)
6343 */
6344 public Intent putExtra(String name, double value) {
6345 if (mExtras == null) {
6346 mExtras = new Bundle();
6347 }
6348 mExtras.putDouble(name, value);
6349 return this;
6350 }
6351
6352 /**
6353 * Add extended data to the intent. The name must include a package
6354 * prefix, for example the app com.android.contacts would use names
6355 * like "com.android.contacts.ShowAll".
6356 *
6357 * @param name The name of the extra data, with package prefix.
6358 * @param value The String data value.
6359 *
6360 * @return Returns the same Intent object, for chaining multiple calls
6361 * into a single statement.
6362 *
6363 * @see #putExtras
6364 * @see #removeExtra
6365 * @see #getStringExtra(String)
6366 */
6367 public Intent putExtra(String name, String value) {
6368 if (mExtras == null) {
6369 mExtras = new Bundle();
6370 }
6371 mExtras.putString(name, value);
6372 return this;
6373 }
6374
6375 /**
6376 * Add extended data to the intent. The name must include a package
6377 * prefix, for example the app com.android.contacts would use names
6378 * like "com.android.contacts.ShowAll".
6379 *
6380 * @param name The name of the extra data, with package prefix.
6381 * @param value The CharSequence data value.
6382 *
6383 * @return Returns the same Intent object, for chaining multiple calls
6384 * into a single statement.
6385 *
6386 * @see #putExtras
6387 * @see #removeExtra
6388 * @see #getCharSequenceExtra(String)
6389 */
6390 public Intent putExtra(String name, CharSequence value) {
6391 if (mExtras == null) {
6392 mExtras = new Bundle();
6393 }
6394 mExtras.putCharSequence(name, value);
6395 return this;
6396 }
6397
6398 /**
6399 * Add extended data to the intent. The name must include a package
6400 * prefix, for example the app com.android.contacts would use names
6401 * like "com.android.contacts.ShowAll".
6402 *
6403 * @param name The name of the extra data, with package prefix.
6404 * @param value The Parcelable data value.
6405 *
6406 * @return Returns the same Intent object, for chaining multiple calls
6407 * into a single statement.
6408 *
6409 * @see #putExtras
6410 * @see #removeExtra
6411 * @see #getParcelableExtra(String)
6412 */
6413 public Intent putExtra(String name, Parcelable value) {
6414 if (mExtras == null) {
6415 mExtras = new Bundle();
6416 }
6417 mExtras.putParcelable(name, value);
6418 return this;
6419 }
6420
6421 /**
6422 * Add extended data to the intent. The name must include a package
6423 * prefix, for example the app com.android.contacts would use names
6424 * like "com.android.contacts.ShowAll".
6425 *
6426 * @param name The name of the extra data, with package prefix.
6427 * @param value The Parcelable[] data value.
6428 *
6429 * @return Returns the same Intent object, for chaining multiple calls
6430 * into a single statement.
6431 *
6432 * @see #putExtras
6433 * @see #removeExtra
6434 * @see #getParcelableArrayExtra(String)
6435 */
6436 public Intent putExtra(String name, Parcelable[] value) {
6437 if (mExtras == null) {
6438 mExtras = new Bundle();
6439 }
6440 mExtras.putParcelableArray(name, value);
6441 return this;
6442 }
6443
6444 /**
6445 * Add extended data to the intent. The name must include a package
6446 * prefix, for example the app com.android.contacts would use names
6447 * like "com.android.contacts.ShowAll".
6448 *
6449 * @param name The name of the extra data, with package prefix.
6450 * @param value The ArrayList<Parcelable> data value.
6451 *
6452 * @return Returns the same Intent object, for chaining multiple calls
6453 * into a single statement.
6454 *
6455 * @see #putExtras
6456 * @see #removeExtra
6457 * @see #getParcelableArrayListExtra(String)
6458 */
6459 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6460 if (mExtras == null) {
6461 mExtras = new Bundle();
6462 }
6463 mExtras.putParcelableArrayList(name, value);
6464 return this;
6465 }
6466
6467 /**
6468 * Add extended data to the intent. The name must include a package
6469 * prefix, for example the app com.android.contacts would use names
6470 * like "com.android.contacts.ShowAll".
6471 *
6472 * @param name The name of the extra data, with package prefix.
6473 * @param value The ArrayList<Integer> data value.
6474 *
6475 * @return Returns the same Intent object, for chaining multiple calls
6476 * into a single statement.
6477 *
6478 * @see #putExtras
6479 * @see #removeExtra
6480 * @see #getIntegerArrayListExtra(String)
6481 */
6482 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6483 if (mExtras == null) {
6484 mExtras = new Bundle();
6485 }
6486 mExtras.putIntegerArrayList(name, value);
6487 return this;
6488 }
6489
6490 /**
6491 * Add extended data to the intent. The name must include a package
6492 * prefix, for example the app com.android.contacts would use names
6493 * like "com.android.contacts.ShowAll".
6494 *
6495 * @param name The name of the extra data, with package prefix.
6496 * @param value The ArrayList<String> data value.
6497 *
6498 * @return Returns the same Intent object, for chaining multiple calls
6499 * into a single statement.
6500 *
6501 * @see #putExtras
6502 * @see #removeExtra
6503 * @see #getStringArrayListExtra(String)
6504 */
6505 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6506 if (mExtras == null) {
6507 mExtras = new Bundle();
6508 }
6509 mExtras.putStringArrayList(name, value);
6510 return this;
6511 }
6512
6513 /**
6514 * Add extended data to the intent. The name must include a package
6515 * prefix, for example the app com.android.contacts would use names
6516 * like "com.android.contacts.ShowAll".
6517 *
6518 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006519 * @param value The ArrayList<CharSequence> data value.
6520 *
6521 * @return Returns the same Intent object, for chaining multiple calls
6522 * into a single statement.
6523 *
6524 * @see #putExtras
6525 * @see #removeExtra
6526 * @see #getCharSequenceArrayListExtra(String)
6527 */
6528 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6529 if (mExtras == null) {
6530 mExtras = new Bundle();
6531 }
6532 mExtras.putCharSequenceArrayList(name, value);
6533 return this;
6534 }
6535
6536 /**
6537 * Add extended data to the intent. The name must include a package
6538 * prefix, for example the app com.android.contacts would use names
6539 * like "com.android.contacts.ShowAll".
6540 *
6541 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006542 * @param value The Serializable data value.
6543 *
6544 * @return Returns the same Intent object, for chaining multiple calls
6545 * into a single statement.
6546 *
6547 * @see #putExtras
6548 * @see #removeExtra
6549 * @see #getSerializableExtra(String)
6550 */
6551 public Intent putExtra(String name, Serializable value) {
6552 if (mExtras == null) {
6553 mExtras = new Bundle();
6554 }
6555 mExtras.putSerializable(name, value);
6556 return this;
6557 }
6558
6559 /**
6560 * Add extended data to the intent. The name must include a package
6561 * prefix, for example the app com.android.contacts would use names
6562 * like "com.android.contacts.ShowAll".
6563 *
6564 * @param name The name of the extra data, with package prefix.
6565 * @param value The boolean array data value.
6566 *
6567 * @return Returns the same Intent object, for chaining multiple calls
6568 * into a single statement.
6569 *
6570 * @see #putExtras
6571 * @see #removeExtra
6572 * @see #getBooleanArrayExtra(String)
6573 */
6574 public Intent putExtra(String name, boolean[] value) {
6575 if (mExtras == null) {
6576 mExtras = new Bundle();
6577 }
6578 mExtras.putBooleanArray(name, value);
6579 return this;
6580 }
6581
6582 /**
6583 * Add extended data to the intent. The name must include a package
6584 * prefix, for example the app com.android.contacts would use names
6585 * like "com.android.contacts.ShowAll".
6586 *
6587 * @param name The name of the extra data, with package prefix.
6588 * @param value The byte array data value.
6589 *
6590 * @return Returns the same Intent object, for chaining multiple calls
6591 * into a single statement.
6592 *
6593 * @see #putExtras
6594 * @see #removeExtra
6595 * @see #getByteArrayExtra(String)
6596 */
6597 public Intent putExtra(String name, byte[] value) {
6598 if (mExtras == null) {
6599 mExtras = new Bundle();
6600 }
6601 mExtras.putByteArray(name, value);
6602 return this;
6603 }
6604
6605 /**
6606 * Add extended data to the intent. The name must include a package
6607 * prefix, for example the app com.android.contacts would use names
6608 * like "com.android.contacts.ShowAll".
6609 *
6610 * @param name The name of the extra data, with package prefix.
6611 * @param value The short array data value.
6612 *
6613 * @return Returns the same Intent object, for chaining multiple calls
6614 * into a single statement.
6615 *
6616 * @see #putExtras
6617 * @see #removeExtra
6618 * @see #getShortArrayExtra(String)
6619 */
6620 public Intent putExtra(String name, short[] value) {
6621 if (mExtras == null) {
6622 mExtras = new Bundle();
6623 }
6624 mExtras.putShortArray(name, value);
6625 return this;
6626 }
6627
6628 /**
6629 * Add extended data to the intent. The name must include a package
6630 * prefix, for example the app com.android.contacts would use names
6631 * like "com.android.contacts.ShowAll".
6632 *
6633 * @param name The name of the extra data, with package prefix.
6634 * @param value The char array data value.
6635 *
6636 * @return Returns the same Intent object, for chaining multiple calls
6637 * into a single statement.
6638 *
6639 * @see #putExtras
6640 * @see #removeExtra
6641 * @see #getCharArrayExtra(String)
6642 */
6643 public Intent putExtra(String name, char[] value) {
6644 if (mExtras == null) {
6645 mExtras = new Bundle();
6646 }
6647 mExtras.putCharArray(name, value);
6648 return this;
6649 }
6650
6651 /**
6652 * Add extended data to the intent. The name must include a package
6653 * prefix, for example the app com.android.contacts would use names
6654 * like "com.android.contacts.ShowAll".
6655 *
6656 * @param name The name of the extra data, with package prefix.
6657 * @param value The int array data value.
6658 *
6659 * @return Returns the same Intent object, for chaining multiple calls
6660 * into a single statement.
6661 *
6662 * @see #putExtras
6663 * @see #removeExtra
6664 * @see #getIntArrayExtra(String)
6665 */
6666 public Intent putExtra(String name, int[] value) {
6667 if (mExtras == null) {
6668 mExtras = new Bundle();
6669 }
6670 mExtras.putIntArray(name, value);
6671 return this;
6672 }
6673
6674 /**
6675 * Add extended data to the intent. The name must include a package
6676 * prefix, for example the app com.android.contacts would use names
6677 * like "com.android.contacts.ShowAll".
6678 *
6679 * @param name The name of the extra data, with package prefix.
6680 * @param value The byte array data value.
6681 *
6682 * @return Returns the same Intent object, for chaining multiple calls
6683 * into a single statement.
6684 *
6685 * @see #putExtras
6686 * @see #removeExtra
6687 * @see #getLongArrayExtra(String)
6688 */
6689 public Intent putExtra(String name, long[] value) {
6690 if (mExtras == null) {
6691 mExtras = new Bundle();
6692 }
6693 mExtras.putLongArray(name, value);
6694 return this;
6695 }
6696
6697 /**
6698 * Add extended data to the intent. The name must include a package
6699 * prefix, for example the app com.android.contacts would use names
6700 * like "com.android.contacts.ShowAll".
6701 *
6702 * @param name The name of the extra data, with package prefix.
6703 * @param value The float array data value.
6704 *
6705 * @return Returns the same Intent object, for chaining multiple calls
6706 * into a single statement.
6707 *
6708 * @see #putExtras
6709 * @see #removeExtra
6710 * @see #getFloatArrayExtra(String)
6711 */
6712 public Intent putExtra(String name, float[] value) {
6713 if (mExtras == null) {
6714 mExtras = new Bundle();
6715 }
6716 mExtras.putFloatArray(name, value);
6717 return this;
6718 }
6719
6720 /**
6721 * Add extended data to the intent. The name must include a package
6722 * prefix, for example the app com.android.contacts would use names
6723 * like "com.android.contacts.ShowAll".
6724 *
6725 * @param name The name of the extra data, with package prefix.
6726 * @param value The double array data value.
6727 *
6728 * @return Returns the same Intent object, for chaining multiple calls
6729 * into a single statement.
6730 *
6731 * @see #putExtras
6732 * @see #removeExtra
6733 * @see #getDoubleArrayExtra(String)
6734 */
6735 public Intent putExtra(String name, double[] value) {
6736 if (mExtras == null) {
6737 mExtras = new Bundle();
6738 }
6739 mExtras.putDoubleArray(name, value);
6740 return this;
6741 }
6742
6743 /**
6744 * Add extended data to the intent. The name must include a package
6745 * prefix, for example the app com.android.contacts would use names
6746 * like "com.android.contacts.ShowAll".
6747 *
6748 * @param name The name of the extra data, with package prefix.
6749 * @param value The String array data value.
6750 *
6751 * @return Returns the same Intent object, for chaining multiple calls
6752 * into a single statement.
6753 *
6754 * @see #putExtras
6755 * @see #removeExtra
6756 * @see #getStringArrayExtra(String)
6757 */
6758 public Intent putExtra(String name, String[] value) {
6759 if (mExtras == null) {
6760 mExtras = new Bundle();
6761 }
6762 mExtras.putStringArray(name, value);
6763 return this;
6764 }
6765
6766 /**
6767 * Add extended data to the intent. The name must include a package
6768 * prefix, for example the app com.android.contacts would use names
6769 * like "com.android.contacts.ShowAll".
6770 *
6771 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006772 * @param value The CharSequence array data value.
6773 *
6774 * @return Returns the same Intent object, for chaining multiple calls
6775 * into a single statement.
6776 *
6777 * @see #putExtras
6778 * @see #removeExtra
6779 * @see #getCharSequenceArrayExtra(String)
6780 */
6781 public Intent putExtra(String name, CharSequence[] value) {
6782 if (mExtras == null) {
6783 mExtras = new Bundle();
6784 }
6785 mExtras.putCharSequenceArray(name, value);
6786 return this;
6787 }
6788
6789 /**
6790 * Add extended data to the intent. The name must include a package
6791 * prefix, for example the app com.android.contacts would use names
6792 * like "com.android.contacts.ShowAll".
6793 *
6794 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006795 * @param value The Bundle data value.
6796 *
6797 * @return Returns the same Intent object, for chaining multiple calls
6798 * into a single statement.
6799 *
6800 * @see #putExtras
6801 * @see #removeExtra
6802 * @see #getBundleExtra(String)
6803 */
6804 public Intent putExtra(String name, Bundle value) {
6805 if (mExtras == null) {
6806 mExtras = new Bundle();
6807 }
6808 mExtras.putBundle(name, value);
6809 return this;
6810 }
6811
6812 /**
6813 * Add extended data to the intent. The name must include a package
6814 * prefix, for example the app com.android.contacts would use names
6815 * like "com.android.contacts.ShowAll".
6816 *
6817 * @param name The name of the extra data, with package prefix.
6818 * @param value The IBinder data value.
6819 *
6820 * @return Returns the same Intent object, for chaining multiple calls
6821 * into a single statement.
6822 *
6823 * @see #putExtras
6824 * @see #removeExtra
6825 * @see #getIBinderExtra(String)
6826 *
6827 * @deprecated
6828 * @hide
6829 */
6830 @Deprecated
6831 public Intent putExtra(String name, IBinder value) {
6832 if (mExtras == null) {
6833 mExtras = new Bundle();
6834 }
6835 mExtras.putIBinder(name, value);
6836 return this;
6837 }
6838
6839 /**
6840 * Copy all extras in 'src' in to this intent.
6841 *
6842 * @param src Contains the extras to copy.
6843 *
6844 * @see #putExtra
6845 */
6846 public Intent putExtras(Intent src) {
6847 if (src.mExtras != null) {
6848 if (mExtras == null) {
6849 mExtras = new Bundle(src.mExtras);
6850 } else {
6851 mExtras.putAll(src.mExtras);
6852 }
6853 }
6854 return this;
6855 }
6856
6857 /**
6858 * Add a set of extended data to the intent. The keys must include a package
6859 * prefix, for example the app com.android.contacts would use names
6860 * like "com.android.contacts.ShowAll".
6861 *
6862 * @param extras The Bundle of extras to add to this intent.
6863 *
6864 * @see #putExtra
6865 * @see #removeExtra
6866 */
6867 public Intent putExtras(Bundle extras) {
6868 if (mExtras == null) {
6869 mExtras = new Bundle();
6870 }
6871 mExtras.putAll(extras);
6872 return this;
6873 }
6874
6875 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006876 * Completely replace the extras in the Intent with the extras in the
6877 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006878 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006879 * @param src The exact extras contained in this Intent are copied
6880 * into the target intent, replacing any that were previously there.
6881 */
6882 public Intent replaceExtras(Intent src) {
6883 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6884 return this;
6885 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006886
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006887 /**
6888 * Completely replace the extras in the Intent with the given Bundle of
6889 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006890 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006891 * @param extras The new set of extras in the Intent, or null to erase
6892 * all extras.
6893 */
6894 public Intent replaceExtras(Bundle extras) {
6895 mExtras = extras != null ? new Bundle(extras) : null;
6896 return this;
6897 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006898
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006899 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006900 * Remove extended data from the intent.
6901 *
6902 * @see #putExtra
6903 */
6904 public void removeExtra(String name) {
6905 if (mExtras != null) {
6906 mExtras.remove(name);
6907 if (mExtras.size() == 0) {
6908 mExtras = null;
6909 }
6910 }
6911 }
6912
6913 /**
6914 * Set special flags controlling how this intent is handled. Most values
6915 * here depend on the type of component being executed by the Intent,
6916 * specifically the FLAG_ACTIVITY_* flags are all for use with
6917 * {@link Context#startActivity Context.startActivity()} and the
6918 * FLAG_RECEIVER_* flags are all for use with
6919 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6920 *
Scott Main7aee61f2011-02-08 11:25:01 -08006921 * <p>See the
6922 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6923 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006924 * the behavior of your application.
6925 *
6926 * @param flags The desired flags.
6927 *
6928 * @return Returns the same Intent object, for chaining multiple calls
6929 * into a single statement.
6930 *
6931 * @see #getFlags
6932 * @see #addFlags
6933 *
6934 * @see #FLAG_GRANT_READ_URI_PERMISSION
6935 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006936 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6937 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006938 * @see #FLAG_DEBUG_LOG_RESOLUTION
6939 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006940 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006941 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006942 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006943 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006944 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6945 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006946 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006947 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006948 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006949 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006950 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006951 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006952 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006953 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6954 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006955 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006956 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006957 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006958 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6959 */
6960 public Intent setFlags(int flags) {
6961 mFlags = flags;
6962 return this;
6963 }
6964
6965 /**
6966 * Add additional flags to the intent (or with existing flags
6967 * value).
6968 *
6969 * @param flags The new flags to set.
6970 *
6971 * @return Returns the same Intent object, for chaining multiple calls
6972 * into a single statement.
6973 *
6974 * @see #setFlags
6975 */
6976 public Intent addFlags(int flags) {
6977 mFlags |= flags;
6978 return this;
6979 }
6980
6981 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006982 * (Usually optional) Set an explicit application package name that limits
6983 * the components this Intent will resolve to. If left to the default
6984 * value of null, all components in all applications will considered.
6985 * If non-null, the Intent can only match the components in the given
6986 * application package.
6987 *
6988 * @param packageName The name of the application package to handle the
6989 * intent, or null to allow any application package.
6990 *
6991 * @return Returns the same Intent object, for chaining multiple calls
6992 * into a single statement.
6993 *
6994 * @see #getPackage
6995 * @see #resolveActivity
6996 */
6997 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006998 if (packageName != null && mSelector != null) {
6999 throw new IllegalArgumentException(
7000 "Can't set package name when selector is already set");
7001 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007002 mPackage = packageName;
7003 return this;
7004 }
7005
7006 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007007 * (Usually optional) Explicitly set the component to handle the intent.
7008 * If left with the default value of null, the system will determine the
7009 * appropriate class to use based on the other fields (action, data,
7010 * type, categories) in the Intent. If this class is defined, the
7011 * specified class will always be used regardless of the other fields. You
7012 * should only set this value when you know you absolutely want a specific
7013 * class to be used; otherwise it is better to let the system find the
7014 * appropriate class so that you will respect the installed applications
7015 * and user preferences.
7016 *
7017 * @param component The name of the application component to handle the
7018 * intent, or null to let the system find one for you.
7019 *
7020 * @return Returns the same Intent object, for chaining multiple calls
7021 * into a single statement.
7022 *
7023 * @see #setClass
7024 * @see #setClassName(Context, String)
7025 * @see #setClassName(String, String)
7026 * @see #getComponent
7027 * @see #resolveActivity
7028 */
7029 public Intent setComponent(ComponentName component) {
7030 mComponent = component;
7031 return this;
7032 }
7033
7034 /**
7035 * Convenience for calling {@link #setComponent} with an
7036 * explicit class name.
7037 *
7038 * @param packageContext A Context of the application package implementing
7039 * this class.
7040 * @param className The name of a class inside of the application package
7041 * that will be used as the component for this Intent.
7042 *
7043 * @return Returns the same Intent object, for chaining multiple calls
7044 * into a single statement.
7045 *
7046 * @see #setComponent
7047 * @see #setClass
7048 */
7049 public Intent setClassName(Context packageContext, String className) {
7050 mComponent = new ComponentName(packageContext, className);
7051 return this;
7052 }
7053
7054 /**
7055 * Convenience for calling {@link #setComponent} with an
7056 * explicit application package name and class name.
7057 *
7058 * @param packageName The name of the package implementing the desired
7059 * component.
7060 * @param className The name of a class inside of the application package
7061 * that will be used as the component for this Intent.
7062 *
7063 * @return Returns the same Intent object, for chaining multiple calls
7064 * into a single statement.
7065 *
7066 * @see #setComponent
7067 * @see #setClass
7068 */
7069 public Intent setClassName(String packageName, String className) {
7070 mComponent = new ComponentName(packageName, className);
7071 return this;
7072 }
7073
7074 /**
7075 * Convenience for calling {@link #setComponent(ComponentName)} with the
7076 * name returned by a {@link Class} object.
7077 *
7078 * @param packageContext A Context of the application package implementing
7079 * this class.
7080 * @param cls The class name to set, equivalent to
7081 * <code>setClassName(context, cls.getName())</code>.
7082 *
7083 * @return Returns the same Intent object, for chaining multiple calls
7084 * into a single statement.
7085 *
7086 * @see #setComponent
7087 */
7088 public Intent setClass(Context packageContext, Class<?> cls) {
7089 mComponent = new ComponentName(packageContext, cls);
7090 return this;
7091 }
7092
7093 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007094 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7095 * used as a hint to the receiver for animations and the like. Null means that there
7096 * is no source bounds.
7097 */
7098 public void setSourceBounds(Rect r) {
7099 if (r != null) {
7100 mSourceBounds = new Rect(r);
7101 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007102 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007103 }
7104 }
7105
Tor Norbyed9273d62013-05-30 15:59:53 -07007106 /** @hide */
7107 @IntDef(flag = true,
7108 value = {
7109 FILL_IN_ACTION,
7110 FILL_IN_DATA,
7111 FILL_IN_CATEGORIES,
7112 FILL_IN_COMPONENT,
7113 FILL_IN_PACKAGE,
7114 FILL_IN_SOURCE_BOUNDS,
7115 FILL_IN_SELECTOR,
7116 FILL_IN_CLIP_DATA
7117 })
7118 @Retention(RetentionPolicy.SOURCE)
7119 public @interface FillInFlags {}
7120
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007121 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007122 * Use with {@link #fillIn} to allow the current action value to be
7123 * overwritten, even if it is already set.
7124 */
7125 public static final int FILL_IN_ACTION = 1<<0;
7126
7127 /**
7128 * Use with {@link #fillIn} to allow the current data or type value
7129 * overwritten, even if it is already set.
7130 */
7131 public static final int FILL_IN_DATA = 1<<1;
7132
7133 /**
7134 * Use with {@link #fillIn} to allow the current categories to be
7135 * overwritten, even if they are already set.
7136 */
7137 public static final int FILL_IN_CATEGORIES = 1<<2;
7138
7139 /**
7140 * Use with {@link #fillIn} to allow the current component value to be
7141 * overwritten, even if it is already set.
7142 */
7143 public static final int FILL_IN_COMPONENT = 1<<3;
7144
7145 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007146 * Use with {@link #fillIn} to allow the current package value to be
7147 * overwritten, even if it is already set.
7148 */
7149 public static final int FILL_IN_PACKAGE = 1<<4;
7150
7151 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007152 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007153 * overwritten, even if it is already set.
7154 */
7155 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7156
7157 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007158 * Use with {@link #fillIn} to allow the current selector to be
7159 * overwritten, even if it is already set.
7160 */
7161 public static final int FILL_IN_SELECTOR = 1<<6;
7162
7163 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007164 * Use with {@link #fillIn} to allow the current ClipData to be
7165 * overwritten, even if it is already set.
7166 */
7167 public static final int FILL_IN_CLIP_DATA = 1<<7;
7168
7169 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007170 * Copy the contents of <var>other</var> in to this object, but only
7171 * where fields are not defined by this object. For purposes of a field
7172 * being defined, the following pieces of data in the Intent are
7173 * considered to be separate fields:
7174 *
7175 * <ul>
7176 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007177 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007178 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7179 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007180 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007181 * <li> component, as set by {@link #setComponent(ComponentName)} or
7182 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007183 * <li> source bounds, as set by {@link #setSourceBounds}.
7184 * <li> selector, as set by {@link #setSelector(Intent)}.
7185 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007186 * <li> each top-level name in the associated extras.
7187 * </ul>
7188 *
7189 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007190 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007191 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7192 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7193 * the restriction where the corresponding field will not be replaced if
7194 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007195 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007196 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7197 * is explicitly specified. The selector will only be copied if
7198 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007199 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007200 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7201 * and Intent B with {action="gotit", data-type="some/thing",
7202 * categories="one","two"}.
7203 *
7204 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7205 * containing: {action="gotit", data-type="some/thing",
7206 * categories="bar"}.
7207 *
7208 * @param other Another Intent whose values are to be used to fill in
7209 * the current one.
7210 * @param flags Options to control which fields can be filled in.
7211 *
7212 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007213 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007214 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7215 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7216 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007217 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007218 @FillInFlags
7219 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007220 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007221 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007222 if (other.mAction != null
7223 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007224 mAction = other.mAction;
7225 changes |= FILL_IN_ACTION;
7226 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007227 if ((other.mData != null || other.mType != null)
7228 && ((mData == null && mType == null)
7229 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007230 mData = other.mData;
7231 mType = other.mType;
7232 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007233 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007234 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007235 if (other.mCategories != null
7236 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007237 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007238 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007239 }
7240 changes |= FILL_IN_CATEGORIES;
7241 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007242 if (other.mPackage != null
7243 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007244 // Only do this if mSelector is not set.
7245 if (mSelector == null) {
7246 mPackage = other.mPackage;
7247 changes |= FILL_IN_PACKAGE;
7248 }
7249 }
7250 // Selector is special: it can only be set if explicitly allowed,
7251 // for the same reason as the component name.
7252 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7253 if (mPackage == null) {
7254 mSelector = new Intent(other.mSelector);
7255 mPackage = null;
7256 changes |= FILL_IN_SELECTOR;
7257 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007258 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007259 if (other.mClipData != null
7260 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7261 mClipData = other.mClipData;
7262 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007263 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007264 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007265 // Component is special: it can -only- be set if explicitly allowed,
7266 // since otherwise the sender could force the intent somewhere the
7267 // originator didn't intend.
7268 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007269 mComponent = other.mComponent;
7270 changes |= FILL_IN_COMPONENT;
7271 }
7272 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007273 if (other.mSourceBounds != null
7274 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7275 mSourceBounds = new Rect(other.mSourceBounds);
7276 changes |= FILL_IN_SOURCE_BOUNDS;
7277 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007278 if (mExtras == null) {
7279 if (other.mExtras != null) {
7280 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007281 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007282 }
7283 } else if (other.mExtras != null) {
7284 try {
7285 Bundle newb = new Bundle(other.mExtras);
7286 newb.putAll(mExtras);
7287 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007288 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007289 } catch (RuntimeException e) {
7290 // Modifying the extras can cause us to unparcel the contents
7291 // of the bundle, and if we do this in the system process that
7292 // may fail. We really should handle this (i.e., the Bundle
7293 // impl shouldn't be on top of a plain map), but for now just
7294 // ignore it and keep the original contents. :(
7295 Log.w("Intent", "Failure filling in extras", e);
7296 }
7297 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007298 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7299 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7300 mContentUserHint = other.mContentUserHint;
7301 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007302 return changes;
7303 }
7304
7305 /**
7306 * Wrapper class holding an Intent and implementing comparisons on it for
7307 * the purpose of filtering. The class implements its
7308 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7309 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7310 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7311 * on the wrapped Intent.
7312 */
7313 public static final class FilterComparison {
7314 private final Intent mIntent;
7315 private final int mHashCode;
7316
7317 public FilterComparison(Intent intent) {
7318 mIntent = intent;
7319 mHashCode = intent.filterHashCode();
7320 }
7321
7322 /**
7323 * Return the Intent that this FilterComparison represents.
7324 * @return Returns the Intent held by the FilterComparison. Do
7325 * not modify!
7326 */
7327 public Intent getIntent() {
7328 return mIntent;
7329 }
7330
7331 @Override
7332 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007333 if (obj instanceof FilterComparison) {
7334 Intent other = ((FilterComparison)obj).mIntent;
7335 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007336 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007337 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007338 }
7339
7340 @Override
7341 public int hashCode() {
7342 return mHashCode;
7343 }
7344 }
7345
7346 /**
7347 * Determine if two intents are the same for the purposes of intent
7348 * resolution (filtering). That is, if their action, data, type,
7349 * class, and categories are the same. This does <em>not</em> compare
7350 * any extra data included in the intents.
7351 *
7352 * @param other The other Intent to compare against.
7353 *
7354 * @return Returns true if action, data, type, class, and categories
7355 * are the same.
7356 */
7357 public boolean filterEquals(Intent other) {
7358 if (other == null) {
7359 return false;
7360 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007361 if (!Objects.equals(this.mAction, other.mAction)) return false;
7362 if (!Objects.equals(this.mData, other.mData)) return false;
7363 if (!Objects.equals(this.mType, other.mType)) return false;
7364 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7365 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7366 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007367
7368 return true;
7369 }
7370
7371 /**
7372 * Generate hash code that matches semantics of filterEquals().
7373 *
7374 * @return Returns the hash value of the action, data, type, class, and
7375 * categories.
7376 *
7377 * @see #filterEquals
7378 */
7379 public int filterHashCode() {
7380 int code = 0;
7381 if (mAction != null) {
7382 code += mAction.hashCode();
7383 }
7384 if (mData != null) {
7385 code += mData.hashCode();
7386 }
7387 if (mType != null) {
7388 code += mType.hashCode();
7389 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007390 if (mPackage != null) {
7391 code += mPackage.hashCode();
7392 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007393 if (mComponent != null) {
7394 code += mComponent.hashCode();
7395 }
7396 if (mCategories != null) {
7397 code += mCategories.hashCode();
7398 }
7399 return code;
7400 }
7401
7402 @Override
7403 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007404 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007405
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007406 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007407 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007408 b.append(" }");
7409
7410 return b.toString();
7411 }
7412
7413 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007414 public String toInsecureString() {
7415 StringBuilder b = new StringBuilder(128);
7416
7417 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007418 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007419 b.append(" }");
7420
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007421 return b.toString();
7422 }
Romain Guy4969af72009-06-17 10:53:19 -07007423
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007424 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007425 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007426 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007427
7428 b.append("Intent { ");
7429 toShortString(b, false, true, true, true);
7430 b.append(" }");
7431
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007432 return b.toString();
7433 }
7434
7435 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007436 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7437 StringBuilder b = new StringBuilder(128);
7438 toShortString(b, secure, comp, extras, clip);
7439 return b.toString();
7440 }
7441
7442 /** @hide */
7443 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7444 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007445 boolean first = true;
7446 if (mAction != null) {
7447 b.append("act=").append(mAction);
7448 first = false;
7449 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007450 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007451 if (!first) {
7452 b.append(' ');
7453 }
7454 first = false;
7455 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007456 for (int i=0; i<mCategories.size(); i++) {
7457 if (i > 0) b.append(',');
7458 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007459 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007460 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007461 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007462 if (mData != null) {
7463 if (!first) {
7464 b.append(' ');
7465 }
7466 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007467 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007468 if (secure) {
7469 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007470 } else {
7471 b.append(mData);
7472 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007473 }
7474 if (mType != null) {
7475 if (!first) {
7476 b.append(' ');
7477 }
7478 first = false;
7479 b.append("typ=").append(mType);
7480 }
7481 if (mFlags != 0) {
7482 if (!first) {
7483 b.append(' ');
7484 }
7485 first = false;
7486 b.append("flg=0x").append(Integer.toHexString(mFlags));
7487 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007488 if (mPackage != null) {
7489 if (!first) {
7490 b.append(' ');
7491 }
7492 first = false;
7493 b.append("pkg=").append(mPackage);
7494 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007495 if (comp && mComponent != null) {
7496 if (!first) {
7497 b.append(' ');
7498 }
7499 first = false;
7500 b.append("cmp=").append(mComponent.flattenToShortString());
7501 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007502 if (mSourceBounds != null) {
7503 if (!first) {
7504 b.append(' ');
7505 }
7506 first = false;
7507 b.append("bnds=").append(mSourceBounds.toShortString());
7508 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007509 if (mClipData != null) {
7510 if (!first) {
7511 b.append(' ');
7512 }
7513 first = false;
7514 if (clip) {
7515 b.append("clip={");
7516 mClipData.toShortString(b);
7517 b.append('}');
7518 } else {
7519 b.append("(has clip)");
7520 }
7521 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007522 if (extras && mExtras != null) {
7523 if (!first) {
7524 b.append(' ');
7525 }
7526 first = false;
7527 b.append("(has extras)");
7528 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007529 if (mContentUserHint != UserHandle.USER_CURRENT) {
7530 if (!first) {
7531 b.append(' ');
7532 }
7533 first = false;
7534 b.append("u=").append(mContentUserHint);
7535 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007536 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007537 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007538 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007539 b.append("}");
7540 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007541 }
7542
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007543 /**
7544 * Call {@link #toUri} with 0 flags.
7545 * @deprecated Use {@link #toUri} instead.
7546 */
7547 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007548 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007549 return toUri(0);
7550 }
7551
7552 /**
7553 * Convert this Intent into a String holding a URI representation of it.
7554 * The returned URI string has been properly URI encoded, so it can be
7555 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7556 * Intent's data as the base URI, with an additional fragment describing
7557 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007558 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007559 * <p>You can convert the returned string back to an Intent with
7560 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007561 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007562 * @param flags Additional operating flags. Either 0,
7563 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007564 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007565 * @return Returns a URI encoding URI string describing the entire contents
7566 * of the Intent.
7567 */
7568 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007569 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007570 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7571 if (mPackage == null) {
7572 throw new IllegalArgumentException(
7573 "Intent must include an explicit package name to build an android-app: "
7574 + this);
7575 }
7576 uri.append("android-app://");
7577 uri.append(mPackage);
7578 String scheme = null;
7579 if (mData != null) {
7580 scheme = mData.getScheme();
7581 if (scheme != null) {
7582 uri.append('/');
7583 uri.append(scheme);
7584 String authority = mData.getEncodedAuthority();
7585 if (authority != null) {
7586 uri.append('/');
7587 uri.append(authority);
7588 String path = mData.getEncodedPath();
7589 if (path != null) {
7590 uri.append(path);
7591 }
7592 String queryParams = mData.getEncodedQuery();
7593 if (queryParams != null) {
7594 uri.append('?');
7595 uri.append(queryParams);
7596 }
7597 String fragment = mData.getEncodedFragment();
7598 if (fragment != null) {
7599 uri.append('#');
7600 uri.append(fragment);
7601 }
7602 }
7603 }
7604 }
7605 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7606 mPackage, flags);
7607 return uri.toString();
7608 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007609 String scheme = null;
7610 if (mData != null) {
7611 String data = mData.toString();
7612 if ((flags&URI_INTENT_SCHEME) != 0) {
7613 final int N = data.length();
7614 for (int i=0; i<N; i++) {
7615 char c = data.charAt(i);
7616 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7617 || c == '.' || c == '-') {
7618 continue;
7619 }
7620 if (c == ':' && i > 0) {
7621 // Valid scheme.
7622 scheme = data.substring(0, i);
7623 uri.append("intent:");
7624 data = data.substring(i+1);
7625 break;
7626 }
Tom Taylord4a47292009-12-21 13:59:18 -08007627
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007628 // No scheme.
7629 break;
7630 }
7631 }
7632 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007633
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007634 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7635 uri.append("intent:");
7636 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007637
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007638 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007639
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007640 return uri.toString();
7641 }
7642
7643 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7644 String defPackage, int flags) {
7645 StringBuilder frag = new StringBuilder(128);
7646
7647 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007648 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007649 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007650 // Note that for now we are not going to try to handle the
7651 // data part; not clear how to represent this as a URI, and
7652 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007653 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7654 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007655 }
7656
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007657 if (frag.length() > 0) {
7658 uri.append("#Intent;");
7659 uri.append(frag);
7660 uri.append("end");
7661 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007662 }
7663
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007664 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7665 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007666 if (scheme != null) {
7667 uri.append("scheme=").append(scheme).append(';');
7668 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007669 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007670 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007671 }
7672 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007673 for (int i=0; i<mCategories.size(); i++) {
7674 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007675 }
7676 }
7677 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007678 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007679 }
7680 if (mFlags != 0) {
7681 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7682 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007683 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007684 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7685 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007686 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007687 uri.append("component=").append(Uri.encode(
7688 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007689 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007690 if (mSourceBounds != null) {
7691 uri.append("sourceBounds=")
7692 .append(Uri.encode(mSourceBounds.flattenToString()))
7693 .append(';');
7694 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007695 if (mExtras != null) {
7696 for (String key : mExtras.keySet()) {
7697 final Object value = mExtras.get(key);
7698 char entryType =
7699 value instanceof String ? 'S' :
7700 value instanceof Boolean ? 'B' :
7701 value instanceof Byte ? 'b' :
7702 value instanceof Character ? 'c' :
7703 value instanceof Double ? 'd' :
7704 value instanceof Float ? 'f' :
7705 value instanceof Integer ? 'i' :
7706 value instanceof Long ? 'l' :
7707 value instanceof Short ? 's' :
7708 '\0';
7709
7710 if (entryType != '\0') {
7711 uri.append(entryType);
7712 uri.append('.');
7713 uri.append(Uri.encode(key));
7714 uri.append('=');
7715 uri.append(Uri.encode(value.toString()));
7716 uri.append(';');
7717 }
7718 }
7719 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007720 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007721
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007722 public int describeContents() {
7723 return (mExtras != null) ? mExtras.describeContents() : 0;
7724 }
7725
7726 public void writeToParcel(Parcel out, int flags) {
7727 out.writeString(mAction);
7728 Uri.writeToParcel(out, mData);
7729 out.writeString(mType);
7730 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007731 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007732 ComponentName.writeToParcel(mComponent, out);
7733
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007734 if (mSourceBounds != null) {
7735 out.writeInt(1);
7736 mSourceBounds.writeToParcel(out, flags);
7737 } else {
7738 out.writeInt(0);
7739 }
7740
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007741 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007742 final int N = mCategories.size();
7743 out.writeInt(N);
7744 for (int i=0; i<N; i++) {
7745 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007746 }
7747 } else {
7748 out.writeInt(0);
7749 }
7750
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007751 if (mSelector != null) {
7752 out.writeInt(1);
7753 mSelector.writeToParcel(out, flags);
7754 } else {
7755 out.writeInt(0);
7756 }
7757
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007758 if (mClipData != null) {
7759 out.writeInt(1);
7760 mClipData.writeToParcel(out, flags);
7761 } else {
7762 out.writeInt(0);
7763 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007764 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007765 out.writeBundle(mExtras);
7766 }
7767
7768 public static final Parcelable.Creator<Intent> CREATOR
7769 = new Parcelable.Creator<Intent>() {
7770 public Intent createFromParcel(Parcel in) {
7771 return new Intent(in);
7772 }
7773 public Intent[] newArray(int size) {
7774 return new Intent[size];
7775 }
7776 };
7777
Dianne Hackborneb034652009-09-07 00:49:58 -07007778 /** @hide */
7779 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007780 readFromParcel(in);
7781 }
7782
7783 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007784 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007785 mData = Uri.CREATOR.createFromParcel(in);
7786 mType = in.readString();
7787 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007788 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007789 mComponent = ComponentName.readFromParcel(in);
7790
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007791 if (in.readInt() != 0) {
7792 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7793 }
7794
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 int N = in.readInt();
7796 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007797 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007798 int i;
7799 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007800 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007801 }
7802 } else {
7803 mCategories = null;
7804 }
7805
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007806 if (in.readInt() != 0) {
7807 mSelector = new Intent(in);
7808 }
7809
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007810 if (in.readInt() != 0) {
7811 mClipData = new ClipData(in);
7812 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007813 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007814 mExtras = in.readBundle();
7815 }
7816
7817 /**
7818 * Parses the "intent" element (and its children) from XML and instantiates
7819 * an Intent object. The given XML parser should be located at the tag
7820 * where parsing should start (often named "intent"), from which the
7821 * basic action, data, type, and package and class name will be
7822 * retrieved. The function will then parse in to any child elements,
7823 * looking for <category android:name="xxx"> tags to add categories and
7824 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7825 * to the intent.
7826 *
7827 * @param resources The Resources to use when inflating resources.
7828 * @param parser The XML parser pointing at an "intent" tag.
7829 * @param attrs The AttributeSet interface for retrieving extended
7830 * attribute data at the current <var>parser</var> location.
7831 * @return An Intent object matching the XML data.
7832 * @throws XmlPullParserException If there was an XML parsing error.
7833 * @throws IOException If there was an I/O error.
7834 */
7835 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7836 throws XmlPullParserException, IOException {
7837 Intent intent = new Intent();
7838
7839 TypedArray sa = resources.obtainAttributes(attrs,
7840 com.android.internal.R.styleable.Intent);
7841
7842 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7843
7844 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7845 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7846 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7847
7848 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7849 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7850 if (packageName != null && className != null) {
7851 intent.setComponent(new ComponentName(packageName, className));
7852 }
7853
7854 sa.recycle();
7855
7856 int outerDepth = parser.getDepth();
7857 int type;
7858 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7859 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7860 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7861 continue;
7862 }
7863
7864 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007865 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007866 sa = resources.obtainAttributes(attrs,
7867 com.android.internal.R.styleable.IntentCategory);
7868 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7869 sa.recycle();
7870
7871 if (cat != null) {
7872 intent.addCategory(cat);
7873 }
7874 XmlUtils.skipCurrentTag(parser);
7875
Craig Mautner21d24a22014-04-23 11:45:37 -07007876 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007877 if (intent.mExtras == null) {
7878 intent.mExtras = new Bundle();
7879 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007880 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007881 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007882
7883 } else {
7884 XmlUtils.skipCurrentTag(parser);
7885 }
7886 }
7887
7888 return intent;
7889 }
Nick Pellyccae4122012-01-09 14:12:58 -08007890
Craig Mautner21d24a22014-04-23 11:45:37 -07007891 /** @hide */
7892 public void saveToXml(XmlSerializer out) throws IOException {
7893 if (mAction != null) {
7894 out.attribute(null, ATTR_ACTION, mAction);
7895 }
7896 if (mData != null) {
7897 out.attribute(null, ATTR_DATA, mData.toString());
7898 }
7899 if (mType != null) {
7900 out.attribute(null, ATTR_TYPE, mType);
7901 }
7902 if (mComponent != null) {
7903 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7904 }
7905 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7906
7907 if (mCategories != null) {
7908 out.startTag(null, TAG_CATEGORIES);
7909 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7910 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7911 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007912 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007913 }
7914 }
7915
7916 /** @hide */
7917 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7918 XmlPullParserException {
7919 Intent intent = new Intent();
7920 final int outerDepth = in.getDepth();
7921
7922 int attrCount = in.getAttributeCount();
7923 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7924 final String attrName = in.getAttributeName(attrNdx);
7925 final String attrValue = in.getAttributeValue(attrNdx);
7926 if (ATTR_ACTION.equals(attrName)) {
7927 intent.setAction(attrValue);
7928 } else if (ATTR_DATA.equals(attrName)) {
7929 intent.setData(Uri.parse(attrValue));
7930 } else if (ATTR_TYPE.equals(attrName)) {
7931 intent.setType(attrValue);
7932 } else if (ATTR_COMPONENT.equals(attrName)) {
7933 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7934 } else if (ATTR_FLAGS.equals(attrName)) {
7935 intent.setFlags(Integer.valueOf(attrValue, 16));
7936 } else {
7937 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7938 }
7939 }
7940
7941 int event;
7942 String name;
7943 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7944 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7945 if (event == XmlPullParser.START_TAG) {
7946 name = in.getName();
7947 if (TAG_CATEGORIES.equals(name)) {
7948 attrCount = in.getAttributeCount();
7949 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7950 intent.addCategory(in.getAttributeValue(attrNdx));
7951 }
7952 } else {
7953 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7954 XmlUtils.skipCurrentTag(in);
7955 }
7956 }
7957 }
7958
7959 return intent;
7960 }
7961
Nick Pellyccae4122012-01-09 14:12:58 -08007962 /**
7963 * Normalize a MIME data type.
7964 *
7965 * <p>A normalized MIME type has white-space trimmed,
7966 * content-type parameters removed, and is lower-case.
7967 * This aligns the type with Android best practices for
7968 * intent filtering.
7969 *
7970 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7971 * "text/x-vCard" becomes "text/x-vcard".
7972 *
7973 * <p>All MIME types received from outside Android (such as user input,
7974 * or external sources like Bluetooth, NFC, or the Internet) should
7975 * be normalized before they are used to create an Intent.
7976 *
7977 * @param type MIME data type to normalize
7978 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007979 * @see #setType
7980 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007981 */
7982 public static String normalizeMimeType(String type) {
7983 if (type == null) {
7984 return null;
7985 }
7986
Elliott Hughescb64d432013-08-02 10:00:44 -07007987 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007988
7989 final int semicolonIndex = type.indexOf(';');
7990 if (semicolonIndex != -1) {
7991 type = type.substring(0, semicolonIndex);
7992 }
7993 return type;
7994 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007995
7996 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007997 * Prepare this {@link Intent} to leave an app process.
7998 *
7999 * @hide
8000 */
8001 public void prepareToLeaveProcess() {
8002 setAllowFds(false);
8003
8004 if (mSelector != null) {
8005 mSelector.prepareToLeaveProcess();
8006 }
8007 if (mClipData != null) {
8008 mClipData.prepareToLeaveProcess();
8009 }
8010
8011 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8012 // There are several ACTION_MEDIA_* broadcasts that send file://
8013 // Uris, so only check common actions.
8014 if (ACTION_VIEW.equals(mAction) ||
8015 ACTION_EDIT.equals(mAction) ||
8016 ACTION_ATTACH_DATA.equals(mAction)) {
8017 mData.checkFileUriExposed("Intent.getData()");
8018 }
8019 }
8020 }
8021
8022 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008023 * @hide
8024 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008025 public void prepareToEnterProcess() {
8026 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008027 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8028 fixUris(mContentUserHint);
8029 mContentUserHint = UserHandle.USER_CURRENT;
8030 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008031 }
8032 }
8033
8034 /**
8035 * @hide
8036 */
8037 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008038 Uri data = getData();
8039 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008040 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008041 }
8042 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008043 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008044 }
8045 String action = getAction();
8046 if (ACTION_SEND.equals(action)) {
8047 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8048 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008049 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008050 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008051 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008052 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8053 if (streams != null) {
8054 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8055 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008056 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008057 }
8058 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8059 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008060 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8061 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8062 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8063 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8064 if (output != null) {
8065 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8066 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008067 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008068 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008069
8070 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008071 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008072 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8073 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008074 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008075 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008076 * @hide
8077 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008078 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008079 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008080 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008081
8082 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008083 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008084
8085 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008086 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008087 // Inspect contained intents to see if we need to migrate extras. We
8088 // don't promote ClipData to the parent, since ChooserActivity will
8089 // already start the picked item as the caller, and we can't combine
8090 // the flags in a safe way.
8091
8092 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008093 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008094 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8095 if (intent != null) {
8096 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008097 }
8098 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008099 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008100 try {
8101 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8102 if (intents != null) {
8103 for (int i = 0; i < intents.length; i++) {
8104 final Intent intent = (Intent) intents[i];
8105 if (intent != null) {
8106 migrated |= intent.migrateExtraStreamToClipData();
8107 }
8108 }
8109 }
8110 } catch (ClassCastException e) {
8111 }
8112 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008113
8114 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008115 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008116 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8117 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8118 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8119 if (stream != null || text != null || htmlText != null) {
8120 final ClipData clipData = new ClipData(
8121 null, new String[] { getType() },
8122 new ClipData.Item(text, htmlText, null, stream));
8123 setClipData(clipData);
8124 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008125 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008126 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008127 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008128 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008129
8130 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008131 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008132 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8133 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8134 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8135 int num = -1;
8136 if (streams != null) {
8137 num = streams.size();
8138 }
8139 if (texts != null) {
8140 if (num >= 0 && num != texts.size()) {
8141 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008142 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008143 }
8144 num = texts.size();
8145 }
8146 if (htmlTexts != null) {
8147 if (num >= 0 && num != htmlTexts.size()) {
8148 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008149 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008150 }
8151 num = htmlTexts.size();
8152 }
8153 if (num > 0) {
8154 final ClipData clipData = new ClipData(
8155 null, new String[] { getType() },
8156 makeClipItem(streams, texts, htmlTexts, 0));
8157
8158 for (int i = 1; i < num; i++) {
8159 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8160 }
8161
8162 setClipData(clipData);
8163 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008164 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008165 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008166 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008167 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008168 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8169 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8170 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8171 final Uri output;
8172 try {
8173 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8174 } catch (ClassCastException e) {
8175 return false;
8176 }
8177 if (output != null) {
8178 setClipData(ClipData.newRawUri("", output));
8179 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8180 return true;
8181 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008182 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008183
8184 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008185 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008186
8187 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8188 ArrayList<String> htmlTexts, int which) {
8189 Uri uri = streams != null ? streams.get(which) : null;
8190 CharSequence text = texts != null ? texts.get(which) : null;
8191 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8192 return new ClipData.Item(text, htmlText, null, uri);
8193 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008194
8195 /** @hide */
8196 public boolean isDocument() {
8197 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8198 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008199}