blob: d0298cdc7ff929f330e3d04cdc9d8099b74e68e5 [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 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001277 * Activity Action: List all available applications
1278 * <p>Input: Nothing.
1279 * <p>Output: nothing.
1280 */
1281 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1282 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1283 /**
1284 * Activity Action: Show settings for choosing wallpaper
1285 * <p>Input: Nothing.
1286 * <p>Output: Nothing.
1287 */
1288 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1289 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1290
1291 /**
1292 * Activity Action: Show activity for reporting a bug.
1293 * <p>Input: Nothing.
1294 * <p>Output: Nothing.
1295 */
1296 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1297 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1298
1299 /**
1300 * Activity Action: Main entry point for factory tests. Only used when
1301 * the device is booting in factory test node. The implementing package
1302 * must be installed in the system image.
1303 * <p>Input: nothing
1304 * <p>Output: nothing
1305 */
1306 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1307
1308 /**
1309 * Activity Action: The user pressed the "call" button to go to the dialer
1310 * or other appropriate UI for placing a call.
1311 * <p>Input: Nothing.
1312 * <p>Output: Nothing.
1313 */
1314 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1315 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1316
1317 /**
1318 * Activity Action: Start Voice Command.
1319 * <p>Input: Nothing.
1320 * <p>Output: Nothing.
1321 */
1322 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1323 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001324
1325 /**
1326 * Activity Action: Start action associated with long pressing on the
1327 * search key.
1328 * <p>Input: Nothing.
1329 * <p>Output: Nothing.
1330 */
1331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1332 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001333
Jacek Surazski86b6c532009-05-13 14:38:28 +02001334 /**
1335 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1336 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001337 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001338 * <p>Input: No data is specified. The bug report is passed in using
1339 * an {@link #EXTRA_BUG_REPORT} field.
1340 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001341 *
1342 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001343 */
1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001346
1347 /**
1348 * Activity Action: Show power usage information to the user.
1349 * <p>Input: Nothing.
1350 * <p>Output: Nothing.
1351 */
1352 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1353 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001354
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001355 /**
1356 * Activity Action: Setup wizard to launch after a platform update. This
1357 * activity should have a string meta-data field associated with it,
1358 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1359 * the platform for setup. The activity will be launched only if
1360 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1361 * same value.
1362 * <p>Input: Nothing.
1363 * <p>Output: Nothing.
1364 * @hide
1365 */
1366 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1367 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001368
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001369 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001370 * Activity Action: Show settings for managing network data usage of a
1371 * specific application. Applications should define an activity that offers
1372 * options to control data usage.
1373 */
1374 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1375 public static final String ACTION_MANAGE_NETWORK_USAGE =
1376 "android.intent.action.MANAGE_NETWORK_USAGE";
1377
1378 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001379 * Activity Action: Launch application installer.
1380 * <p>
1381 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001382 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1383 * you can also use "package:<package-name>" to install an application for the
1384 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001385 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1386 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1387 * <p>
1388 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1389 * succeeded.
1390 *
1391 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1392 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1393 * @see #EXTRA_RETURN_RESULT
1394 */
1395 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1396 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1397
1398 /**
1399 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1400 * package. Specifies the installer package name; this package will receive the
1401 * {@link #ACTION_APP_ERROR} intent.
1402 */
1403 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1404 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1405
1406 /**
1407 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1408 * package. Specifies that the application being installed should not be
1409 * treated as coming from an unknown source, but as coming from the app
1410 * invoking the Intent. For this to work you must start the installer with
1411 * startActivityForResult().
1412 */
1413 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1414 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1415
1416 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001417 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1418 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001419 * data field originated from.
1420 */
rich cannings706e8ba2012-08-20 13:20:14 -07001421 public static final String EXTRA_ORIGINATING_URI
1422 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001423
1424 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001425 * This extra can be used with any Intent used to launch an activity, supplying information
1426 * about who is launching that activity. This field contains a {@link android.net.Uri}
1427 * object, typically an http: or https: URI of the web site that the referral came from;
1428 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1429 * a native application that it came from.
1430 *
1431 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1432 * instead of directly retrieving the extra. It is also valid for applications to
1433 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1434 * a string, not a Uri; the field here, if supplied, will always take precedence,
1435 * however.</p>
1436 *
1437 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001438 */
1439 public static final String EXTRA_REFERRER
1440 = "android.intent.extra.REFERRER";
1441
1442 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001443 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1444 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1445 * not be created, in particular when Intent extras are supplied through the
1446 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1447 * schemes.
1448 *
1449 * @see #EXTRA_REFERRER
1450 */
1451 public static final String EXTRA_REFERRER_NAME
1452 = "android.intent.extra.REFERRER_NAME";
1453
1454 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001455 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1456 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1457 * @hide
1458 */
1459 public static final String EXTRA_ORIGINATING_UID
1460 = "android.intent.extra.ORIGINATING_UID";
1461
1462 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001463 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1464 * package. Tells the installer UI to skip the confirmation with the user
1465 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001466 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1467 * will no longer show an interstitial message about updating existing
1468 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001469 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001470 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001471 public static final String EXTRA_ALLOW_REPLACE
1472 = "android.intent.extra.ALLOW_REPLACE";
1473
1474 /**
1475 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1476 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1477 * return to the application the result code of the install/uninstall. The returned result
1478 * code will be {@link android.app.Activity#RESULT_OK} on success or
1479 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1480 */
1481 public static final String EXTRA_RETURN_RESULT
1482 = "android.intent.extra.RETURN_RESULT";
1483
1484 /**
1485 * Package manager install result code. @hide because result codes are not
1486 * yet ready to be exposed.
1487 */
1488 public static final String EXTRA_INSTALL_RESULT
1489 = "android.intent.extra.INSTALL_RESULT";
1490
1491 /**
1492 * Activity Action: Launch application uninstaller.
1493 * <p>
1494 * Input: The data must be a package: URI whose scheme specific part is
1495 * the package name of the current installed package to be uninstalled.
1496 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1497 * <p>
1498 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1499 * succeeded.
1500 */
1501 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1502 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1503
1504 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001505 * Specify whether the package should be uninstalled for all users.
1506 * @hide because these should not be part of normal application flow.
1507 */
1508 public static final String EXTRA_UNINSTALL_ALL_USERS
1509 = "android.intent.extra.UNINSTALL_ALL_USERS";
1510
1511 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001512 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1513 * describing the last run version of the platform that was setup.
1514 * @hide
1515 */
1516 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1517
Svet Ganov3695b8a2015-03-24 16:30:25 -07001518 /**
1519 * Activity action: Launch UI to manage the permissions of an app.
1520 * <p>
1521 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1522 * will be managed by the launched UI.
1523 * </p>
1524 * <p>
1525 * Output: Nothing.
1526 * </p>
1527 *
1528 * @see #EXTRA_PACKAGE_NAME
1529 *
1530 * @hide
1531 */
1532 @SystemApi
1533 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1534 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1535 "android.intent.action.MANAGE_APP_PERMISSIONS";
1536
1537 /**
1538 * Intent extra: An app package name.
1539 * <p>
1540 * Type: String
1541 * </p>S
1542 *
1543 * @hide
1544 */
1545 @SystemApi
1546 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1547
1548 /**
1549 * Activity action: Launch UI to manage which apps have a given permission.
1550 * <p>
1551 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1552 * to which will be managed by the launched UI.
1553 * </p>
1554 * <p>
1555 * Output: Nothing.
1556 * </p>
1557 *
1558 * @see #EXTRA_PERMISSION_NAME
1559 *
1560 * @hide
1561 */
1562 @SystemApi
1563 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1564 public static final String ACTION_MANAGE_PERMISSION_APPS =
1565 "android.intent.action.MANAGE_PERMISSION_APPS";
1566
1567 /**
1568 * Intent extra: The name of a permission.
1569 * <p>
1570 * Type: String
1571 * </p>
1572 *
1573 * @hide
1574 */
1575 @SystemApi
1576 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1577
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001578 // ---------------------------------------------------------------------
1579 // ---------------------------------------------------------------------
1580 // Standard intent broadcast actions (see action variable).
1581
1582 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001583 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1584 * <p>
1585 * For historical reasons, the name of this broadcast action refers to the power
1586 * state of the screen but it is actually sent in response to changes in the
1587 * overall interactive state of the device.
1588 * </p><p>
1589 * This broadcast is sent when the device becomes non-interactive which may have
1590 * nothing to do with the screen turning off. To determine the
1591 * actual state of the screen, use {@link android.view.Display#getState}.
1592 * </p><p>
1593 * See {@link android.os.PowerManager#isInteractive} for details.
1594 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001595 * You <em>cannot</em> receive this through components declared in
1596 * manifests, only by explicitly registering for it with
1597 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1598 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001599 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001600 * <p class="note">This is a protected intent that can only be sent
1601 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001602 */
1603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1604 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001605
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001606 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001607 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1608 * <p>
1609 * For historical reasons, the name of this broadcast action refers to the power
1610 * state of the screen but it is actually sent in response to changes in the
1611 * overall interactive state of the device.
1612 * </p><p>
1613 * This broadcast is sent when the device becomes interactive which may have
1614 * nothing to do with the screen turning on. To determine the
1615 * actual state of the screen, use {@link android.view.Display#getState}.
1616 * </p><p>
1617 * See {@link android.os.PowerManager#isInteractive} for details.
1618 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001619 * You <em>cannot</em> receive this through components declared in
1620 * manifests, only by explicitly registering for it with
1621 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1622 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001623 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001624 * <p class="note">This is a protected intent that can only be sent
1625 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001626 */
1627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1628 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001629
1630 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001631 * Broadcast Action: Sent after the system stops dreaming.
1632 *
1633 * <p class="note">This is a protected intent that can only be sent by the system.
1634 * It is only sent to registered receivers.</p>
1635 */
1636 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1637 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1638
1639 /**
1640 * Broadcast Action: Sent after the system starts dreaming.
1641 *
1642 * <p class="note">This is a protected intent that can only be sent by the system.
1643 * It is only sent to registered receivers.</p>
1644 */
1645 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1646 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1647
1648 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001649 * 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 -07001650 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001651 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001652 * <p class="note">This is a protected intent that can only be sent
1653 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001654 */
1655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001656 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001658 /**
1659 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001660 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001661 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001662 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1663 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001664 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001665 * <p class="note">This is a protected intent that can only be sent
1666 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001667 */
1668 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1669 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1670 /**
1671 * Broadcast Action: The time was set.
1672 */
1673 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1674 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1675 /**
1676 * Broadcast Action: The date has changed.
1677 */
1678 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1679 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1680 /**
1681 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1682 * <ul>
1683 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1684 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001685 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001686 * <p class="note">This is a protected intent that can only be sent
1687 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001688 */
1689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1690 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1691 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001692 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1693 * DNS entries should be tossed.
1694 * @hide
1695 */
1696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1697 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1698 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001699 * Alarm Changed Action: This is broadcast when the AlarmClock
1700 * application's alarm is set or unset. It is used by the
1701 * AlarmClock application and the StatusBar service.
1702 * @hide
1703 */
1704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1705 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1706 /**
1707 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1708 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1709 * @hide
1710 */
1711 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1712 public static final String ACTION_SYNC_STATE_CHANGED
1713 = "android.intent.action.SYNC_STATE_CHANGED";
1714 /**
1715 * Broadcast Action: This is broadcast once, after the system has finished
1716 * booting. It can be used to perform application-specific initialization,
1717 * such as installing alarms. You must hold the
1718 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1719 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001720 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001721 * <p class="note">This is a protected intent that can only be sent
1722 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001723 */
1724 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1725 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1726 /**
1727 * Broadcast Action: This is broadcast when a user action should request a
1728 * temporary system dialog to dismiss. Some examples of temporary system
1729 * dialogs are the notification window-shade and the recent tasks dialog.
1730 */
1731 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1732 /**
1733 * Broadcast Action: Trigger the download and eventual installation
1734 * of a package.
1735 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001736 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001737 * <p class="note">This is a protected intent that can only be sent
1738 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001739 *
1740 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001741 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001742 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001743 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1744 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1745 /**
1746 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001747 * device. The data contains the name of the package. Note that the
1748 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001749 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001750 * <ul>
1751 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1752 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1753 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1754 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001755 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001756 * <p class="note">This is a protected intent that can only be sent
1757 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001758 */
1759 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1760 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1761 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001762 * Broadcast Action: A new version of an application package has been
1763 * installed, replacing an existing version that was previously installed.
1764 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001765 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001766 * <ul>
1767 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1768 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001769 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001770 * <p class="note">This is a protected intent that can only be sent
1771 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001772 */
1773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1774 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1775 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001776 * Broadcast Action: A new version of your application has been installed
1777 * over an existing one. This is only sent to the application that was
1778 * replaced. It does not contain any additional data; to receive it, just
1779 * use an intent filter for this action.
1780 *
1781 * <p class="note">This is a protected intent that can only be sent
1782 * by the system.
1783 */
1784 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1785 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1786 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001787 * Broadcast Action: An existing application package has been removed from
1788 * the device. The data contains the name of the package. The package
1789 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001790 * <ul>
1791 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1792 * to the package.
1793 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1794 * application -- data and code -- is being removed.
1795 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1796 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1797 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001798 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001799 * <p class="note">This is a protected intent that can only be sent
1800 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001801 */
1802 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1803 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1804 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001805 * Broadcast Action: An existing application package has been completely
1806 * removed from the device. The data contains the name of the package.
1807 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1808 * {@link #EXTRA_DATA_REMOVED} is true and
1809 * {@link #EXTRA_REPLACING} is false of that broadcast.
1810 *
1811 * <ul>
1812 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1813 * to the package.
1814 * </ul>
1815 *
1816 * <p class="note">This is a protected intent that can only be sent
1817 * by the system.
1818 */
1819 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1820 public static final String ACTION_PACKAGE_FULLY_REMOVED
1821 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1822 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001823 * Broadcast Action: An existing application package has been changed (e.g.
1824 * a component has been enabled or disabled). The data contains the name of
1825 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001826 * <ul>
1827 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001828 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001829 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001830 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1831 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001832 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001833 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001834 * <p class="note">This is a protected intent that can only be sent
1835 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001836 */
1837 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1838 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1839 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001840 * @hide
1841 * Broadcast Action: Ask system services if there is any reason to
1842 * restart the given package. The data contains the name of the
1843 * package.
1844 * <ul>
1845 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1846 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1847 * </ul>
1848 *
1849 * <p class="note">This is a protected intent that can only be sent
1850 * by the system.
1851 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001852 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001853 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1854 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1855 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001856 * Broadcast Action: The user has restarted a package, and all of its
1857 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001858 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001859 * be removed. Note that the restarted package does <em>not</em>
1860 * receive this broadcast.
1861 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001862 * <ul>
1863 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1864 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001865 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001866 * <p class="note">This is a protected intent that can only be sent
1867 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001868 */
1869 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1870 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1871 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001872 * Broadcast Action: The user has cleared the data of a package. This should
1873 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001874 * its persistent data is erased and this broadcast sent.
1875 * Note that the cleared package does <em>not</em>
1876 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001877 * <ul>
1878 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1879 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001880 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001881 * <p class="note">This is a protected intent that can only be sent
1882 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001883 */
1884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1885 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1886 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001887 * Broadcast Action: A user ID has been removed from the system. The user
1888 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001889 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001890 * <p class="note">This is a protected intent that can only be sent
1891 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001892 */
1893 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1894 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001895
1896 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001897 * Broadcast Action: Sent to the installer package of an application
1898 * when that application is first launched (that is the first time it
1899 * is moved out of the stopped state). The data contains the name of the package.
1900 *
1901 * <p class="note">This is a protected intent that can only be sent
1902 * by the system.
1903 */
1904 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1905 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1906
1907 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001908 * Broadcast Action: Sent to the system package verifier when a package
1909 * needs to be verified. The data contains the package URI.
1910 * <p class="note">
1911 * This is a protected intent that can only be sent by the system.
1912 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001913 */
1914 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1915 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1916
1917 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001918 * Broadcast Action: Sent to the system package verifier when a package is
1919 * verified. The data contains the package URI.
1920 * <p class="note">
1921 * This is a protected intent that can only be sent by the system.
1922 */
1923 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1924 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1925
1926 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001927 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
1928 * needs to be verified. The data contains the filter data hosts to be verified against.
1929 * <p class="note">
1930 * This is a protected intent that can only be sent by the system.
1931 * </p>
1932 *
1933 * @hide
1934 */
1935 @SystemApi
1936 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1937 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
1938
1939 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001940 * Broadcast Action: Resources for a set of packages (which were
1941 * previously unavailable) are currently
1942 * available since the media on which they exist is available.
1943 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1944 * list of packages whose availability changed.
1945 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1946 * list of uids of packages whose availability changed.
1947 * Note that the
1948 * packages in this list do <em>not</em> receive this broadcast.
1949 * The specified set of packages are now available on the system.
1950 * <p>Includes the following extras:
1951 * <ul>
1952 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1953 * whose resources(were previously unavailable) are currently available.
1954 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1955 * packages whose resources(were previously unavailable)
1956 * are currently available.
1957 * </ul>
1958 *
1959 * <p class="note">This is a protected intent that can only be sent
1960 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001961 */
1962 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001963 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1964 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001965
1966 /**
1967 * Broadcast Action: Resources for a set of packages are currently
1968 * unavailable since the media on which they exist is unavailable.
1969 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1970 * list of packages whose availability changed.
1971 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1972 * list of uids of packages whose availability changed.
1973 * The specified set of packages can no longer be
1974 * launched and are practically unavailable on the system.
1975 * <p>Inclues the following extras:
1976 * <ul>
1977 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1978 * whose resources are no longer available.
1979 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1980 * whose resources are no longer available.
1981 * </ul>
1982 *
1983 * <p class="note">This is a protected intent that can only be sent
1984 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001985 */
1986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001987 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001988 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001989
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001990 /**
1991 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001992 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001993 * This should <em>only</em> be used to determine when the wallpaper
1994 * has changed to show the new wallpaper to the user. You should certainly
1995 * never, in response to this, change the wallpaper or other attributes of
1996 * it such as the suggested size. That would be crazy, right? You'd cause
1997 * all kinds of loops, especially if other apps are doing similar things,
1998 * right? Of course. So please don't do this.
1999 *
2000 * @deprecated Modern applications should use
2001 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2002 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2003 * shown behind their UI, rather than watching for this broadcast and
2004 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002005 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002006 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002007 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2008 /**
2009 * Broadcast Action: The current device {@link android.content.res.Configuration}
2010 * (orientation, locale, etc) has changed. When such a change happens, the
2011 * UIs (view hierarchy) will need to be rebuilt based on this new
2012 * information; for the most part, applications don't need to worry about
2013 * this, because the system will take care of stopping and restarting the
2014 * application to make sure it sees the new changes. Some system code that
2015 * can not be restarted will need to watch for this action and handle it
2016 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002017 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002018 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002019 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002020 * in manifests, only by explicitly registering for it with
2021 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2022 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002023 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002024 * <p class="note">This is a protected intent that can only be sent
2025 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002026 *
2027 * @see android.content.res.Configuration
2028 */
2029 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2030 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2031 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002032 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002033 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002034 * <p class="note">This is a protected intent that can only be sent
2035 * by the system.
2036 */
2037 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2038 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2039 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002040 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2041 * charging state, level, and other information about the battery.
2042 * See {@link android.os.BatteryManager} for documentation on the
2043 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002044 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002045 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002046 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002047 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002048 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002049 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2050 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2051 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2052 * broadcasts that are sent and can be received through manifest
2053 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002054 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002055 * <p class="note">This is a protected intent that can only be sent
2056 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002057 */
2058 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2059 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2060 /**
2061 * Broadcast Action: Indicates low battery condition on the device.
2062 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002063 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002064 * <p class="note">This is a protected intent that can only be sent
2065 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002066 */
2067 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2068 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2069 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002070 * Broadcast Action: Indicates the battery is now okay after being low.
2071 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2072 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002073 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002074 * <p class="note">This is a protected intent that can only be sent
2075 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002076 */
2077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2078 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2079 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002080 * Broadcast Action: External power has been connected to the device.
2081 * This is intended for applications that wish to register specifically to this notification.
2082 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2083 * stay active to receive this notification. This action can be used to implement actions
2084 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002085 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002086 * <p class="note">This is a protected intent that can only be sent
2087 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002088 */
2089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002090 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002091 /**
2092 * Broadcast Action: External power has been removed from the device.
2093 * This is intended for applications that wish to register specifically to this notification.
2094 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2095 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002096 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002097 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002098 * <p class="note">This is a protected intent that can only be sent
2099 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002100 */
2101 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002102 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002103 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002104 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002105 * Broadcast Action: Device is shutting down.
2106 * This is broadcast when the device is being shut down (completely turned
2107 * off, not sleeping). Once the broadcast is complete, the final shutdown
2108 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002109 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002110 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002111 * <p class="note">This is a protected intent that can only be sent
2112 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002113 * <p>May include the following extras:
2114 * <ul>
2115 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2116 * shutdown is only for userspace processes. If not set, assumed to be false.
2117 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002118 */
2119 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002120 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002121 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002122 * Activity Action: Start this activity to request system shutdown.
2123 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2124 * to request confirmation from the user before shutting down.
2125 *
2126 * <p class="note">This is a protected intent that can only be sent
2127 * by the system.
2128 *
2129 * {@hide}
2130 */
2131 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2132 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002133 * Broadcast Action: A sticky broadcast that indicates low memory
2134 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002135 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002136 * <p class="note">This is a protected intent that can only be sent
2137 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002138 */
2139 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2140 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2141 /**
2142 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002143 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002144 * <p class="note">This is a protected intent that can only be sent
2145 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002146 */
2147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2148 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2149 /**
Jake Hambybb371632010-08-23 18:16:48 -07002150 * Broadcast Action: A sticky broadcast that indicates a memory full
2151 * condition on the device. This is intended for activities that want
2152 * to be able to fill the data partition completely, leaving only
2153 * enough free space to prevent system-wide SQLite failures.
2154 *
2155 * <p class="note">This is a protected intent that can only be sent
2156 * by the system.
2157 *
2158 * {@hide}
2159 */
2160 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2161 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2162 /**
2163 * Broadcast Action: Indicates memory full condition on the device
2164 * no longer exists.
2165 *
2166 * <p class="note">This is a protected intent that can only be sent
2167 * by the system.
2168 *
2169 * {@hide}
2170 */
2171 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2172 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2173 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002174 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2175 * and package management should be started.
2176 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2177 * notification.
2178 */
2179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2180 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2181 /**
2182 * Broadcast Action: The device has entered USB Mass Storage mode.
2183 * This is used mainly for the USB Settings panel.
2184 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2185 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002186 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002187 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002188 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002189 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2190
2191 /**
2192 * Broadcast Action: The device has exited USB Mass Storage mode.
2193 * This is used mainly for the USB Settings panel.
2194 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2195 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002196 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002197 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002198 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002199 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2200
2201 /**
2202 * Broadcast Action: External media has been removed.
2203 * The path to the mount point for the removed media is contained in the Intent.mData field.
2204 */
2205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2206 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2207
2208 /**
2209 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002210 * 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 -07002211 */
2212 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2213 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2214
2215 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002216 * Broadcast Action: External media is present, and being disk-checked
2217 * 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 -08002218 */
2219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2220 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2221
2222 /**
2223 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2224 * 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 -08002225 */
2226 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2227 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2228
2229 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002230 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002231 * 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 -07002232 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2233 * media was mounted read only.
2234 */
2235 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2236 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2237
2238 /**
2239 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002240 * 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 -07002241 */
2242 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2243 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2244
2245 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002246 * Broadcast Action: External media is no longer being shared via USB mass storage.
2247 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2248 *
2249 * @hide
2250 */
2251 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2252
2253 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002254 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2255 * The path to the mount point for the removed media is contained in the Intent.mData field.
2256 */
2257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2258 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2259
2260 /**
2261 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002262 * 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 -07002263 */
2264 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2265 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2266
2267 /**
2268 * Broadcast Action: User has expressed the desire to remove the external storage media.
2269 * Applications should close all files they have open within the mount point when they receive this intent.
2270 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2271 */
2272 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2273 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2274
2275 /**
2276 * Broadcast Action: The media scanner has started scanning a directory.
2277 * The path to the directory being scanned is contained in the Intent.mData field.
2278 */
2279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2280 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2281
2282 /**
2283 * Broadcast Action: The media scanner has finished scanning a directory.
2284 * The path to the scanned directory is contained in the Intent.mData field.
2285 */
2286 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2287 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2288
2289 /**
2290 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2291 * The path to the file is contained in the Intent.mData field.
2292 */
2293 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2294 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2295
2296 /**
2297 * Broadcast Action: The "Media Button" was pressed. Includes a single
2298 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2299 * caused the broadcast.
2300 */
2301 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2302 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2303
2304 /**
2305 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2306 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2307 * caused the broadcast.
2308 */
2309 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2310 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2311
2312 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2313 // location; they are not general-purpose actions.
2314
2315 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002316 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002317 */
2318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2319 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2320 "android.intent.action.GTALK_CONNECTED";
2321
2322 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002323 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002324 */
2325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2326 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2327 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002328
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002329 /**
2330 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002331 */
2332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2333 public static final String ACTION_INPUT_METHOD_CHANGED =
2334 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002335
2336 /**
2337 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2338 * more radios have been turned off or on. The intent will have the following extra value:</p>
2339 * <ul>
2340 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2341 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2342 * turned off</li>
2343 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002344 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002345 * <p class="note">This is a protected intent that can only be sent
2346 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002347 */
2348 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2349 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2350
2351 /**
2352 * Broadcast Action: Some content providers have parts of their namespace
2353 * where they publish new events or items that the user may be especially
2354 * interested in. For these things, they may broadcast this action when the
2355 * set of interesting items change.
2356 *
2357 * For example, GmailProvider sends this notification when the set of unread
2358 * mail in the inbox changes.
2359 *
2360 * <p>The data of the intent identifies which part of which provider
2361 * changed. When queried through the content resolver, the data URI will
2362 * return the data set in question.
2363 *
2364 * <p>The intent will have the following extra values:
2365 * <ul>
2366 * <li><em>count</em> - The number of items in the data set. This is the
2367 * same as the number of items in the cursor returned by querying the
2368 * data URI. </li>
2369 * </ul>
2370 *
2371 * This intent will be sent at boot (if the count is non-zero) and when the
2372 * data set changes. It is possible for the data set to change without the
2373 * count changing (for example, if a new unread message arrives in the same
2374 * sync operation in which a message is archived). The phone should still
2375 * ring/vibrate/etc as normal in this case.
2376 */
2377 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2378 public static final String ACTION_PROVIDER_CHANGED =
2379 "android.intent.action.PROVIDER_CHANGED";
2380
2381 /**
2382 * Broadcast Action: Wired Headset plugged in or unplugged.
2383 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002384 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2385 * and documentation.
2386 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002387 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002388 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002389 */
2390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002391 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002392
2393 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002394 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2395 * <ul>
2396 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2397 * </ul>
2398 *
2399 * <p class="note">This is a protected intent that can only be sent
2400 * by the system.
2401 *
2402 * @hide
2403 */
2404 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2405 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2406 = "android.intent.action.ADVANCED_SETTINGS";
2407
2408 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002409 * Broadcast Action: Sent after application restrictions are changed.
2410 *
2411 * <p class="note">This is a protected intent that can only be sent
2412 * by the system.</p>
2413 */
2414 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2415 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2416 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2417
2418 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002419 * Broadcast Action: An outgoing call is about to be placed.
2420 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002421 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002422 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002423 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002424 * the phone number originally intended to be dialed.</li>
2425 * </ul>
2426 * <p>Once the broadcast is finished, the resultData is used as the actual
2427 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002428 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002429 * outgoing call in turn: for example, a parental control application
2430 * might verify that the user is authorized to place the call at that
2431 * time, then a number-rewriting application might add an area code if
2432 * one was not specified.</p>
2433 * <p>For consistency, any receiver whose purpose is to prohibit phone
2434 * calls should have a priority of 0, to ensure it will see the final
2435 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002436 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002437 * should have a positive priority.
2438 * Negative priorities are reserved for the system for this broadcast;
2439 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002440 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2441 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002442 * <p>Emergency calls cannot be intercepted using this mechanism, and
2443 * other calls cannot be modified to call emergency numbers using this
2444 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002445 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2446 * call to use their own service instead. Those apps should first prevent
2447 * the call from being placed by setting resultData to <code>null</code>
2448 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002449 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002450 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2451 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002452 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002453 * <p class="note">This is a protected intent that can only be sent
2454 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002455 */
2456 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2457 public static final String ACTION_NEW_OUTGOING_CALL =
2458 "android.intent.action.NEW_OUTGOING_CALL";
2459
2460 /**
2461 * Broadcast Action: Have the device reboot. This is only for use by
2462 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002463 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002464 * <p class="note">This is a protected intent that can only be sent
2465 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 */
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2468 public static final String ACTION_REBOOT =
2469 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002470
Wei Huang97ecc9c2009-05-11 17:44:20 -07002471 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002472 * Broadcast Action: A sticky broadcast for changes in the physical
2473 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002474 *
2475 * <p>The intent will have the following extra values:
2476 * <ul>
2477 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002478 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002479 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002480 * <p>This is intended for monitoring the current physical dock state.
2481 * See {@link android.app.UiModeManager} for the normal API dealing with
2482 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002483 */
2484 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2485 public static final String ACTION_DOCK_EVENT =
2486 "android.intent.action.DOCK_EVENT";
2487
2488 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002489 * Broadcast Action: A broadcast when idle maintenance can be started.
2490 * This means that the user is not interacting with the device and is
2491 * not expected to do so soon. Typical use of the idle maintenance is
2492 * to perform somehow expensive tasks that can be postponed at a moment
2493 * when they will not degrade user experience.
2494 * <p>
2495 * <p class="note">In order to keep the device responsive in case of an
2496 * unexpected user interaction, implementations of a maintenance task
2497 * should be interruptible. In such a scenario a broadcast with action
2498 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2499 * should not do the maintenance work in
2500 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2501 * maintenance service by {@link Context#startService(Intent)}. Also
2502 * you should hold a wake lock while your maintenance service is running
2503 * to prevent the device going to sleep.
2504 * </p>
2505 * <p>
2506 * <p class="note">This is a protected intent that can only be sent by
2507 * the system.
2508 * </p>
2509 *
2510 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002511 *
2512 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002513 */
2514 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2515 public static final String ACTION_IDLE_MAINTENANCE_START =
2516 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2517
2518 /**
2519 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2520 * This means that the user was not interacting with the device as a result
2521 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2522 * was sent and now the user started interacting with the device. Typical
2523 * use of the idle maintenance is to perform somehow expensive tasks that
2524 * can be postponed at a moment when they will not degrade user experience.
2525 * <p>
2526 * <p class="note">In order to keep the device responsive in case of an
2527 * unexpected user interaction, implementations of a maintenance task
2528 * should be interruptible. Hence, on receiving a broadcast with this
2529 * action, the maintenance task should be interrupted as soon as possible.
2530 * In other words, you should not do the maintenance work in
2531 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2532 * maintenance service that was started on receiving of
2533 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2534 * lock you acquired when your maintenance service started.
2535 * </p>
2536 * <p class="note">This is a protected intent that can only be sent
2537 * by the system.
2538 *
2539 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002540 *
2541 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002542 */
2543 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2544 public static final String ACTION_IDLE_MAINTENANCE_END =
2545 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2546
2547 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002548 * Broadcast Action: a remote intent is to be broadcasted.
2549 *
2550 * A remote intent is used for remote RPC between devices. The remote intent
2551 * is serialized and sent from one device to another device. The receiving
2552 * device parses the remote intent and broadcasts it. Note that anyone can
2553 * broadcast a remote intent. However, if the intent receiver of the remote intent
2554 * does not trust intent broadcasts from arbitrary intent senders, it should require
2555 * the sender to hold certain permissions so only trusted sender's broadcast will be
2556 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002557 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002558 */
2559 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002560 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002561
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002562 /**
2563 * Broadcast Action: hook for permforming cleanup after a system update.
2564 *
2565 * The broadcast is sent when the system is booting, before the
2566 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2567 * image. A receiver for this should do its work and then disable itself
2568 * so that it does not get run again at the next boot.
2569 * @hide
2570 */
2571 public static final String ACTION_PRE_BOOT_COMPLETED =
2572 "android.intent.action.PRE_BOOT_COMPLETED";
2573
Amith Yamasani13593602012-03-22 16:16:17 -07002574 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002575 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002576 * on restricted users. The broadcast intent contains an extra
2577 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2578 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2579 * String[] depending on the restriction type.<p/>
2580 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002581 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2582 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2583 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002584 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2585 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002586 * @see RestrictionEntry
2587 */
2588 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2589 "android.intent.action.GET_RESTRICTION_ENTRIES";
2590
2591 /**
Amith Yamasanid304af62013-09-05 09:30:23 -07002592 * @hide
Amith Yamasani655d0e22013-06-12 14:19:10 -07002593 * Activity to challenge the user for a PIN that was configured when setting up
Amith Yamasanid304af62013-09-05 09:30:23 -07002594 * restrictions. Restrictions include blocking of apps and preventing certain user operations,
2595 * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle).
2596 * Launch the activity using
Amith Yamasani655d0e22013-06-12 14:19:10 -07002597 * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the
2598 * result is {@link android.app.Activity#RESULT_OK} for a successful response to the
2599 * challenge.<p/>
2600 * Before launching this activity, make sure that there is a PIN in effect, by calling
Amith Yamasanid304af62013-09-05 09:30:23 -07002601 * {@link android.os.UserManager#hasRestrictionsChallenge()}.
Amith Yamasani655d0e22013-06-12 14:19:10 -07002602 */
Amith Yamasanid304af62013-09-05 09:30:23 -07002603 public static final String ACTION_RESTRICTIONS_CHALLENGE =
2604 "android.intent.action.RESTRICTIONS_CHALLENGE";
Amith Yamasani655d0e22013-06-12 14:19:10 -07002605
2606 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002607 * Sent the first time a user is starting, to allow system apps to
2608 * perform one time initialization. (This will not be seen by third
2609 * party applications because a newly initialized user does not have any
2610 * third party applications installed for it.) This is sent early in
2611 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002612 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2613 * broadcast, since it is part of a visible user interaction; be as quick
2614 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002615 */
2616 public static final String ACTION_USER_INITIALIZE =
2617 "android.intent.action.USER_INITIALIZE";
2618
2619 /**
2620 * Sent when a user switch is happening, causing the process's user to be
2621 * brought to the foreground. This is only sent to receivers registered
2622 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2623 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002624 * foreground. This is sent as a foreground
2625 * broadcast, since it is part of a visible user interaction; be as quick
2626 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002627 */
2628 public static final String ACTION_USER_FOREGROUND =
2629 "android.intent.action.USER_FOREGROUND";
2630
2631 /**
2632 * Sent when a user switch is happening, causing the process's user to be
2633 * sent to the background. This is only sent to receivers registered
2634 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2635 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002636 * background. This is sent as a foreground
2637 * broadcast, since it is part of a visible user interaction; be as quick
2638 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002639 */
2640 public static final String ACTION_USER_BACKGROUND =
2641 "android.intent.action.USER_BACKGROUND";
2642
2643 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002644 * Broadcast sent to the system when a user is added. Carries an extra
2645 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2646 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002647 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002648 * @hide
2649 */
2650 public static final String ACTION_USER_ADDED =
2651 "android.intent.action.USER_ADDED";
2652
2653 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002654 * Broadcast sent by the system when a user is started. Carries an extra
2655 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002656 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002657 * that has been started. This is sent as a foreground
2658 * broadcast, since it is part of a visible user interaction; be as quick
2659 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002660 * @hide
2661 */
2662 public static final String ACTION_USER_STARTED =
2663 "android.intent.action.USER_STARTED";
2664
2665 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002666 * Broadcast sent when a user is in the process of starting. Carries an extra
2667 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2668 * sent to registered receivers, not manifest receivers. It is sent to all
2669 * users (including the one that is being started). You must hold
2670 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2671 * this broadcast. This is sent as a background broadcast, since
2672 * its result is not part of the primary UX flow; to safely keep track of
2673 * started/stopped state of a user you can use this in conjunction with
2674 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2675 * other user state broadcasts since those are foreground broadcasts so can
2676 * execute in a different order.
2677 * @hide
2678 */
2679 public static final String ACTION_USER_STARTING =
2680 "android.intent.action.USER_STARTING";
2681
2682 /**
2683 * Broadcast sent when a user is going to be stopped. Carries an extra
2684 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2685 * sent to registered receivers, not manifest receivers. It is sent to all
2686 * users (including the one that is being stopped). You must hold
2687 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2688 * this broadcast. The user will not stop until all receivers have
2689 * handled the broadcast. This is sent as a background broadcast, since
2690 * its result is not part of the primary UX flow; to safely keep track of
2691 * started/stopped state of a user you can use this in conjunction with
2692 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2693 * other user state broadcasts since those are foreground broadcasts so can
2694 * execute in a different order.
2695 * @hide
2696 */
2697 public static final String ACTION_USER_STOPPING =
2698 "android.intent.action.USER_STOPPING";
2699
2700 /**
2701 * Broadcast sent to the system when a user is stopped. Carries an extra
2702 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2703 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2704 * specific package. This is only sent to registered receivers, not manifest
2705 * receivers. It is sent to all running users <em>except</em> the one that
2706 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002707 * @hide
2708 */
2709 public static final String ACTION_USER_STOPPED =
2710 "android.intent.action.USER_STOPPED";
2711
2712 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002713 * 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 -07002714 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002715 * one that has been removed. The user will not be completely removed until all receivers have
2716 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002717 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002718 * @hide
2719 */
2720 public static final String ACTION_USER_REMOVED =
2721 "android.intent.action.USER_REMOVED";
2722
2723 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002724 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002725 * the userHandle of the user to become the current one. This is only sent to
2726 * registered receivers, not manifest receivers. It is sent to all running users.
2727 * You must hold
2728 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002729 * @hide
2730 */
2731 public static final String ACTION_USER_SWITCHED =
2732 "android.intent.action.USER_SWITCHED";
2733
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002734 /**
2735 * Broadcast sent to the system when a user's information changes. Carries an extra
2736 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002737 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002738 * @hide
2739 */
2740 public static final String ACTION_USER_INFO_CHANGED =
2741 "android.intent.action.USER_INFO_CHANGED";
2742
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002743 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002744 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2745 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002746 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2747 * that need to display merged content across both primary and managed profiles need to
2748 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002749 * not manifest receivers.
2750 */
2751 public static final String ACTION_MANAGED_PROFILE_ADDED =
2752 "android.intent.action.MANAGED_PROFILE_ADDED";
2753
2754 /**
2755 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002756 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2757 * Only applications (for example Launchers) that need to display merged content across both
2758 * primary and managed profiles need to worry about this broadcast. This is only sent to
2759 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002760 */
2761 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2762 "android.intent.action.MANAGED_PROFILE_REMOVED";
2763
2764 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002765 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2766 */
2767 public static final String ACTION_QUICK_CLOCK =
2768 "android.intent.action.QUICK_CLOCK";
2769
Michael Wright0087a142013-02-05 16:29:39 -08002770 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002771 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002772 * @hide
2773 */
2774 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2775 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2776
Justin Kohd378ad72013-04-01 12:18:26 -07002777 /**
2778 * Broadcast Action: A global button was pressed. Includes a single
2779 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2780 * caused the broadcast.
2781 * @hide
2782 */
2783 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2784
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002785 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002786 * Activity Action: Allow the user to select and return one or more existing
2787 * documents. When invoked, the system will display the various
2788 * {@link DocumentsProvider} instances installed on the device, letting the
2789 * user interactively navigate through them. These documents include local
2790 * media, such as photos and video, and documents provided by installed
2791 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002792 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002793 * Each document is represented as a {@code content://} URI backed by a
2794 * {@link DocumentsProvider}, which can be opened as a stream with
2795 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2796 * {@link android.provider.DocumentsContract.Document} metadata.
2797 * <p>
2798 * All selected documents are returned to the calling application with
2799 * persistable read and write permission grants. If you want to maintain
2800 * access to the documents across device reboots, you need to explicitly
2801 * take the persistable permissions using
2802 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2803 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002804 * Callers must indicate the acceptable document MIME types through
2805 * {@link #setType(String)}. For example, to select photos, use
2806 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2807 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2808 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002809 * <p>
2810 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002811 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2812 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002813 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002814 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2815 * returned URIs can be opened with
2816 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002817 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002818 * Output: The URI of the item that was picked, returned in
2819 * {@link #getData()}. This must be a {@code content://} URI so that any
2820 * receiver can access it. If multiple documents were selected, they are
2821 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002822 *
2823 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002824 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002825 * @see #ACTION_CREATE_DOCUMENT
2826 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002827 */
2828 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2829 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2830
2831 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002832 * Activity Action: Allow the user to create a new document. When invoked,
2833 * the system will display the various {@link DocumentsProvider} instances
2834 * installed on the device, letting the user navigate through them. The
2835 * returned document may be a newly created document with no content, or it
2836 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002837 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002838 * Each document is represented as a {@code content://} URI backed by a
2839 * {@link DocumentsProvider}, which can be opened as a stream with
2840 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2841 * {@link android.provider.DocumentsContract.Document} metadata.
2842 * <p>
2843 * Callers must indicate the concrete MIME type of the document being
2844 * created by setting {@link #setType(String)}. This MIME type cannot be
2845 * changed after the document is created.
2846 * <p>
2847 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2848 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002849 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002850 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2851 * returned URIs can be opened with
2852 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002853 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002854 * Output: The URI of the item that was created. This must be a
2855 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002856 *
2857 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002858 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002859 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002860 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002861 */
2862 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2863 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2864
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002865 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002866 * Activity Action: Allow the user to pick a directory subtree. When
2867 * invoked, the system will display the various {@link DocumentsProvider}
2868 * instances installed on the device, letting the user navigate through
2869 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002870 * <p>
2871 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002872 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2873 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2874 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002875 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002876 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002877 *
2878 * @see DocumentsContract
2879 */
2880 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002881 public static final String
2882 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002883
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002884 /** {@hide} */
2885 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2886
Christopher Tate6597e342015-02-17 12:15:25 -08002887 /**
2888 * Broadcast action: report that a settings element is being restored from backup. The intent
2889 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
2890 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
2891 * is the value of that settings entry prior to the restore operation. All of these values are
2892 * represented as strings.
2893 *
2894 * <p>This broadcast is sent only for settings provider entries known to require special handling
2895 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
2896 * the provider's backup agent implementation.
2897 *
2898 * @see #EXTRA_SETTING_NAME
2899 * @see #EXTRA_SETTING_PREVIOUS_VALUE
2900 * @see #EXTRA_SETTING_NEW_VALUE
2901 * {@hide}
2902 */
2903 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
2904
2905 /** {@hide} */
2906 public static final String EXTRA_SETTING_NAME = "setting_name";
2907 /** {@hide} */
2908 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
2909 /** {@hide} */
2910 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
2911
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002912 /**
2913 * Activity Action: Process a piece of text.
2914 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
2915 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
2916 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
2917 */
2918 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2919 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
2920 /**
2921 * The name of the extra used to define the text to be processed.
2922 */
2923 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
2924 /**
2925 * The name of the extra used to define if the processed text will be used as read-only.
2926 */
2927 public static final String EXTRA_PROCESS_TEXT_READONLY =
2928 "android.intent.extra.PROCESS_TEXT_READONLY";
2929
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002930 // ---------------------------------------------------------------------
2931 // ---------------------------------------------------------------------
2932 // Standard intent categories (see addCategory()).
2933
2934 /**
2935 * Set if the activity should be an option for the default action
2936 * (center press) to perform on a piece of data. Setting this will
2937 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002938 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002939 * Intent when initiating an action -- it is for use in intent filters
2940 * specified in packages.
2941 */
2942 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2943 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2944 /**
2945 * Activities that can be safely invoked from a browser must support this
2946 * category. For example, if the user is viewing a web page or an e-mail
2947 * and clicks on a link in the text, the Intent generated execute that
2948 * link will require the BROWSABLE category, so that only activities
2949 * supporting this category will be considered as possible actions. By
2950 * supporting this category, you are promising that there is nothing
2951 * damaging (without user intervention) that can happen by invoking any
2952 * matching Intent.
2953 */
2954 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2955 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2956 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002957 * Categories for activities that can participate in voice interaction.
2958 * An activity that supports this category must be prepared to run with
2959 * no UI shown at all (though in some case it may have a UI shown), and
2960 * rely on {@link android.app.VoiceInteractor} to interact with the user.
2961 */
2962 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2963 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
2964 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002965 * Set if the activity should be considered as an alternative action to
2966 * the data the user is currently viewing. See also
2967 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2968 * applies to the selection in a list of items.
2969 *
2970 * <p>Supporting this category means that you would like your activity to be
2971 * displayed in the set of alternative things the user can do, usually as
2972 * part of the current activity's options menu. You will usually want to
2973 * include a specific label in the &lt;intent-filter&gt; of this action
2974 * describing to the user what it does.
2975 *
2976 * <p>The action of IntentFilter with this category is important in that it
2977 * describes the specific action the target will perform. This generally
2978 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2979 * a specific name such as "com.android.camera.action.CROP. Only one
2980 * alternative of any particular action will be shown to the user, so using
2981 * a specific action like this makes sure that your alternative will be
2982 * displayed while also allowing other applications to provide their own
2983 * overrides of that particular action.
2984 */
2985 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2986 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2987 /**
2988 * Set if the activity should be considered as an alternative selection
2989 * action to the data the user has currently selected. This is like
2990 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2991 * of items from which the user can select, giving them alternatives to the
2992 * default action that will be performed on it.
2993 */
2994 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2995 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2996 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002997 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002998 */
2999 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3000 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3001 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003002 * Should be displayed in the top-level launcher.
3003 */
3004 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3005 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3006 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003007 * Indicates an activity optimized for Leanback mode, and that should
3008 * be displayed in the Leanback launcher.
3009 */
3010 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3011 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3012 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003013 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3014 * @hide
3015 */
3016 @SystemApi
3017 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3018 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003019 * Provides information about the package it is in; typically used if
3020 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3021 * a front-door to the user without having to be shown in the all apps list.
3022 */
3023 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3024 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3025 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003026 * This is the home activity, that is the first activity that is displayed
3027 * when the device boots.
3028 */
3029 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3030 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3031 /**
3032 * This activity is a preference panel.
3033 */
3034 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3035 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3036 /**
3037 * This activity is a development preference panel.
3038 */
3039 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3040 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3041 /**
3042 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003043 */
3044 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3045 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3046 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003047 * This activity allows the user to browse and download new applications.
3048 */
3049 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3050 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3051 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003052 * This activity may be exercised by the monkey or other automated test tools.
3053 */
3054 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3055 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3056 /**
3057 * To be used as a test (not part of the normal user experience).
3058 */
3059 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3060 /**
3061 * To be used as a unit test (run through the Test Harness).
3062 */
3063 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3064 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003065 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003066 * experience).
3067 */
3068 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003069
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003070 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003071 * Used to indicate that an intent only wants URIs that can be opened with
3072 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3073 * must support at least the columns defined in {@link OpenableColumns} when
3074 * queried.
3075 *
3076 * @see #ACTION_GET_CONTENT
3077 * @see #ACTION_OPEN_DOCUMENT
3078 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003079 */
3080 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3081 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3082
3083 /**
3084 * To be used as code under test for framework instrumentation tests.
3085 */
3086 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3087 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003088 /**
3089 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003090 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3091 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003092 */
3093 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3094 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3095 /**
3096 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003097 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3098 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003099 */
3100 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3101 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003102 /**
3103 * An activity to run when device is inserted into a analog (low end) dock.
3104 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3105 * information, see {@link android.app.UiModeManager}.
3106 */
3107 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3108 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3109
3110 /**
3111 * An activity to run when device is inserted into a digital (high end) dock.
3112 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3113 * information, see {@link android.app.UiModeManager}.
3114 */
3115 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3116 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003117
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003118 /**
3119 * Used to indicate that the activity can be used in a car environment.
3120 */
3121 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3122 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3123
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003124 // ---------------------------------------------------------------------
3125 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003126 // Application launch intent categories (see addCategory()).
3127
3128 /**
3129 * Used with {@link #ACTION_MAIN} to launch the browser application.
3130 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003131 * <p>NOTE: This should not be used as the primary key of an Intent,
3132 * since it will not result in the app launching with the correct
3133 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003134 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003135 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003136 */
3137 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3138 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3139
3140 /**
3141 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3142 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003143 * <p>NOTE: This should not be used as the primary key of an Intent,
3144 * since it will not result in the app launching with the correct
3145 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003146 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003147 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003148 */
3149 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3150 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3151
3152 /**
3153 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3154 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003155 * <p>NOTE: This should not be used as the primary key of an Intent,
3156 * since it will not result in the app launching with the correct
3157 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003158 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003159 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003160 */
3161 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3162 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3163
3164 /**
3165 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3166 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003167 * <p>NOTE: This should not be used as the primary key of an Intent,
3168 * since it will not result in the app launching with the correct
3169 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003170 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003171 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003172 */
3173 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3174 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3175
3176 /**
3177 * Used with {@link #ACTION_MAIN} to launch the email application.
3178 * The activity should be able to send and receive email.
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_EMAIL = "android.intent.category.APP_EMAIL";
3187
3188 /**
3189 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3190 * The activity should be able to view and manipulate image and video files
3191 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003192 * <p>NOTE: This should not be used as the primary key of an Intent,
3193 * since it will not result in the app launching with the correct
3194 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003195 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003196 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003197 */
3198 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3199 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3200
3201 /**
3202 * Used with {@link #ACTION_MAIN} to launch the maps application.
3203 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003204 * <p>NOTE: This should not be used as the primary key of an Intent,
3205 * since it will not result in the app launching with the correct
3206 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003207 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003208 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003209 */
3210 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3211 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3212
3213 /**
3214 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3215 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003216 * <p>NOTE: This should not be used as the primary key of an Intent,
3217 * since it will not result in the app launching with the correct
3218 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003219 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003220 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003221 */
3222 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3223 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3224
3225 /**
3226 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003227 * The activity should be able to play, browse, or manipulate music files
3228 * stored on the device.
3229 * <p>NOTE: This should not be used as the primary key of an Intent,
3230 * since it will not result in the app launching with the correct
3231 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003232 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003233 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003234 */
3235 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3236 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3237
3238 // ---------------------------------------------------------------------
3239 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003240 // Standard extra data keys.
3241
3242 /**
3243 * The initial data to place in a newly created record. Use with
3244 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3245 * fields as would be given to the underlying ContentProvider.insert()
3246 * call.
3247 */
3248 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3249
3250 /**
3251 * A constant CharSequence that is associated with the Intent, used with
3252 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3253 * this may be a styled CharSequence, so you must use
3254 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3255 * retrieve it.
3256 */
3257 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3258
3259 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003260 * A constant String that is associated with the Intent, used with
3261 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3262 * as HTML formatted text. Note that you <em>must</em> also supply
3263 * {@link #EXTRA_TEXT}.
3264 */
3265 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3266
3267 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003268 * A content: URI holding a stream of data associated with the Intent,
3269 * used with {@link #ACTION_SEND} to supply the data being sent.
3270 */
3271 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3272
3273 /**
3274 * A String[] holding e-mail addresses that should be delivered to.
3275 */
3276 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3277
3278 /**
3279 * A String[] holding e-mail addresses that should be carbon copied.
3280 */
3281 public static final String EXTRA_CC = "android.intent.extra.CC";
3282
3283 /**
3284 * A String[] holding e-mail addresses that should be blind carbon copied.
3285 */
3286 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3287
3288 /**
3289 * A constant string holding the desired subject line of a message.
3290 */
3291 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3292
3293 /**
3294 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003295 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003296 */
3297 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3298
3299 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003300 * An Intent[] describing additional, alternate choices you would like shown with
3301 * {@link #ACTION_CHOOSER}.
3302 *
3303 * <p>An app may be capable of providing several different payload types to complete a
3304 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3305 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3306 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3307 * photo data or a hosted link where the photos can be viewed.</p>
3308 *
3309 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3310 * first/primary/preferred intent in the set. Additional intents specified in
3311 * this extra are ordered; by default intents that appear earlier in the array will be
3312 * preferred over intents that appear later in the array as matches for the same
3313 * target component. To alter this preference, a calling app may also supply
3314 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3315 */
3316 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3317
3318 /**
3319 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3320 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3321 *
3322 * <p>An app preparing an action for another app to complete may wish to allow the user to
3323 * disambiguate between several options for completing the action based on the chosen target
3324 * or otherwise refine the action before it is invoked.
3325 * </p>
3326 *
3327 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3328 * <ul>
3329 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3330 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3331 * chosen target beyond the first</li>
3332 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3333 * should fill in and send once the disambiguation is complete</li>
3334 * </ul>
3335 */
3336 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3337 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3338
3339 /**
3340 * A {@link ResultReceiver} used to return data back to the sender.
3341 *
3342 * <p>Used to complete an app-specific
3343 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3344 *
3345 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3346 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3347 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3348 * when the user selects a target component from the chooser. It is up to the recipient
3349 * to send a result to this ResultReceiver to signal that disambiguation is complete
3350 * and that the chooser should invoke the user's choice.</p>
3351 *
3352 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3353 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3354 * to match and fill in the final Intent or ChooserTarget before starting it.
3355 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3356 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3357 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3358 *
3359 * <p>The result code passed to the ResultReceiver should be
3360 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3361 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3362 * the chooser should finish without starting a target.</p>
3363 */
3364 public static final String EXTRA_RESULT_RECEIVER
3365 = "android.intent.extra.RESULT_RECEIVER";
3366
3367 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003368 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003369 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003370 */
3371 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3372
3373 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003374 * A Parcelable[] of {@link Intent} or
3375 * {@link android.content.pm.LabeledIntent} objects as set with
3376 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3377 * a the front of the list of choices, when shown to the user with a
3378 * {@link #ACTION_CHOOSER}.
3379 */
3380 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3381
3382 /**
Adam Powell24428412015-04-01 17:19:56 -07003383 * A Parcelable[] of {@link android.service.chooser.ChooserTarget ChooserTarget} objects
3384 * as set with {@link #putExtra(String, Parcelable[])} representing additional app-specific
3385 * targets to place at the front of the list of choices. Shown to the user with
3386 * {@link #ACTION_CHOOSER}.
3387 */
3388 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3389
3390 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003391 * A Bundle forming a mapping of potential target package names to different extras Bundles
3392 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3393 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3394 * be currently installed on the device.
3395 *
3396 * <p>An application may choose to provide alternate extras for the case where a user
3397 * selects an activity from a predetermined set of target packages. If the activity
3398 * the user selects from the chooser belongs to a package with its package name as
3399 * a key in this bundle, the corresponding extras for that package will be merged with
3400 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3401 * extra has the same key as an extra already present in the intent it will overwrite
3402 * the extra from the intent.</p>
3403 *
3404 * <p><em>Examples:</em>
3405 * <ul>
3406 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3407 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3408 * parameters for that target.</li>
3409 * <li>An application may offer additional metadata for known targets of a given intent
3410 * to pass along information only relevant to that target such as account or content
3411 * identifiers already known to that application.</li>
3412 * </ul></p>
3413 */
3414 public static final String EXTRA_REPLACEMENT_EXTRAS =
3415 "android.intent.extra.REPLACEMENT_EXTRAS";
3416
3417 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003418 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3419 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3420 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3421 * {@link ComponentName} of the chosen component.
3422 *
3423 * <p>In some situations this callback may never come, for example if the user abandons
3424 * the chooser, switches to another task or any number of other reasons. Apps should not
3425 * be written assuming that this callback will always occur.</p>
3426 */
3427 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3428 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3429
3430 /**
3431 * The {@link ComponentName} chosen by the user to complete an action.
3432 *
3433 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3434 */
3435 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3436
3437 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003438 * A {@link android.view.KeyEvent} object containing the event that
3439 * triggered the creation of the Intent it is in.
3440 */
3441 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3442
3443 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003444 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3445 * before shutting down.
3446 *
3447 * {@hide}
3448 */
3449 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3450
3451 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003452 * 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 -07003453 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3454 * of restarting the application.
3455 */
3456 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3457
3458 /**
3459 * A String holding the phone number originally entered in
3460 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3461 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3462 */
3463 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003464
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003465 /**
3466 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3467 * intents to supply the uid the package had been assigned. Also an optional
3468 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3469 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3470 * purpose.
3471 */
3472 public static final String EXTRA_UID = "android.intent.extra.UID";
3473
3474 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003475 * @hide String array of package names.
3476 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003477 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003478 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3479
3480 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003481 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3482 * intents to indicate whether this represents a full uninstall (removing
3483 * both the code and its data) or a partial uninstall (leaving its data,
3484 * implying that this is an update).
3485 */
3486 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003487
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003488 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003489 * @hide
3490 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3491 * intents to indicate that at this point the package has been removed for
3492 * all users on the device.
3493 */
3494 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3495 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3496
3497 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003498 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3499 * intents to indicate that this is a replacement of the package, so this
3500 * broadcast will immediately be followed by an add broadcast for a
3501 * different version of the same package.
3502 */
3503 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003504
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003505 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003506 * Used as an int extra field in {@link android.app.AlarmManager} intents
3507 * to tell the application being invoked how many pending alarms are being
3508 * delievered with the intent. For one-shot alarms this will always be 1.
3509 * For recurring alarms, this might be greater than 1 if the device was
3510 * asleep or powered off at the time an earlier alarm would have been
3511 * delivered.
3512 */
3513 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003514
Jacek Surazski86b6c532009-05-13 14:38:28 +02003515 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003516 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3517 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003518 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3519 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003520 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3521 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3522 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003523 */
3524 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3525
3526 /**
3527 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3528 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003529 */
3530 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3531
3532 /**
3533 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3534 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003535 */
3536 public static final int EXTRA_DOCK_STATE_DESK = 1;
3537
3538 /**
3539 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3540 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003541 */
3542 public static final int EXTRA_DOCK_STATE_CAR = 2;
3543
3544 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003545 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3546 * to represent that the phone is in a analog (low end) dock.
3547 */
3548 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3549
3550 /**
3551 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3552 * to represent that the phone is in a digital (high end) dock.
3553 */
3554 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3555
3556 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003557 * Boolean that can be supplied as meta-data with a dock activity, to
3558 * indicate that the dock should take over the home key when it is active.
3559 */
3560 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003561
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003562 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003563 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3564 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003565 */
3566 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3567
3568 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003569 * Used in the extra field in the remote intent. It's astring token passed with the
3570 * remote intent.
3571 */
3572 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3573 "android.intent.extra.remote_intent_token";
3574
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003575 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003576 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003577 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003578 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003579 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003580 "android.intent.extra.changed_component_name";
3581
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003582 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003583 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003584 * and contains a string array of all of the components that have changed. If
3585 * the state of the overall package has changed, then it will contain an entry
3586 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003587 */
3588 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3589 "android.intent.extra.changed_component_name_list";
3590
3591 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003592 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003593 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3594 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003595 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003596 */
3597 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3598 "android.intent.extra.changed_package_list";
3599
3600 /**
3601 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003602 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3603 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003604 * and contains an integer array of uids of all of the components
3605 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003606 */
3607 public static final String EXTRA_CHANGED_UID_LIST =
3608 "android.intent.extra.changed_uid_list";
3609
3610 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003611 * @hide
3612 * Magic extra system code can use when binding, to give a label for
3613 * who it is that has bound to a service. This is an integer giving
3614 * a framework string resource that can be displayed to the user.
3615 */
3616 public static final String EXTRA_CLIENT_LABEL =
3617 "android.intent.extra.client_label";
3618
3619 /**
3620 * @hide
3621 * Magic extra system code can use when binding, to give a PendingIntent object
3622 * that can be launched for the user to disable the system's use of this
3623 * service.
3624 */
3625 public static final String EXTRA_CLIENT_INTENT =
3626 "android.intent.extra.client_intent";
3627
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003628 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003629 * Extra used to indicate that an intent should only return data that is on
3630 * the local device. This is a boolean extra; the default is false. If true,
3631 * an implementation should only allow the user to select data that is
3632 * already on the device, not requiring it be downloaded from a remote
3633 * service when opened.
3634 *
3635 * @see #ACTION_GET_CONTENT
3636 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003637 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003638 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003639 */
3640 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003641 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003642
Amith Yamasani13593602012-03-22 16:16:17 -07003643 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003644 * Extra used to indicate that an intent can allow the user to select and
3645 * return multiple items. This is a boolean extra; the default is false. If
3646 * true, an implementation is allowed to present the user with a UI where
3647 * they can pick multiple items that are all returned to the caller. When
3648 * this happens, they should be returned as the {@link #getClipData()} part
3649 * of the result Intent.
3650 *
3651 * @see #ACTION_GET_CONTENT
3652 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003653 */
3654 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003655 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003656
3657 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003658 * The integer userHandle carried with broadcast intents related to addition, removal and
3659 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3660 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3661 *
Amith Yamasani13593602012-03-22 16:16:17 -07003662 * @hide
3663 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003664 public static final String EXTRA_USER_HANDLE =
3665 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003666
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003667 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003668 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3669 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3670 */
3671 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003672 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003673
3674 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003675 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003676 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3677 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003678 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003679 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3680
3681 /**
3682 * Extra sent in the intent to the BroadcastReceiver that handles
3683 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3684 * the restrictions as key/value pairs.
3685 */
3686 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3687 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003688
Amith Yamasani86118ba2013-03-28 14:33:16 -07003689 /**
3690 * Extra used in the response from a BroadcastReceiver that handles
3691 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3692 */
3693 public static final String EXTRA_RESTRICTIONS_INTENT =
3694 "android.intent.extra.restrictions_intent";
3695
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003696 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003697 * Extra used to communicate a set of acceptable MIME types. The type of the
3698 * extra is {@code String[]}. Values may be a combination of concrete MIME
3699 * types (such as "image/png") and/or partial MIME types (such as
3700 * "audio/*").
3701 *
3702 * @see #ACTION_GET_CONTENT
3703 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003704 */
3705 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3706
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003707 /**
3708 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3709 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003710 * When this is true, hardware devices can use this information to determine that
3711 * they shouldn't do a complete shutdown of their device since this is not a
3712 * complete shutdown down to the kernel, but only user space restarting.
3713 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003714 */
3715 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3716 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3717
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003718 /**
3719 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3720 * user has set their time format preferences to the 24 hour format.
3721 *
3722 * @hide for internal use only.
3723 */
3724 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3725 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3726
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003727 /** {@hide} */
3728 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3729
Santos Cordon15a13782015-03-31 18:32:31 -07003730 /**
3731 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3732 * activation request.
3733 * TODO: Add information about the structure and response data used with the pending intent.
3734 * @hide
3735 */
3736 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3737 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3738
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003739 // ---------------------------------------------------------------------
3740 // ---------------------------------------------------------------------
3741 // Intent flags (see mFlags variable).
3742
Tor Norbyed9273d62013-05-30 15:59:53 -07003743 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003744 @IntDef(flag = true, value = {
3745 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3746 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003747 @Retention(RetentionPolicy.SOURCE)
3748 public @interface GrantUriMode {}
3749
Jeff Sharkey846318a2014-04-04 12:12:41 -07003750 /** @hide */
3751 @IntDef(flag = true, value = {
3752 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3753 @Retention(RetentionPolicy.SOURCE)
3754 public @interface AccessUriMode {}
3755
3756 /**
3757 * Test if given mode flags specify an access mode, which must be at least
3758 * read and/or write.
3759 *
3760 * @hide
3761 */
3762 public static boolean isAccessUriMode(int modeFlags) {
3763 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3764 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3765 }
3766
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003767 /**
3768 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003769 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003770 * specified in its ClipData. When applying to an Intent's ClipData,
3771 * all URIs as well as recursive traversals through data or other ClipData
3772 * in Intent items will be granted; only the grant flags of the top-level
3773 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003774 */
3775 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3776 /**
3777 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003778 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003779 * specified in its ClipData. When applying to an Intent's ClipData,
3780 * all URIs as well as recursive traversals through data or other ClipData
3781 * in Intent items will be granted; only the grant flags of the top-level
3782 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003783 */
3784 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3785 /**
3786 * Can be set by the caller to indicate that this Intent is coming from
3787 * a background operation, not from direct user interaction.
3788 */
3789 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3790 /**
3791 * A flag you can enable for debugging: when set, log messages will be
3792 * printed during the resolution of this intent to show you what has
3793 * been found to create the final resolved list.
3794 */
3795 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003796 /**
3797 * If set, this intent will not match any components in packages that
3798 * are currently stopped. If this is not set, then the default behavior
3799 * is to include such applications in the result.
3800 */
3801 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3802 /**
3803 * If set, this intent will always match any components in packages that
3804 * are currently stopped. This is the default behavior when
3805 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3806 * flags are set, this one wins (it allows overriding of exclude for
3807 * places where the framework may automatically set the exclude flag).
3808 */
3809 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003810
3811 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003812 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003813 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003814 * persisted across device reboots until explicitly revoked with
3815 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3816 * grant for possible persisting; the receiving application must call
3817 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3818 * actually persist.
3819 *
3820 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3821 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3822 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003823 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003824 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003825 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003826
3827 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003828 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3829 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3830 * applies to any URI that is a prefix match against the original granted
3831 * URI. (Without this flag, the URI must match exactly for access to be
3832 * granted.) Another URI is considered a prefix match only when scheme,
3833 * authority, and all path segments defined by the prefix are an exact
3834 * match.
3835 */
3836 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3837
3838 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003839 * If set, the new activity is not kept in the history stack. As soon as
3840 * the user navigates away from it, the activity is finished. This may also
3841 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3842 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003843 *
3844 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3845 * is never invoked when the current activity starts a new activity which
3846 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003847 */
3848 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3849 /**
3850 * If set, the activity will not be launched if it is already running
3851 * at the top of the history stack.
3852 */
3853 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3854 /**
3855 * If set, this activity will become the start of a new task on this
3856 * history stack. A task (from the activity that started it to the
3857 * next task activity) defines an atomic group of activities that the
3858 * user can move to. Tasks can be moved to the foreground and background;
3859 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003860 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003861 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3862 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003863 *
3864 * <p>This flag is generally used by activities that want
3865 * to present a "launcher" style behavior: they give the user a list of
3866 * separate things that can be done, which otherwise run completely
3867 * independently of the activity launching them.
3868 *
3869 * <p>When using this flag, if a task is already running for the activity
3870 * you are now starting, then a new activity will not be started; instead,
3871 * the current task will simply be brought to the front of the screen with
3872 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3873 * to disable this behavior.
3874 *
3875 * <p>This flag can not be used when the caller is requesting a result from
3876 * the activity being launched.
3877 */
3878 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3879 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003880 * This flag is used to create a new task and launch an activity into it.
3881 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3882 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3883 * search through existing tasks for ones matching this Intent. Only if no such
3884 * task is found would a new task be created. When paired with
3885 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3886 * the search for a matching task and unconditionally start a new task.
3887 *
3888 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3889 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003890 * top-level application launcher.</strong> Used in conjunction with
3891 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3892 * behavior of bringing an existing task to the foreground. When set,
3893 * a new task is <em>always</em> started to host the Activity for the
3894 * Intent, regardless of whether there is already an existing task running
3895 * the same thing.
3896 *
3897 * <p><strong>Because the default system does not include graphical task management,
3898 * you should not use this flag unless you provide some way for a user to
3899 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003900 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003901 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3902 * creating new document tasks.
3903 *
3904 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003905 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003906 *
Scott Main7aee61f2011-02-08 11:25:01 -08003907 * <p>See
3908 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3909 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003910 *
3911 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3912 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003913 */
3914 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3915 /**
3916 * If set, and the activity being launched is already running in the
3917 * current task, then instead of launching a new instance of that activity,
3918 * all of the other activities on top of it will be closed and this Intent
3919 * will be delivered to the (now on top) old activity as a new Intent.
3920 *
3921 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3922 * If D calls startActivity() with an Intent that resolves to the component
3923 * of activity B, then C and D will be finished and B receive the given
3924 * Intent, resulting in the stack now being: A, B.
3925 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003926 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003927 * either receive the new intent you are starting here in its
3928 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003929 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003930 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3931 * the same intent, then it will be finished and re-created; for all other
3932 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3933 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003934 *
3935 * <p>This launch mode can also be used to good effect in conjunction with
3936 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3937 * of a task, it will bring any currently running instance of that task
3938 * to the foreground, and then clear it to its root state. This is
3939 * especially useful, for example, when launching an activity from the
3940 * notification manager.
3941 *
Scott Main7aee61f2011-02-08 11:25:01 -08003942 * <p>See
3943 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3944 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003945 */
3946 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3947 /**
3948 * If set and this intent is being used to launch a new activity from an
3949 * existing one, then the reply target of the existing activity will be
3950 * transfered to the new activity. This way the new activity can call
3951 * {@link android.app.Activity#setResult} and have that result sent back to
3952 * the reply target of the original activity.
3953 */
3954 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3955 /**
3956 * If set and this intent is being used to launch a new activity from an
3957 * existing one, the current activity will not be counted as the top
3958 * activity for deciding whether the new intent should be delivered to
3959 * the top instead of starting a new one. The previous activity will
3960 * be used as the top, with the assumption being that the current activity
3961 * will finish itself immediately.
3962 */
3963 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3964 /**
3965 * If set, the new activity is not kept in the list of recently launched
3966 * activities.
3967 */
3968 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3969 /**
3970 * This flag is not normally set by application code, but set for you by
3971 * the system as described in the
3972 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3973 * launchMode} documentation for the singleTask mode.
3974 */
3975 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3976 /**
3977 * If set, and this activity is either being started in a new task or
3978 * bringing to the top an existing task, then it will be launched as
3979 * the front door of the task. This will result in the application of
3980 * any affinities needed to have that task in the proper state (either
3981 * moving activities to or from it), or simply resetting that task to
3982 * its initial state if needed.
3983 */
3984 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3985 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003986 * This flag is not normally set by application code, but set for you by
3987 * the system if this activity is being launched from history
3988 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003989 */
3990 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003991 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003992 * @deprecated As of API 21 this performs identically to
3993 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003994 */
3995 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003996 /**
Craig Mautner026596b2014-05-21 15:35:44 -07003997 * This flag is used to open a document into a new task rooted at the activity launched
3998 * by this Intent. Through the use of this flag, or its equivalent attribute,
3999 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004000 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004001 *
Craig Mautner026596b2014-05-21 15:35:44 -07004002 * <p>The use of the activity attribute form of this,
4003 * {@link android.R.attr#documentLaunchMode}, is
4004 * preferred over the Intent flag described here. The attribute form allows the
4005 * Activity to specify multiple document behavior for all launchers of the Activity
4006 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004007 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004008 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4009 * it is kept after the activity is finished is different than the use of
4010 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4011 * this flag is being used to create a new recents entry, then by default that entry
4012 * will be removed once the activity is finished. You can modify this behavior with
4013 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4014 *
Craig Mautner026596b2014-05-21 15:35:44 -07004015 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4016 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4017 * equivalent of the Activity manifest specifying {@link
4018 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4019 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4020 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004021 *
Craig Mautner026596b2014-05-21 15:35:44 -07004022 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004023 *
Craig Mautner026596b2014-05-21 15:35:44 -07004024 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004025 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4026 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004027 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004028 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004029 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004030 * callback from occurring on the current frontmost activity before it is
4031 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004032 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004033 * <p>Typically, an activity can rely on that callback to indicate that an
4034 * explicit user action has caused their activity to be moved out of the
4035 * foreground. The callback marks an appropriate point in the activity's
4036 * lifecycle for it to dismiss any notifications that it intends to display
4037 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004038 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004039 * <p>If an activity is ever started via any non-user-driven events such as
4040 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4041 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004042 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004043 */
4044 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004045 /**
4046 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4047 * this flag will cause the launched activity to be brought to the front of its
4048 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004049 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004050 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4051 * If D calls startActivity() with an Intent that resolves to the component
4052 * of activity B, then B will be brought to the front of the history stack,
4053 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004054 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004055 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004056 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004057 */
4058 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004059 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004060 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4061 * this flag will prevent the system from applying an activity transition
4062 * animation to go to the next activity state. This doesn't mean an
4063 * animation will never run -- if another activity change happens that doesn't
4064 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004065 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004066 * when you are going to do a series of activity operations but the
4067 * animation seen by the user shouldn't be driven by the first activity
4068 * change but rather a later one.
4069 */
4070 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4071 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004072 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4073 * this flag will cause any existing task that would be associated with the
4074 * activity to be cleared before the activity is started. That is, the activity
4075 * becomes the new root of an otherwise empty task, and any old activities
4076 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4077 */
4078 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4079 /**
4080 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4081 * this flag will cause a newly launching task to be placed on top of the current
4082 * home activity task (if there is one). That is, pressing back from the task
4083 * will always return the user to home even if that was not the last activity they
4084 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4085 */
4086 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4087 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004088 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4089 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004090 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004091 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004092 * this flag. When set and the task's activity is finished, the recents
4093 * entry will remain in the interface for the user to re-launch it, like a
4094 * recents entry for a top-level application.
4095 * <p>
4096 * The receiving activity can override this request with
4097 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4098 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004099 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004100 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004101 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004102
4103 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004104 * If set, when sending a broadcast only registered receivers will be
4105 * called -- no BroadcastReceiver components will be launched.
4106 */
4107 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004108 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004109 * If set, when sending a broadcast the new broadcast will replace
4110 * any existing pending broadcast that matches it. Matching is defined
4111 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4112 * true for the intents of the two broadcasts. When a match is found,
4113 * the new broadcast (and receivers associated with it) will replace the
4114 * existing one in the pending broadcast list, remaining at the same
4115 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004116 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004117 * <p>This flag is most typically used with sticky broadcasts, which
4118 * only care about delivering the most recent values of the broadcast
4119 * to their receivers.
4120 */
4121 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4122 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004123 * If set, when sending a broadcast the recipient is allowed to run at
4124 * foreground priority, with a shorter timeout interval. During normal
4125 * broadcasts the receivers are not automatically hoisted out of the
4126 * background priority class.
4127 */
4128 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4129 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004130 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4131 * They can still propagate results through to later receivers, but they can not prevent
4132 * later receivers from seeing the broadcast.
4133 */
4134 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4135 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004136 * If set, when sending a broadcast <i>before boot has completed</i> only
4137 * registered receivers will be called -- no BroadcastReceiver components
4138 * will be launched. Sticky intent state will be recorded properly even
4139 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4140 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004141 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004142 * <p>This flag is only for use by system sevices as a convenience to
4143 * avoid having to implement a more complex mechanism around detection
4144 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004145 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004146 * @hide
4147 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004148 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004149 /**
4150 * Set when this broadcast is for a boot upgrade, a special mode that
4151 * allows the broadcast to be sent before the system is ready and launches
4152 * the app process with no providers running in it.
4153 * @hide
4154 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004155 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004156
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004157 /**
4158 * @hide Flags that can't be changed with PendingIntent.
4159 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004160 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4161 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4162 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004163
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004164 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004165 // ---------------------------------------------------------------------
4166 // toUri() and parseUri() options.
4167
4168 /**
4169 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4170 * always has the "intent:" scheme. This syntax can be used when you want
4171 * to later disambiguate between URIs that are intended to describe an
4172 * Intent vs. all others that should be treated as raw URIs. When used
4173 * with {@link #parseUri}, any other scheme will result in a generic
4174 * VIEW action for that raw URI.
4175 */
4176 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004177
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004178 /**
4179 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4180 * always has the "android-app:" scheme. This is a variation of
4181 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4182 * http/https URI being delivered to a specific package name. The format
4183 * is:
4184 *
4185 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004186 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004187 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004188 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4189 * you must also include a scheme; including a path also requires both a host and a scheme.
4190 * The final #Intent; fragment can be used without a scheme, host, or path.
4191 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004192 * used with intents that have a {@link #setSelector}, since the base intent
4193 * will always have an explicit package name.</p>
4194 *
4195 * <p>Some examples of how this scheme maps to Intent objects:</p>
4196 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4197 * <colgroup align="left" />
4198 * <colgroup align="left" />
4199 * <thead>
4200 * <tr><th>URI</th> <th>Intent</th></tr>
4201 * </thead>
4202 *
4203 * <tbody>
4204 * <tr><td><code>android-app://com.example.app</code></td>
4205 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4206 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4207 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4208 * </table></td>
4209 * </tr>
4210 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4211 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4212 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4213 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4214 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4215 * </table></td>
4216 * </tr>
4217 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4218 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4219 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4220 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4221 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4222 * </table></td>
4223 * </tr>
4224 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4225 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4226 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4227 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4228 * </table></td>
4229 * </tr>
4230 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4231 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4232 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4233 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4234 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4235 * </table></td>
4236 * </tr>
4237 * <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>
4238 * <td><table border="" style="margin:0" >
4239 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4240 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4241 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4242 * </table></td>
4243 * </tr>
4244 * </tbody>
4245 * </table>
4246 */
4247 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4248
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004249 /**
4250 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4251 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4252 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4253 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4254 * generated Intent can not cause unexpected data access to happen.
4255 *
4256 * <p>If you do not trust the source of the URI being parsed, you should still do further
4257 * processing to protect yourself from it. In particular, when using it to start an
4258 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4259 * that can handle it.</p>
4260 */
4261 public static final int URI_ALLOW_UNSAFE = 1<<2;
4262
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004263 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004264
4265 private String mAction;
4266 private Uri mData;
4267 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004268 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004269 private ComponentName mComponent;
4270 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004271 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004272 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004273 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004274 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004275 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004276 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004277
4278 // ---------------------------------------------------------------------
4279
4280 /**
4281 * Create an empty intent.
4282 */
4283 public Intent() {
4284 }
4285
4286 /**
4287 * Copy constructor.
4288 */
4289 public Intent(Intent o) {
4290 this.mAction = o.mAction;
4291 this.mData = o.mData;
4292 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004293 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004294 this.mComponent = o.mComponent;
4295 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004296 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004297 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004298 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004299 }
4300 if (o.mExtras != null) {
4301 this.mExtras = new Bundle(o.mExtras);
4302 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004303 if (o.mSourceBounds != null) {
4304 this.mSourceBounds = new Rect(o.mSourceBounds);
4305 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004306 if (o.mSelector != null) {
4307 this.mSelector = new Intent(o.mSelector);
4308 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004309 if (o.mClipData != null) {
4310 this.mClipData = new ClipData(o.mClipData);
4311 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004312 }
4313
4314 @Override
4315 public Object clone() {
4316 return new Intent(this);
4317 }
4318
4319 private Intent(Intent o, boolean all) {
4320 this.mAction = o.mAction;
4321 this.mData = o.mData;
4322 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004323 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004324 this.mComponent = o.mComponent;
4325 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004326 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004327 }
4328 }
4329
4330 /**
4331 * Make a clone of only the parts of the Intent that are relevant for
4332 * filter matching: the action, data, type, component, and categories.
4333 */
4334 public Intent cloneFilter() {
4335 return new Intent(this, false);
4336 }
4337
4338 /**
4339 * Create an intent with a given action. All other fields (data, type,
4340 * class) are null. Note that the action <em>must</em> be in a
4341 * namespace because Intents are used globally in the system -- for
4342 * example the system VIEW action is android.intent.action.VIEW; an
4343 * application's custom action would be something like
4344 * com.google.app.myapp.CUSTOM_ACTION.
4345 *
4346 * @param action The Intent action, such as ACTION_VIEW.
4347 */
4348 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004349 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004350 }
4351
4352 /**
4353 * Create an intent with a given action and for a given data url. Note
4354 * that the action <em>must</em> be in a namespace because Intents are
4355 * used globally in the system -- for example the system VIEW action is
4356 * android.intent.action.VIEW; an application's custom action would be
4357 * something like com.google.app.myapp.CUSTOM_ACTION.
4358 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004359 * <p><em>Note: scheme and host name matching in the Android framework is
4360 * case-sensitive, unlike the formal RFC. As a result,
4361 * you should always ensure that you write your Uri with these elements
4362 * using lower case letters, and normalize any Uris you receive from
4363 * outside of Android to ensure the scheme and host is lower case.</em></p>
4364 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004365 * @param action The Intent action, such as ACTION_VIEW.
4366 * @param uri The Intent data URI.
4367 */
4368 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004369 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004370 mData = uri;
4371 }
4372
4373 /**
4374 * Create an intent for a specific component. All other fields (action, data,
4375 * type, class) are null, though they can be modified later with explicit
4376 * calls. This provides a convenient way to create an intent that is
4377 * intended to execute a hard-coded class name, rather than relying on the
4378 * system to find an appropriate class for you; see {@link #setComponent}
4379 * for more information on the repercussions of this.
4380 *
4381 * @param packageContext A Context of the application package implementing
4382 * this class.
4383 * @param cls The component class that is to be used for the intent.
4384 *
4385 * @see #setClass
4386 * @see #setComponent
4387 * @see #Intent(String, android.net.Uri , Context, Class)
4388 */
4389 public Intent(Context packageContext, Class<?> cls) {
4390 mComponent = new ComponentName(packageContext, cls);
4391 }
4392
4393 /**
4394 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004395 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004396 * construct the Intent and then calling {@link #setClass} to set its
4397 * class.
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 * @param packageContext A Context of the application package implementing
4408 * this class.
4409 * @param cls The component class that is to be used for the intent.
4410 *
4411 * @see #Intent(String, android.net.Uri)
4412 * @see #Intent(Context, Class)
4413 * @see #setClass
4414 * @see #setComponent
4415 */
4416 public Intent(String action, Uri uri,
4417 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004418 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004419 mData = uri;
4420 mComponent = new ComponentName(packageContext, cls);
4421 }
4422
4423 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004424 * Create an intent to launch the main (root) activity of a task. This
4425 * is the Intent that is started when the application's is launched from
4426 * Home. For anything else that wants to launch an application in the
4427 * same way, it is important that they use an Intent structured the same
4428 * way, and can use this function to ensure this is the case.
4429 *
4430 * <p>The returned Intent has the given Activity component as its explicit
4431 * component, {@link #ACTION_MAIN} as its action, and includes the
4432 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4433 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4434 * to do that through {@link #addFlags(int)} on the returned Intent.
4435 *
4436 * @param mainActivity The main activity component that this Intent will
4437 * launch.
4438 * @return Returns a newly created Intent that can be used to launch the
4439 * activity as a main application entry.
4440 *
4441 * @see #setClass
4442 * @see #setComponent
4443 */
4444 public static Intent makeMainActivity(ComponentName mainActivity) {
4445 Intent intent = new Intent(ACTION_MAIN);
4446 intent.setComponent(mainActivity);
4447 intent.addCategory(CATEGORY_LAUNCHER);
4448 return intent;
4449 }
4450
4451 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004452 * Make an Intent for the main activity of an application, without
4453 * specifying a specific activity to run but giving a selector to find
4454 * the activity. This results in a final Intent that is structured
4455 * the same as when the application is launched from
4456 * Home. For anything else that wants to launch an application in the
4457 * same way, it is important that they use an Intent structured the same
4458 * way, and can use this function to ensure this is the case.
4459 *
4460 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4461 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4462 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4463 * to do that through {@link #addFlags(int)} on the returned Intent.
4464 *
4465 * @param selectorAction The action name of the Intent's selector.
4466 * @param selectorCategory The name of a category to add to the Intent's
4467 * selector.
4468 * @return Returns a newly created Intent that can be used to launch the
4469 * activity as a main application entry.
4470 *
4471 * @see #setSelector(Intent)
4472 */
4473 public static Intent makeMainSelectorActivity(String selectorAction,
4474 String selectorCategory) {
4475 Intent intent = new Intent(ACTION_MAIN);
4476 intent.addCategory(CATEGORY_LAUNCHER);
4477 Intent selector = new Intent();
4478 selector.setAction(selectorAction);
4479 selector.addCategory(selectorCategory);
4480 intent.setSelector(selector);
4481 return intent;
4482 }
4483
4484 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004485 * Make an Intent that can be used to re-launch an application's task
4486 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4487 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4488 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4489 *
4490 * @param mainActivity The activity component that is the root of the
4491 * task; this is the activity that has been published in the application's
4492 * manifest as the main launcher icon.
4493 *
4494 * @return Returns a newly created Intent that can be used to relaunch the
4495 * activity's task in its root state.
4496 */
4497 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4498 Intent intent = makeMainActivity(mainActivity);
4499 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4500 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4501 return intent;
4502 }
4503
4504 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004505 * Call {@link #parseUri} with 0 flags.
4506 * @deprecated Use {@link #parseUri} instead.
4507 */
4508 @Deprecated
4509 public static Intent getIntent(String uri) throws URISyntaxException {
4510 return parseUri(uri, 0);
4511 }
Tom Taylord4a47292009-12-21 13:59:18 -08004512
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004513 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004514 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004515 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004516 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004517 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004518 *
4519 * <p>The URI given here must not be relative -- that is, it must include
4520 * the scheme and full path.
4521 *
4522 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004523 * @param flags Additional processing flags. Either 0,
4524 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004525 *
4526 * @return Intent The newly created Intent object.
4527 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004528 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4529 * it bad (as parsed by the Uri class) or the Intent data within the
4530 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004531 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004532 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004533 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004534 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004535 int i = 0;
4536 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004537 final boolean androidApp = uri.startsWith("android-app:");
4538
4539 // Validate intent scheme if requested.
4540 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4541 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004542 Intent intent = new Intent(ACTION_VIEW);
4543 try {
4544 intent.setData(Uri.parse(uri));
4545 } catch (IllegalArgumentException e) {
4546 throw new URISyntaxException(uri, e.getMessage());
4547 }
4548 return intent;
4549 }
4550 }
Tom Taylord4a47292009-12-21 13:59:18 -08004551
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004552 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004553 // simple case
4554 if (i == -1) {
4555 if (!androidApp) {
4556 return new Intent(ACTION_VIEW, Uri.parse(uri));
4557 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004558
4559 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004560 } else if (!uri.startsWith("#Intent;", i)) {
4561 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004562 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004563 } else {
4564 i = -1;
4565 }
4566 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004567
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004568 // new format
4569 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004570 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004571 boolean explicitAction = false;
4572 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004573
4574 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004575 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004576 String data;
4577 if (i >= 0) {
4578 data = uri.substring(0, i);
4579 i += 8; // length of "#Intent;"
4580 } else {
4581 data = uri;
4582 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004583
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004584 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004585 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004586 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004587 if (eq < 0) eq = i-1;
4588 int semi = uri.indexOf(';', i);
4589 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004590
4591 // action
4592 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004593 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004594 if (!inSelector) {
4595 explicitAction = true;
4596 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004597 }
4598
4599 // categories
4600 else if (uri.startsWith("category=", i)) {
4601 intent.addCategory(value);
4602 }
4603
4604 // type
4605 else if (uri.startsWith("type=", i)) {
4606 intent.mType = value;
4607 }
4608
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004609 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004610 else if (uri.startsWith("launchFlags=", i)) {
4611 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004612 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4613 intent.mFlags &= ~IMMUTABLE_FLAGS;
4614 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004615 }
4616
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004617 // package
4618 else if (uri.startsWith("package=", i)) {
4619 intent.mPackage = value;
4620 }
4621
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004622 // component
4623 else if (uri.startsWith("component=", i)) {
4624 intent.mComponent = ComponentName.unflattenFromString(value);
4625 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004626
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004627 // scheme
4628 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004629 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004630 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004631 } else {
4632 scheme = value;
4633 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004634 }
4635
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004636 // source bounds
4637 else if (uri.startsWith("sourceBounds=", i)) {
4638 intent.mSourceBounds = Rect.unflattenFromString(value);
4639 }
4640
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004641 // selector
4642 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4643 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004644 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004645 }
4646
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004647 // extra
4648 else {
4649 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004650 // create Bundle if it doesn't already exist
4651 if (intent.mExtras == null) intent.mExtras = new Bundle();
4652 Bundle b = intent.mExtras;
4653 // add EXTRA
4654 if (uri.startsWith("S.", i)) b.putString(key, value);
4655 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4656 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4657 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4658 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4659 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4660 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4661 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4662 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4663 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4664 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004665
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004666 // move to the next item
4667 i = semi + 1;
4668 }
4669
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004670 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004671 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004672 if (baseIntent.mPackage == null) {
4673 baseIntent.setSelector(intent);
4674 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004675 intent = baseIntent;
4676 }
4677
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004678 if (data != null) {
4679 if (data.startsWith("intent:")) {
4680 data = data.substring(7);
4681 if (scheme != null) {
4682 data = scheme + ':' + data;
4683 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004684 } else if (data.startsWith("android-app:")) {
4685 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4686 // Correctly formed android-app, first part is package name.
4687 int end = data.indexOf('/', 14);
4688 if (end < 0) {
4689 // All we have is a package name.
4690 intent.mPackage = data.substring(14);
4691 if (!explicitAction) {
4692 intent.setAction(ACTION_MAIN);
4693 }
4694 data = "";
4695 } else {
4696 // Target the Intent at the given package name always.
4697 String authority = null;
4698 intent.mPackage = data.substring(14, end);
4699 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004700 if ((end+1) < data.length()) {
4701 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4702 // Found a scheme, remember it.
4703 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004704 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004705 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4706 // Found a authority, remember it.
4707 authority = data.substring(end+1, newEnd);
4708 end = newEnd;
4709 }
4710 } else {
4711 // All we have is a scheme.
4712 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004713 }
4714 }
4715 if (scheme == null) {
4716 // If there was no scheme, then this just targets the package.
4717 if (!explicitAction) {
4718 intent.setAction(ACTION_MAIN);
4719 }
4720 data = "";
4721 } else if (authority == null) {
4722 data = scheme + ":";
4723 } else {
4724 data = scheme + "://" + authority + data.substring(end);
4725 }
4726 }
4727 } else {
4728 data = "";
4729 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004730 }
Tom Taylord4a47292009-12-21 13:59:18 -08004731
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004732 if (data.length() > 0) {
4733 try {
4734 intent.mData = Uri.parse(data);
4735 } catch (IllegalArgumentException e) {
4736 throw new URISyntaxException(uri, e.getMessage());
4737 }
4738 }
4739 }
Tom Taylord4a47292009-12-21 13:59:18 -08004740
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004742
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004743 } catch (IndexOutOfBoundsException e) {
4744 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4745 }
4746 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004747
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004748 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004749 return getIntentOld(uri, 0);
4750 }
4751
4752 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004753 Intent intent;
4754
4755 int i = uri.lastIndexOf('#');
4756 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004757 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004758 final int intentFragmentStart = i;
4759 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004760
4761 i++;
4762
4763 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004764 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004765 i += 7;
4766 int j = uri.indexOf(')', i);
4767 action = uri.substring(i, j);
4768 i = j + 1;
4769 }
4770
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004771 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004772
4773 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004774 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004775 i += 11;
4776 int j = uri.indexOf(')', i);
4777 while (i < j) {
4778 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004779 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004780 if (i < sep) {
4781 intent.addCategory(uri.substring(i, sep));
4782 }
4783 i = sep + 1;
4784 }
4785 i = j + 1;
4786 }
4787
4788 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004789 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004790 i += 5;
4791 int j = uri.indexOf(')', i);
4792 intent.mType = uri.substring(i, j);
4793 i = j + 1;
4794 }
4795
4796 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004797 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004798 i += 12;
4799 int j = uri.indexOf(')', i);
4800 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004801 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4802 intent.mFlags &= ~IMMUTABLE_FLAGS;
4803 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004804 i = j + 1;
4805 }
4806
4807 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004808 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004809 i += 10;
4810 int j = uri.indexOf(')', i);
4811 int sep = uri.indexOf('!', i);
4812 if (sep >= 0 && sep < j) {
4813 String pkg = uri.substring(i, sep);
4814 String cls = uri.substring(sep + 1, j);
4815 intent.mComponent = new ComponentName(pkg, cls);
4816 }
4817 i = j + 1;
4818 }
4819
4820 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004821 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004822 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004823
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004824 final int closeParen = uri.indexOf(')', i);
4825 if (closeParen == -1) throw new URISyntaxException(uri,
4826 "EXTRA missing trailing ')'", i);
4827
4828 while (i < closeParen) {
4829 // fetch the key value
4830 int j = uri.indexOf('=', i);
4831 if (j <= i + 1 || i >= closeParen) {
4832 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4833 }
4834 char type = uri.charAt(i);
4835 i++;
4836 String key = uri.substring(i, j);
4837 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004838
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004839 // get type-value
4840 j = uri.indexOf('!', i);
4841 if (j == -1 || j >= closeParen) j = closeParen;
4842 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4843 String value = uri.substring(i, j);
4844 i = j;
4845
4846 // create Bundle if it doesn't already exist
4847 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004848
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004849 // add item to bundle
4850 try {
4851 switch (type) {
4852 case 'S':
4853 intent.mExtras.putString(key, Uri.decode(value));
4854 break;
4855 case 'B':
4856 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4857 break;
4858 case 'b':
4859 intent.mExtras.putByte(key, Byte.parseByte(value));
4860 break;
4861 case 'c':
4862 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4863 break;
4864 case 'd':
4865 intent.mExtras.putDouble(key, Double.parseDouble(value));
4866 break;
4867 case 'f':
4868 intent.mExtras.putFloat(key, Float.parseFloat(value));
4869 break;
4870 case 'i':
4871 intent.mExtras.putInt(key, Integer.parseInt(value));
4872 break;
4873 case 'l':
4874 intent.mExtras.putLong(key, Long.parseLong(value));
4875 break;
4876 case 's':
4877 intent.mExtras.putShort(key, Short.parseShort(value));
4878 break;
4879 default:
4880 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4881 }
4882 } catch (NumberFormatException e) {
4883 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4884 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004885
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004886 char ch = uri.charAt(i);
4887 if (ch == ')') break;
4888 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4889 i++;
4890 }
4891 }
4892
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004893 if (isIntentFragment) {
4894 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4895 } else {
4896 intent.mData = Uri.parse(uri);
4897 }
Tom Taylord4a47292009-12-21 13:59:18 -08004898
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004899 if (intent.mAction == null) {
4900 // By default, if no action is specified, then use VIEW.
4901 intent.mAction = ACTION_VIEW;
4902 }
4903
4904 } else {
4905 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4906 }
4907
4908 return intent;
4909 }
4910
4911 /**
4912 * Retrieve the general action to be performed, such as
4913 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4914 * the information in the intent should be interpreted -- most importantly,
4915 * what to do with the data returned by {@link #getData}.
4916 *
4917 * @return The action of this intent or null if none is specified.
4918 *
4919 * @see #setAction
4920 */
4921 public String getAction() {
4922 return mAction;
4923 }
4924
4925 /**
4926 * Retrieve data this intent is operating on. This URI specifies the name
4927 * of the data; often it uses the content: scheme, specifying data in a
4928 * content provider. Other schemes may be handled by specific activities,
4929 * such as http: by the web browser.
4930 *
4931 * @return The URI of the data this intent is targeting or null.
4932 *
4933 * @see #getScheme
4934 * @see #setData
4935 */
4936 public Uri getData() {
4937 return mData;
4938 }
4939
4940 /**
4941 * The same as {@link #getData()}, but returns the URI as an encoded
4942 * String.
4943 */
4944 public String getDataString() {
4945 return mData != null ? mData.toString() : null;
4946 }
4947
4948 /**
4949 * Return the scheme portion of the intent's data. If the data is null or
4950 * does not include a scheme, null is returned. Otherwise, the scheme
4951 * prefix without the final ':' is returned, i.e. "http".
4952 *
4953 * <p>This is the same as calling getData().getScheme() (and checking for
4954 * null data).
4955 *
4956 * @return The scheme of this intent.
4957 *
4958 * @see #getData
4959 */
4960 public String getScheme() {
4961 return mData != null ? mData.getScheme() : null;
4962 }
4963
4964 /**
4965 * Retrieve any explicit MIME type included in the intent. This is usually
4966 * null, as the type is determined by the intent data.
4967 *
4968 * @return If a type was manually set, it is returned; else null is
4969 * returned.
4970 *
4971 * @see #resolveType(ContentResolver)
4972 * @see #setType
4973 */
4974 public String getType() {
4975 return mType;
4976 }
4977
4978 /**
4979 * Return the MIME data type of this intent. If the type field is
4980 * explicitly set, that is simply returned. Otherwise, if the data is set,
4981 * the type of that data is returned. If neither fields are set, a null is
4982 * returned.
4983 *
4984 * @return The MIME type of this intent.
4985 *
4986 * @see #getType
4987 * @see #resolveType(ContentResolver)
4988 */
4989 public String resolveType(Context context) {
4990 return resolveType(context.getContentResolver());
4991 }
4992
4993 /**
4994 * Return the MIME data type of this intent. If the type field is
4995 * explicitly set, that is simply returned. Otherwise, if the data is set,
4996 * the type of that data is returned. If neither fields are set, a null is
4997 * returned.
4998 *
4999 * @param resolver A ContentResolver that can be used to determine the MIME
5000 * type of the intent's data.
5001 *
5002 * @return The MIME type of this intent.
5003 *
5004 * @see #getType
5005 * @see #resolveType(Context)
5006 */
5007 public String resolveType(ContentResolver resolver) {
5008 if (mType != null) {
5009 return mType;
5010 }
5011 if (mData != null) {
5012 if ("content".equals(mData.getScheme())) {
5013 return resolver.getType(mData);
5014 }
5015 }
5016 return null;
5017 }
5018
5019 /**
5020 * Return the MIME data type of this intent, only if it will be needed for
5021 * intent resolution. This is not generally useful for application code;
5022 * it is used by the frameworks for communicating with back-end system
5023 * services.
5024 *
5025 * @param resolver A ContentResolver that can be used to determine the MIME
5026 * type of the intent's data.
5027 *
5028 * @return The MIME type of this intent, or null if it is unknown or not
5029 * needed.
5030 */
5031 public String resolveTypeIfNeeded(ContentResolver resolver) {
5032 if (mComponent != null) {
5033 return mType;
5034 }
5035 return resolveType(resolver);
5036 }
5037
5038 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005039 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005040 *
5041 * @param category The category to check.
5042 *
5043 * @return boolean True if the intent contains the category, else false.
5044 *
5045 * @see #getCategories
5046 * @see #addCategory
5047 */
5048 public boolean hasCategory(String category) {
5049 return mCategories != null && mCategories.contains(category);
5050 }
5051
5052 /**
5053 * Return the set of all categories in the intent. If there are no categories,
5054 * returns NULL.
5055 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005056 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005057 *
5058 * @see #hasCategory
5059 * @see #addCategory
5060 */
5061 public Set<String> getCategories() {
5062 return mCategories;
5063 }
5064
5065 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005066 * Return the specific selector associated with this Intent. If there is
5067 * none, returns null. See {@link #setSelector} for more information.
5068 *
5069 * @see #setSelector
5070 */
5071 public Intent getSelector() {
5072 return mSelector;
5073 }
5074
5075 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005076 * Return the {@link ClipData} associated with this Intent. If there is
5077 * none, returns null. See {@link #setClipData} for more information.
5078 *
John Spurlock125d1332013-11-25 11:58:37 -05005079 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005080 */
5081 public ClipData getClipData() {
5082 return mClipData;
5083 }
5084
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005085 /** @hide */
5086 public int getContentUserHint() {
5087 return mContentUserHint;
5088 }
5089
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005090 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005091 * Sets the ClassLoader that will be used when unmarshalling
5092 * any Parcelable values from the extras of this Intent.
5093 *
5094 * @param loader a ClassLoader, or null to use the default loader
5095 * at the time of unmarshalling.
5096 */
5097 public void setExtrasClassLoader(ClassLoader loader) {
5098 if (mExtras != null) {
5099 mExtras.setClassLoader(loader);
5100 }
5101 }
5102
5103 /**
5104 * Returns true if an extra value is associated with the given name.
5105 * @param name the extra's name
5106 * @return true if the given extra is present.
5107 */
5108 public boolean hasExtra(String name) {
5109 return mExtras != null && mExtras.containsKey(name);
5110 }
5111
5112 /**
5113 * Returns true if the Intent's extras contain a parcelled file descriptor.
5114 * @return true if the Intent contains a parcelled file descriptor.
5115 */
5116 public boolean hasFileDescriptors() {
5117 return mExtras != null && mExtras.hasFileDescriptors();
5118 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005119
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005120 /** @hide */
5121 public void setAllowFds(boolean allowFds) {
5122 if (mExtras != null) {
5123 mExtras.setAllowFds(allowFds);
5124 }
5125 }
5126
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005127 /**
5128 * Retrieve extended data from the intent.
5129 *
5130 * @param name The name of the desired item.
5131 *
5132 * @return the value of an item that previously added with putExtra()
5133 * or null if none was found.
5134 *
5135 * @deprecated
5136 * @hide
5137 */
5138 @Deprecated
5139 public Object getExtra(String name) {
5140 return getExtra(name, null);
5141 }
5142
5143 /**
5144 * Retrieve extended data from the intent.
5145 *
5146 * @param name The name of the desired item.
5147 * @param defaultValue the value to be returned if no value of the desired
5148 * type is stored with the given name.
5149 *
5150 * @return the value of an item that previously added with putExtra()
5151 * or the default value if none was found.
5152 *
5153 * @see #putExtra(String, boolean)
5154 */
5155 public boolean getBooleanExtra(String name, boolean defaultValue) {
5156 return mExtras == null ? defaultValue :
5157 mExtras.getBoolean(name, defaultValue);
5158 }
5159
5160 /**
5161 * Retrieve extended data from the intent.
5162 *
5163 * @param name The name of the desired item.
5164 * @param defaultValue the value to be returned if no value of the desired
5165 * type is stored with the given name.
5166 *
5167 * @return the value of an item that previously added with putExtra()
5168 * or the default value if none was found.
5169 *
5170 * @see #putExtra(String, byte)
5171 */
5172 public byte getByteExtra(String name, byte defaultValue) {
5173 return mExtras == null ? defaultValue :
5174 mExtras.getByte(name, defaultValue);
5175 }
5176
5177 /**
5178 * Retrieve extended data from the intent.
5179 *
5180 * @param name The name of the desired item.
5181 * @param defaultValue the value to be returned if no value of the desired
5182 * type is stored with the given name.
5183 *
5184 * @return the value of an item that previously added with putExtra()
5185 * or the default value if none was found.
5186 *
5187 * @see #putExtra(String, short)
5188 */
5189 public short getShortExtra(String name, short defaultValue) {
5190 return mExtras == null ? defaultValue :
5191 mExtras.getShort(name, defaultValue);
5192 }
5193
5194 /**
5195 * Retrieve extended data from the intent.
5196 *
5197 * @param name The name of the desired item.
5198 * @param defaultValue the value to be returned if no value of the desired
5199 * type is stored with the given name.
5200 *
5201 * @return the value of an item that previously added with putExtra()
5202 * or the default value if none was found.
5203 *
5204 * @see #putExtra(String, char)
5205 */
5206 public char getCharExtra(String name, char defaultValue) {
5207 return mExtras == null ? defaultValue :
5208 mExtras.getChar(name, defaultValue);
5209 }
5210
5211 /**
5212 * Retrieve extended data from the intent.
5213 *
5214 * @param name The name of the desired item.
5215 * @param defaultValue the value to be returned if no value of the desired
5216 * type is stored with the given name.
5217 *
5218 * @return the value of an item that previously added with putExtra()
5219 * or the default value if none was found.
5220 *
5221 * @see #putExtra(String, int)
5222 */
5223 public int getIntExtra(String name, int defaultValue) {
5224 return mExtras == null ? defaultValue :
5225 mExtras.getInt(name, defaultValue);
5226 }
5227
5228 /**
5229 * Retrieve extended data from the intent.
5230 *
5231 * @param name The name of the desired item.
5232 * @param defaultValue the value to be returned if no value of the desired
5233 * type is stored with the given name.
5234 *
5235 * @return the value of an item that previously added with putExtra()
5236 * or the default value if none was found.
5237 *
5238 * @see #putExtra(String, long)
5239 */
5240 public long getLongExtra(String name, long defaultValue) {
5241 return mExtras == null ? defaultValue :
5242 mExtras.getLong(name, defaultValue);
5243 }
5244
5245 /**
5246 * Retrieve extended data from the intent.
5247 *
5248 * @param name The name of the desired item.
5249 * @param defaultValue the value to be returned if no value of the desired
5250 * type is stored with the given name.
5251 *
5252 * @return the value of an item that previously added with putExtra(),
5253 * or the default value if no such item is present
5254 *
5255 * @see #putExtra(String, float)
5256 */
5257 public float getFloatExtra(String name, float defaultValue) {
5258 return mExtras == null ? defaultValue :
5259 mExtras.getFloat(name, defaultValue);
5260 }
5261
5262 /**
5263 * Retrieve extended data from the intent.
5264 *
5265 * @param name The name of the desired item.
5266 * @param defaultValue the value to be returned if no value of the desired
5267 * type is stored with the given name.
5268 *
5269 * @return the value of an item that previously added with putExtra()
5270 * or the default value if none was found.
5271 *
5272 * @see #putExtra(String, double)
5273 */
5274 public double getDoubleExtra(String name, double defaultValue) {
5275 return mExtras == null ? defaultValue :
5276 mExtras.getDouble(name, defaultValue);
5277 }
5278
5279 /**
5280 * Retrieve extended data from the intent.
5281 *
5282 * @param name The name of the desired item.
5283 *
5284 * @return the value of an item that previously added with putExtra()
5285 * or null if no String value was found.
5286 *
5287 * @see #putExtra(String, String)
5288 */
5289 public String getStringExtra(String name) {
5290 return mExtras == null ? null : mExtras.getString(name);
5291 }
5292
5293 /**
5294 * Retrieve extended data from the intent.
5295 *
5296 * @param name The name of the desired item.
5297 *
5298 * @return the value of an item that previously added with putExtra()
5299 * or null if no CharSequence value was found.
5300 *
5301 * @see #putExtra(String, CharSequence)
5302 */
5303 public CharSequence getCharSequenceExtra(String name) {
5304 return mExtras == null ? null : mExtras.getCharSequence(name);
5305 }
5306
5307 /**
5308 * Retrieve extended data from the intent.
5309 *
5310 * @param name The name of the desired item.
5311 *
5312 * @return the value of an item that previously added with putExtra()
5313 * or null if no Parcelable value was found.
5314 *
5315 * @see #putExtra(String, Parcelable)
5316 */
5317 public <T extends Parcelable> T getParcelableExtra(String name) {
5318 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5319 }
5320
5321 /**
5322 * Retrieve extended data from the intent.
5323 *
5324 * @param name The name of the desired item.
5325 *
5326 * @return the value of an item that previously added with putExtra()
5327 * or null if no Parcelable[] value was found.
5328 *
5329 * @see #putExtra(String, Parcelable[])
5330 */
5331 public Parcelable[] getParcelableArrayExtra(String name) {
5332 return mExtras == null ? null : mExtras.getParcelableArray(name);
5333 }
5334
5335 /**
5336 * Retrieve extended data from the intent.
5337 *
5338 * @param name The name of the desired item.
5339 *
5340 * @return the value of an item that previously added with putExtra()
5341 * or null if no ArrayList<Parcelable> value was found.
5342 *
5343 * @see #putParcelableArrayListExtra(String, ArrayList)
5344 */
5345 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5346 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5347 }
5348
5349 /**
5350 * Retrieve extended data from the intent.
5351 *
5352 * @param name The name of the desired item.
5353 *
5354 * @return the value of an item that previously added with putExtra()
5355 * or null if no Serializable value was found.
5356 *
5357 * @see #putExtra(String, Serializable)
5358 */
5359 public Serializable getSerializableExtra(String name) {
5360 return mExtras == null ? null : mExtras.getSerializable(name);
5361 }
5362
5363 /**
5364 * Retrieve extended data from the intent.
5365 *
5366 * @param name The name of the desired item.
5367 *
5368 * @return the value of an item that previously added with putExtra()
5369 * or null if no ArrayList<Integer> value was found.
5370 *
5371 * @see #putIntegerArrayListExtra(String, ArrayList)
5372 */
5373 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5374 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5375 }
5376
5377 /**
5378 * Retrieve extended data from the intent.
5379 *
5380 * @param name The name of the desired item.
5381 *
5382 * @return the value of an item that previously added with putExtra()
5383 * or null if no ArrayList<String> value was found.
5384 *
5385 * @see #putStringArrayListExtra(String, ArrayList)
5386 */
5387 public ArrayList<String> getStringArrayListExtra(String name) {
5388 return mExtras == null ? null : mExtras.getStringArrayList(name);
5389 }
5390
5391 /**
5392 * Retrieve extended data from the intent.
5393 *
5394 * @param name The name of the desired item.
5395 *
5396 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005397 * or null if no ArrayList<CharSequence> value was found.
5398 *
5399 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5400 */
5401 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5402 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5403 }
5404
5405 /**
5406 * Retrieve extended data from the intent.
5407 *
5408 * @param name The name of the desired item.
5409 *
5410 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005411 * or null if no boolean array value was found.
5412 *
5413 * @see #putExtra(String, boolean[])
5414 */
5415 public boolean[] getBooleanArrayExtra(String name) {
5416 return mExtras == null ? null : mExtras.getBooleanArray(name);
5417 }
5418
5419 /**
5420 * Retrieve extended data from the intent.
5421 *
5422 * @param name The name of the desired item.
5423 *
5424 * @return the value of an item that previously added with putExtra()
5425 * or null if no byte array value was found.
5426 *
5427 * @see #putExtra(String, byte[])
5428 */
5429 public byte[] getByteArrayExtra(String name) {
5430 return mExtras == null ? null : mExtras.getByteArray(name);
5431 }
5432
5433 /**
5434 * Retrieve extended data from the intent.
5435 *
5436 * @param name The name of the desired item.
5437 *
5438 * @return the value of an item that previously added with putExtra()
5439 * or null if no short array value was found.
5440 *
5441 * @see #putExtra(String, short[])
5442 */
5443 public short[] getShortArrayExtra(String name) {
5444 return mExtras == null ? null : mExtras.getShortArray(name);
5445 }
5446
5447 /**
5448 * Retrieve extended data from the intent.
5449 *
5450 * @param name The name of the desired item.
5451 *
5452 * @return the value of an item that previously added with putExtra()
5453 * or null if no char array value was found.
5454 *
5455 * @see #putExtra(String, char[])
5456 */
5457 public char[] getCharArrayExtra(String name) {
5458 return mExtras == null ? null : mExtras.getCharArray(name);
5459 }
5460
5461 /**
5462 * Retrieve extended data from the intent.
5463 *
5464 * @param name The name of the desired item.
5465 *
5466 * @return the value of an item that previously added with putExtra()
5467 * or null if no int array value was found.
5468 *
5469 * @see #putExtra(String, int[])
5470 */
5471 public int[] getIntArrayExtra(String name) {
5472 return mExtras == null ? null : mExtras.getIntArray(name);
5473 }
5474
5475 /**
5476 * Retrieve extended data from the intent.
5477 *
5478 * @param name The name of the desired item.
5479 *
5480 * @return the value of an item that previously added with putExtra()
5481 * or null if no long array value was found.
5482 *
5483 * @see #putExtra(String, long[])
5484 */
5485 public long[] getLongArrayExtra(String name) {
5486 return mExtras == null ? null : mExtras.getLongArray(name);
5487 }
5488
5489 /**
5490 * Retrieve extended data from the intent.
5491 *
5492 * @param name The name of the desired item.
5493 *
5494 * @return the value of an item that previously added with putExtra()
5495 * or null if no float array value was found.
5496 *
5497 * @see #putExtra(String, float[])
5498 */
5499 public float[] getFloatArrayExtra(String name) {
5500 return mExtras == null ? null : mExtras.getFloatArray(name);
5501 }
5502
5503 /**
5504 * Retrieve extended data from the intent.
5505 *
5506 * @param name The name of the desired item.
5507 *
5508 * @return the value of an item that previously added with putExtra()
5509 * or null if no double array value was found.
5510 *
5511 * @see #putExtra(String, double[])
5512 */
5513 public double[] getDoubleArrayExtra(String name) {
5514 return mExtras == null ? null : mExtras.getDoubleArray(name);
5515 }
5516
5517 /**
5518 * Retrieve extended data from the intent.
5519 *
5520 * @param name The name of the desired item.
5521 *
5522 * @return the value of an item that previously added with putExtra()
5523 * or null if no String array value was found.
5524 *
5525 * @see #putExtra(String, String[])
5526 */
5527 public String[] getStringArrayExtra(String name) {
5528 return mExtras == null ? null : mExtras.getStringArray(name);
5529 }
5530
5531 /**
5532 * Retrieve extended data from the intent.
5533 *
5534 * @param name The name of the desired item.
5535 *
5536 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005537 * or null if no CharSequence array value was found.
5538 *
5539 * @see #putExtra(String, CharSequence[])
5540 */
5541 public CharSequence[] getCharSequenceArrayExtra(String name) {
5542 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5543 }
5544
5545 /**
5546 * Retrieve extended data from the intent.
5547 *
5548 * @param name The name of the desired item.
5549 *
5550 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005551 * or null if no Bundle value was found.
5552 *
5553 * @see #putExtra(String, Bundle)
5554 */
5555 public Bundle getBundleExtra(String name) {
5556 return mExtras == null ? null : mExtras.getBundle(name);
5557 }
5558
5559 /**
5560 * Retrieve extended data from the intent.
5561 *
5562 * @param name The name of the desired item.
5563 *
5564 * @return the value of an item that previously added with putExtra()
5565 * or null if no IBinder value was found.
5566 *
5567 * @see #putExtra(String, IBinder)
5568 *
5569 * @deprecated
5570 * @hide
5571 */
5572 @Deprecated
5573 public IBinder getIBinderExtra(String name) {
5574 return mExtras == null ? null : mExtras.getIBinder(name);
5575 }
5576
5577 /**
5578 * Retrieve extended data from the intent.
5579 *
5580 * @param name The name of the desired item.
5581 * @param defaultValue The default value to return in case no item is
5582 * associated with the key 'name'
5583 *
5584 * @return the value of an item that previously added with putExtra()
5585 * or defaultValue if none was found.
5586 *
5587 * @see #putExtra
5588 *
5589 * @deprecated
5590 * @hide
5591 */
5592 @Deprecated
5593 public Object getExtra(String name, Object defaultValue) {
5594 Object result = defaultValue;
5595 if (mExtras != null) {
5596 Object result2 = mExtras.get(name);
5597 if (result2 != null) {
5598 result = result2;
5599 }
5600 }
5601
5602 return result;
5603 }
5604
5605 /**
5606 * Retrieves a map of extended data from the intent.
5607 *
5608 * @return the map of all extras previously added with putExtra(),
5609 * or null if none have been added.
5610 */
5611 public Bundle getExtras() {
5612 return (mExtras != null)
5613 ? new Bundle(mExtras)
5614 : null;
5615 }
5616
5617 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005618 * Filter extras to only basic types.
5619 * @hide
5620 */
5621 public void removeUnsafeExtras() {
5622 if (mExtras != null) {
5623 mExtras.filterValues();
5624 }
5625 }
5626
5627 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005628 * Retrieve any special flags associated with this intent. You will
5629 * normally just set them with {@link #setFlags} and let the system
5630 * take the appropriate action with them.
5631 *
5632 * @return int The currently set flags.
5633 *
5634 * @see #setFlags
5635 */
5636 public int getFlags() {
5637 return mFlags;
5638 }
5639
Dianne Hackborne7f97212011-02-24 14:40:20 -08005640 /** @hide */
5641 public boolean isExcludingStopped() {
5642 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5643 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5644 }
5645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005646 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005647 * Retrieve the application package name this Intent is limited to. When
5648 * resolving an Intent, if non-null this limits the resolution to only
5649 * components in the given application package.
5650 *
5651 * @return The name of the application package for the Intent.
5652 *
5653 * @see #resolveActivity
5654 * @see #setPackage
5655 */
5656 public String getPackage() {
5657 return mPackage;
5658 }
5659
5660 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005661 * Retrieve the concrete component associated with the intent. When receiving
5662 * an intent, this is the component that was found to best handle it (that is,
5663 * yourself) and will always be non-null; in all other cases it will be
5664 * null unless explicitly set.
5665 *
5666 * @return The name of the application component to handle the intent.
5667 *
5668 * @see #resolveActivity
5669 * @see #setComponent
5670 */
5671 public ComponentName getComponent() {
5672 return mComponent;
5673 }
5674
5675 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005676 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5677 * used as a hint to the receiver for animations and the like. Null means that there
5678 * is no source bounds.
5679 */
5680 public Rect getSourceBounds() {
5681 return mSourceBounds;
5682 }
5683
5684 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005685 * Return the Activity component that should be used to handle this intent.
5686 * The appropriate component is determined based on the information in the
5687 * intent, evaluated as follows:
5688 *
5689 * <p>If {@link #getComponent} returns an explicit class, that is returned
5690 * without any further consideration.
5691 *
5692 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5693 * category to be considered.
5694 *
5695 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5696 * action.
5697 *
5698 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5699 * this type.
5700 *
5701 * <p>If {@link #addCategory} has added any categories, the activity must
5702 * handle ALL of the categories specified.
5703 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005704 * <p>If {@link #getPackage} is non-NULL, only activity components in
5705 * that application package will be considered.
5706 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005707 * <p>If there are no activities that satisfy all of these conditions, a
5708 * null string is returned.
5709 *
5710 * <p>If multiple activities are found to satisfy the intent, the one with
5711 * the highest priority will be used. If there are multiple activities
5712 * with the same priority, the system will either pick the best activity
5713 * based on user preference, or resolve to a system class that will allow
5714 * the user to pick an activity and forward from there.
5715 *
5716 * <p>This method is implemented simply by calling
5717 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5718 * true.</p>
5719 * <p> This API is called for you as part of starting an activity from an
5720 * intent. You do not normally need to call it yourself.</p>
5721 *
5722 * @param pm The package manager with which to resolve the Intent.
5723 *
5724 * @return Name of the component implementing an activity that can
5725 * display the intent.
5726 *
5727 * @see #setComponent
5728 * @see #getComponent
5729 * @see #resolveActivityInfo
5730 */
5731 public ComponentName resolveActivity(PackageManager pm) {
5732 if (mComponent != null) {
5733 return mComponent;
5734 }
5735
5736 ResolveInfo info = pm.resolveActivity(
5737 this, PackageManager.MATCH_DEFAULT_ONLY);
5738 if (info != null) {
5739 return new ComponentName(
5740 info.activityInfo.applicationInfo.packageName,
5741 info.activityInfo.name);
5742 }
5743
5744 return null;
5745 }
5746
5747 /**
5748 * Resolve the Intent into an {@link ActivityInfo}
5749 * describing the activity that should execute the intent. Resolution
5750 * follows the same rules as described for {@link #resolveActivity}, but
5751 * you get back the completely information about the resolved activity
5752 * instead of just its class name.
5753 *
5754 * @param pm The package manager with which to resolve the Intent.
5755 * @param flags Addition information to retrieve as per
5756 * {@link PackageManager#getActivityInfo(ComponentName, int)
5757 * PackageManager.getActivityInfo()}.
5758 *
5759 * @return PackageManager.ActivityInfo
5760 *
5761 * @see #resolveActivity
5762 */
5763 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5764 ActivityInfo ai = null;
5765 if (mComponent != null) {
5766 try {
5767 ai = pm.getActivityInfo(mComponent, flags);
5768 } catch (PackageManager.NameNotFoundException e) {
5769 // ignore
5770 }
5771 } else {
5772 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005773 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005774 if (info != null) {
5775 ai = info.activityInfo;
5776 }
5777 }
5778
5779 return ai;
5780 }
5781
5782 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005783 * Special function for use by the system to resolve service
5784 * intents to system apps. Throws an exception if there are
5785 * multiple potential matches to the Intent. Returns null if
5786 * there are no matches.
5787 * @hide
5788 */
5789 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5790 if (mComponent != null) {
5791 return mComponent;
5792 }
5793
5794 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5795 if (results == null) {
5796 return null;
5797 }
5798 ComponentName comp = null;
5799 for (int i=0; i<results.size(); i++) {
5800 ResolveInfo ri = results.get(i);
5801 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5802 continue;
5803 }
5804 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5805 ri.serviceInfo.name);
5806 if (comp != null) {
5807 throw new IllegalStateException("Multiple system services handle " + this
5808 + ": " + comp + ", " + foundComp);
5809 }
5810 comp = foundComp;
5811 }
5812 return comp;
5813 }
5814
5815 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005816 * Set the general action to be performed.
5817 *
5818 * @param action An action name, such as ACTION_VIEW. Application-specific
5819 * actions should be prefixed with the vendor's package name.
5820 *
5821 * @return Returns the same Intent object, for chaining multiple calls
5822 * into a single statement.
5823 *
5824 * @see #getAction
5825 */
5826 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005827 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005828 return this;
5829 }
5830
5831 /**
5832 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005833 * clears any type that was previously set by {@link #setType} or
5834 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005835 *
Nick Pellyccae4122012-01-09 14:12:58 -08005836 * <p><em>Note: scheme matching in the Android framework is
5837 * case-sensitive, unlike the formal RFC. As a result,
5838 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005839 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005840 * {@link #setDataAndNormalize}
5841 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005842 *
Nick Pellyccae4122012-01-09 14:12:58 -08005843 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005844 *
5845 * @return Returns the same Intent object, for chaining multiple calls
5846 * into a single statement.
5847 *
5848 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005849 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005850 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005851 */
5852 public Intent setData(Uri data) {
5853 mData = data;
5854 mType = null;
5855 return this;
5856 }
5857
5858 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005859 * Normalize and set the data this intent is operating on.
5860 *
5861 * <p>This method automatically clears any type that was
5862 * previously set (for example, by {@link #setType}).
5863 *
5864 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005865 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005866 * so really this is just a convenience method for
5867 * <pre>
5868 * setData(data.normalize())
5869 * </pre>
5870 *
5871 * @param data The Uri of the data this intent is now targeting.
5872 *
5873 * @return Returns the same Intent object, for chaining multiple calls
5874 * into a single statement.
5875 *
5876 * @see #getData
5877 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005878 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005879 */
5880 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005881 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005882 }
5883
5884 /**
5885 * Set an explicit MIME data type.
5886 *
5887 * <p>This is used to create intents that only specify a type and not data,
5888 * for example to indicate the type of data to return.
5889 *
5890 * <p>This method automatically clears any data that was
5891 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005892 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005893 * <p><em>Note: MIME type matching in the Android framework is
5894 * case-sensitive, unlike formal RFC MIME types. As a result,
5895 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005896 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5897 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005898 *
5899 * @param type The MIME type of the data being handled by this intent.
5900 *
5901 * @return Returns the same Intent object, for chaining multiple calls
5902 * into a single statement.
5903 *
5904 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005905 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005906 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005907 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005908 */
5909 public Intent setType(String type) {
5910 mData = null;
5911 mType = type;
5912 return this;
5913 }
5914
5915 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005916 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005917 *
Nick Pellyccae4122012-01-09 14:12:58 -08005918 * <p>This is used to create intents that only specify a type and not data,
5919 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005920 *
Nick Pellyccae4122012-01-09 14:12:58 -08005921 * <p>This method automatically clears any data that was
5922 * previously set (for example by {@link #setData}).
5923 *
5924 * <p>The MIME type is normalized using
5925 * {@link #normalizeMimeType} before it is set,
5926 * so really this is just a convenience method for
5927 * <pre>
5928 * setType(Intent.normalizeMimeType(type))
5929 * </pre>
5930 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005931 * @param type The MIME type of the data being handled by this intent.
5932 *
5933 * @return Returns the same Intent object, for chaining multiple calls
5934 * into a single statement.
5935 *
Nick Pellyccae4122012-01-09 14:12:58 -08005936 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005937 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005938 * @see #normalizeMimeType
5939 */
5940 public Intent setTypeAndNormalize(String type) {
5941 return setType(normalizeMimeType(type));
5942 }
5943
5944 /**
5945 * (Usually optional) Set the data for the intent along with an explicit
5946 * MIME data type. This method should very rarely be used -- it allows you
5947 * to override the MIME type that would ordinarily be inferred from the
5948 * data with your own type given here.
5949 *
5950 * <p><em>Note: MIME type and Uri scheme matching in the
5951 * Android framework is case-sensitive, unlike the formal RFC definitions.
5952 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005953 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005954 * {@link #setDataAndTypeAndNormalize}
5955 * to ensure that they are converted to lower case.</em>
5956 *
5957 * @param data The Uri of the data this intent is now targeting.
5958 * @param type The MIME type of the data being handled by this intent.
5959 *
5960 * @return Returns the same Intent object, for chaining multiple calls
5961 * into a single statement.
5962 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005963 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08005964 * @see #setData
5965 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005966 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005967 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005968 */
5969 public Intent setDataAndType(Uri data, String type) {
5970 mData = data;
5971 mType = type;
5972 return this;
5973 }
5974
5975 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005976 * (Usually optional) Normalize and set both the data Uri and an explicit
5977 * MIME data type. This method should very rarely be used -- it allows you
5978 * to override the MIME type that would ordinarily be inferred from the
5979 * data with your own type given here.
5980 *
5981 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005982 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08005983 * before they are set, so really this is just a convenience method for
5984 * <pre>
5985 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
5986 * </pre>
5987 *
5988 * @param data The Uri of the data this intent is now targeting.
5989 * @param type The MIME type of the data being handled by this intent.
5990 *
5991 * @return Returns the same Intent object, for chaining multiple calls
5992 * into a single statement.
5993 *
5994 * @see #setType
5995 * @see #setData
5996 * @see #setDataAndType
5997 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005998 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005999 */
6000 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006001 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006002 }
6003
6004 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006005 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006006 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006007 * activities that provide <em>all</em> of the requested categories will be
6008 * used.
6009 *
6010 * @param category The desired category. This can be either one of the
6011 * predefined Intent categories, or a custom category in your own
6012 * namespace.
6013 *
6014 * @return Returns the same Intent object, for chaining multiple calls
6015 * into a single statement.
6016 *
6017 * @see #hasCategory
6018 * @see #removeCategory
6019 */
6020 public Intent addCategory(String category) {
6021 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006022 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006023 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006024 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006025 return this;
6026 }
6027
6028 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006029 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006030 *
6031 * @param category The category to remove.
6032 *
6033 * @see #addCategory
6034 */
6035 public void removeCategory(String category) {
6036 if (mCategories != null) {
6037 mCategories.remove(category);
6038 if (mCategories.size() == 0) {
6039 mCategories = null;
6040 }
6041 }
6042 }
6043
6044 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006045 * Set a selector for this Intent. This is a modification to the kinds of
6046 * things the Intent will match. If the selector is set, it will be used
6047 * when trying to find entities that can handle the Intent, instead of the
6048 * main contents of the Intent. This allows you build an Intent containing
6049 * a generic protocol while targeting it more specifically.
6050 *
6051 * <p>An example of where this may be used is with things like
6052 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6053 * Intent that will launch the Browser application. However, the correct
6054 * main entry point of an application is actually {@link #ACTION_MAIN}
6055 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6056 * used to specify the actual Activity to launch. If you launch the browser
6057 * with something different, undesired behavior may happen if the user has
6058 * previously or later launches it the normal way, since they do not match.
6059 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6060 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6061 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6062 *
6063 * <p>Setting a selector does not impact the behavior of
6064 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6065 * desired behavior of a selector -- it does not impact the base meaning
6066 * of the Intent, just what kinds of things will be matched against it
6067 * when determining who can handle it.</p>
6068 *
6069 * <p>You can not use both a selector and {@link #setPackage(String)} on
6070 * the same base Intent.</p>
6071 *
6072 * @param selector The desired selector Intent; set to null to not use
6073 * a special selector.
6074 */
6075 public void setSelector(Intent selector) {
6076 if (selector == this) {
6077 throw new IllegalArgumentException(
6078 "Intent being set as a selector of itself");
6079 }
6080 if (selector != null && mPackage != null) {
6081 throw new IllegalArgumentException(
6082 "Can't set selector when package name is already set");
6083 }
6084 mSelector = selector;
6085 }
6086
6087 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006088 * Set a {@link ClipData} associated with this Intent. This replaces any
6089 * previously set ClipData.
6090 *
6091 * <p>The ClipData in an intent is not used for Intent matching or other
6092 * such operations. Semantically it is like extras, used to transmit
6093 * additional data with the Intent. The main feature of using this over
6094 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6095 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6096 * items included in the clip data. This is useful, in particular, if
6097 * you want to transmit an Intent containing multiple <code>content:</code>
6098 * URIs for which the recipient may not have global permission to access the
6099 * content provider.
6100 *
6101 * <p>If the ClipData contains items that are themselves Intents, any
6102 * grant flags in those Intents will be ignored. Only the top-level flags
6103 * of the main Intent are respected, and will be applied to all Uri or
6104 * Intent items in the clip (or sub-items of the clip).
6105 *
6106 * <p>The MIME type, label, and icon in the ClipData object are not
6107 * directly used by Intent. Applications should generally rely on the
6108 * MIME type of the Intent itself, not what it may find in the ClipData.
6109 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006110 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006111 *
6112 * @param clip The new clip to set. May be null to clear the current clip.
6113 */
6114 public void setClipData(ClipData clip) {
6115 mClipData = clip;
6116 }
6117
6118 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006119 * This is NOT a secure mechanism to identify the user who sent the intent.
6120 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6121 * who sent the intent.
6122 * @hide
6123 */
6124 public void setContentUserHint(int contentUserHint) {
6125 mContentUserHint = contentUserHint;
6126 }
6127
6128 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006129 * Add extended data to the intent. The name must include a package
6130 * prefix, for example the app com.android.contacts would use names
6131 * like "com.android.contacts.ShowAll".
6132 *
6133 * @param name The name of the extra data, with package prefix.
6134 * @param value The boolean data value.
6135 *
6136 * @return Returns the same Intent object, for chaining multiple calls
6137 * into a single statement.
6138 *
6139 * @see #putExtras
6140 * @see #removeExtra
6141 * @see #getBooleanExtra(String, boolean)
6142 */
6143 public Intent putExtra(String name, boolean value) {
6144 if (mExtras == null) {
6145 mExtras = new Bundle();
6146 }
6147 mExtras.putBoolean(name, value);
6148 return this;
6149 }
6150
6151 /**
6152 * Add extended data to the intent. The name must include a package
6153 * prefix, for example the app com.android.contacts would use names
6154 * like "com.android.contacts.ShowAll".
6155 *
6156 * @param name The name of the extra data, with package prefix.
6157 * @param value The byte data value.
6158 *
6159 * @return Returns the same Intent object, for chaining multiple calls
6160 * into a single statement.
6161 *
6162 * @see #putExtras
6163 * @see #removeExtra
6164 * @see #getByteExtra(String, byte)
6165 */
6166 public Intent putExtra(String name, byte value) {
6167 if (mExtras == null) {
6168 mExtras = new Bundle();
6169 }
6170 mExtras.putByte(name, value);
6171 return this;
6172 }
6173
6174 /**
6175 * Add extended data to the intent. The name must include a package
6176 * prefix, for example the app com.android.contacts would use names
6177 * like "com.android.contacts.ShowAll".
6178 *
6179 * @param name The name of the extra data, with package prefix.
6180 * @param value The char data value.
6181 *
6182 * @return Returns the same Intent object, for chaining multiple calls
6183 * into a single statement.
6184 *
6185 * @see #putExtras
6186 * @see #removeExtra
6187 * @see #getCharExtra(String, char)
6188 */
6189 public Intent putExtra(String name, char value) {
6190 if (mExtras == null) {
6191 mExtras = new Bundle();
6192 }
6193 mExtras.putChar(name, value);
6194 return this;
6195 }
6196
6197 /**
6198 * Add extended data to the intent. The name must include a package
6199 * prefix, for example the app com.android.contacts would use names
6200 * like "com.android.contacts.ShowAll".
6201 *
6202 * @param name The name of the extra data, with package prefix.
6203 * @param value The short data value.
6204 *
6205 * @return Returns the same Intent object, for chaining multiple calls
6206 * into a single statement.
6207 *
6208 * @see #putExtras
6209 * @see #removeExtra
6210 * @see #getShortExtra(String, short)
6211 */
6212 public Intent putExtra(String name, short value) {
6213 if (mExtras == null) {
6214 mExtras = new Bundle();
6215 }
6216 mExtras.putShort(name, value);
6217 return this;
6218 }
6219
6220 /**
6221 * Add extended data to the intent. The name must include a package
6222 * prefix, for example the app com.android.contacts would use names
6223 * like "com.android.contacts.ShowAll".
6224 *
6225 * @param name The name of the extra data, with package prefix.
6226 * @param value The integer data value.
6227 *
6228 * @return Returns the same Intent object, for chaining multiple calls
6229 * into a single statement.
6230 *
6231 * @see #putExtras
6232 * @see #removeExtra
6233 * @see #getIntExtra(String, int)
6234 */
6235 public Intent putExtra(String name, int value) {
6236 if (mExtras == null) {
6237 mExtras = new Bundle();
6238 }
6239 mExtras.putInt(name, value);
6240 return this;
6241 }
6242
6243 /**
6244 * Add extended data to the intent. The name must include a package
6245 * prefix, for example the app com.android.contacts would use names
6246 * like "com.android.contacts.ShowAll".
6247 *
6248 * @param name The name of the extra data, with package prefix.
6249 * @param value The long data value.
6250 *
6251 * @return Returns the same Intent object, for chaining multiple calls
6252 * into a single statement.
6253 *
6254 * @see #putExtras
6255 * @see #removeExtra
6256 * @see #getLongExtra(String, long)
6257 */
6258 public Intent putExtra(String name, long value) {
6259 if (mExtras == null) {
6260 mExtras = new Bundle();
6261 }
6262 mExtras.putLong(name, value);
6263 return this;
6264 }
6265
6266 /**
6267 * Add extended data to the intent. The name must include a package
6268 * prefix, for example the app com.android.contacts would use names
6269 * like "com.android.contacts.ShowAll".
6270 *
6271 * @param name The name of the extra data, with package prefix.
6272 * @param value The float data value.
6273 *
6274 * @return Returns the same Intent object, for chaining multiple calls
6275 * into a single statement.
6276 *
6277 * @see #putExtras
6278 * @see #removeExtra
6279 * @see #getFloatExtra(String, float)
6280 */
6281 public Intent putExtra(String name, float value) {
6282 if (mExtras == null) {
6283 mExtras = new Bundle();
6284 }
6285 mExtras.putFloat(name, value);
6286 return this;
6287 }
6288
6289 /**
6290 * Add extended data to the intent. The name must include a package
6291 * prefix, for example the app com.android.contacts would use names
6292 * like "com.android.contacts.ShowAll".
6293 *
6294 * @param name The name of the extra data, with package prefix.
6295 * @param value The double data value.
6296 *
6297 * @return Returns the same Intent object, for chaining multiple calls
6298 * into a single statement.
6299 *
6300 * @see #putExtras
6301 * @see #removeExtra
6302 * @see #getDoubleExtra(String, double)
6303 */
6304 public Intent putExtra(String name, double value) {
6305 if (mExtras == null) {
6306 mExtras = new Bundle();
6307 }
6308 mExtras.putDouble(name, value);
6309 return this;
6310 }
6311
6312 /**
6313 * Add extended data to the intent. The name must include a package
6314 * prefix, for example the app com.android.contacts would use names
6315 * like "com.android.contacts.ShowAll".
6316 *
6317 * @param name The name of the extra data, with package prefix.
6318 * @param value The String data value.
6319 *
6320 * @return Returns the same Intent object, for chaining multiple calls
6321 * into a single statement.
6322 *
6323 * @see #putExtras
6324 * @see #removeExtra
6325 * @see #getStringExtra(String)
6326 */
6327 public Intent putExtra(String name, String value) {
6328 if (mExtras == null) {
6329 mExtras = new Bundle();
6330 }
6331 mExtras.putString(name, value);
6332 return this;
6333 }
6334
6335 /**
6336 * Add extended data to the intent. The name must include a package
6337 * prefix, for example the app com.android.contacts would use names
6338 * like "com.android.contacts.ShowAll".
6339 *
6340 * @param name The name of the extra data, with package prefix.
6341 * @param value The CharSequence data value.
6342 *
6343 * @return Returns the same Intent object, for chaining multiple calls
6344 * into a single statement.
6345 *
6346 * @see #putExtras
6347 * @see #removeExtra
6348 * @see #getCharSequenceExtra(String)
6349 */
6350 public Intent putExtra(String name, CharSequence value) {
6351 if (mExtras == null) {
6352 mExtras = new Bundle();
6353 }
6354 mExtras.putCharSequence(name, value);
6355 return this;
6356 }
6357
6358 /**
6359 * Add extended data to the intent. The name must include a package
6360 * prefix, for example the app com.android.contacts would use names
6361 * like "com.android.contacts.ShowAll".
6362 *
6363 * @param name The name of the extra data, with package prefix.
6364 * @param value The Parcelable data value.
6365 *
6366 * @return Returns the same Intent object, for chaining multiple calls
6367 * into a single statement.
6368 *
6369 * @see #putExtras
6370 * @see #removeExtra
6371 * @see #getParcelableExtra(String)
6372 */
6373 public Intent putExtra(String name, Parcelable value) {
6374 if (mExtras == null) {
6375 mExtras = new Bundle();
6376 }
6377 mExtras.putParcelable(name, value);
6378 return this;
6379 }
6380
6381 /**
6382 * Add extended data to the intent. The name must include a package
6383 * prefix, for example the app com.android.contacts would use names
6384 * like "com.android.contacts.ShowAll".
6385 *
6386 * @param name The name of the extra data, with package prefix.
6387 * @param value The Parcelable[] data value.
6388 *
6389 * @return Returns the same Intent object, for chaining multiple calls
6390 * into a single statement.
6391 *
6392 * @see #putExtras
6393 * @see #removeExtra
6394 * @see #getParcelableArrayExtra(String)
6395 */
6396 public Intent putExtra(String name, Parcelable[] value) {
6397 if (mExtras == null) {
6398 mExtras = new Bundle();
6399 }
6400 mExtras.putParcelableArray(name, value);
6401 return this;
6402 }
6403
6404 /**
6405 * Add extended data to the intent. The name must include a package
6406 * prefix, for example the app com.android.contacts would use names
6407 * like "com.android.contacts.ShowAll".
6408 *
6409 * @param name The name of the extra data, with package prefix.
6410 * @param value The ArrayList<Parcelable> data value.
6411 *
6412 * @return Returns the same Intent object, for chaining multiple calls
6413 * into a single statement.
6414 *
6415 * @see #putExtras
6416 * @see #removeExtra
6417 * @see #getParcelableArrayListExtra(String)
6418 */
6419 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6420 if (mExtras == null) {
6421 mExtras = new Bundle();
6422 }
6423 mExtras.putParcelableArrayList(name, value);
6424 return this;
6425 }
6426
6427 /**
6428 * Add extended data to the intent. The name must include a package
6429 * prefix, for example the app com.android.contacts would use names
6430 * like "com.android.contacts.ShowAll".
6431 *
6432 * @param name The name of the extra data, with package prefix.
6433 * @param value The ArrayList<Integer> data value.
6434 *
6435 * @return Returns the same Intent object, for chaining multiple calls
6436 * into a single statement.
6437 *
6438 * @see #putExtras
6439 * @see #removeExtra
6440 * @see #getIntegerArrayListExtra(String)
6441 */
6442 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6443 if (mExtras == null) {
6444 mExtras = new Bundle();
6445 }
6446 mExtras.putIntegerArrayList(name, value);
6447 return this;
6448 }
6449
6450 /**
6451 * Add extended data to the intent. The name must include a package
6452 * prefix, for example the app com.android.contacts would use names
6453 * like "com.android.contacts.ShowAll".
6454 *
6455 * @param name The name of the extra data, with package prefix.
6456 * @param value The ArrayList<String> data value.
6457 *
6458 * @return Returns the same Intent object, for chaining multiple calls
6459 * into a single statement.
6460 *
6461 * @see #putExtras
6462 * @see #removeExtra
6463 * @see #getStringArrayListExtra(String)
6464 */
6465 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6466 if (mExtras == null) {
6467 mExtras = new Bundle();
6468 }
6469 mExtras.putStringArrayList(name, value);
6470 return this;
6471 }
6472
6473 /**
6474 * Add extended data to the intent. The name must include a package
6475 * prefix, for example the app com.android.contacts would use names
6476 * like "com.android.contacts.ShowAll".
6477 *
6478 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006479 * @param value The ArrayList<CharSequence> data value.
6480 *
6481 * @return Returns the same Intent object, for chaining multiple calls
6482 * into a single statement.
6483 *
6484 * @see #putExtras
6485 * @see #removeExtra
6486 * @see #getCharSequenceArrayListExtra(String)
6487 */
6488 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6489 if (mExtras == null) {
6490 mExtras = new Bundle();
6491 }
6492 mExtras.putCharSequenceArrayList(name, value);
6493 return this;
6494 }
6495
6496 /**
6497 * Add extended data to the intent. The name must include a package
6498 * prefix, for example the app com.android.contacts would use names
6499 * like "com.android.contacts.ShowAll".
6500 *
6501 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006502 * @param value The Serializable data value.
6503 *
6504 * @return Returns the same Intent object, for chaining multiple calls
6505 * into a single statement.
6506 *
6507 * @see #putExtras
6508 * @see #removeExtra
6509 * @see #getSerializableExtra(String)
6510 */
6511 public Intent putExtra(String name, Serializable value) {
6512 if (mExtras == null) {
6513 mExtras = new Bundle();
6514 }
6515 mExtras.putSerializable(name, value);
6516 return this;
6517 }
6518
6519 /**
6520 * Add extended data to the intent. The name must include a package
6521 * prefix, for example the app com.android.contacts would use names
6522 * like "com.android.contacts.ShowAll".
6523 *
6524 * @param name The name of the extra data, with package prefix.
6525 * @param value The boolean array data value.
6526 *
6527 * @return Returns the same Intent object, for chaining multiple calls
6528 * into a single statement.
6529 *
6530 * @see #putExtras
6531 * @see #removeExtra
6532 * @see #getBooleanArrayExtra(String)
6533 */
6534 public Intent putExtra(String name, boolean[] value) {
6535 if (mExtras == null) {
6536 mExtras = new Bundle();
6537 }
6538 mExtras.putBooleanArray(name, value);
6539 return this;
6540 }
6541
6542 /**
6543 * Add extended data to the intent. The name must include a package
6544 * prefix, for example the app com.android.contacts would use names
6545 * like "com.android.contacts.ShowAll".
6546 *
6547 * @param name The name of the extra data, with package prefix.
6548 * @param value The byte array data value.
6549 *
6550 * @return Returns the same Intent object, for chaining multiple calls
6551 * into a single statement.
6552 *
6553 * @see #putExtras
6554 * @see #removeExtra
6555 * @see #getByteArrayExtra(String)
6556 */
6557 public Intent putExtra(String name, byte[] value) {
6558 if (mExtras == null) {
6559 mExtras = new Bundle();
6560 }
6561 mExtras.putByteArray(name, value);
6562 return this;
6563 }
6564
6565 /**
6566 * Add extended data to the intent. The name must include a package
6567 * prefix, for example the app com.android.contacts would use names
6568 * like "com.android.contacts.ShowAll".
6569 *
6570 * @param name The name of the extra data, with package prefix.
6571 * @param value The short array data value.
6572 *
6573 * @return Returns the same Intent object, for chaining multiple calls
6574 * into a single statement.
6575 *
6576 * @see #putExtras
6577 * @see #removeExtra
6578 * @see #getShortArrayExtra(String)
6579 */
6580 public Intent putExtra(String name, short[] value) {
6581 if (mExtras == null) {
6582 mExtras = new Bundle();
6583 }
6584 mExtras.putShortArray(name, value);
6585 return this;
6586 }
6587
6588 /**
6589 * Add extended data to the intent. The name must include a package
6590 * prefix, for example the app com.android.contacts would use names
6591 * like "com.android.contacts.ShowAll".
6592 *
6593 * @param name The name of the extra data, with package prefix.
6594 * @param value The char array data value.
6595 *
6596 * @return Returns the same Intent object, for chaining multiple calls
6597 * into a single statement.
6598 *
6599 * @see #putExtras
6600 * @see #removeExtra
6601 * @see #getCharArrayExtra(String)
6602 */
6603 public Intent putExtra(String name, char[] value) {
6604 if (mExtras == null) {
6605 mExtras = new Bundle();
6606 }
6607 mExtras.putCharArray(name, value);
6608 return this;
6609 }
6610
6611 /**
6612 * Add extended data to the intent. The name must include a package
6613 * prefix, for example the app com.android.contacts would use names
6614 * like "com.android.contacts.ShowAll".
6615 *
6616 * @param name The name of the extra data, with package prefix.
6617 * @param value The int array data value.
6618 *
6619 * @return Returns the same Intent object, for chaining multiple calls
6620 * into a single statement.
6621 *
6622 * @see #putExtras
6623 * @see #removeExtra
6624 * @see #getIntArrayExtra(String)
6625 */
6626 public Intent putExtra(String name, int[] value) {
6627 if (mExtras == null) {
6628 mExtras = new Bundle();
6629 }
6630 mExtras.putIntArray(name, value);
6631 return this;
6632 }
6633
6634 /**
6635 * Add extended data to the intent. The name must include a package
6636 * prefix, for example the app com.android.contacts would use names
6637 * like "com.android.contacts.ShowAll".
6638 *
6639 * @param name The name of the extra data, with package prefix.
6640 * @param value The byte array data value.
6641 *
6642 * @return Returns the same Intent object, for chaining multiple calls
6643 * into a single statement.
6644 *
6645 * @see #putExtras
6646 * @see #removeExtra
6647 * @see #getLongArrayExtra(String)
6648 */
6649 public Intent putExtra(String name, long[] value) {
6650 if (mExtras == null) {
6651 mExtras = new Bundle();
6652 }
6653 mExtras.putLongArray(name, value);
6654 return this;
6655 }
6656
6657 /**
6658 * Add extended data to the intent. The name must include a package
6659 * prefix, for example the app com.android.contacts would use names
6660 * like "com.android.contacts.ShowAll".
6661 *
6662 * @param name The name of the extra data, with package prefix.
6663 * @param value The float array data value.
6664 *
6665 * @return Returns the same Intent object, for chaining multiple calls
6666 * into a single statement.
6667 *
6668 * @see #putExtras
6669 * @see #removeExtra
6670 * @see #getFloatArrayExtra(String)
6671 */
6672 public Intent putExtra(String name, float[] value) {
6673 if (mExtras == null) {
6674 mExtras = new Bundle();
6675 }
6676 mExtras.putFloatArray(name, value);
6677 return this;
6678 }
6679
6680 /**
6681 * Add extended data to the intent. The name must include a package
6682 * prefix, for example the app com.android.contacts would use names
6683 * like "com.android.contacts.ShowAll".
6684 *
6685 * @param name The name of the extra data, with package prefix.
6686 * @param value The double array data value.
6687 *
6688 * @return Returns the same Intent object, for chaining multiple calls
6689 * into a single statement.
6690 *
6691 * @see #putExtras
6692 * @see #removeExtra
6693 * @see #getDoubleArrayExtra(String)
6694 */
6695 public Intent putExtra(String name, double[] value) {
6696 if (mExtras == null) {
6697 mExtras = new Bundle();
6698 }
6699 mExtras.putDoubleArray(name, value);
6700 return this;
6701 }
6702
6703 /**
6704 * Add extended data to the intent. The name must include a package
6705 * prefix, for example the app com.android.contacts would use names
6706 * like "com.android.contacts.ShowAll".
6707 *
6708 * @param name The name of the extra data, with package prefix.
6709 * @param value The String array data value.
6710 *
6711 * @return Returns the same Intent object, for chaining multiple calls
6712 * into a single statement.
6713 *
6714 * @see #putExtras
6715 * @see #removeExtra
6716 * @see #getStringArrayExtra(String)
6717 */
6718 public Intent putExtra(String name, String[] value) {
6719 if (mExtras == null) {
6720 mExtras = new Bundle();
6721 }
6722 mExtras.putStringArray(name, value);
6723 return this;
6724 }
6725
6726 /**
6727 * Add extended data to the intent. The name must include a package
6728 * prefix, for example the app com.android.contacts would use names
6729 * like "com.android.contacts.ShowAll".
6730 *
6731 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006732 * @param value The CharSequence array data value.
6733 *
6734 * @return Returns the same Intent object, for chaining multiple calls
6735 * into a single statement.
6736 *
6737 * @see #putExtras
6738 * @see #removeExtra
6739 * @see #getCharSequenceArrayExtra(String)
6740 */
6741 public Intent putExtra(String name, CharSequence[] value) {
6742 if (mExtras == null) {
6743 mExtras = new Bundle();
6744 }
6745 mExtras.putCharSequenceArray(name, value);
6746 return this;
6747 }
6748
6749 /**
6750 * Add extended data to the intent. The name must include a package
6751 * prefix, for example the app com.android.contacts would use names
6752 * like "com.android.contacts.ShowAll".
6753 *
6754 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006755 * @param value The Bundle data value.
6756 *
6757 * @return Returns the same Intent object, for chaining multiple calls
6758 * into a single statement.
6759 *
6760 * @see #putExtras
6761 * @see #removeExtra
6762 * @see #getBundleExtra(String)
6763 */
6764 public Intent putExtra(String name, Bundle value) {
6765 if (mExtras == null) {
6766 mExtras = new Bundle();
6767 }
6768 mExtras.putBundle(name, value);
6769 return this;
6770 }
6771
6772 /**
6773 * Add extended data to the intent. The name must include a package
6774 * prefix, for example the app com.android.contacts would use names
6775 * like "com.android.contacts.ShowAll".
6776 *
6777 * @param name The name of the extra data, with package prefix.
6778 * @param value The IBinder data value.
6779 *
6780 * @return Returns the same Intent object, for chaining multiple calls
6781 * into a single statement.
6782 *
6783 * @see #putExtras
6784 * @see #removeExtra
6785 * @see #getIBinderExtra(String)
6786 *
6787 * @deprecated
6788 * @hide
6789 */
6790 @Deprecated
6791 public Intent putExtra(String name, IBinder value) {
6792 if (mExtras == null) {
6793 mExtras = new Bundle();
6794 }
6795 mExtras.putIBinder(name, value);
6796 return this;
6797 }
6798
6799 /**
6800 * Copy all extras in 'src' in to this intent.
6801 *
6802 * @param src Contains the extras to copy.
6803 *
6804 * @see #putExtra
6805 */
6806 public Intent putExtras(Intent src) {
6807 if (src.mExtras != null) {
6808 if (mExtras == null) {
6809 mExtras = new Bundle(src.mExtras);
6810 } else {
6811 mExtras.putAll(src.mExtras);
6812 }
6813 }
6814 return this;
6815 }
6816
6817 /**
6818 * Add a set of extended data to the intent. The keys must include a package
6819 * prefix, for example the app com.android.contacts would use names
6820 * like "com.android.contacts.ShowAll".
6821 *
6822 * @param extras The Bundle of extras to add to this intent.
6823 *
6824 * @see #putExtra
6825 * @see #removeExtra
6826 */
6827 public Intent putExtras(Bundle extras) {
6828 if (mExtras == null) {
6829 mExtras = new Bundle();
6830 }
6831 mExtras.putAll(extras);
6832 return this;
6833 }
6834
6835 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006836 * Completely replace the extras in the Intent with the extras in the
6837 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006838 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006839 * @param src The exact extras contained in this Intent are copied
6840 * into the target intent, replacing any that were previously there.
6841 */
6842 public Intent replaceExtras(Intent src) {
6843 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6844 return this;
6845 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006846
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006847 /**
6848 * Completely replace the extras in the Intent with the given Bundle of
6849 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006850 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006851 * @param extras The new set of extras in the Intent, or null to erase
6852 * all extras.
6853 */
6854 public Intent replaceExtras(Bundle extras) {
6855 mExtras = extras != null ? new Bundle(extras) : null;
6856 return this;
6857 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006858
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006859 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006860 * Remove extended data from the intent.
6861 *
6862 * @see #putExtra
6863 */
6864 public void removeExtra(String name) {
6865 if (mExtras != null) {
6866 mExtras.remove(name);
6867 if (mExtras.size() == 0) {
6868 mExtras = null;
6869 }
6870 }
6871 }
6872
6873 /**
6874 * Set special flags controlling how this intent is handled. Most values
6875 * here depend on the type of component being executed by the Intent,
6876 * specifically the FLAG_ACTIVITY_* flags are all for use with
6877 * {@link Context#startActivity Context.startActivity()} and the
6878 * FLAG_RECEIVER_* flags are all for use with
6879 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6880 *
Scott Main7aee61f2011-02-08 11:25:01 -08006881 * <p>See the
6882 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6883 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006884 * the behavior of your application.
6885 *
6886 * @param flags The desired flags.
6887 *
6888 * @return Returns the same Intent object, for chaining multiple calls
6889 * into a single statement.
6890 *
6891 * @see #getFlags
6892 * @see #addFlags
6893 *
6894 * @see #FLAG_GRANT_READ_URI_PERMISSION
6895 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006896 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6897 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006898 * @see #FLAG_DEBUG_LOG_RESOLUTION
6899 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006900 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006901 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006902 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006903 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006904 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6905 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006906 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006907 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006908 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006909 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006910 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006911 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006912 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006913 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6914 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006915 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006916 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006917 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006918 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6919 */
6920 public Intent setFlags(int flags) {
6921 mFlags = flags;
6922 return this;
6923 }
6924
6925 /**
6926 * Add additional flags to the intent (or with existing flags
6927 * value).
6928 *
6929 * @param flags The new flags to set.
6930 *
6931 * @return Returns the same Intent object, for chaining multiple calls
6932 * into a single statement.
6933 *
6934 * @see #setFlags
6935 */
6936 public Intent addFlags(int flags) {
6937 mFlags |= flags;
6938 return this;
6939 }
6940
6941 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006942 * (Usually optional) Set an explicit application package name that limits
6943 * the components this Intent will resolve to. If left to the default
6944 * value of null, all components in all applications will considered.
6945 * If non-null, the Intent can only match the components in the given
6946 * application package.
6947 *
6948 * @param packageName The name of the application package to handle the
6949 * intent, or null to allow any application package.
6950 *
6951 * @return Returns the same Intent object, for chaining multiple calls
6952 * into a single statement.
6953 *
6954 * @see #getPackage
6955 * @see #resolveActivity
6956 */
6957 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006958 if (packageName != null && mSelector != null) {
6959 throw new IllegalArgumentException(
6960 "Can't set package name when selector is already set");
6961 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006962 mPackage = packageName;
6963 return this;
6964 }
6965
6966 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006967 * (Usually optional) Explicitly set the component to handle the intent.
6968 * If left with the default value of null, the system will determine the
6969 * appropriate class to use based on the other fields (action, data,
6970 * type, categories) in the Intent. If this class is defined, the
6971 * specified class will always be used regardless of the other fields. You
6972 * should only set this value when you know you absolutely want a specific
6973 * class to be used; otherwise it is better to let the system find the
6974 * appropriate class so that you will respect the installed applications
6975 * and user preferences.
6976 *
6977 * @param component The name of the application component to handle the
6978 * intent, or null to let the system find one for you.
6979 *
6980 * @return Returns the same Intent object, for chaining multiple calls
6981 * into a single statement.
6982 *
6983 * @see #setClass
6984 * @see #setClassName(Context, String)
6985 * @see #setClassName(String, String)
6986 * @see #getComponent
6987 * @see #resolveActivity
6988 */
6989 public Intent setComponent(ComponentName component) {
6990 mComponent = component;
6991 return this;
6992 }
6993
6994 /**
6995 * Convenience for calling {@link #setComponent} with an
6996 * explicit class name.
6997 *
6998 * @param packageContext A Context of the application package implementing
6999 * this class.
7000 * @param className The name of a class inside of the application package
7001 * that will be used as the component for this Intent.
7002 *
7003 * @return Returns the same Intent object, for chaining multiple calls
7004 * into a single statement.
7005 *
7006 * @see #setComponent
7007 * @see #setClass
7008 */
7009 public Intent setClassName(Context packageContext, String className) {
7010 mComponent = new ComponentName(packageContext, className);
7011 return this;
7012 }
7013
7014 /**
7015 * Convenience for calling {@link #setComponent} with an
7016 * explicit application package name and class name.
7017 *
7018 * @param packageName The name of the package implementing the desired
7019 * component.
7020 * @param className The name of a class inside of the application package
7021 * that will be used as the component for this Intent.
7022 *
7023 * @return Returns the same Intent object, for chaining multiple calls
7024 * into a single statement.
7025 *
7026 * @see #setComponent
7027 * @see #setClass
7028 */
7029 public Intent setClassName(String packageName, String className) {
7030 mComponent = new ComponentName(packageName, className);
7031 return this;
7032 }
7033
7034 /**
7035 * Convenience for calling {@link #setComponent(ComponentName)} with the
7036 * name returned by a {@link Class} object.
7037 *
7038 * @param packageContext A Context of the application package implementing
7039 * this class.
7040 * @param cls The class name to set, equivalent to
7041 * <code>setClassName(context, cls.getName())</code>.
7042 *
7043 * @return Returns the same Intent object, for chaining multiple calls
7044 * into a single statement.
7045 *
7046 * @see #setComponent
7047 */
7048 public Intent setClass(Context packageContext, Class<?> cls) {
7049 mComponent = new ComponentName(packageContext, cls);
7050 return this;
7051 }
7052
7053 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007054 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7055 * used as a hint to the receiver for animations and the like. Null means that there
7056 * is no source bounds.
7057 */
7058 public void setSourceBounds(Rect r) {
7059 if (r != null) {
7060 mSourceBounds = new Rect(r);
7061 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007062 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007063 }
7064 }
7065
Tor Norbyed9273d62013-05-30 15:59:53 -07007066 /** @hide */
7067 @IntDef(flag = true,
7068 value = {
7069 FILL_IN_ACTION,
7070 FILL_IN_DATA,
7071 FILL_IN_CATEGORIES,
7072 FILL_IN_COMPONENT,
7073 FILL_IN_PACKAGE,
7074 FILL_IN_SOURCE_BOUNDS,
7075 FILL_IN_SELECTOR,
7076 FILL_IN_CLIP_DATA
7077 })
7078 @Retention(RetentionPolicy.SOURCE)
7079 public @interface FillInFlags {}
7080
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007081 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007082 * Use with {@link #fillIn} to allow the current action value to be
7083 * overwritten, even if it is already set.
7084 */
7085 public static final int FILL_IN_ACTION = 1<<0;
7086
7087 /**
7088 * Use with {@link #fillIn} to allow the current data or type value
7089 * overwritten, even if it is already set.
7090 */
7091 public static final int FILL_IN_DATA = 1<<1;
7092
7093 /**
7094 * Use with {@link #fillIn} to allow the current categories to be
7095 * overwritten, even if they are already set.
7096 */
7097 public static final int FILL_IN_CATEGORIES = 1<<2;
7098
7099 /**
7100 * Use with {@link #fillIn} to allow the current component value to be
7101 * overwritten, even if it is already set.
7102 */
7103 public static final int FILL_IN_COMPONENT = 1<<3;
7104
7105 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007106 * Use with {@link #fillIn} to allow the current package value to be
7107 * overwritten, even if it is already set.
7108 */
7109 public static final int FILL_IN_PACKAGE = 1<<4;
7110
7111 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007112 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007113 * overwritten, even if it is already set.
7114 */
7115 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7116
7117 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007118 * Use with {@link #fillIn} to allow the current selector to be
7119 * overwritten, even if it is already set.
7120 */
7121 public static final int FILL_IN_SELECTOR = 1<<6;
7122
7123 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007124 * Use with {@link #fillIn} to allow the current ClipData to be
7125 * overwritten, even if it is already set.
7126 */
7127 public static final int FILL_IN_CLIP_DATA = 1<<7;
7128
7129 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007130 * Copy the contents of <var>other</var> in to this object, but only
7131 * where fields are not defined by this object. For purposes of a field
7132 * being defined, the following pieces of data in the Intent are
7133 * considered to be separate fields:
7134 *
7135 * <ul>
7136 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007137 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007138 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7139 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007140 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007141 * <li> component, as set by {@link #setComponent(ComponentName)} or
7142 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007143 * <li> source bounds, as set by {@link #setSourceBounds}.
7144 * <li> selector, as set by {@link #setSelector(Intent)}.
7145 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007146 * <li> each top-level name in the associated extras.
7147 * </ul>
7148 *
7149 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007150 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007151 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7152 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7153 * the restriction where the corresponding field will not be replaced if
7154 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007155 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007156 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7157 * is explicitly specified. The selector will only be copied if
7158 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007159 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007160 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7161 * and Intent B with {action="gotit", data-type="some/thing",
7162 * categories="one","two"}.
7163 *
7164 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7165 * containing: {action="gotit", data-type="some/thing",
7166 * categories="bar"}.
7167 *
7168 * @param other Another Intent whose values are to be used to fill in
7169 * the current one.
7170 * @param flags Options to control which fields can be filled in.
7171 *
7172 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007173 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007174 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7175 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7176 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007177 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007178 @FillInFlags
7179 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007180 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007181 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007182 if (other.mAction != null
7183 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007184 mAction = other.mAction;
7185 changes |= FILL_IN_ACTION;
7186 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007187 if ((other.mData != null || other.mType != null)
7188 && ((mData == null && mType == null)
7189 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007190 mData = other.mData;
7191 mType = other.mType;
7192 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007193 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007194 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007195 if (other.mCategories != null
7196 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007197 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007198 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007199 }
7200 changes |= FILL_IN_CATEGORIES;
7201 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007202 if (other.mPackage != null
7203 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007204 // Only do this if mSelector is not set.
7205 if (mSelector == null) {
7206 mPackage = other.mPackage;
7207 changes |= FILL_IN_PACKAGE;
7208 }
7209 }
7210 // Selector is special: it can only be set if explicitly allowed,
7211 // for the same reason as the component name.
7212 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7213 if (mPackage == null) {
7214 mSelector = new Intent(other.mSelector);
7215 mPackage = null;
7216 changes |= FILL_IN_SELECTOR;
7217 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007218 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007219 if (other.mClipData != null
7220 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7221 mClipData = other.mClipData;
7222 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007223 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007224 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007225 // Component is special: it can -only- be set if explicitly allowed,
7226 // since otherwise the sender could force the intent somewhere the
7227 // originator didn't intend.
7228 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007229 mComponent = other.mComponent;
7230 changes |= FILL_IN_COMPONENT;
7231 }
7232 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007233 if (other.mSourceBounds != null
7234 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7235 mSourceBounds = new Rect(other.mSourceBounds);
7236 changes |= FILL_IN_SOURCE_BOUNDS;
7237 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007238 if (mExtras == null) {
7239 if (other.mExtras != null) {
7240 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007241 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007242 }
7243 } else if (other.mExtras != null) {
7244 try {
7245 Bundle newb = new Bundle(other.mExtras);
7246 newb.putAll(mExtras);
7247 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007248 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007249 } catch (RuntimeException e) {
7250 // Modifying the extras can cause us to unparcel the contents
7251 // of the bundle, and if we do this in the system process that
7252 // may fail. We really should handle this (i.e., the Bundle
7253 // impl shouldn't be on top of a plain map), but for now just
7254 // ignore it and keep the original contents. :(
7255 Log.w("Intent", "Failure filling in extras", e);
7256 }
7257 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007258 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7259 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7260 mContentUserHint = other.mContentUserHint;
7261 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007262 return changes;
7263 }
7264
7265 /**
7266 * Wrapper class holding an Intent and implementing comparisons on it for
7267 * the purpose of filtering. The class implements its
7268 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7269 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7270 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7271 * on the wrapped Intent.
7272 */
7273 public static final class FilterComparison {
7274 private final Intent mIntent;
7275 private final int mHashCode;
7276
7277 public FilterComparison(Intent intent) {
7278 mIntent = intent;
7279 mHashCode = intent.filterHashCode();
7280 }
7281
7282 /**
7283 * Return the Intent that this FilterComparison represents.
7284 * @return Returns the Intent held by the FilterComparison. Do
7285 * not modify!
7286 */
7287 public Intent getIntent() {
7288 return mIntent;
7289 }
7290
7291 @Override
7292 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007293 if (obj instanceof FilterComparison) {
7294 Intent other = ((FilterComparison)obj).mIntent;
7295 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007296 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007297 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007298 }
7299
7300 @Override
7301 public int hashCode() {
7302 return mHashCode;
7303 }
7304 }
7305
7306 /**
7307 * Determine if two intents are the same for the purposes of intent
7308 * resolution (filtering). That is, if their action, data, type,
7309 * class, and categories are the same. This does <em>not</em> compare
7310 * any extra data included in the intents.
7311 *
7312 * @param other The other Intent to compare against.
7313 *
7314 * @return Returns true if action, data, type, class, and categories
7315 * are the same.
7316 */
7317 public boolean filterEquals(Intent other) {
7318 if (other == null) {
7319 return false;
7320 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007321 if (!Objects.equals(this.mAction, other.mAction)) return false;
7322 if (!Objects.equals(this.mData, other.mData)) return false;
7323 if (!Objects.equals(this.mType, other.mType)) return false;
7324 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7325 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7326 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007327
7328 return true;
7329 }
7330
7331 /**
7332 * Generate hash code that matches semantics of filterEquals().
7333 *
7334 * @return Returns the hash value of the action, data, type, class, and
7335 * categories.
7336 *
7337 * @see #filterEquals
7338 */
7339 public int filterHashCode() {
7340 int code = 0;
7341 if (mAction != null) {
7342 code += mAction.hashCode();
7343 }
7344 if (mData != null) {
7345 code += mData.hashCode();
7346 }
7347 if (mType != null) {
7348 code += mType.hashCode();
7349 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007350 if (mPackage != null) {
7351 code += mPackage.hashCode();
7352 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007353 if (mComponent != null) {
7354 code += mComponent.hashCode();
7355 }
7356 if (mCategories != null) {
7357 code += mCategories.hashCode();
7358 }
7359 return code;
7360 }
7361
7362 @Override
7363 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007364 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007365
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007366 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007367 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007368 b.append(" }");
7369
7370 return b.toString();
7371 }
7372
7373 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007374 public String toInsecureString() {
7375 StringBuilder b = new StringBuilder(128);
7376
7377 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007378 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007379 b.append(" }");
7380
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007381 return b.toString();
7382 }
Romain Guy4969af72009-06-17 10:53:19 -07007383
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007384 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007385 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007386 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007387
7388 b.append("Intent { ");
7389 toShortString(b, false, true, true, true);
7390 b.append(" }");
7391
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007392 return b.toString();
7393 }
7394
7395 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007396 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7397 StringBuilder b = new StringBuilder(128);
7398 toShortString(b, secure, comp, extras, clip);
7399 return b.toString();
7400 }
7401
7402 /** @hide */
7403 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7404 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007405 boolean first = true;
7406 if (mAction != null) {
7407 b.append("act=").append(mAction);
7408 first = false;
7409 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007410 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007411 if (!first) {
7412 b.append(' ');
7413 }
7414 first = false;
7415 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007416 for (int i=0; i<mCategories.size(); i++) {
7417 if (i > 0) b.append(',');
7418 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007419 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007420 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007421 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007422 if (mData != null) {
7423 if (!first) {
7424 b.append(' ');
7425 }
7426 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007427 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007428 if (secure) {
7429 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007430 } else {
7431 b.append(mData);
7432 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007433 }
7434 if (mType != null) {
7435 if (!first) {
7436 b.append(' ');
7437 }
7438 first = false;
7439 b.append("typ=").append(mType);
7440 }
7441 if (mFlags != 0) {
7442 if (!first) {
7443 b.append(' ');
7444 }
7445 first = false;
7446 b.append("flg=0x").append(Integer.toHexString(mFlags));
7447 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007448 if (mPackage != null) {
7449 if (!first) {
7450 b.append(' ');
7451 }
7452 first = false;
7453 b.append("pkg=").append(mPackage);
7454 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007455 if (comp && mComponent != null) {
7456 if (!first) {
7457 b.append(' ');
7458 }
7459 first = false;
7460 b.append("cmp=").append(mComponent.flattenToShortString());
7461 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007462 if (mSourceBounds != null) {
7463 if (!first) {
7464 b.append(' ');
7465 }
7466 first = false;
7467 b.append("bnds=").append(mSourceBounds.toShortString());
7468 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007469 if (mClipData != null) {
7470 if (!first) {
7471 b.append(' ');
7472 }
7473 first = false;
7474 if (clip) {
7475 b.append("clip={");
7476 mClipData.toShortString(b);
7477 b.append('}');
7478 } else {
7479 b.append("(has clip)");
7480 }
7481 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007482 if (extras && mExtras != null) {
7483 if (!first) {
7484 b.append(' ');
7485 }
7486 first = false;
7487 b.append("(has extras)");
7488 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007489 if (mContentUserHint != UserHandle.USER_CURRENT) {
7490 if (!first) {
7491 b.append(' ');
7492 }
7493 first = false;
7494 b.append("u=").append(mContentUserHint);
7495 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007496 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007497 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007498 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007499 b.append("}");
7500 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007501 }
7502
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007503 /**
7504 * Call {@link #toUri} with 0 flags.
7505 * @deprecated Use {@link #toUri} instead.
7506 */
7507 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007508 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007509 return toUri(0);
7510 }
7511
7512 /**
7513 * Convert this Intent into a String holding a URI representation of it.
7514 * The returned URI string has been properly URI encoded, so it can be
7515 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7516 * Intent's data as the base URI, with an additional fragment describing
7517 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007518 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007519 * <p>You can convert the returned string back to an Intent with
7520 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007521 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007522 * @param flags Additional operating flags. Either 0,
7523 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007524 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007525 * @return Returns a URI encoding URI string describing the entire contents
7526 * of the Intent.
7527 */
7528 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007529 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007530 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7531 if (mPackage == null) {
7532 throw new IllegalArgumentException(
7533 "Intent must include an explicit package name to build an android-app: "
7534 + this);
7535 }
7536 uri.append("android-app://");
7537 uri.append(mPackage);
7538 String scheme = null;
7539 if (mData != null) {
7540 scheme = mData.getScheme();
7541 if (scheme != null) {
7542 uri.append('/');
7543 uri.append(scheme);
7544 String authority = mData.getEncodedAuthority();
7545 if (authority != null) {
7546 uri.append('/');
7547 uri.append(authority);
7548 String path = mData.getEncodedPath();
7549 if (path != null) {
7550 uri.append(path);
7551 }
7552 String queryParams = mData.getEncodedQuery();
7553 if (queryParams != null) {
7554 uri.append('?');
7555 uri.append(queryParams);
7556 }
7557 String fragment = mData.getEncodedFragment();
7558 if (fragment != null) {
7559 uri.append('#');
7560 uri.append(fragment);
7561 }
7562 }
7563 }
7564 }
7565 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7566 mPackage, flags);
7567 return uri.toString();
7568 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007569 String scheme = null;
7570 if (mData != null) {
7571 String data = mData.toString();
7572 if ((flags&URI_INTENT_SCHEME) != 0) {
7573 final int N = data.length();
7574 for (int i=0; i<N; i++) {
7575 char c = data.charAt(i);
7576 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7577 || c == '.' || c == '-') {
7578 continue;
7579 }
7580 if (c == ':' && i > 0) {
7581 // Valid scheme.
7582 scheme = data.substring(0, i);
7583 uri.append("intent:");
7584 data = data.substring(i+1);
7585 break;
7586 }
Tom Taylord4a47292009-12-21 13:59:18 -08007587
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007588 // No scheme.
7589 break;
7590 }
7591 }
7592 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007593
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007594 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7595 uri.append("intent:");
7596 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007597
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007598 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007599
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007600 return uri.toString();
7601 }
7602
7603 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7604 String defPackage, int flags) {
7605 StringBuilder frag = new StringBuilder(128);
7606
7607 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007608 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007609 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007610 // Note that for now we are not going to try to handle the
7611 // data part; not clear how to represent this as a URI, and
7612 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007613 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7614 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007615 }
7616
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007617 if (frag.length() > 0) {
7618 uri.append("#Intent;");
7619 uri.append(frag);
7620 uri.append("end");
7621 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007622 }
7623
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007624 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7625 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007626 if (scheme != null) {
7627 uri.append("scheme=").append(scheme).append(';');
7628 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007629 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007630 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007631 }
7632 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007633 for (int i=0; i<mCategories.size(); i++) {
7634 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007635 }
7636 }
7637 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007638 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007639 }
7640 if (mFlags != 0) {
7641 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7642 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007643 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007644 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7645 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007646 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007647 uri.append("component=").append(Uri.encode(
7648 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007649 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007650 if (mSourceBounds != null) {
7651 uri.append("sourceBounds=")
7652 .append(Uri.encode(mSourceBounds.flattenToString()))
7653 .append(';');
7654 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007655 if (mExtras != null) {
7656 for (String key : mExtras.keySet()) {
7657 final Object value = mExtras.get(key);
7658 char entryType =
7659 value instanceof String ? 'S' :
7660 value instanceof Boolean ? 'B' :
7661 value instanceof Byte ? 'b' :
7662 value instanceof Character ? 'c' :
7663 value instanceof Double ? 'd' :
7664 value instanceof Float ? 'f' :
7665 value instanceof Integer ? 'i' :
7666 value instanceof Long ? 'l' :
7667 value instanceof Short ? 's' :
7668 '\0';
7669
7670 if (entryType != '\0') {
7671 uri.append(entryType);
7672 uri.append('.');
7673 uri.append(Uri.encode(key));
7674 uri.append('=');
7675 uri.append(Uri.encode(value.toString()));
7676 uri.append(';');
7677 }
7678 }
7679 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007680 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007681
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007682 public int describeContents() {
7683 return (mExtras != null) ? mExtras.describeContents() : 0;
7684 }
7685
7686 public void writeToParcel(Parcel out, int flags) {
7687 out.writeString(mAction);
7688 Uri.writeToParcel(out, mData);
7689 out.writeString(mType);
7690 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007691 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007692 ComponentName.writeToParcel(mComponent, out);
7693
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007694 if (mSourceBounds != null) {
7695 out.writeInt(1);
7696 mSourceBounds.writeToParcel(out, flags);
7697 } else {
7698 out.writeInt(0);
7699 }
7700
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007701 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007702 final int N = mCategories.size();
7703 out.writeInt(N);
7704 for (int i=0; i<N; i++) {
7705 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007706 }
7707 } else {
7708 out.writeInt(0);
7709 }
7710
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007711 if (mSelector != null) {
7712 out.writeInt(1);
7713 mSelector.writeToParcel(out, flags);
7714 } else {
7715 out.writeInt(0);
7716 }
7717
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007718 if (mClipData != null) {
7719 out.writeInt(1);
7720 mClipData.writeToParcel(out, flags);
7721 } else {
7722 out.writeInt(0);
7723 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007724 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007725 out.writeBundle(mExtras);
7726 }
7727
7728 public static final Parcelable.Creator<Intent> CREATOR
7729 = new Parcelable.Creator<Intent>() {
7730 public Intent createFromParcel(Parcel in) {
7731 return new Intent(in);
7732 }
7733 public Intent[] newArray(int size) {
7734 return new Intent[size];
7735 }
7736 };
7737
Dianne Hackborneb034652009-09-07 00:49:58 -07007738 /** @hide */
7739 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007740 readFromParcel(in);
7741 }
7742
7743 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007744 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007745 mData = Uri.CREATOR.createFromParcel(in);
7746 mType = in.readString();
7747 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007748 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007749 mComponent = ComponentName.readFromParcel(in);
7750
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007751 if (in.readInt() != 0) {
7752 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7753 }
7754
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007755 int N = in.readInt();
7756 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007757 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007758 int i;
7759 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007760 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007761 }
7762 } else {
7763 mCategories = null;
7764 }
7765
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007766 if (in.readInt() != 0) {
7767 mSelector = new Intent(in);
7768 }
7769
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007770 if (in.readInt() != 0) {
7771 mClipData = new ClipData(in);
7772 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007773 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007774 mExtras = in.readBundle();
7775 }
7776
7777 /**
7778 * Parses the "intent" element (and its children) from XML and instantiates
7779 * an Intent object. The given XML parser should be located at the tag
7780 * where parsing should start (often named "intent"), from which the
7781 * basic action, data, type, and package and class name will be
7782 * retrieved. The function will then parse in to any child elements,
7783 * looking for <category android:name="xxx"> tags to add categories and
7784 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7785 * to the intent.
7786 *
7787 * @param resources The Resources to use when inflating resources.
7788 * @param parser The XML parser pointing at an "intent" tag.
7789 * @param attrs The AttributeSet interface for retrieving extended
7790 * attribute data at the current <var>parser</var> location.
7791 * @return An Intent object matching the XML data.
7792 * @throws XmlPullParserException If there was an XML parsing error.
7793 * @throws IOException If there was an I/O error.
7794 */
7795 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7796 throws XmlPullParserException, IOException {
7797 Intent intent = new Intent();
7798
7799 TypedArray sa = resources.obtainAttributes(attrs,
7800 com.android.internal.R.styleable.Intent);
7801
7802 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7803
7804 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7805 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7806 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7807
7808 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7809 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7810 if (packageName != null && className != null) {
7811 intent.setComponent(new ComponentName(packageName, className));
7812 }
7813
7814 sa.recycle();
7815
7816 int outerDepth = parser.getDepth();
7817 int type;
7818 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7819 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7820 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7821 continue;
7822 }
7823
7824 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007825 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007826 sa = resources.obtainAttributes(attrs,
7827 com.android.internal.R.styleable.IntentCategory);
7828 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7829 sa.recycle();
7830
7831 if (cat != null) {
7832 intent.addCategory(cat);
7833 }
7834 XmlUtils.skipCurrentTag(parser);
7835
Craig Mautner21d24a22014-04-23 11:45:37 -07007836 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007837 if (intent.mExtras == null) {
7838 intent.mExtras = new Bundle();
7839 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007840 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007841 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007842
7843 } else {
7844 XmlUtils.skipCurrentTag(parser);
7845 }
7846 }
7847
7848 return intent;
7849 }
Nick Pellyccae4122012-01-09 14:12:58 -08007850
Craig Mautner21d24a22014-04-23 11:45:37 -07007851 /** @hide */
7852 public void saveToXml(XmlSerializer out) throws IOException {
7853 if (mAction != null) {
7854 out.attribute(null, ATTR_ACTION, mAction);
7855 }
7856 if (mData != null) {
7857 out.attribute(null, ATTR_DATA, mData.toString());
7858 }
7859 if (mType != null) {
7860 out.attribute(null, ATTR_TYPE, mType);
7861 }
7862 if (mComponent != null) {
7863 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7864 }
7865 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7866
7867 if (mCategories != null) {
7868 out.startTag(null, TAG_CATEGORIES);
7869 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7870 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7871 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007872 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007873 }
7874 }
7875
7876 /** @hide */
7877 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7878 XmlPullParserException {
7879 Intent intent = new Intent();
7880 final int outerDepth = in.getDepth();
7881
7882 int attrCount = in.getAttributeCount();
7883 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7884 final String attrName = in.getAttributeName(attrNdx);
7885 final String attrValue = in.getAttributeValue(attrNdx);
7886 if (ATTR_ACTION.equals(attrName)) {
7887 intent.setAction(attrValue);
7888 } else if (ATTR_DATA.equals(attrName)) {
7889 intent.setData(Uri.parse(attrValue));
7890 } else if (ATTR_TYPE.equals(attrName)) {
7891 intent.setType(attrValue);
7892 } else if (ATTR_COMPONENT.equals(attrName)) {
7893 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7894 } else if (ATTR_FLAGS.equals(attrName)) {
7895 intent.setFlags(Integer.valueOf(attrValue, 16));
7896 } else {
7897 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7898 }
7899 }
7900
7901 int event;
7902 String name;
7903 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7904 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7905 if (event == XmlPullParser.START_TAG) {
7906 name = in.getName();
7907 if (TAG_CATEGORIES.equals(name)) {
7908 attrCount = in.getAttributeCount();
7909 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7910 intent.addCategory(in.getAttributeValue(attrNdx));
7911 }
7912 } else {
7913 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7914 XmlUtils.skipCurrentTag(in);
7915 }
7916 }
7917 }
7918
7919 return intent;
7920 }
7921
Nick Pellyccae4122012-01-09 14:12:58 -08007922 /**
7923 * Normalize a MIME data type.
7924 *
7925 * <p>A normalized MIME type has white-space trimmed,
7926 * content-type parameters removed, and is lower-case.
7927 * This aligns the type with Android best practices for
7928 * intent filtering.
7929 *
7930 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7931 * "text/x-vCard" becomes "text/x-vcard".
7932 *
7933 * <p>All MIME types received from outside Android (such as user input,
7934 * or external sources like Bluetooth, NFC, or the Internet) should
7935 * be normalized before they are used to create an Intent.
7936 *
7937 * @param type MIME data type to normalize
7938 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007939 * @see #setType
7940 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007941 */
7942 public static String normalizeMimeType(String type) {
7943 if (type == null) {
7944 return null;
7945 }
7946
Elliott Hughescb64d432013-08-02 10:00:44 -07007947 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007948
7949 final int semicolonIndex = type.indexOf(';');
7950 if (semicolonIndex != -1) {
7951 type = type.substring(0, semicolonIndex);
7952 }
7953 return type;
7954 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007955
7956 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007957 * Prepare this {@link Intent} to leave an app process.
7958 *
7959 * @hide
7960 */
7961 public void prepareToLeaveProcess() {
7962 setAllowFds(false);
7963
7964 if (mSelector != null) {
7965 mSelector.prepareToLeaveProcess();
7966 }
7967 if (mClipData != null) {
7968 mClipData.prepareToLeaveProcess();
7969 }
7970
7971 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
7972 // There are several ACTION_MEDIA_* broadcasts that send file://
7973 // Uris, so only check common actions.
7974 if (ACTION_VIEW.equals(mAction) ||
7975 ACTION_EDIT.equals(mAction) ||
7976 ACTION_ATTACH_DATA.equals(mAction)) {
7977 mData.checkFileUriExposed("Intent.getData()");
7978 }
7979 }
7980 }
7981
7982 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007983 * @hide
7984 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007985 public void prepareToEnterProcess() {
7986 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00007987 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
7988 fixUris(mContentUserHint);
7989 mContentUserHint = UserHandle.USER_CURRENT;
7990 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007991 }
7992 }
7993
7994 /**
7995 * @hide
7996 */
7997 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007998 Uri data = getData();
7999 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008000 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008001 }
8002 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008003 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008004 }
8005 String action = getAction();
8006 if (ACTION_SEND.equals(action)) {
8007 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8008 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008009 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008010 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008011 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008012 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8013 if (streams != null) {
8014 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8015 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008016 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008017 }
8018 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8019 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008020 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8021 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8022 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8023 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8024 if (output != null) {
8025 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8026 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008027 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008028 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008029
8030 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008031 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008032 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8033 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008034 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008035 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008036 * @hide
8037 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008038 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008039 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008040 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008041
8042 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008043 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008044
8045 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008046 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008047 // Inspect contained intents to see if we need to migrate extras. We
8048 // don't promote ClipData to the parent, since ChooserActivity will
8049 // already start the picked item as the caller, and we can't combine
8050 // the flags in a safe way.
8051
8052 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008053 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008054 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8055 if (intent != null) {
8056 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008057 }
8058 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008059 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008060 try {
8061 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8062 if (intents != null) {
8063 for (int i = 0; i < intents.length; i++) {
8064 final Intent intent = (Intent) intents[i];
8065 if (intent != null) {
8066 migrated |= intent.migrateExtraStreamToClipData();
8067 }
8068 }
8069 }
8070 } catch (ClassCastException e) {
8071 }
8072 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008073
8074 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008075 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008076 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8077 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8078 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8079 if (stream != null || text != null || htmlText != null) {
8080 final ClipData clipData = new ClipData(
8081 null, new String[] { getType() },
8082 new ClipData.Item(text, htmlText, null, stream));
8083 setClipData(clipData);
8084 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008085 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008086 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008087 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008088 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008089
8090 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008091 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008092 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8093 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8094 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8095 int num = -1;
8096 if (streams != null) {
8097 num = streams.size();
8098 }
8099 if (texts != null) {
8100 if (num >= 0 && num != texts.size()) {
8101 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008102 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008103 }
8104 num = texts.size();
8105 }
8106 if (htmlTexts != null) {
8107 if (num >= 0 && num != htmlTexts.size()) {
8108 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008109 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008110 }
8111 num = htmlTexts.size();
8112 }
8113 if (num > 0) {
8114 final ClipData clipData = new ClipData(
8115 null, new String[] { getType() },
8116 makeClipItem(streams, texts, htmlTexts, 0));
8117
8118 for (int i = 1; i < num; i++) {
8119 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8120 }
8121
8122 setClipData(clipData);
8123 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008124 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008125 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008126 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008127 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008128 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8129 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8130 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8131 final Uri output;
8132 try {
8133 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8134 } catch (ClassCastException e) {
8135 return false;
8136 }
8137 if (output != null) {
8138 setClipData(ClipData.newRawUri("", output));
8139 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8140 return true;
8141 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008142 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008143
8144 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008145 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008146
8147 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8148 ArrayList<String> htmlTexts, int which) {
8149 Uri uri = streams != null ? streams.get(which) : null;
8150 CharSequence text = texts != null ? texts.get(which) : null;
8151 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8152 return new ClipData.Item(text, htmlText, null, uri);
8153 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008154
8155 /** @hide */
8156 public boolean isDocument() {
8157 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8158 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008159}