blob: 2db623b342da89c60b565ca30668d737a683c79e [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 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001538 * Activity action: Launch UI to manage permissions.
1539 * <p>
1540 * Input: Nothing.
1541 * </p>
1542 * <p>
1543 * Output: Nothing.
1544 * </p>
1545 *
1546 * @hide
1547 */
1548 @SystemApi
1549 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1550 public static final String ACTION_MANAGE_PERMISSIONS =
1551 "android.intent.action.MANAGE_PERMISSIONS";
1552
1553 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001554 * Intent extra: An app package name.
1555 * <p>
1556 * Type: String
1557 * </p>S
1558 *
1559 * @hide
1560 */
1561 @SystemApi
1562 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1563
1564 /**
1565 * Activity action: Launch UI to manage which apps have a given permission.
1566 * <p>
1567 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1568 * to which will be managed by the launched UI.
1569 * </p>
1570 * <p>
1571 * Output: Nothing.
1572 * </p>
1573 *
1574 * @see #EXTRA_PERMISSION_NAME
1575 *
1576 * @hide
1577 */
1578 @SystemApi
1579 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1580 public static final String ACTION_MANAGE_PERMISSION_APPS =
1581 "android.intent.action.MANAGE_PERMISSION_APPS";
1582
1583 /**
1584 * Intent extra: The name of a permission.
1585 * <p>
1586 * Type: String
1587 * </p>
1588 *
1589 * @hide
1590 */
1591 @SystemApi
1592 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1593
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001594 // ---------------------------------------------------------------------
1595 // ---------------------------------------------------------------------
1596 // Standard intent broadcast actions (see action variable).
1597
1598 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001599 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1600 * <p>
1601 * For historical reasons, the name of this broadcast action refers to the power
1602 * state of the screen but it is actually sent in response to changes in the
1603 * overall interactive state of the device.
1604 * </p><p>
1605 * This broadcast is sent when the device becomes non-interactive which may have
1606 * nothing to do with the screen turning off. To determine the
1607 * actual state of the screen, use {@link android.view.Display#getState}.
1608 * </p><p>
1609 * See {@link android.os.PowerManager#isInteractive} for details.
1610 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001611 * You <em>cannot</em> receive this through components declared in
1612 * manifests, only by explicitly registering for it with
1613 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1614 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001615 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001616 * <p class="note">This is a protected intent that can only be sent
1617 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001618 */
1619 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1620 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001621
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001622 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001623 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1624 * <p>
1625 * For historical reasons, the name of this broadcast action refers to the power
1626 * state of the screen but it is actually sent in response to changes in the
1627 * overall interactive state of the device.
1628 * </p><p>
1629 * This broadcast is sent when the device becomes interactive which may have
1630 * nothing to do with the screen turning on. To determine the
1631 * actual state of the screen, use {@link android.view.Display#getState}.
1632 * </p><p>
1633 * See {@link android.os.PowerManager#isInteractive} for details.
1634 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001635 * You <em>cannot</em> receive this through components declared in
1636 * manifests, only by explicitly registering for it with
1637 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1638 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001639 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001640 * <p class="note">This is a protected intent that can only be sent
1641 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001642 */
1643 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1644 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001645
1646 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001647 * Broadcast Action: Sent after the system stops dreaming.
1648 *
1649 * <p class="note">This is a protected intent that can only be sent by the system.
1650 * It is only sent to registered receivers.</p>
1651 */
1652 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1653 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1654
1655 /**
1656 * Broadcast Action: Sent after the system starts dreaming.
1657 *
1658 * <p class="note">This is a protected intent that can only be sent by the system.
1659 * It is only sent to registered receivers.</p>
1660 */
1661 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1662 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1663
1664 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001665 * 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 -07001666 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001667 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001668 * <p class="note">This is a protected intent that can only be sent
1669 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001670 */
1671 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001672 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001673
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001674 /**
1675 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001676 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001677 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001678 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1679 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001680 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001681 * <p class="note">This is a protected intent that can only be sent
1682 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001683 */
1684 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1685 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1686 /**
1687 * Broadcast Action: The time was set.
1688 */
1689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1690 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1691 /**
1692 * Broadcast Action: The date has changed.
1693 */
1694 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1695 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1696 /**
1697 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1698 * <ul>
1699 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1700 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001701 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001702 * <p class="note">This is a protected intent that can only be sent
1703 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001704 */
1705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1706 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1707 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001708 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1709 * DNS entries should be tossed.
1710 * @hide
1711 */
1712 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1713 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1714 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001715 * Alarm Changed Action: This is broadcast when the AlarmClock
1716 * application's alarm is set or unset. It is used by the
1717 * AlarmClock application and the StatusBar service.
1718 * @hide
1719 */
1720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1721 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1722 /**
1723 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1724 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1725 * @hide
1726 */
1727 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1728 public static final String ACTION_SYNC_STATE_CHANGED
1729 = "android.intent.action.SYNC_STATE_CHANGED";
1730 /**
1731 * Broadcast Action: This is broadcast once, after the system has finished
1732 * booting. It can be used to perform application-specific initialization,
1733 * such as installing alarms. You must hold the
1734 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1735 * in order to receive this broadcast.
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.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001739 */
1740 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1741 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1742 /**
1743 * Broadcast Action: This is broadcast when a user action should request a
1744 * temporary system dialog to dismiss. Some examples of temporary system
1745 * dialogs are the notification window-shade and the recent tasks dialog.
1746 */
1747 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1748 /**
1749 * Broadcast Action: Trigger the download and eventual installation
1750 * of a package.
1751 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001752 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001753 * <p class="note">This is a protected intent that can only be sent
1754 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001755 *
1756 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001757 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001758 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001759 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1760 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1761 /**
1762 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001763 * device. The data contains the name of the package. Note that the
1764 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001765 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001766 * <ul>
1767 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1768 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1769 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1770 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001771 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001772 * <p class="note">This is a protected intent that can only be sent
1773 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001774 */
1775 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1776 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1777 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001778 * Broadcast Action: A new version of an application package has been
1779 * installed, replacing an existing version that was previously installed.
1780 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001781 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001782 * <ul>
1783 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1784 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001785 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001786 * <p class="note">This is a protected intent that can only be sent
1787 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001788 */
1789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1790 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1791 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001792 * Broadcast Action: A new version of your application has been installed
1793 * over an existing one. This is only sent to the application that was
1794 * replaced. It does not contain any additional data; to receive it, just
1795 * use an intent filter for this action.
1796 *
1797 * <p class="note">This is a protected intent that can only be sent
1798 * by the system.
1799 */
1800 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1801 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1802 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001803 * Broadcast Action: An existing application package has been removed from
1804 * the device. The data contains the name of the package. The package
1805 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001806 * <ul>
1807 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1808 * to the package.
1809 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1810 * application -- data and code -- is being removed.
1811 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1812 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1813 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001814 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001815 * <p class="note">This is a protected intent that can only be sent
1816 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001817 */
1818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1819 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1820 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001821 * Broadcast Action: An existing application package has been completely
1822 * removed from the device. The data contains the name of the package.
1823 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1824 * {@link #EXTRA_DATA_REMOVED} is true and
1825 * {@link #EXTRA_REPLACING} is false of that broadcast.
1826 *
1827 * <ul>
1828 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1829 * to the package.
1830 * </ul>
1831 *
1832 * <p class="note">This is a protected intent that can only be sent
1833 * by the system.
1834 */
1835 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1836 public static final String ACTION_PACKAGE_FULLY_REMOVED
1837 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1838 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001839 * Broadcast Action: An existing application package has been changed (e.g.
1840 * a component has been enabled or disabled). The data contains the name of
1841 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001842 * <ul>
1843 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001844 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001845 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001846 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1847 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001848 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001849 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001850 * <p class="note">This is a protected intent that can only be sent
1851 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001852 */
1853 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1854 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1855 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001856 * @hide
1857 * Broadcast Action: Ask system services if there is any reason to
1858 * restart the given package. The data contains the name of the
1859 * package.
1860 * <ul>
1861 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1862 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1863 * </ul>
1864 *
1865 * <p class="note">This is a protected intent that can only be sent
1866 * by the system.
1867 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001868 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001869 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1870 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1871 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001872 * Broadcast Action: The user has restarted a package, and all of its
1873 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001874 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001875 * be removed. Note that the restarted package does <em>not</em>
1876 * receive this broadcast.
1877 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001878 * <ul>
1879 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1880 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001881 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001882 * <p class="note">This is a protected intent that can only be sent
1883 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001884 */
1885 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1886 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1887 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001888 * Broadcast Action: The user has cleared the data of a package. This should
1889 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001890 * its persistent data is erased and this broadcast sent.
1891 * Note that the cleared package does <em>not</em>
1892 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001893 * <ul>
1894 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1895 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001896 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001897 * <p class="note">This is a protected intent that can only be sent
1898 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001899 */
1900 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1901 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1902 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001903 * Broadcast Action: A user ID has been removed from the system. The user
1904 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001905 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001906 * <p class="note">This is a protected intent that can only be sent
1907 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001908 */
1909 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1910 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001911
1912 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001913 * Broadcast Action: Sent to the installer package of an application
1914 * when that application is first launched (that is the first time it
1915 * is moved out of the stopped state). The data contains the name of the package.
1916 *
1917 * <p class="note">This is a protected intent that can only be sent
1918 * by the system.
1919 */
1920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1921 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1922
1923 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001924 * Broadcast Action: Sent to the system package verifier when a package
1925 * needs to be verified. The data contains the package URI.
1926 * <p class="note">
1927 * This is a protected intent that can only be sent by the system.
1928 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001929 */
1930 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1931 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1932
1933 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001934 * Broadcast Action: Sent to the system package verifier when a package is
1935 * verified. The data contains the package URI.
1936 * <p class="note">
1937 * This is a protected intent that can only be sent by the system.
1938 */
1939 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1940 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1941
1942 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08001943 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
1944 * needs to be verified. The data contains the filter data hosts to be verified against.
1945 * <p class="note">
1946 * This is a protected intent that can only be sent by the system.
1947 * </p>
1948 *
1949 * @hide
1950 */
1951 @SystemApi
1952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1953 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
1954
1955 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001956 * Broadcast Action: Resources for a set of packages (which were
1957 * previously unavailable) are currently
1958 * available since the media on which they exist is available.
1959 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1960 * list of packages whose availability changed.
1961 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1962 * list of uids of packages whose availability changed.
1963 * Note that the
1964 * packages in this list do <em>not</em> receive this broadcast.
1965 * The specified set of packages are now available on the system.
1966 * <p>Includes the following extras:
1967 * <ul>
1968 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1969 * whose resources(were previously unavailable) are currently available.
1970 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1971 * packages whose resources(were previously unavailable)
1972 * are currently available.
1973 * </ul>
1974 *
1975 * <p class="note">This is a protected intent that can only be sent
1976 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001977 */
1978 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001979 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1980 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001981
1982 /**
1983 * Broadcast Action: Resources for a set of packages are currently
1984 * unavailable since the media on which they exist is unavailable.
1985 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1986 * list of packages whose availability changed.
1987 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1988 * list of uids of packages whose availability changed.
1989 * The specified set of packages can no longer be
1990 * launched and are practically unavailable on the system.
1991 * <p>Inclues the following extras:
1992 * <ul>
1993 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1994 * whose resources are no longer available.
1995 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1996 * whose resources are no longer available.
1997 * </ul>
1998 *
1999 * <p class="note">This is a protected intent that can only be sent
2000 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002001 */
2002 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002003 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002004 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002005
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002006 /**
2007 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002008 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002009 * This should <em>only</em> be used to determine when the wallpaper
2010 * has changed to show the new wallpaper to the user. You should certainly
2011 * never, in response to this, change the wallpaper or other attributes of
2012 * it such as the suggested size. That would be crazy, right? You'd cause
2013 * all kinds of loops, especially if other apps are doing similar things,
2014 * right? Of course. So please don't do this.
2015 *
2016 * @deprecated Modern applications should use
2017 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2018 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2019 * shown behind their UI, rather than watching for this broadcast and
2020 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002022 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002023 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2024 /**
2025 * Broadcast Action: The current device {@link android.content.res.Configuration}
2026 * (orientation, locale, etc) has changed. When such a change happens, the
2027 * UIs (view hierarchy) will need to be rebuilt based on this new
2028 * information; for the most part, applications don't need to worry about
2029 * this, because the system will take care of stopping and restarting the
2030 * application to make sure it sees the new changes. Some system code that
2031 * can not be restarted will need to watch for this action and handle it
2032 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002033 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002034 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002035 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002036 * in manifests, only by explicitly registering for it with
2037 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2038 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002039 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002040 * <p class="note">This is a protected intent that can only be sent
2041 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002042 *
2043 * @see android.content.res.Configuration
2044 */
2045 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2046 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2047 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002048 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002049 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002050 * <p class="note">This is a protected intent that can only be sent
2051 * by the system.
2052 */
2053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2054 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2055 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002056 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2057 * charging state, level, and other information about the battery.
2058 * See {@link android.os.BatteryManager} for documentation on the
2059 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002060 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002061 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002062 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002063 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002064 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002065 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2066 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2067 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2068 * broadcasts that are sent and can be received through manifest
2069 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002070 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002071 * <p class="note">This is a protected intent that can only be sent
2072 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002073 */
2074 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2075 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2076 /**
2077 * Broadcast Action: Indicates low battery condition on the device.
2078 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002079 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002080 * <p class="note">This is a protected intent that can only be sent
2081 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002082 */
2083 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2084 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2085 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002086 * Broadcast Action: Indicates the battery is now okay after being low.
2087 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2088 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002089 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002090 * <p class="note">This is a protected intent that can only be sent
2091 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002092 */
2093 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2094 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2095 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002096 * Broadcast Action: External power has been connected to the device.
2097 * This is intended for applications that wish to register specifically to this notification.
2098 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2099 * stay active to receive this notification. This action can be used to implement actions
2100 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002101 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002102 * <p class="note">This is a protected intent that can only be sent
2103 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002104 */
2105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002106 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002107 /**
2108 * Broadcast Action: External power has been removed from the device.
2109 * This is intended for applications that wish to register specifically to this notification.
2110 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2111 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002112 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002113 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002114 * <p class="note">This is a protected intent that can only be sent
2115 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002116 */
2117 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002118 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002119 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002120 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002121 * Broadcast Action: Device is shutting down.
2122 * This is broadcast when the device is being shut down (completely turned
2123 * off, not sleeping). Once the broadcast is complete, the final shutdown
2124 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002125 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002126 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002127 * <p class="note">This is a protected intent that can only be sent
2128 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002129 * <p>May include the following extras:
2130 * <ul>
2131 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2132 * shutdown is only for userspace processes. If not set, assumed to be false.
2133 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002134 */
2135 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002136 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002137 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002138 * Activity Action: Start this activity to request system shutdown.
2139 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2140 * to request confirmation from the user before shutting down.
2141 *
2142 * <p class="note">This is a protected intent that can only be sent
2143 * by the system.
2144 *
2145 * {@hide}
2146 */
2147 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2148 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002149 * Broadcast Action: A sticky broadcast that indicates low memory
2150 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002151 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002152 * <p class="note">This is a protected intent that can only be sent
2153 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002154 */
2155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2156 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2157 /**
2158 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002159 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002160 * <p class="note">This is a protected intent that can only be sent
2161 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002162 */
2163 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2164 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2165 /**
Jake Hambybb371632010-08-23 18:16:48 -07002166 * Broadcast Action: A sticky broadcast that indicates a memory full
2167 * condition on the device. This is intended for activities that want
2168 * to be able to fill the data partition completely, leaving only
2169 * enough free space to prevent system-wide SQLite failures.
2170 *
2171 * <p class="note">This is a protected intent that can only be sent
2172 * by the system.
2173 *
2174 * {@hide}
2175 */
2176 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2177 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2178 /**
2179 * Broadcast Action: Indicates memory full condition on the device
2180 * no longer exists.
2181 *
2182 * <p class="note">This is a protected intent that can only be sent
2183 * by the system.
2184 *
2185 * {@hide}
2186 */
2187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2188 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2189 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002190 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2191 * and package management should be started.
2192 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2193 * notification.
2194 */
2195 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2196 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2197 /**
2198 * Broadcast Action: The device has entered USB Mass Storage mode.
2199 * This is used mainly for the USB Settings panel.
2200 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2201 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002202 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002203 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002204 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002205 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2206
2207 /**
2208 * Broadcast Action: The device has exited USB Mass Storage mode.
2209 * This is used mainly for the USB Settings panel.
2210 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2211 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002212 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002213 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002214 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002215 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2216
2217 /**
2218 * Broadcast Action: External media has been removed.
2219 * The path to the mount point for the removed media is contained in the Intent.mData field.
2220 */
2221 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2222 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2223
2224 /**
2225 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002226 * 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 -07002227 */
2228 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2229 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2230
2231 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002232 * Broadcast Action: External media is present, and being disk-checked
2233 * 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 -08002234 */
2235 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2236 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2237
2238 /**
2239 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2240 * 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 -08002241 */
2242 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2243 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2244
2245 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002246 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002247 * 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 -07002248 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2249 * media was mounted read only.
2250 */
2251 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2252 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2253
2254 /**
2255 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002256 * 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 -07002257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2259 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2260
2261 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002262 * Broadcast Action: External media is no longer being shared via USB mass storage.
2263 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2264 *
2265 * @hide
2266 */
2267 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2268
2269 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002270 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2271 * The path to the mount point for the removed media is contained in the Intent.mData field.
2272 */
2273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2274 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2275
2276 /**
2277 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002278 * 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 -07002279 */
2280 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2281 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2282
2283 /**
2284 * Broadcast Action: User has expressed the desire to remove the external storage media.
2285 * Applications should close all files they have open within the mount point when they receive this intent.
2286 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2287 */
2288 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2289 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2290
2291 /**
2292 * Broadcast Action: The media scanner has started scanning a directory.
2293 * The path to the directory being scanned is contained in the Intent.mData field.
2294 */
2295 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2296 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2297
2298 /**
2299 * Broadcast Action: The media scanner has finished scanning a directory.
2300 * The path to the scanned directory is contained in the Intent.mData field.
2301 */
2302 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2303 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2304
2305 /**
2306 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2307 * The path to the file is contained in the Intent.mData field.
2308 */
2309 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2310 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2311
2312 /**
2313 * Broadcast Action: The "Media Button" was pressed. Includes a single
2314 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2315 * caused the broadcast.
2316 */
2317 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2318 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2319
2320 /**
2321 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2322 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2323 * caused the broadcast.
2324 */
2325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2326 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2327
2328 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2329 // location; they are not general-purpose actions.
2330
2331 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002332 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002333 */
2334 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2335 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2336 "android.intent.action.GTALK_CONNECTED";
2337
2338 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002339 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002340 */
2341 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2342 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2343 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002344
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002345 /**
2346 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002347 */
2348 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2349 public static final String ACTION_INPUT_METHOD_CHANGED =
2350 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002351
2352 /**
2353 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2354 * more radios have been turned off or on. The intent will have the following extra value:</p>
2355 * <ul>
2356 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2357 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2358 * turned off</li>
2359 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002360 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002361 * <p class="note">This is a protected intent that can only be sent
2362 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002363 */
2364 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2365 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2366
2367 /**
2368 * Broadcast Action: Some content providers have parts of their namespace
2369 * where they publish new events or items that the user may be especially
2370 * interested in. For these things, they may broadcast this action when the
2371 * set of interesting items change.
2372 *
2373 * For example, GmailProvider sends this notification when the set of unread
2374 * mail in the inbox changes.
2375 *
2376 * <p>The data of the intent identifies which part of which provider
2377 * changed. When queried through the content resolver, the data URI will
2378 * return the data set in question.
2379 *
2380 * <p>The intent will have the following extra values:
2381 * <ul>
2382 * <li><em>count</em> - The number of items in the data set. This is the
2383 * same as the number of items in the cursor returned by querying the
2384 * data URI. </li>
2385 * </ul>
2386 *
2387 * This intent will be sent at boot (if the count is non-zero) and when the
2388 * data set changes. It is possible for the data set to change without the
2389 * count changing (for example, if a new unread message arrives in the same
2390 * sync operation in which a message is archived). The phone should still
2391 * ring/vibrate/etc as normal in this case.
2392 */
2393 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2394 public static final String ACTION_PROVIDER_CHANGED =
2395 "android.intent.action.PROVIDER_CHANGED";
2396
2397 /**
2398 * Broadcast Action: Wired Headset plugged in or unplugged.
2399 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002400 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2401 * and documentation.
2402 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002403 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002404 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002405 */
2406 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002407 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002408
2409 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002410 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2411 * <ul>
2412 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2413 * </ul>
2414 *
2415 * <p class="note">This is a protected intent that can only be sent
2416 * by the system.
2417 *
2418 * @hide
2419 */
2420 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2421 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2422 = "android.intent.action.ADVANCED_SETTINGS";
2423
2424 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002425 * Broadcast Action: Sent after application restrictions are changed.
2426 *
2427 * <p class="note">This is a protected intent that can only be sent
2428 * by the system.</p>
2429 */
2430 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2431 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2432 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2433
2434 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002435 * Broadcast Action: An outgoing call is about to be placed.
2436 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002437 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002438 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002439 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002440 * the phone number originally intended to be dialed.</li>
2441 * </ul>
2442 * <p>Once the broadcast is finished, the resultData is used as the actual
2443 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002444 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002445 * outgoing call in turn: for example, a parental control application
2446 * might verify that the user is authorized to place the call at that
2447 * time, then a number-rewriting application might add an area code if
2448 * one was not specified.</p>
2449 * <p>For consistency, any receiver whose purpose is to prohibit phone
2450 * calls should have a priority of 0, to ensure it will see the final
2451 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002452 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002453 * should have a positive priority.
2454 * Negative priorities are reserved for the system for this broadcast;
2455 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002456 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2457 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002458 * <p>Emergency calls cannot be intercepted using this mechanism, and
2459 * other calls cannot be modified to call emergency numbers using this
2460 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002461 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2462 * call to use their own service instead. Those apps should first prevent
2463 * the call from being placed by setting resultData to <code>null</code>
2464 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002465 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2467 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002468 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002469 * <p class="note">This is a protected intent that can only be sent
2470 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002471 */
2472 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2473 public static final String ACTION_NEW_OUTGOING_CALL =
2474 "android.intent.action.NEW_OUTGOING_CALL";
2475
2476 /**
2477 * Broadcast Action: Have the device reboot. This is only for use by
2478 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002479 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002480 * <p class="note">This is a protected intent that can only be sent
2481 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002482 */
2483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2484 public static final String ACTION_REBOOT =
2485 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002486
Wei Huang97ecc9c2009-05-11 17:44:20 -07002487 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002488 * Broadcast Action: A sticky broadcast for changes in the physical
2489 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002490 *
2491 * <p>The intent will have the following extra values:
2492 * <ul>
2493 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002494 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002495 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002496 * <p>This is intended for monitoring the current physical dock state.
2497 * See {@link android.app.UiModeManager} for the normal API dealing with
2498 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002499 */
2500 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2501 public static final String ACTION_DOCK_EVENT =
2502 "android.intent.action.DOCK_EVENT";
2503
2504 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002505 * Broadcast Action: A broadcast when idle maintenance can be started.
2506 * This means that the user is not interacting with the device and is
2507 * not expected to do so soon. Typical use of the idle maintenance is
2508 * to perform somehow expensive tasks that can be postponed at a moment
2509 * when they will not degrade user experience.
2510 * <p>
2511 * <p class="note">In order to keep the device responsive in case of an
2512 * unexpected user interaction, implementations of a maintenance task
2513 * should be interruptible. In such a scenario a broadcast with action
2514 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2515 * should not do the maintenance work in
2516 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2517 * maintenance service by {@link Context#startService(Intent)}. Also
2518 * you should hold a wake lock while your maintenance service is running
2519 * to prevent the device going to sleep.
2520 * </p>
2521 * <p>
2522 * <p class="note">This is a protected intent that can only be sent by
2523 * the system.
2524 * </p>
2525 *
2526 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002527 *
2528 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002529 */
2530 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2531 public static final String ACTION_IDLE_MAINTENANCE_START =
2532 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2533
2534 /**
2535 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2536 * This means that the user was not interacting with the device as a result
2537 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2538 * was sent and now the user started interacting with the device. Typical
2539 * use of the idle maintenance is to perform somehow expensive tasks that
2540 * can be postponed at a moment when they will not degrade user experience.
2541 * <p>
2542 * <p class="note">In order to keep the device responsive in case of an
2543 * unexpected user interaction, implementations of a maintenance task
2544 * should be interruptible. Hence, on receiving a broadcast with this
2545 * action, the maintenance task should be interrupted as soon as possible.
2546 * In other words, you should not do the maintenance work in
2547 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2548 * maintenance service that was started on receiving of
2549 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2550 * lock you acquired when your maintenance service started.
2551 * </p>
2552 * <p class="note">This is a protected intent that can only be sent
2553 * by the system.
2554 *
2555 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002556 *
2557 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002558 */
2559 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2560 public static final String ACTION_IDLE_MAINTENANCE_END =
2561 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2562
2563 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002564 * Broadcast Action: a remote intent is to be broadcasted.
2565 *
2566 * A remote intent is used for remote RPC between devices. The remote intent
2567 * is serialized and sent from one device to another device. The receiving
2568 * device parses the remote intent and broadcasts it. Note that anyone can
2569 * broadcast a remote intent. However, if the intent receiver of the remote intent
2570 * does not trust intent broadcasts from arbitrary intent senders, it should require
2571 * the sender to hold certain permissions so only trusted sender's broadcast will be
2572 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002573 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002574 */
2575 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002576 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002577
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002578 /**
2579 * Broadcast Action: hook for permforming cleanup after a system update.
2580 *
2581 * The broadcast is sent when the system is booting, before the
2582 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2583 * image. A receiver for this should do its work and then disable itself
2584 * so that it does not get run again at the next boot.
2585 * @hide
2586 */
2587 public static final String ACTION_PRE_BOOT_COMPLETED =
2588 "android.intent.action.PRE_BOOT_COMPLETED";
2589
Amith Yamasani13593602012-03-22 16:16:17 -07002590 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002591 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002592 * on restricted users. The broadcast intent contains an extra
2593 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2594 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2595 * String[] depending on the restriction type.<p/>
2596 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002597 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2598 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2599 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002600 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2601 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002602 * @see RestrictionEntry
2603 */
2604 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2605 "android.intent.action.GET_RESTRICTION_ENTRIES";
2606
2607 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002608 * Sent the first time a user is starting, to allow system apps to
2609 * perform one time initialization. (This will not be seen by third
2610 * party applications because a newly initialized user does not have any
2611 * third party applications installed for it.) This is sent early in
2612 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002613 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2614 * broadcast, since it is part of a visible user interaction; be as quick
2615 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002616 */
2617 public static final String ACTION_USER_INITIALIZE =
2618 "android.intent.action.USER_INITIALIZE";
2619
2620 /**
2621 * Sent when a user switch is happening, causing the process's user to be
2622 * brought to the foreground. This is only sent to receivers registered
2623 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2624 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002625 * foreground. This is sent as a foreground
2626 * broadcast, since it is part of a visible user interaction; be as quick
2627 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002628 */
2629 public static final String ACTION_USER_FOREGROUND =
2630 "android.intent.action.USER_FOREGROUND";
2631
2632 /**
2633 * Sent when a user switch is happening, causing the process's user to be
2634 * sent to the background. This is only sent to receivers registered
2635 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2636 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002637 * background. This is sent as a foreground
2638 * broadcast, since it is part of a visible user interaction; be as quick
2639 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002640 */
2641 public static final String ACTION_USER_BACKGROUND =
2642 "android.intent.action.USER_BACKGROUND";
2643
2644 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002645 * Broadcast sent to the system when a user is added. Carries an extra
2646 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2647 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002648 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002649 * @hide
2650 */
2651 public static final String ACTION_USER_ADDED =
2652 "android.intent.action.USER_ADDED";
2653
2654 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002655 * Broadcast sent by the system when a user is started. Carries an extra
2656 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002657 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002658 * that has been started. This is sent as a foreground
2659 * broadcast, since it is part of a visible user interaction; be as quick
2660 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002661 * @hide
2662 */
2663 public static final String ACTION_USER_STARTED =
2664 "android.intent.action.USER_STARTED";
2665
2666 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002667 * Broadcast sent when a user is in the process of starting. Carries an extra
2668 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2669 * sent to registered receivers, not manifest receivers. It is sent to all
2670 * users (including the one that is being started). You must hold
2671 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2672 * this broadcast. This is sent as a background broadcast, since
2673 * its result is not part of the primary UX flow; to safely keep track of
2674 * started/stopped state of a user you can use this in conjunction with
2675 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2676 * other user state broadcasts since those are foreground broadcasts so can
2677 * execute in a different order.
2678 * @hide
2679 */
2680 public static final String ACTION_USER_STARTING =
2681 "android.intent.action.USER_STARTING";
2682
2683 /**
2684 * Broadcast sent when a user is going to be stopped. Carries an extra
2685 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2686 * sent to registered receivers, not manifest receivers. It is sent to all
2687 * users (including the one that is being stopped). You must hold
2688 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2689 * this broadcast. The user will not stop until all receivers have
2690 * handled the broadcast. This is sent as a background broadcast, since
2691 * its result is not part of the primary UX flow; to safely keep track of
2692 * started/stopped state of a user you can use this in conjunction with
2693 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2694 * other user state broadcasts since those are foreground broadcasts so can
2695 * execute in a different order.
2696 * @hide
2697 */
2698 public static final String ACTION_USER_STOPPING =
2699 "android.intent.action.USER_STOPPING";
2700
2701 /**
2702 * Broadcast sent to the system when a user is stopped. Carries an extra
2703 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2704 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2705 * specific package. This is only sent to registered receivers, not manifest
2706 * receivers. It is sent to all running users <em>except</em> the one that
2707 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002708 * @hide
2709 */
2710 public static final String ACTION_USER_STOPPED =
2711 "android.intent.action.USER_STOPPED";
2712
2713 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002714 * 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 -07002715 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002716 * one that has been removed. The user will not be completely removed until all receivers have
2717 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002718 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002719 * @hide
2720 */
2721 public static final String ACTION_USER_REMOVED =
2722 "android.intent.action.USER_REMOVED";
2723
2724 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002725 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002726 * the userHandle of the user to become the current one. This is only sent to
2727 * registered receivers, not manifest receivers. It is sent to all running users.
2728 * You must hold
2729 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002730 * @hide
2731 */
2732 public static final String ACTION_USER_SWITCHED =
2733 "android.intent.action.USER_SWITCHED";
2734
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002735 /**
2736 * Broadcast sent to the system when a user's information changes. Carries an extra
2737 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002738 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002739 * @hide
2740 */
2741 public static final String ACTION_USER_INFO_CHANGED =
2742 "android.intent.action.USER_INFO_CHANGED";
2743
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002744 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002745 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2746 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002747 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2748 * that need to display merged content across both primary and managed profiles need to
2749 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002750 * not manifest receivers.
2751 */
2752 public static final String ACTION_MANAGED_PROFILE_ADDED =
2753 "android.intent.action.MANAGED_PROFILE_ADDED";
2754
2755 /**
2756 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002757 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2758 * Only applications (for example Launchers) that need to display merged content across both
2759 * primary and managed profiles need to worry about this broadcast. This is only sent to
2760 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002761 */
2762 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2763 "android.intent.action.MANAGED_PROFILE_REMOVED";
2764
2765 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002766 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2767 */
2768 public static final String ACTION_QUICK_CLOCK =
2769 "android.intent.action.QUICK_CLOCK";
2770
Michael Wright0087a142013-02-05 16:29:39 -08002771 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002772 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002773 * @hide
2774 */
2775 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2776 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2777
Justin Kohd378ad72013-04-01 12:18:26 -07002778 /**
2779 * Broadcast Action: A global button was pressed. Includes a single
2780 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2781 * caused the broadcast.
2782 * @hide
2783 */
2784 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2785
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002786 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002787 * Activity Action: Allow the user to select and return one or more existing
2788 * documents. When invoked, the system will display the various
2789 * {@link DocumentsProvider} instances installed on the device, letting the
2790 * user interactively navigate through them. These documents include local
2791 * media, such as photos and video, and documents provided by installed
2792 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002793 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002794 * Each document is represented as a {@code content://} URI backed by a
2795 * {@link DocumentsProvider}, which can be opened as a stream with
2796 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2797 * {@link android.provider.DocumentsContract.Document} metadata.
2798 * <p>
2799 * All selected documents are returned to the calling application with
2800 * persistable read and write permission grants. If you want to maintain
2801 * access to the documents across device reboots, you need to explicitly
2802 * take the persistable permissions using
2803 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2804 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002805 * Callers must indicate the acceptable document MIME types through
2806 * {@link #setType(String)}. For example, to select photos, use
2807 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2808 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2809 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002810 * <p>
2811 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002812 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2813 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002814 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002815 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2816 * returned URIs can be opened with
2817 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002818 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002819 * Output: The URI of the item that was picked, returned in
2820 * {@link #getData()}. This must be a {@code content://} URI so that any
2821 * receiver can access it. If multiple documents were selected, they are
2822 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002823 *
2824 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002825 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002826 * @see #ACTION_CREATE_DOCUMENT
2827 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002828 */
2829 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2830 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2831
2832 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002833 * Activity Action: Allow the user to create a new document. When invoked,
2834 * the system will display the various {@link DocumentsProvider} instances
2835 * installed on the device, letting the user navigate through them. The
2836 * returned document may be a newly created document with no content, or it
2837 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002838 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002839 * Each document is represented as a {@code content://} URI backed by a
2840 * {@link DocumentsProvider}, which can be opened as a stream with
2841 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2842 * {@link android.provider.DocumentsContract.Document} metadata.
2843 * <p>
2844 * Callers must indicate the concrete MIME type of the document being
2845 * created by setting {@link #setType(String)}. This MIME type cannot be
2846 * changed after the document is created.
2847 * <p>
2848 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2849 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002850 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002851 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2852 * returned URIs can be opened with
2853 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002854 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002855 * Output: The URI of the item that was created. This must be a
2856 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002857 *
2858 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002859 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002860 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002861 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002862 */
2863 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2864 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2865
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002866 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002867 * Activity Action: Allow the user to pick a directory subtree. When
2868 * invoked, the system will display the various {@link DocumentsProvider}
2869 * instances installed on the device, letting the user navigate through
2870 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002871 * <p>
2872 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002873 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2874 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2875 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002876 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002877 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002878 *
2879 * @see DocumentsContract
2880 */
2881 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002882 public static final String
2883 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002884
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002885 /** {@hide} */
2886 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2887
Christopher Tate6597e342015-02-17 12:15:25 -08002888 /**
2889 * Broadcast action: report that a settings element is being restored from backup. The intent
2890 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
2891 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
2892 * is the value of that settings entry prior to the restore operation. All of these values are
2893 * represented as strings.
2894 *
2895 * <p>This broadcast is sent only for settings provider entries known to require special handling
2896 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
2897 * the provider's backup agent implementation.
2898 *
2899 * @see #EXTRA_SETTING_NAME
2900 * @see #EXTRA_SETTING_PREVIOUS_VALUE
2901 * @see #EXTRA_SETTING_NEW_VALUE
2902 * {@hide}
2903 */
2904 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
2905
2906 /** {@hide} */
2907 public static final String EXTRA_SETTING_NAME = "setting_name";
2908 /** {@hide} */
2909 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
2910 /** {@hide} */
2911 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
2912
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002913 /**
2914 * Activity Action: Process a piece of text.
2915 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
2916 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
2917 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
2918 */
2919 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2920 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
2921 /**
2922 * The name of the extra used to define the text to be processed.
2923 */
2924 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
2925 /**
2926 * The name of the extra used to define if the processed text will be used as read-only.
2927 */
2928 public static final String EXTRA_PROCESS_TEXT_READONLY =
2929 "android.intent.extra.PROCESS_TEXT_READONLY";
2930
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002931 // ---------------------------------------------------------------------
2932 // ---------------------------------------------------------------------
2933 // Standard intent categories (see addCategory()).
2934
2935 /**
2936 * Set if the activity should be an option for the default action
2937 * (center press) to perform on a piece of data. Setting this will
2938 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002939 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002940 * Intent when initiating an action -- it is for use in intent filters
2941 * specified in packages.
2942 */
2943 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2944 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2945 /**
2946 * Activities that can be safely invoked from a browser must support this
2947 * category. For example, if the user is viewing a web page or an e-mail
2948 * and clicks on a link in the text, the Intent generated execute that
2949 * link will require the BROWSABLE category, so that only activities
2950 * supporting this category will be considered as possible actions. By
2951 * supporting this category, you are promising that there is nothing
2952 * damaging (without user intervention) that can happen by invoking any
2953 * matching Intent.
2954 */
2955 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2956 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2957 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002958 * Categories for activities that can participate in voice interaction.
2959 * An activity that supports this category must be prepared to run with
2960 * no UI shown at all (though in some case it may have a UI shown), and
2961 * rely on {@link android.app.VoiceInteractor} to interact with the user.
2962 */
2963 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2964 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
2965 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002966 * Set if the activity should be considered as an alternative action to
2967 * the data the user is currently viewing. See also
2968 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2969 * applies to the selection in a list of items.
2970 *
2971 * <p>Supporting this category means that you would like your activity to be
2972 * displayed in the set of alternative things the user can do, usually as
2973 * part of the current activity's options menu. You will usually want to
2974 * include a specific label in the &lt;intent-filter&gt; of this action
2975 * describing to the user what it does.
2976 *
2977 * <p>The action of IntentFilter with this category is important in that it
2978 * describes the specific action the target will perform. This generally
2979 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2980 * a specific name such as "com.android.camera.action.CROP. Only one
2981 * alternative of any particular action will be shown to the user, so using
2982 * a specific action like this makes sure that your alternative will be
2983 * displayed while also allowing other applications to provide their own
2984 * overrides of that particular action.
2985 */
2986 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2987 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2988 /**
2989 * Set if the activity should be considered as an alternative selection
2990 * action to the data the user has currently selected. This is like
2991 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2992 * of items from which the user can select, giving them alternatives to the
2993 * default action that will be performed on it.
2994 */
2995 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2996 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2997 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002998 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002999 */
3000 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3001 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3002 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003003 * Should be displayed in the top-level launcher.
3004 */
3005 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3006 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3007 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003008 * Indicates an activity optimized for Leanback mode, and that should
3009 * be displayed in the Leanback launcher.
3010 */
3011 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3012 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3013 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003014 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3015 * @hide
3016 */
3017 @SystemApi
3018 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3019 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003020 * Provides information about the package it is in; typically used if
3021 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3022 * a front-door to the user without having to be shown in the all apps list.
3023 */
3024 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3025 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3026 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003027 * This is the home activity, that is the first activity that is displayed
3028 * when the device boots.
3029 */
3030 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3031 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3032 /**
3033 * This activity is a preference panel.
3034 */
3035 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3036 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3037 /**
3038 * This activity is a development preference panel.
3039 */
3040 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3041 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3042 /**
3043 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003044 */
3045 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3046 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3047 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003048 * This activity allows the user to browse and download new applications.
3049 */
3050 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3051 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3052 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003053 * This activity may be exercised by the monkey or other automated test tools.
3054 */
3055 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3056 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3057 /**
3058 * To be used as a test (not part of the normal user experience).
3059 */
3060 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3061 /**
3062 * To be used as a unit test (run through the Test Harness).
3063 */
3064 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3065 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003066 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003067 * experience).
3068 */
3069 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003070
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003071 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003072 * Used to indicate that an intent only wants URIs that can be opened with
3073 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3074 * must support at least the columns defined in {@link OpenableColumns} when
3075 * queried.
3076 *
3077 * @see #ACTION_GET_CONTENT
3078 * @see #ACTION_OPEN_DOCUMENT
3079 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003080 */
3081 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3082 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3083
3084 /**
3085 * To be used as code under test for framework instrumentation tests.
3086 */
3087 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3088 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003089 /**
3090 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003091 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3092 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003093 */
3094 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3095 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3096 /**
3097 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003098 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3099 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003100 */
3101 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3102 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003103 /**
3104 * An activity to run when device is inserted into a analog (low end) dock.
3105 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3106 * information, see {@link android.app.UiModeManager}.
3107 */
3108 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3109 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3110
3111 /**
3112 * An activity to run when device is inserted into a digital (high end) dock.
3113 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3114 * information, see {@link android.app.UiModeManager}.
3115 */
3116 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3117 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003118
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003119 /**
3120 * Used to indicate that the activity can be used in a car environment.
3121 */
3122 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3123 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3124
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003125 // ---------------------------------------------------------------------
3126 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003127 // Application launch intent categories (see addCategory()).
3128
3129 /**
3130 * Used with {@link #ACTION_MAIN} to launch the browser application.
3131 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003132 * <p>NOTE: This should not be used as the primary key of an Intent,
3133 * since it will not result in the app launching with the correct
3134 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003135 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003136 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003137 */
3138 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3139 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3140
3141 /**
3142 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3143 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003144 * <p>NOTE: This should not be used as the primary key of an Intent,
3145 * since it will not result in the app launching with the correct
3146 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003147 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003148 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003149 */
3150 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3151 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3152
3153 /**
3154 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3155 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003156 * <p>NOTE: This should not be used as the primary key of an Intent,
3157 * since it will not result in the app launching with the correct
3158 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003159 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003160 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003161 */
3162 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3163 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3164
3165 /**
3166 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3167 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003168 * <p>NOTE: This should not be used as the primary key of an Intent,
3169 * since it will not result in the app launching with the correct
3170 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003171 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003172 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003173 */
3174 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3175 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3176
3177 /**
3178 * Used with {@link #ACTION_MAIN} to launch the email application.
3179 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003180 * <p>NOTE: This should not be used as the primary key of an Intent,
3181 * since it will not result in the app launching with the correct
3182 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003183 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003184 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003185 */
3186 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3187 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3188
3189 /**
3190 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3191 * The activity should be able to view and manipulate image and video files
3192 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003193 * <p>NOTE: This should not be used as the primary key of an Intent,
3194 * since it will not result in the app launching with the correct
3195 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003196 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003197 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003198 */
3199 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3200 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3201
3202 /**
3203 * Used with {@link #ACTION_MAIN} to launch the maps application.
3204 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003205 * <p>NOTE: This should not be used as the primary key of an Intent,
3206 * since it will not result in the app launching with the correct
3207 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003208 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003209 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003210 */
3211 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3212 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3213
3214 /**
3215 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3216 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003217 * <p>NOTE: This should not be used as the primary key of an Intent,
3218 * since it will not result in the app launching with the correct
3219 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003220 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003221 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003222 */
3223 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3224 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3225
3226 /**
3227 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003228 * The activity should be able to play, browse, or manipulate music files
3229 * stored on the device.
3230 * <p>NOTE: This should not be used as the primary key of an Intent,
3231 * since it will not result in the app launching with the correct
3232 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003233 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003234 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003235 */
3236 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3237 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3238
3239 // ---------------------------------------------------------------------
3240 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003241 // Standard extra data keys.
3242
3243 /**
3244 * The initial data to place in a newly created record. Use with
3245 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3246 * fields as would be given to the underlying ContentProvider.insert()
3247 * call.
3248 */
3249 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3250
3251 /**
3252 * A constant CharSequence that is associated with the Intent, used with
3253 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3254 * this may be a styled CharSequence, so you must use
3255 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3256 * retrieve it.
3257 */
3258 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3259
3260 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003261 * A constant String that is associated with the Intent, used with
3262 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3263 * as HTML formatted text. Note that you <em>must</em> also supply
3264 * {@link #EXTRA_TEXT}.
3265 */
3266 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3267
3268 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003269 * A content: URI holding a stream of data associated with the Intent,
3270 * used with {@link #ACTION_SEND} to supply the data being sent.
3271 */
3272 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3273
3274 /**
3275 * A String[] holding e-mail addresses that should be delivered to.
3276 */
3277 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3278
3279 /**
3280 * A String[] holding e-mail addresses that should be carbon copied.
3281 */
3282 public static final String EXTRA_CC = "android.intent.extra.CC";
3283
3284 /**
3285 * A String[] holding e-mail addresses that should be blind carbon copied.
3286 */
3287 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3288
3289 /**
3290 * A constant string holding the desired subject line of a message.
3291 */
3292 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3293
3294 /**
3295 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003296 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003297 */
3298 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3299
3300 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003301 * An Intent[] describing additional, alternate choices you would like shown with
3302 * {@link #ACTION_CHOOSER}.
3303 *
3304 * <p>An app may be capable of providing several different payload types to complete a
3305 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3306 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3307 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3308 * photo data or a hosted link where the photos can be viewed.</p>
3309 *
3310 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3311 * first/primary/preferred intent in the set. Additional intents specified in
3312 * this extra are ordered; by default intents that appear earlier in the array will be
3313 * preferred over intents that appear later in the array as matches for the same
3314 * target component. To alter this preference, a calling app may also supply
3315 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3316 */
3317 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3318
3319 /**
3320 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3321 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3322 *
3323 * <p>An app preparing an action for another app to complete may wish to allow the user to
3324 * disambiguate between several options for completing the action based on the chosen target
3325 * or otherwise refine the action before it is invoked.
3326 * </p>
3327 *
3328 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3329 * <ul>
3330 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3331 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3332 * chosen target beyond the first</li>
3333 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3334 * should fill in and send once the disambiguation is complete</li>
3335 * </ul>
3336 */
3337 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3338 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3339
3340 /**
3341 * A {@link ResultReceiver} used to return data back to the sender.
3342 *
3343 * <p>Used to complete an app-specific
3344 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3345 *
3346 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3347 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3348 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3349 * when the user selects a target component from the chooser. It is up to the recipient
3350 * to send a result to this ResultReceiver to signal that disambiguation is complete
3351 * and that the chooser should invoke the user's choice.</p>
3352 *
3353 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3354 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3355 * to match and fill in the final Intent or ChooserTarget before starting it.
3356 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3357 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3358 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3359 *
3360 * <p>The result code passed to the ResultReceiver should be
3361 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3362 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3363 * the chooser should finish without starting a target.</p>
3364 */
3365 public static final String EXTRA_RESULT_RECEIVER
3366 = "android.intent.extra.RESULT_RECEIVER";
3367
3368 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003369 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003370 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003371 */
3372 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3373
3374 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003375 * A Parcelable[] of {@link Intent} or
3376 * {@link android.content.pm.LabeledIntent} objects as set with
3377 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3378 * a the front of the list of choices, when shown to the user with a
3379 * {@link #ACTION_CHOOSER}.
3380 */
3381 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3382
3383 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003384 * A Bundle forming a mapping of potential target package names to different extras Bundles
3385 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3386 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3387 * be currently installed on the device.
3388 *
3389 * <p>An application may choose to provide alternate extras for the case where a user
3390 * selects an activity from a predetermined set of target packages. If the activity
3391 * the user selects from the chooser belongs to a package with its package name as
3392 * a key in this bundle, the corresponding extras for that package will be merged with
3393 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3394 * extra has the same key as an extra already present in the intent it will overwrite
3395 * the extra from the intent.</p>
3396 *
3397 * <p><em>Examples:</em>
3398 * <ul>
3399 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3400 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3401 * parameters for that target.</li>
3402 * <li>An application may offer additional metadata for known targets of a given intent
3403 * to pass along information only relevant to that target such as account or content
3404 * identifiers already known to that application.</li>
3405 * </ul></p>
3406 */
3407 public static final String EXTRA_REPLACEMENT_EXTRAS =
3408 "android.intent.extra.REPLACEMENT_EXTRAS";
3409
3410 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003411 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3412 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3413 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3414 * {@link ComponentName} of the chosen component.
3415 *
3416 * <p>In some situations this callback may never come, for example if the user abandons
3417 * the chooser, switches to another task or any number of other reasons. Apps should not
3418 * be written assuming that this callback will always occur.</p>
3419 */
3420 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3421 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3422
3423 /**
3424 * The {@link ComponentName} chosen by the user to complete an action.
3425 *
3426 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3427 */
3428 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3429
3430 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003431 * A {@link android.view.KeyEvent} object containing the event that
3432 * triggered the creation of the Intent it is in.
3433 */
3434 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3435
3436 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003437 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3438 * before shutting down.
3439 *
3440 * {@hide}
3441 */
3442 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3443
3444 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003445 * 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 -07003446 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3447 * of restarting the application.
3448 */
3449 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3450
3451 /**
3452 * A String holding the phone number originally entered in
3453 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3454 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3455 */
3456 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003457
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003458 /**
3459 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3460 * intents to supply the uid the package had been assigned. Also an optional
3461 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3462 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3463 * purpose.
3464 */
3465 public static final String EXTRA_UID = "android.intent.extra.UID";
3466
3467 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003468 * @hide String array of package names.
3469 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003470 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003471 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3472
3473 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003474 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3475 * intents to indicate whether this represents a full uninstall (removing
3476 * both the code and its data) or a partial uninstall (leaving its data,
3477 * implying that this is an update).
3478 */
3479 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003480
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003481 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003482 * @hide
3483 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3484 * intents to indicate that at this point the package has been removed for
3485 * all users on the device.
3486 */
3487 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3488 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3489
3490 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003491 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3492 * intents to indicate that this is a replacement of the package, so this
3493 * broadcast will immediately be followed by an add broadcast for a
3494 * different version of the same package.
3495 */
3496 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003497
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003498 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003499 * Used as an int extra field in {@link android.app.AlarmManager} intents
3500 * to tell the application being invoked how many pending alarms are being
3501 * delievered with the intent. For one-shot alarms this will always be 1.
3502 * For recurring alarms, this might be greater than 1 if the device was
3503 * asleep or powered off at the time an earlier alarm would have been
3504 * delivered.
3505 */
3506 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003507
Jacek Surazski86b6c532009-05-13 14:38:28 +02003508 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003509 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3510 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003511 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3512 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003513 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3514 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3515 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003516 */
3517 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3518
3519 /**
3520 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3521 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003522 */
3523 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3524
3525 /**
3526 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3527 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003528 */
3529 public static final int EXTRA_DOCK_STATE_DESK = 1;
3530
3531 /**
3532 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3533 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003534 */
3535 public static final int EXTRA_DOCK_STATE_CAR = 2;
3536
3537 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003538 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3539 * to represent that the phone is in a analog (low end) dock.
3540 */
3541 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3542
3543 /**
3544 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3545 * to represent that the phone is in a digital (high end) dock.
3546 */
3547 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3548
3549 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003550 * Boolean that can be supplied as meta-data with a dock activity, to
3551 * indicate that the dock should take over the home key when it is active.
3552 */
3553 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003554
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003555 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003556 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3557 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003558 */
3559 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3560
3561 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003562 * Used in the extra field in the remote intent. It's astring token passed with the
3563 * remote intent.
3564 */
3565 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3566 "android.intent.extra.remote_intent_token";
3567
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003568 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003569 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003570 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003571 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003572 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003573 "android.intent.extra.changed_component_name";
3574
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003575 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003576 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003577 * and contains a string array of all of the components that have changed. If
3578 * the state of the overall package has changed, then it will contain an entry
3579 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003580 */
3581 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3582 "android.intent.extra.changed_component_name_list";
3583
3584 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003585 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003586 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3587 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003588 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003589 */
3590 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3591 "android.intent.extra.changed_package_list";
3592
3593 /**
3594 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003595 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3596 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003597 * and contains an integer array of uids of all of the components
3598 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003599 */
3600 public static final String EXTRA_CHANGED_UID_LIST =
3601 "android.intent.extra.changed_uid_list";
3602
3603 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003604 * @hide
3605 * Magic extra system code can use when binding, to give a label for
3606 * who it is that has bound to a service. This is an integer giving
3607 * a framework string resource that can be displayed to the user.
3608 */
3609 public static final String EXTRA_CLIENT_LABEL =
3610 "android.intent.extra.client_label";
3611
3612 /**
3613 * @hide
3614 * Magic extra system code can use when binding, to give a PendingIntent object
3615 * that can be launched for the user to disable the system's use of this
3616 * service.
3617 */
3618 public static final String EXTRA_CLIENT_INTENT =
3619 "android.intent.extra.client_intent";
3620
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003621 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003622 * Extra used to indicate that an intent should only return data that is on
3623 * the local device. This is a boolean extra; the default is false. If true,
3624 * an implementation should only allow the user to select data that is
3625 * already on the device, not requiring it be downloaded from a remote
3626 * service when opened.
3627 *
3628 * @see #ACTION_GET_CONTENT
3629 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003630 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003631 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003632 */
3633 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003634 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003635
Amith Yamasani13593602012-03-22 16:16:17 -07003636 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003637 * Extra used to indicate that an intent can allow the user to select and
3638 * return multiple items. This is a boolean extra; the default is false. If
3639 * true, an implementation is allowed to present the user with a UI where
3640 * they can pick multiple items that are all returned to the caller. When
3641 * this happens, they should be returned as the {@link #getClipData()} part
3642 * of the result Intent.
3643 *
3644 * @see #ACTION_GET_CONTENT
3645 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003646 */
3647 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003648 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003649
3650 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003651 * The integer userHandle carried with broadcast intents related to addition, removal and
3652 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3653 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3654 *
Amith Yamasani13593602012-03-22 16:16:17 -07003655 * @hide
3656 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003657 public static final String EXTRA_USER_HANDLE =
3658 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003659
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003660 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003661 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3662 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3663 */
3664 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003665 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003666
3667 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003668 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003669 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3670 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003671 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003672 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3673
3674 /**
3675 * Extra sent in the intent to the BroadcastReceiver that handles
3676 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3677 * the restrictions as key/value pairs.
3678 */
3679 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3680 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003681
Amith Yamasani86118ba2013-03-28 14:33:16 -07003682 /**
3683 * Extra used in the response from a BroadcastReceiver that handles
3684 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3685 */
3686 public static final String EXTRA_RESTRICTIONS_INTENT =
3687 "android.intent.extra.restrictions_intent";
3688
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003689 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003690 * Extra used to communicate a set of acceptable MIME types. The type of the
3691 * extra is {@code String[]}. Values may be a combination of concrete MIME
3692 * types (such as "image/png") and/or partial MIME types (such as
3693 * "audio/*").
3694 *
3695 * @see #ACTION_GET_CONTENT
3696 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003697 */
3698 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3699
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003700 /**
3701 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3702 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003703 * When this is true, hardware devices can use this information to determine that
3704 * they shouldn't do a complete shutdown of their device since this is not a
3705 * complete shutdown down to the kernel, but only user space restarting.
3706 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003707 */
3708 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3709 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3710
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003711 /**
3712 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3713 * user has set their time format preferences to the 24 hour format.
3714 *
3715 * @hide for internal use only.
3716 */
3717 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3718 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3719
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003720 /** {@hide} */
3721 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3722
Santos Cordon15a13782015-03-31 18:32:31 -07003723 /**
3724 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3725 * activation request.
3726 * TODO: Add information about the structure and response data used with the pending intent.
3727 * @hide
3728 */
3729 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3730 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3731
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003732 // ---------------------------------------------------------------------
3733 // ---------------------------------------------------------------------
3734 // Intent flags (see mFlags variable).
3735
Tor Norbyed9273d62013-05-30 15:59:53 -07003736 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003737 @IntDef(flag = true, value = {
3738 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3739 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003740 @Retention(RetentionPolicy.SOURCE)
3741 public @interface GrantUriMode {}
3742
Jeff Sharkey846318a2014-04-04 12:12:41 -07003743 /** @hide */
3744 @IntDef(flag = true, value = {
3745 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3746 @Retention(RetentionPolicy.SOURCE)
3747 public @interface AccessUriMode {}
3748
3749 /**
3750 * Test if given mode flags specify an access mode, which must be at least
3751 * read and/or write.
3752 *
3753 * @hide
3754 */
3755 public static boolean isAccessUriMode(int modeFlags) {
3756 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3757 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3758 }
3759
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003760 /**
3761 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003762 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003763 * specified in its ClipData. When applying to an Intent's ClipData,
3764 * all URIs as well as recursive traversals through data or other ClipData
3765 * in Intent items will be granted; only the grant flags of the top-level
3766 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003767 */
3768 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3769 /**
3770 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003771 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003772 * specified in its ClipData. When applying to an Intent's ClipData,
3773 * all URIs as well as recursive traversals through data or other ClipData
3774 * in Intent items will be granted; only the grant flags of the top-level
3775 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003776 */
3777 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3778 /**
3779 * Can be set by the caller to indicate that this Intent is coming from
3780 * a background operation, not from direct user interaction.
3781 */
3782 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3783 /**
3784 * A flag you can enable for debugging: when set, log messages will be
3785 * printed during the resolution of this intent to show you what has
3786 * been found to create the final resolved list.
3787 */
3788 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003789 /**
3790 * If set, this intent will not match any components in packages that
3791 * are currently stopped. If this is not set, then the default behavior
3792 * is to include such applications in the result.
3793 */
3794 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3795 /**
3796 * If set, this intent will always match any components in packages that
3797 * are currently stopped. This is the default behavior when
3798 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3799 * flags are set, this one wins (it allows overriding of exclude for
3800 * places where the framework may automatically set the exclude flag).
3801 */
3802 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003803
3804 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003805 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003806 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003807 * persisted across device reboots until explicitly revoked with
3808 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3809 * grant for possible persisting; the receiving application must call
3810 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3811 * actually persist.
3812 *
3813 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3814 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3815 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003816 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003817 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003818 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003819
3820 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003821 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3822 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3823 * applies to any URI that is a prefix match against the original granted
3824 * URI. (Without this flag, the URI must match exactly for access to be
3825 * granted.) Another URI is considered a prefix match only when scheme,
3826 * authority, and all path segments defined by the prefix are an exact
3827 * match.
3828 */
3829 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3830
3831 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003832 * If set, the new activity is not kept in the history stack. As soon as
3833 * the user navigates away from it, the activity is finished. This may also
3834 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3835 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003836 *
3837 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3838 * is never invoked when the current activity starts a new activity which
3839 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003840 */
3841 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3842 /**
3843 * If set, the activity will not be launched if it is already running
3844 * at the top of the history stack.
3845 */
3846 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3847 /**
3848 * If set, this activity will become the start of a new task on this
3849 * history stack. A task (from the activity that started it to the
3850 * next task activity) defines an atomic group of activities that the
3851 * user can move to. Tasks can be moved to the foreground and background;
3852 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003853 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003854 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3855 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003856 *
3857 * <p>This flag is generally used by activities that want
3858 * to present a "launcher" style behavior: they give the user a list of
3859 * separate things that can be done, which otherwise run completely
3860 * independently of the activity launching them.
3861 *
3862 * <p>When using this flag, if a task is already running for the activity
3863 * you are now starting, then a new activity will not be started; instead,
3864 * the current task will simply be brought to the front of the screen with
3865 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3866 * to disable this behavior.
3867 *
3868 * <p>This flag can not be used when the caller is requesting a result from
3869 * the activity being launched.
3870 */
3871 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3872 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003873 * This flag is used to create a new task and launch an activity into it.
3874 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3875 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3876 * search through existing tasks for ones matching this Intent. Only if no such
3877 * task is found would a new task be created. When paired with
3878 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3879 * the search for a matching task and unconditionally start a new task.
3880 *
3881 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3882 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003883 * top-level application launcher.</strong> Used in conjunction with
3884 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3885 * behavior of bringing an existing task to the foreground. When set,
3886 * a new task is <em>always</em> started to host the Activity for the
3887 * Intent, regardless of whether there is already an existing task running
3888 * the same thing.
3889 *
3890 * <p><strong>Because the default system does not include graphical task management,
3891 * you should not use this flag unless you provide some way for a user to
3892 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003893 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003894 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3895 * creating new document tasks.
3896 *
3897 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003898 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003899 *
Scott Main7aee61f2011-02-08 11:25:01 -08003900 * <p>See
3901 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3902 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003903 *
3904 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3905 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003906 */
3907 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3908 /**
3909 * If set, and the activity being launched is already running in the
3910 * current task, then instead of launching a new instance of that activity,
3911 * all of the other activities on top of it will be closed and this Intent
3912 * will be delivered to the (now on top) old activity as a new Intent.
3913 *
3914 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3915 * If D calls startActivity() with an Intent that resolves to the component
3916 * of activity B, then C and D will be finished and B receive the given
3917 * Intent, resulting in the stack now being: A, B.
3918 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003919 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003920 * either receive the new intent you are starting here in its
3921 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003922 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003923 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3924 * the same intent, then it will be finished and re-created; for all other
3925 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3926 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003927 *
3928 * <p>This launch mode can also be used to good effect in conjunction with
3929 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3930 * of a task, it will bring any currently running instance of that task
3931 * to the foreground, and then clear it to its root state. This is
3932 * especially useful, for example, when launching an activity from the
3933 * notification manager.
3934 *
Scott Main7aee61f2011-02-08 11:25:01 -08003935 * <p>See
3936 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3937 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003938 */
3939 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3940 /**
3941 * If set and this intent is being used to launch a new activity from an
3942 * existing one, then the reply target of the existing activity will be
3943 * transfered to the new activity. This way the new activity can call
3944 * {@link android.app.Activity#setResult} and have that result sent back to
3945 * the reply target of the original activity.
3946 */
3947 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3948 /**
3949 * If set and this intent is being used to launch a new activity from an
3950 * existing one, the current activity will not be counted as the top
3951 * activity for deciding whether the new intent should be delivered to
3952 * the top instead of starting a new one. The previous activity will
3953 * be used as the top, with the assumption being that the current activity
3954 * will finish itself immediately.
3955 */
3956 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3957 /**
3958 * If set, the new activity is not kept in the list of recently launched
3959 * activities.
3960 */
3961 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3962 /**
3963 * This flag is not normally set by application code, but set for you by
3964 * the system as described in the
3965 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3966 * launchMode} documentation for the singleTask mode.
3967 */
3968 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3969 /**
3970 * If set, and this activity is either being started in a new task or
3971 * bringing to the top an existing task, then it will be launched as
3972 * the front door of the task. This will result in the application of
3973 * any affinities needed to have that task in the proper state (either
3974 * moving activities to or from it), or simply resetting that task to
3975 * its initial state if needed.
3976 */
3977 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3978 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003979 * This flag is not normally set by application code, but set for you by
3980 * the system if this activity is being launched from history
3981 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003982 */
3983 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003984 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003985 * @deprecated As of API 21 this performs identically to
3986 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003987 */
3988 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003989 /**
Craig Mautner026596b2014-05-21 15:35:44 -07003990 * This flag is used to open a document into a new task rooted at the activity launched
3991 * by this Intent. Through the use of this flag, or its equivalent attribute,
3992 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00003993 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003994 *
Craig Mautner026596b2014-05-21 15:35:44 -07003995 * <p>The use of the activity attribute form of this,
3996 * {@link android.R.attr#documentLaunchMode}, is
3997 * preferred over the Intent flag described here. The attribute form allows the
3998 * Activity to specify multiple document behavior for all launchers of the Activity
3999 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004000 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004001 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4002 * it is kept after the activity is finished is different than the use of
4003 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4004 * this flag is being used to create a new recents entry, then by default that entry
4005 * will be removed once the activity is finished. You can modify this behavior with
4006 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4007 *
Craig Mautner026596b2014-05-21 15:35:44 -07004008 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4009 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4010 * equivalent of the Activity manifest specifying {@link
4011 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4012 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4013 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004014 *
Craig Mautner026596b2014-05-21 15:35:44 -07004015 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004016 *
Craig Mautner026596b2014-05-21 15:35:44 -07004017 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004018 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4019 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004020 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004021 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004022 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004023 * callback from occurring on the current frontmost activity before it is
4024 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004025 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004026 * <p>Typically, an activity can rely on that callback to indicate that an
4027 * explicit user action has caused their activity to be moved out of the
4028 * foreground. The callback marks an appropriate point in the activity's
4029 * lifecycle for it to dismiss any notifications that it intends to display
4030 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004031 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004032 * <p>If an activity is ever started via any non-user-driven events such as
4033 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4034 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004035 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004036 */
4037 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004038 /**
4039 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4040 * this flag will cause the launched activity to be brought to the front of its
4041 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004042 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004043 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4044 * If D calls startActivity() with an Intent that resolves to the component
4045 * of activity B, then B will be brought to the front of the history stack,
4046 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004047 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004048 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004049 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004050 */
4051 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004052 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004053 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4054 * this flag will prevent the system from applying an activity transition
4055 * animation to go to the next activity state. This doesn't mean an
4056 * animation will never run -- if another activity change happens that doesn't
4057 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004058 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004059 * when you are going to do a series of activity operations but the
4060 * animation seen by the user shouldn't be driven by the first activity
4061 * change but rather a later one.
4062 */
4063 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4064 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004065 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4066 * this flag will cause any existing task that would be associated with the
4067 * activity to be cleared before the activity is started. That is, the activity
4068 * becomes the new root of an otherwise empty task, and any old activities
4069 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4070 */
4071 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4072 /**
4073 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4074 * this flag will cause a newly launching task to be placed on top of the current
4075 * home activity task (if there is one). That is, pressing back from the task
4076 * will always return the user to home even if that was not the last activity they
4077 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4078 */
4079 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4080 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004081 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4082 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004083 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004084 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004085 * this flag. When set and the task's activity is finished, the recents
4086 * entry will remain in the interface for the user to re-launch it, like a
4087 * recents entry for a top-level application.
4088 * <p>
4089 * The receiving activity can override this request with
4090 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4091 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004092 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004093 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004094 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004095
4096 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004097 * If set, when sending a broadcast only registered receivers will be
4098 * called -- no BroadcastReceiver components will be launched.
4099 */
4100 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004101 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004102 * If set, when sending a broadcast the new broadcast will replace
4103 * any existing pending broadcast that matches it. Matching is defined
4104 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4105 * true for the intents of the two broadcasts. When a match is found,
4106 * the new broadcast (and receivers associated with it) will replace the
4107 * existing one in the pending broadcast list, remaining at the same
4108 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004109 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004110 * <p>This flag is most typically used with sticky broadcasts, which
4111 * only care about delivering the most recent values of the broadcast
4112 * to their receivers.
4113 */
4114 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4115 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004116 * If set, when sending a broadcast the recipient is allowed to run at
4117 * foreground priority, with a shorter timeout interval. During normal
4118 * broadcasts the receivers are not automatically hoisted out of the
4119 * background priority class.
4120 */
4121 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4122 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004123 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4124 * They can still propagate results through to later receivers, but they can not prevent
4125 * later receivers from seeing the broadcast.
4126 */
4127 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4128 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004129 * If set, when sending a broadcast <i>before boot has completed</i> only
4130 * registered receivers will be called -- no BroadcastReceiver components
4131 * will be launched. Sticky intent state will be recorded properly even
4132 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4133 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004134 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004135 * <p>This flag is only for use by system sevices as a convenience to
4136 * avoid having to implement a more complex mechanism around detection
4137 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004138 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004139 * @hide
4140 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004141 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004142 /**
4143 * Set when this broadcast is for a boot upgrade, a special mode that
4144 * allows the broadcast to be sent before the system is ready and launches
4145 * the app process with no providers running in it.
4146 * @hide
4147 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004148 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004149
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004150 /**
4151 * @hide Flags that can't be changed with PendingIntent.
4152 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004153 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4154 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4155 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004156
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004157 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004158 // ---------------------------------------------------------------------
4159 // toUri() and parseUri() options.
4160
4161 /**
4162 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4163 * always has the "intent:" scheme. This syntax can be used when you want
4164 * to later disambiguate between URIs that are intended to describe an
4165 * Intent vs. all others that should be treated as raw URIs. When used
4166 * with {@link #parseUri}, any other scheme will result in a generic
4167 * VIEW action for that raw URI.
4168 */
4169 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004170
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004171 /**
4172 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4173 * always has the "android-app:" scheme. This is a variation of
4174 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4175 * http/https URI being delivered to a specific package name. The format
4176 * is:
4177 *
4178 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004179 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004180 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004181 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4182 * you must also include a scheme; including a path also requires both a host and a scheme.
4183 * The final #Intent; fragment can be used without a scheme, host, or path.
4184 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004185 * used with intents that have a {@link #setSelector}, since the base intent
4186 * will always have an explicit package name.</p>
4187 *
4188 * <p>Some examples of how this scheme maps to Intent objects:</p>
4189 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4190 * <colgroup align="left" />
4191 * <colgroup align="left" />
4192 * <thead>
4193 * <tr><th>URI</th> <th>Intent</th></tr>
4194 * </thead>
4195 *
4196 * <tbody>
4197 * <tr><td><code>android-app://com.example.app</code></td>
4198 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4199 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4200 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4201 * </table></td>
4202 * </tr>
4203 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4204 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4205 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4206 * <tr><td>Data: </td><td><code>http://example.com/</code></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/foo?1234</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/foo?1234</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/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4218 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4219 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4220 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4221 * </table></td>
4222 * </tr>
4223 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4224 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4225 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4226 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</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/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
4231 * <td><table border="" style="margin:0" >
4232 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4233 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4234 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4235 * </table></td>
4236 * </tr>
4237 * </tbody>
4238 * </table>
4239 */
4240 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4241
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004242 /**
4243 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4244 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4245 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4246 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4247 * generated Intent can not cause unexpected data access to happen.
4248 *
4249 * <p>If you do not trust the source of the URI being parsed, you should still do further
4250 * processing to protect yourself from it. In particular, when using it to start an
4251 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4252 * that can handle it.</p>
4253 */
4254 public static final int URI_ALLOW_UNSAFE = 1<<2;
4255
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004256 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004257
4258 private String mAction;
4259 private Uri mData;
4260 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004261 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004262 private ComponentName mComponent;
4263 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004264 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004265 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004266 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004267 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004268 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004269 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004270
4271 // ---------------------------------------------------------------------
4272
4273 /**
4274 * Create an empty intent.
4275 */
4276 public Intent() {
4277 }
4278
4279 /**
4280 * Copy constructor.
4281 */
4282 public Intent(Intent o) {
4283 this.mAction = o.mAction;
4284 this.mData = o.mData;
4285 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004286 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004287 this.mComponent = o.mComponent;
4288 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004289 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004290 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004291 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004292 }
4293 if (o.mExtras != null) {
4294 this.mExtras = new Bundle(o.mExtras);
4295 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004296 if (o.mSourceBounds != null) {
4297 this.mSourceBounds = new Rect(o.mSourceBounds);
4298 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004299 if (o.mSelector != null) {
4300 this.mSelector = new Intent(o.mSelector);
4301 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004302 if (o.mClipData != null) {
4303 this.mClipData = new ClipData(o.mClipData);
4304 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004305 }
4306
4307 @Override
4308 public Object clone() {
4309 return new Intent(this);
4310 }
4311
4312 private Intent(Intent o, boolean all) {
4313 this.mAction = o.mAction;
4314 this.mData = o.mData;
4315 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004316 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004317 this.mComponent = o.mComponent;
4318 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004319 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004320 }
4321 }
4322
4323 /**
4324 * Make a clone of only the parts of the Intent that are relevant for
4325 * filter matching: the action, data, type, component, and categories.
4326 */
4327 public Intent cloneFilter() {
4328 return new Intent(this, false);
4329 }
4330
4331 /**
4332 * Create an intent with a given action. All other fields (data, type,
4333 * class) are null. Note that the action <em>must</em> be in a
4334 * namespace because Intents are used globally in the system -- for
4335 * example the system VIEW action is android.intent.action.VIEW; an
4336 * application's custom action would be something like
4337 * com.google.app.myapp.CUSTOM_ACTION.
4338 *
4339 * @param action The Intent action, such as ACTION_VIEW.
4340 */
4341 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004342 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004343 }
4344
4345 /**
4346 * Create an intent with a given action and for a given data url. Note
4347 * that the action <em>must</em> be in a namespace because Intents are
4348 * used globally in the system -- for example the system VIEW action is
4349 * android.intent.action.VIEW; an application's custom action would be
4350 * something like com.google.app.myapp.CUSTOM_ACTION.
4351 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004352 * <p><em>Note: scheme and host name matching in the Android framework is
4353 * case-sensitive, unlike the formal RFC. As a result,
4354 * you should always ensure that you write your Uri with these elements
4355 * using lower case letters, and normalize any Uris you receive from
4356 * outside of Android to ensure the scheme and host is lower case.</em></p>
4357 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004358 * @param action The Intent action, such as ACTION_VIEW.
4359 * @param uri The Intent data URI.
4360 */
4361 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004362 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004363 mData = uri;
4364 }
4365
4366 /**
4367 * Create an intent for a specific component. All other fields (action, data,
4368 * type, class) are null, though they can be modified later with explicit
4369 * calls. This provides a convenient way to create an intent that is
4370 * intended to execute a hard-coded class name, rather than relying on the
4371 * system to find an appropriate class for you; see {@link #setComponent}
4372 * for more information on the repercussions of this.
4373 *
4374 * @param packageContext A Context of the application package implementing
4375 * this class.
4376 * @param cls The component class that is to be used for the intent.
4377 *
4378 * @see #setClass
4379 * @see #setComponent
4380 * @see #Intent(String, android.net.Uri , Context, Class)
4381 */
4382 public Intent(Context packageContext, Class<?> cls) {
4383 mComponent = new ComponentName(packageContext, cls);
4384 }
4385
4386 /**
4387 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004388 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004389 * construct the Intent and then calling {@link #setClass} to set its
4390 * class.
4391 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004392 * <p><em>Note: scheme and host name matching in the Android framework is
4393 * case-sensitive, unlike the formal RFC. As a result,
4394 * you should always ensure that you write your Uri with these elements
4395 * using lower case letters, and normalize any Uris you receive from
4396 * outside of Android to ensure the scheme and host is lower case.</em></p>
4397 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004398 * @param action The Intent action, such as ACTION_VIEW.
4399 * @param uri The Intent data URI.
4400 * @param packageContext A Context of the application package implementing
4401 * this class.
4402 * @param cls The component class that is to be used for the intent.
4403 *
4404 * @see #Intent(String, android.net.Uri)
4405 * @see #Intent(Context, Class)
4406 * @see #setClass
4407 * @see #setComponent
4408 */
4409 public Intent(String action, Uri uri,
4410 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004411 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004412 mData = uri;
4413 mComponent = new ComponentName(packageContext, cls);
4414 }
4415
4416 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004417 * Create an intent to launch the main (root) activity of a task. This
4418 * is the Intent that is started when the application's is launched from
4419 * Home. For anything else that wants to launch an application in the
4420 * same way, it is important that they use an Intent structured the same
4421 * way, and can use this function to ensure this is the case.
4422 *
4423 * <p>The returned Intent has the given Activity component as its explicit
4424 * component, {@link #ACTION_MAIN} as its action, and includes the
4425 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4426 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4427 * to do that through {@link #addFlags(int)} on the returned Intent.
4428 *
4429 * @param mainActivity The main activity component that this Intent will
4430 * launch.
4431 * @return Returns a newly created Intent that can be used to launch the
4432 * activity as a main application entry.
4433 *
4434 * @see #setClass
4435 * @see #setComponent
4436 */
4437 public static Intent makeMainActivity(ComponentName mainActivity) {
4438 Intent intent = new Intent(ACTION_MAIN);
4439 intent.setComponent(mainActivity);
4440 intent.addCategory(CATEGORY_LAUNCHER);
4441 return intent;
4442 }
4443
4444 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004445 * Make an Intent for the main activity of an application, without
4446 * specifying a specific activity to run but giving a selector to find
4447 * the activity. This results in a final Intent that is structured
4448 * the same as when the application is launched from
4449 * Home. For anything else that wants to launch an application in the
4450 * same way, it is important that they use an Intent structured the same
4451 * way, and can use this function to ensure this is the case.
4452 *
4453 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4454 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4455 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4456 * to do that through {@link #addFlags(int)} on the returned Intent.
4457 *
4458 * @param selectorAction The action name of the Intent's selector.
4459 * @param selectorCategory The name of a category to add to the Intent's
4460 * selector.
4461 * @return Returns a newly created Intent that can be used to launch the
4462 * activity as a main application entry.
4463 *
4464 * @see #setSelector(Intent)
4465 */
4466 public static Intent makeMainSelectorActivity(String selectorAction,
4467 String selectorCategory) {
4468 Intent intent = new Intent(ACTION_MAIN);
4469 intent.addCategory(CATEGORY_LAUNCHER);
4470 Intent selector = new Intent();
4471 selector.setAction(selectorAction);
4472 selector.addCategory(selectorCategory);
4473 intent.setSelector(selector);
4474 return intent;
4475 }
4476
4477 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004478 * Make an Intent that can be used to re-launch an application's task
4479 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4480 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4481 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4482 *
4483 * @param mainActivity The activity component that is the root of the
4484 * task; this is the activity that has been published in the application's
4485 * manifest as the main launcher icon.
4486 *
4487 * @return Returns a newly created Intent that can be used to relaunch the
4488 * activity's task in its root state.
4489 */
4490 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4491 Intent intent = makeMainActivity(mainActivity);
4492 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4493 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4494 return intent;
4495 }
4496
4497 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004498 * Call {@link #parseUri} with 0 flags.
4499 * @deprecated Use {@link #parseUri} instead.
4500 */
4501 @Deprecated
4502 public static Intent getIntent(String uri) throws URISyntaxException {
4503 return parseUri(uri, 0);
4504 }
Tom Taylord4a47292009-12-21 13:59:18 -08004505
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004506 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004507 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004508 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004509 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004510 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004511 *
4512 * <p>The URI given here must not be relative -- that is, it must include
4513 * the scheme and full path.
4514 *
4515 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004516 * @param flags Additional processing flags. Either 0,
4517 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004518 *
4519 * @return Intent The newly created Intent object.
4520 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004521 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4522 * it bad (as parsed by the Uri class) or the Intent data within the
4523 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004524 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004525 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004526 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004527 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004528 int i = 0;
4529 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004530 final boolean androidApp = uri.startsWith("android-app:");
4531
4532 // Validate intent scheme if requested.
4533 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4534 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004535 Intent intent = new Intent(ACTION_VIEW);
4536 try {
4537 intent.setData(Uri.parse(uri));
4538 } catch (IllegalArgumentException e) {
4539 throw new URISyntaxException(uri, e.getMessage());
4540 }
4541 return intent;
4542 }
4543 }
Tom Taylord4a47292009-12-21 13:59:18 -08004544
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004545 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004546 // simple case
4547 if (i == -1) {
4548 if (!androidApp) {
4549 return new Intent(ACTION_VIEW, Uri.parse(uri));
4550 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004551
4552 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004553 } else if (!uri.startsWith("#Intent;", i)) {
4554 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004555 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004556 } else {
4557 i = -1;
4558 }
4559 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004560
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004561 // new format
4562 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004563 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004564 boolean explicitAction = false;
4565 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004566
4567 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004568 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004569 String data;
4570 if (i >= 0) {
4571 data = uri.substring(0, i);
4572 i += 8; // length of "#Intent;"
4573 } else {
4574 data = uri;
4575 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004576
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004577 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004578 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004579 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004580 if (eq < 0) eq = i-1;
4581 int semi = uri.indexOf(';', i);
4582 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004583
4584 // action
4585 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004586 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004587 if (!inSelector) {
4588 explicitAction = true;
4589 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004590 }
4591
4592 // categories
4593 else if (uri.startsWith("category=", i)) {
4594 intent.addCategory(value);
4595 }
4596
4597 // type
4598 else if (uri.startsWith("type=", i)) {
4599 intent.mType = value;
4600 }
4601
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004602 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004603 else if (uri.startsWith("launchFlags=", i)) {
4604 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004605 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4606 intent.mFlags &= ~IMMUTABLE_FLAGS;
4607 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004608 }
4609
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004610 // package
4611 else if (uri.startsWith("package=", i)) {
4612 intent.mPackage = value;
4613 }
4614
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004615 // component
4616 else if (uri.startsWith("component=", i)) {
4617 intent.mComponent = ComponentName.unflattenFromString(value);
4618 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004619
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004620 // scheme
4621 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004622 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004623 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004624 } else {
4625 scheme = value;
4626 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004627 }
4628
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004629 // source bounds
4630 else if (uri.startsWith("sourceBounds=", i)) {
4631 intent.mSourceBounds = Rect.unflattenFromString(value);
4632 }
4633
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004634 // selector
4635 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4636 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004637 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004638 }
4639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004640 // extra
4641 else {
4642 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004643 // create Bundle if it doesn't already exist
4644 if (intent.mExtras == null) intent.mExtras = new Bundle();
4645 Bundle b = intent.mExtras;
4646 // add EXTRA
4647 if (uri.startsWith("S.", i)) b.putString(key, value);
4648 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4649 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4650 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4651 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4652 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4653 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4654 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4655 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4656 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4657 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004659 // move to the next item
4660 i = semi + 1;
4661 }
4662
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004663 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004664 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004665 if (baseIntent.mPackage == null) {
4666 baseIntent.setSelector(intent);
4667 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004668 intent = baseIntent;
4669 }
4670
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004671 if (data != null) {
4672 if (data.startsWith("intent:")) {
4673 data = data.substring(7);
4674 if (scheme != null) {
4675 data = scheme + ':' + data;
4676 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004677 } else if (data.startsWith("android-app:")) {
4678 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4679 // Correctly formed android-app, first part is package name.
4680 int end = data.indexOf('/', 14);
4681 if (end < 0) {
4682 // All we have is a package name.
4683 intent.mPackage = data.substring(14);
4684 if (!explicitAction) {
4685 intent.setAction(ACTION_MAIN);
4686 }
4687 data = "";
4688 } else {
4689 // Target the Intent at the given package name always.
4690 String authority = null;
4691 intent.mPackage = data.substring(14, end);
4692 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004693 if ((end+1) < data.length()) {
4694 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4695 // Found a scheme, remember it.
4696 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004697 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004698 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4699 // Found a authority, remember it.
4700 authority = data.substring(end+1, newEnd);
4701 end = newEnd;
4702 }
4703 } else {
4704 // All we have is a scheme.
4705 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004706 }
4707 }
4708 if (scheme == null) {
4709 // If there was no scheme, then this just targets the package.
4710 if (!explicitAction) {
4711 intent.setAction(ACTION_MAIN);
4712 }
4713 data = "";
4714 } else if (authority == null) {
4715 data = scheme + ":";
4716 } else {
4717 data = scheme + "://" + authority + data.substring(end);
4718 }
4719 }
4720 } else {
4721 data = "";
4722 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004723 }
Tom Taylord4a47292009-12-21 13:59:18 -08004724
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004725 if (data.length() > 0) {
4726 try {
4727 intent.mData = Uri.parse(data);
4728 } catch (IllegalArgumentException e) {
4729 throw new URISyntaxException(uri, e.getMessage());
4730 }
4731 }
4732 }
Tom Taylord4a47292009-12-21 13:59:18 -08004733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004734 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004735
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004736 } catch (IndexOutOfBoundsException e) {
4737 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4738 }
4739 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004740
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004742 return getIntentOld(uri, 0);
4743 }
4744
4745 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004746 Intent intent;
4747
4748 int i = uri.lastIndexOf('#');
4749 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004750 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004751 final int intentFragmentStart = i;
4752 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004753
4754 i++;
4755
4756 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004757 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004758 i += 7;
4759 int j = uri.indexOf(')', i);
4760 action = uri.substring(i, j);
4761 i = j + 1;
4762 }
4763
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004764 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004765
4766 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004767 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004768 i += 11;
4769 int j = uri.indexOf(')', i);
4770 while (i < j) {
4771 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004772 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004773 if (i < sep) {
4774 intent.addCategory(uri.substring(i, sep));
4775 }
4776 i = sep + 1;
4777 }
4778 i = j + 1;
4779 }
4780
4781 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004782 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004783 i += 5;
4784 int j = uri.indexOf(')', i);
4785 intent.mType = uri.substring(i, j);
4786 i = j + 1;
4787 }
4788
4789 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004790 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004791 i += 12;
4792 int j = uri.indexOf(')', i);
4793 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004794 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4795 intent.mFlags &= ~IMMUTABLE_FLAGS;
4796 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004797 i = j + 1;
4798 }
4799
4800 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004801 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004802 i += 10;
4803 int j = uri.indexOf(')', i);
4804 int sep = uri.indexOf('!', i);
4805 if (sep >= 0 && sep < j) {
4806 String pkg = uri.substring(i, sep);
4807 String cls = uri.substring(sep + 1, j);
4808 intent.mComponent = new ComponentName(pkg, cls);
4809 }
4810 i = j + 1;
4811 }
4812
4813 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004814 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004815 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004816
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004817 final int closeParen = uri.indexOf(')', i);
4818 if (closeParen == -1) throw new URISyntaxException(uri,
4819 "EXTRA missing trailing ')'", i);
4820
4821 while (i < closeParen) {
4822 // fetch the key value
4823 int j = uri.indexOf('=', i);
4824 if (j <= i + 1 || i >= closeParen) {
4825 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4826 }
4827 char type = uri.charAt(i);
4828 i++;
4829 String key = uri.substring(i, j);
4830 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004831
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004832 // get type-value
4833 j = uri.indexOf('!', i);
4834 if (j == -1 || j >= closeParen) j = closeParen;
4835 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4836 String value = uri.substring(i, j);
4837 i = j;
4838
4839 // create Bundle if it doesn't already exist
4840 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004841
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004842 // add item to bundle
4843 try {
4844 switch (type) {
4845 case 'S':
4846 intent.mExtras.putString(key, Uri.decode(value));
4847 break;
4848 case 'B':
4849 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4850 break;
4851 case 'b':
4852 intent.mExtras.putByte(key, Byte.parseByte(value));
4853 break;
4854 case 'c':
4855 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4856 break;
4857 case 'd':
4858 intent.mExtras.putDouble(key, Double.parseDouble(value));
4859 break;
4860 case 'f':
4861 intent.mExtras.putFloat(key, Float.parseFloat(value));
4862 break;
4863 case 'i':
4864 intent.mExtras.putInt(key, Integer.parseInt(value));
4865 break;
4866 case 'l':
4867 intent.mExtras.putLong(key, Long.parseLong(value));
4868 break;
4869 case 's':
4870 intent.mExtras.putShort(key, Short.parseShort(value));
4871 break;
4872 default:
4873 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4874 }
4875 } catch (NumberFormatException e) {
4876 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4877 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004878
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004879 char ch = uri.charAt(i);
4880 if (ch == ')') break;
4881 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4882 i++;
4883 }
4884 }
4885
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004886 if (isIntentFragment) {
4887 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4888 } else {
4889 intent.mData = Uri.parse(uri);
4890 }
Tom Taylord4a47292009-12-21 13:59:18 -08004891
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004892 if (intent.mAction == null) {
4893 // By default, if no action is specified, then use VIEW.
4894 intent.mAction = ACTION_VIEW;
4895 }
4896
4897 } else {
4898 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4899 }
4900
4901 return intent;
4902 }
4903
4904 /**
4905 * Retrieve the general action to be performed, such as
4906 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4907 * the information in the intent should be interpreted -- most importantly,
4908 * what to do with the data returned by {@link #getData}.
4909 *
4910 * @return The action of this intent or null if none is specified.
4911 *
4912 * @see #setAction
4913 */
4914 public String getAction() {
4915 return mAction;
4916 }
4917
4918 /**
4919 * Retrieve data this intent is operating on. This URI specifies the name
4920 * of the data; often it uses the content: scheme, specifying data in a
4921 * content provider. Other schemes may be handled by specific activities,
4922 * such as http: by the web browser.
4923 *
4924 * @return The URI of the data this intent is targeting or null.
4925 *
4926 * @see #getScheme
4927 * @see #setData
4928 */
4929 public Uri getData() {
4930 return mData;
4931 }
4932
4933 /**
4934 * The same as {@link #getData()}, but returns the URI as an encoded
4935 * String.
4936 */
4937 public String getDataString() {
4938 return mData != null ? mData.toString() : null;
4939 }
4940
4941 /**
4942 * Return the scheme portion of the intent's data. If the data is null or
4943 * does not include a scheme, null is returned. Otherwise, the scheme
4944 * prefix without the final ':' is returned, i.e. "http".
4945 *
4946 * <p>This is the same as calling getData().getScheme() (and checking for
4947 * null data).
4948 *
4949 * @return The scheme of this intent.
4950 *
4951 * @see #getData
4952 */
4953 public String getScheme() {
4954 return mData != null ? mData.getScheme() : null;
4955 }
4956
4957 /**
4958 * Retrieve any explicit MIME type included in the intent. This is usually
4959 * null, as the type is determined by the intent data.
4960 *
4961 * @return If a type was manually set, it is returned; else null is
4962 * returned.
4963 *
4964 * @see #resolveType(ContentResolver)
4965 * @see #setType
4966 */
4967 public String getType() {
4968 return mType;
4969 }
4970
4971 /**
4972 * Return the MIME data type of this intent. If the type field is
4973 * explicitly set, that is simply returned. Otherwise, if the data is set,
4974 * the type of that data is returned. If neither fields are set, a null is
4975 * returned.
4976 *
4977 * @return The MIME type of this intent.
4978 *
4979 * @see #getType
4980 * @see #resolveType(ContentResolver)
4981 */
4982 public String resolveType(Context context) {
4983 return resolveType(context.getContentResolver());
4984 }
4985
4986 /**
4987 * Return the MIME data type of this intent. If the type field is
4988 * explicitly set, that is simply returned. Otherwise, if the data is set,
4989 * the type of that data is returned. If neither fields are set, a null is
4990 * returned.
4991 *
4992 * @param resolver A ContentResolver that can be used to determine the MIME
4993 * type of the intent's data.
4994 *
4995 * @return The MIME type of this intent.
4996 *
4997 * @see #getType
4998 * @see #resolveType(Context)
4999 */
5000 public String resolveType(ContentResolver resolver) {
5001 if (mType != null) {
5002 return mType;
5003 }
5004 if (mData != null) {
5005 if ("content".equals(mData.getScheme())) {
5006 return resolver.getType(mData);
5007 }
5008 }
5009 return null;
5010 }
5011
5012 /**
5013 * Return the MIME data type of this intent, only if it will be needed for
5014 * intent resolution. This is not generally useful for application code;
5015 * it is used by the frameworks for communicating with back-end system
5016 * services.
5017 *
5018 * @param resolver A ContentResolver that can be used to determine the MIME
5019 * type of the intent's data.
5020 *
5021 * @return The MIME type of this intent, or null if it is unknown or not
5022 * needed.
5023 */
5024 public String resolveTypeIfNeeded(ContentResolver resolver) {
5025 if (mComponent != null) {
5026 return mType;
5027 }
5028 return resolveType(resolver);
5029 }
5030
5031 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005032 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005033 *
5034 * @param category The category to check.
5035 *
5036 * @return boolean True if the intent contains the category, else false.
5037 *
5038 * @see #getCategories
5039 * @see #addCategory
5040 */
5041 public boolean hasCategory(String category) {
5042 return mCategories != null && mCategories.contains(category);
5043 }
5044
5045 /**
5046 * Return the set of all categories in the intent. If there are no categories,
5047 * returns NULL.
5048 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005049 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005050 *
5051 * @see #hasCategory
5052 * @see #addCategory
5053 */
5054 public Set<String> getCategories() {
5055 return mCategories;
5056 }
5057
5058 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005059 * Return the specific selector associated with this Intent. If there is
5060 * none, returns null. See {@link #setSelector} for more information.
5061 *
5062 * @see #setSelector
5063 */
5064 public Intent getSelector() {
5065 return mSelector;
5066 }
5067
5068 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005069 * Return the {@link ClipData} associated with this Intent. If there is
5070 * none, returns null. See {@link #setClipData} for more information.
5071 *
John Spurlock125d1332013-11-25 11:58:37 -05005072 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005073 */
5074 public ClipData getClipData() {
5075 return mClipData;
5076 }
5077
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005078 /** @hide */
5079 public int getContentUserHint() {
5080 return mContentUserHint;
5081 }
5082
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005083 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005084 * Sets the ClassLoader that will be used when unmarshalling
5085 * any Parcelable values from the extras of this Intent.
5086 *
5087 * @param loader a ClassLoader, or null to use the default loader
5088 * at the time of unmarshalling.
5089 */
5090 public void setExtrasClassLoader(ClassLoader loader) {
5091 if (mExtras != null) {
5092 mExtras.setClassLoader(loader);
5093 }
5094 }
5095
5096 /**
5097 * Returns true if an extra value is associated with the given name.
5098 * @param name the extra's name
5099 * @return true if the given extra is present.
5100 */
5101 public boolean hasExtra(String name) {
5102 return mExtras != null && mExtras.containsKey(name);
5103 }
5104
5105 /**
5106 * Returns true if the Intent's extras contain a parcelled file descriptor.
5107 * @return true if the Intent contains a parcelled file descriptor.
5108 */
5109 public boolean hasFileDescriptors() {
5110 return mExtras != null && mExtras.hasFileDescriptors();
5111 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005112
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005113 /** @hide */
5114 public void setAllowFds(boolean allowFds) {
5115 if (mExtras != null) {
5116 mExtras.setAllowFds(allowFds);
5117 }
5118 }
5119
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005120 /**
5121 * Retrieve extended data from the intent.
5122 *
5123 * @param name The name of the desired item.
5124 *
5125 * @return the value of an item that previously added with putExtra()
5126 * or null if none was found.
5127 *
5128 * @deprecated
5129 * @hide
5130 */
5131 @Deprecated
5132 public Object getExtra(String name) {
5133 return getExtra(name, null);
5134 }
5135
5136 /**
5137 * Retrieve extended data from the intent.
5138 *
5139 * @param name The name of the desired item.
5140 * @param defaultValue the value to be returned if no value of the desired
5141 * type is stored with the given name.
5142 *
5143 * @return the value of an item that previously added with putExtra()
5144 * or the default value if none was found.
5145 *
5146 * @see #putExtra(String, boolean)
5147 */
5148 public boolean getBooleanExtra(String name, boolean defaultValue) {
5149 return mExtras == null ? defaultValue :
5150 mExtras.getBoolean(name, defaultValue);
5151 }
5152
5153 /**
5154 * Retrieve extended data from the intent.
5155 *
5156 * @param name The name of the desired item.
5157 * @param defaultValue the value to be returned if no value of the desired
5158 * type is stored with the given name.
5159 *
5160 * @return the value of an item that previously added with putExtra()
5161 * or the default value if none was found.
5162 *
5163 * @see #putExtra(String, byte)
5164 */
5165 public byte getByteExtra(String name, byte defaultValue) {
5166 return mExtras == null ? defaultValue :
5167 mExtras.getByte(name, defaultValue);
5168 }
5169
5170 /**
5171 * Retrieve extended data from the intent.
5172 *
5173 * @param name The name of the desired item.
5174 * @param defaultValue the value to be returned if no value of the desired
5175 * type is stored with the given name.
5176 *
5177 * @return the value of an item that previously added with putExtra()
5178 * or the default value if none was found.
5179 *
5180 * @see #putExtra(String, short)
5181 */
5182 public short getShortExtra(String name, short defaultValue) {
5183 return mExtras == null ? defaultValue :
5184 mExtras.getShort(name, defaultValue);
5185 }
5186
5187 /**
5188 * Retrieve extended data from the intent.
5189 *
5190 * @param name The name of the desired item.
5191 * @param defaultValue the value to be returned if no value of the desired
5192 * type is stored with the given name.
5193 *
5194 * @return the value of an item that previously added with putExtra()
5195 * or the default value if none was found.
5196 *
5197 * @see #putExtra(String, char)
5198 */
5199 public char getCharExtra(String name, char defaultValue) {
5200 return mExtras == null ? defaultValue :
5201 mExtras.getChar(name, defaultValue);
5202 }
5203
5204 /**
5205 * Retrieve extended data from the intent.
5206 *
5207 * @param name The name of the desired item.
5208 * @param defaultValue the value to be returned if no value of the desired
5209 * type is stored with the given name.
5210 *
5211 * @return the value of an item that previously added with putExtra()
5212 * or the default value if none was found.
5213 *
5214 * @see #putExtra(String, int)
5215 */
5216 public int getIntExtra(String name, int defaultValue) {
5217 return mExtras == null ? defaultValue :
5218 mExtras.getInt(name, defaultValue);
5219 }
5220
5221 /**
5222 * Retrieve extended data from the intent.
5223 *
5224 * @param name The name of the desired item.
5225 * @param defaultValue the value to be returned if no value of the desired
5226 * type is stored with the given name.
5227 *
5228 * @return the value of an item that previously added with putExtra()
5229 * or the default value if none was found.
5230 *
5231 * @see #putExtra(String, long)
5232 */
5233 public long getLongExtra(String name, long defaultValue) {
5234 return mExtras == null ? defaultValue :
5235 mExtras.getLong(name, defaultValue);
5236 }
5237
5238 /**
5239 * Retrieve extended data from the intent.
5240 *
5241 * @param name The name of the desired item.
5242 * @param defaultValue the value to be returned if no value of the desired
5243 * type is stored with the given name.
5244 *
5245 * @return the value of an item that previously added with putExtra(),
5246 * or the default value if no such item is present
5247 *
5248 * @see #putExtra(String, float)
5249 */
5250 public float getFloatExtra(String name, float defaultValue) {
5251 return mExtras == null ? defaultValue :
5252 mExtras.getFloat(name, defaultValue);
5253 }
5254
5255 /**
5256 * Retrieve extended data from the intent.
5257 *
5258 * @param name The name of the desired item.
5259 * @param defaultValue the value to be returned if no value of the desired
5260 * type is stored with the given name.
5261 *
5262 * @return the value of an item that previously added with putExtra()
5263 * or the default value if none was found.
5264 *
5265 * @see #putExtra(String, double)
5266 */
5267 public double getDoubleExtra(String name, double defaultValue) {
5268 return mExtras == null ? defaultValue :
5269 mExtras.getDouble(name, defaultValue);
5270 }
5271
5272 /**
5273 * Retrieve extended data from the intent.
5274 *
5275 * @param name The name of the desired item.
5276 *
5277 * @return the value of an item that previously added with putExtra()
5278 * or null if no String value was found.
5279 *
5280 * @see #putExtra(String, String)
5281 */
5282 public String getStringExtra(String name) {
5283 return mExtras == null ? null : mExtras.getString(name);
5284 }
5285
5286 /**
5287 * Retrieve extended data from the intent.
5288 *
5289 * @param name The name of the desired item.
5290 *
5291 * @return the value of an item that previously added with putExtra()
5292 * or null if no CharSequence value was found.
5293 *
5294 * @see #putExtra(String, CharSequence)
5295 */
5296 public CharSequence getCharSequenceExtra(String name) {
5297 return mExtras == null ? null : mExtras.getCharSequence(name);
5298 }
5299
5300 /**
5301 * Retrieve extended data from the intent.
5302 *
5303 * @param name The name of the desired item.
5304 *
5305 * @return the value of an item that previously added with putExtra()
5306 * or null if no Parcelable value was found.
5307 *
5308 * @see #putExtra(String, Parcelable)
5309 */
5310 public <T extends Parcelable> T getParcelableExtra(String name) {
5311 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5312 }
5313
5314 /**
5315 * Retrieve extended data from the intent.
5316 *
5317 * @param name The name of the desired item.
5318 *
5319 * @return the value of an item that previously added with putExtra()
5320 * or null if no Parcelable[] value was found.
5321 *
5322 * @see #putExtra(String, Parcelable[])
5323 */
5324 public Parcelable[] getParcelableArrayExtra(String name) {
5325 return mExtras == null ? null : mExtras.getParcelableArray(name);
5326 }
5327
5328 /**
5329 * Retrieve extended data from the intent.
5330 *
5331 * @param name The name of the desired item.
5332 *
5333 * @return the value of an item that previously added with putExtra()
5334 * or null if no ArrayList<Parcelable> value was found.
5335 *
5336 * @see #putParcelableArrayListExtra(String, ArrayList)
5337 */
5338 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5339 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5340 }
5341
5342 /**
5343 * Retrieve extended data from the intent.
5344 *
5345 * @param name The name of the desired item.
5346 *
5347 * @return the value of an item that previously added with putExtra()
5348 * or null if no Serializable value was found.
5349 *
5350 * @see #putExtra(String, Serializable)
5351 */
5352 public Serializable getSerializableExtra(String name) {
5353 return mExtras == null ? null : mExtras.getSerializable(name);
5354 }
5355
5356 /**
5357 * Retrieve extended data from the intent.
5358 *
5359 * @param name The name of the desired item.
5360 *
5361 * @return the value of an item that previously added with putExtra()
5362 * or null if no ArrayList<Integer> value was found.
5363 *
5364 * @see #putIntegerArrayListExtra(String, ArrayList)
5365 */
5366 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5367 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5368 }
5369
5370 /**
5371 * Retrieve extended data from the intent.
5372 *
5373 * @param name The name of the desired item.
5374 *
5375 * @return the value of an item that previously added with putExtra()
5376 * or null if no ArrayList<String> value was found.
5377 *
5378 * @see #putStringArrayListExtra(String, ArrayList)
5379 */
5380 public ArrayList<String> getStringArrayListExtra(String name) {
5381 return mExtras == null ? null : mExtras.getStringArrayList(name);
5382 }
5383
5384 /**
5385 * Retrieve extended data from the intent.
5386 *
5387 * @param name The name of the desired item.
5388 *
5389 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005390 * or null if no ArrayList<CharSequence> value was found.
5391 *
5392 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5393 */
5394 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5395 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5396 }
5397
5398 /**
5399 * Retrieve extended data from the intent.
5400 *
5401 * @param name The name of the desired item.
5402 *
5403 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005404 * or null if no boolean array value was found.
5405 *
5406 * @see #putExtra(String, boolean[])
5407 */
5408 public boolean[] getBooleanArrayExtra(String name) {
5409 return mExtras == null ? null : mExtras.getBooleanArray(name);
5410 }
5411
5412 /**
5413 * Retrieve extended data from the intent.
5414 *
5415 * @param name The name of the desired item.
5416 *
5417 * @return the value of an item that previously added with putExtra()
5418 * or null if no byte array value was found.
5419 *
5420 * @see #putExtra(String, byte[])
5421 */
5422 public byte[] getByteArrayExtra(String name) {
5423 return mExtras == null ? null : mExtras.getByteArray(name);
5424 }
5425
5426 /**
5427 * Retrieve extended data from the intent.
5428 *
5429 * @param name The name of the desired item.
5430 *
5431 * @return the value of an item that previously added with putExtra()
5432 * or null if no short array value was found.
5433 *
5434 * @see #putExtra(String, short[])
5435 */
5436 public short[] getShortArrayExtra(String name) {
5437 return mExtras == null ? null : mExtras.getShortArray(name);
5438 }
5439
5440 /**
5441 * Retrieve extended data from the intent.
5442 *
5443 * @param name The name of the desired item.
5444 *
5445 * @return the value of an item that previously added with putExtra()
5446 * or null if no char array value was found.
5447 *
5448 * @see #putExtra(String, char[])
5449 */
5450 public char[] getCharArrayExtra(String name) {
5451 return mExtras == null ? null : mExtras.getCharArray(name);
5452 }
5453
5454 /**
5455 * Retrieve extended data from the intent.
5456 *
5457 * @param name The name of the desired item.
5458 *
5459 * @return the value of an item that previously added with putExtra()
5460 * or null if no int array value was found.
5461 *
5462 * @see #putExtra(String, int[])
5463 */
5464 public int[] getIntArrayExtra(String name) {
5465 return mExtras == null ? null : mExtras.getIntArray(name);
5466 }
5467
5468 /**
5469 * Retrieve extended data from the intent.
5470 *
5471 * @param name The name of the desired item.
5472 *
5473 * @return the value of an item that previously added with putExtra()
5474 * or null if no long array value was found.
5475 *
5476 * @see #putExtra(String, long[])
5477 */
5478 public long[] getLongArrayExtra(String name) {
5479 return mExtras == null ? null : mExtras.getLongArray(name);
5480 }
5481
5482 /**
5483 * Retrieve extended data from the intent.
5484 *
5485 * @param name The name of the desired item.
5486 *
5487 * @return the value of an item that previously added with putExtra()
5488 * or null if no float array value was found.
5489 *
5490 * @see #putExtra(String, float[])
5491 */
5492 public float[] getFloatArrayExtra(String name) {
5493 return mExtras == null ? null : mExtras.getFloatArray(name);
5494 }
5495
5496 /**
5497 * Retrieve extended data from the intent.
5498 *
5499 * @param name The name of the desired item.
5500 *
5501 * @return the value of an item that previously added with putExtra()
5502 * or null if no double array value was found.
5503 *
5504 * @see #putExtra(String, double[])
5505 */
5506 public double[] getDoubleArrayExtra(String name) {
5507 return mExtras == null ? null : mExtras.getDoubleArray(name);
5508 }
5509
5510 /**
5511 * Retrieve extended data from the intent.
5512 *
5513 * @param name The name of the desired item.
5514 *
5515 * @return the value of an item that previously added with putExtra()
5516 * or null if no String array value was found.
5517 *
5518 * @see #putExtra(String, String[])
5519 */
5520 public String[] getStringArrayExtra(String name) {
5521 return mExtras == null ? null : mExtras.getStringArray(name);
5522 }
5523
5524 /**
5525 * Retrieve extended data from the intent.
5526 *
5527 * @param name The name of the desired item.
5528 *
5529 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005530 * or null if no CharSequence array value was found.
5531 *
5532 * @see #putExtra(String, CharSequence[])
5533 */
5534 public CharSequence[] getCharSequenceArrayExtra(String name) {
5535 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5536 }
5537
5538 /**
5539 * Retrieve extended data from the intent.
5540 *
5541 * @param name The name of the desired item.
5542 *
5543 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005544 * or null if no Bundle value was found.
5545 *
5546 * @see #putExtra(String, Bundle)
5547 */
5548 public Bundle getBundleExtra(String name) {
5549 return mExtras == null ? null : mExtras.getBundle(name);
5550 }
5551
5552 /**
5553 * Retrieve extended data from the intent.
5554 *
5555 * @param name The name of the desired item.
5556 *
5557 * @return the value of an item that previously added with putExtra()
5558 * or null if no IBinder value was found.
5559 *
5560 * @see #putExtra(String, IBinder)
5561 *
5562 * @deprecated
5563 * @hide
5564 */
5565 @Deprecated
5566 public IBinder getIBinderExtra(String name) {
5567 return mExtras == null ? null : mExtras.getIBinder(name);
5568 }
5569
5570 /**
5571 * Retrieve extended data from the intent.
5572 *
5573 * @param name The name of the desired item.
5574 * @param defaultValue The default value to return in case no item is
5575 * associated with the key 'name'
5576 *
5577 * @return the value of an item that previously added with putExtra()
5578 * or defaultValue if none was found.
5579 *
5580 * @see #putExtra
5581 *
5582 * @deprecated
5583 * @hide
5584 */
5585 @Deprecated
5586 public Object getExtra(String name, Object defaultValue) {
5587 Object result = defaultValue;
5588 if (mExtras != null) {
5589 Object result2 = mExtras.get(name);
5590 if (result2 != null) {
5591 result = result2;
5592 }
5593 }
5594
5595 return result;
5596 }
5597
5598 /**
5599 * Retrieves a map of extended data from the intent.
5600 *
5601 * @return the map of all extras previously added with putExtra(),
5602 * or null if none have been added.
5603 */
5604 public Bundle getExtras() {
5605 return (mExtras != null)
5606 ? new Bundle(mExtras)
5607 : null;
5608 }
5609
5610 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005611 * Filter extras to only basic types.
5612 * @hide
5613 */
5614 public void removeUnsafeExtras() {
5615 if (mExtras != null) {
5616 mExtras.filterValues();
5617 }
5618 }
5619
5620 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005621 * Retrieve any special flags associated with this intent. You will
5622 * normally just set them with {@link #setFlags} and let the system
5623 * take the appropriate action with them.
5624 *
5625 * @return int The currently set flags.
5626 *
5627 * @see #setFlags
5628 */
5629 public int getFlags() {
5630 return mFlags;
5631 }
5632
Dianne Hackborne7f97212011-02-24 14:40:20 -08005633 /** @hide */
5634 public boolean isExcludingStopped() {
5635 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5636 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5637 }
5638
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005639 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005640 * Retrieve the application package name this Intent is limited to. When
5641 * resolving an Intent, if non-null this limits the resolution to only
5642 * components in the given application package.
5643 *
5644 * @return The name of the application package for the Intent.
5645 *
5646 * @see #resolveActivity
5647 * @see #setPackage
5648 */
5649 public String getPackage() {
5650 return mPackage;
5651 }
5652
5653 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005654 * Retrieve the concrete component associated with the intent. When receiving
5655 * an intent, this is the component that was found to best handle it (that is,
5656 * yourself) and will always be non-null; in all other cases it will be
5657 * null unless explicitly set.
5658 *
5659 * @return The name of the application component to handle the intent.
5660 *
5661 * @see #resolveActivity
5662 * @see #setComponent
5663 */
5664 public ComponentName getComponent() {
5665 return mComponent;
5666 }
5667
5668 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005669 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5670 * used as a hint to the receiver for animations and the like. Null means that there
5671 * is no source bounds.
5672 */
5673 public Rect getSourceBounds() {
5674 return mSourceBounds;
5675 }
5676
5677 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005678 * Return the Activity component that should be used to handle this intent.
5679 * The appropriate component is determined based on the information in the
5680 * intent, evaluated as follows:
5681 *
5682 * <p>If {@link #getComponent} returns an explicit class, that is returned
5683 * without any further consideration.
5684 *
5685 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5686 * category to be considered.
5687 *
5688 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5689 * action.
5690 *
5691 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5692 * this type.
5693 *
5694 * <p>If {@link #addCategory} has added any categories, the activity must
5695 * handle ALL of the categories specified.
5696 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005697 * <p>If {@link #getPackage} is non-NULL, only activity components in
5698 * that application package will be considered.
5699 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005700 * <p>If there are no activities that satisfy all of these conditions, a
5701 * null string is returned.
5702 *
5703 * <p>If multiple activities are found to satisfy the intent, the one with
5704 * the highest priority will be used. If there are multiple activities
5705 * with the same priority, the system will either pick the best activity
5706 * based on user preference, or resolve to a system class that will allow
5707 * the user to pick an activity and forward from there.
5708 *
5709 * <p>This method is implemented simply by calling
5710 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5711 * true.</p>
5712 * <p> This API is called for you as part of starting an activity from an
5713 * intent. You do not normally need to call it yourself.</p>
5714 *
5715 * @param pm The package manager with which to resolve the Intent.
5716 *
5717 * @return Name of the component implementing an activity that can
5718 * display the intent.
5719 *
5720 * @see #setComponent
5721 * @see #getComponent
5722 * @see #resolveActivityInfo
5723 */
5724 public ComponentName resolveActivity(PackageManager pm) {
5725 if (mComponent != null) {
5726 return mComponent;
5727 }
5728
5729 ResolveInfo info = pm.resolveActivity(
5730 this, PackageManager.MATCH_DEFAULT_ONLY);
5731 if (info != null) {
5732 return new ComponentName(
5733 info.activityInfo.applicationInfo.packageName,
5734 info.activityInfo.name);
5735 }
5736
5737 return null;
5738 }
5739
5740 /**
5741 * Resolve the Intent into an {@link ActivityInfo}
5742 * describing the activity that should execute the intent. Resolution
5743 * follows the same rules as described for {@link #resolveActivity}, but
5744 * you get back the completely information about the resolved activity
5745 * instead of just its class name.
5746 *
5747 * @param pm The package manager with which to resolve the Intent.
5748 * @param flags Addition information to retrieve as per
5749 * {@link PackageManager#getActivityInfo(ComponentName, int)
5750 * PackageManager.getActivityInfo()}.
5751 *
5752 * @return PackageManager.ActivityInfo
5753 *
5754 * @see #resolveActivity
5755 */
5756 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5757 ActivityInfo ai = null;
5758 if (mComponent != null) {
5759 try {
5760 ai = pm.getActivityInfo(mComponent, flags);
5761 } catch (PackageManager.NameNotFoundException e) {
5762 // ignore
5763 }
5764 } else {
5765 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005766 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005767 if (info != null) {
5768 ai = info.activityInfo;
5769 }
5770 }
5771
5772 return ai;
5773 }
5774
5775 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005776 * Special function for use by the system to resolve service
5777 * intents to system apps. Throws an exception if there are
5778 * multiple potential matches to the Intent. Returns null if
5779 * there are no matches.
5780 * @hide
5781 */
5782 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5783 if (mComponent != null) {
5784 return mComponent;
5785 }
5786
5787 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5788 if (results == null) {
5789 return null;
5790 }
5791 ComponentName comp = null;
5792 for (int i=0; i<results.size(); i++) {
5793 ResolveInfo ri = results.get(i);
5794 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5795 continue;
5796 }
5797 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5798 ri.serviceInfo.name);
5799 if (comp != null) {
5800 throw new IllegalStateException("Multiple system services handle " + this
5801 + ": " + comp + ", " + foundComp);
5802 }
5803 comp = foundComp;
5804 }
5805 return comp;
5806 }
5807
5808 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005809 * Set the general action to be performed.
5810 *
5811 * @param action An action name, such as ACTION_VIEW. Application-specific
5812 * actions should be prefixed with the vendor's package name.
5813 *
5814 * @return Returns the same Intent object, for chaining multiple calls
5815 * into a single statement.
5816 *
5817 * @see #getAction
5818 */
5819 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005820 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005821 return this;
5822 }
5823
5824 /**
5825 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005826 * clears any type that was previously set by {@link #setType} or
5827 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005828 *
Nick Pellyccae4122012-01-09 14:12:58 -08005829 * <p><em>Note: scheme matching in the Android framework is
5830 * case-sensitive, unlike the formal RFC. As a result,
5831 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005832 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005833 * {@link #setDataAndNormalize}
5834 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005835 *
Nick Pellyccae4122012-01-09 14:12:58 -08005836 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005837 *
5838 * @return Returns the same Intent object, for chaining multiple calls
5839 * into a single statement.
5840 *
5841 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005842 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005843 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005844 */
5845 public Intent setData(Uri data) {
5846 mData = data;
5847 mType = null;
5848 return this;
5849 }
5850
5851 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005852 * Normalize and set the data this intent is operating on.
5853 *
5854 * <p>This method automatically clears any type that was
5855 * previously set (for example, by {@link #setType}).
5856 *
5857 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005858 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005859 * so really this is just a convenience method for
5860 * <pre>
5861 * setData(data.normalize())
5862 * </pre>
5863 *
5864 * @param data The Uri of the data this intent is now targeting.
5865 *
5866 * @return Returns the same Intent object, for chaining multiple calls
5867 * into a single statement.
5868 *
5869 * @see #getData
5870 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005871 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005872 */
5873 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005874 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005875 }
5876
5877 /**
5878 * Set an explicit MIME data type.
5879 *
5880 * <p>This is used to create intents that only specify a type and not data,
5881 * for example to indicate the type of data to return.
5882 *
5883 * <p>This method automatically clears any data that was
5884 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005885 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005886 * <p><em>Note: MIME type matching in the Android framework is
5887 * case-sensitive, unlike formal RFC MIME types. As a result,
5888 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005889 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5890 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005891 *
5892 * @param type The MIME type of the data being handled by this intent.
5893 *
5894 * @return Returns the same Intent object, for chaining multiple calls
5895 * into a single statement.
5896 *
5897 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005898 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005899 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005900 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005901 */
5902 public Intent setType(String type) {
5903 mData = null;
5904 mType = type;
5905 return this;
5906 }
5907
5908 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005909 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005910 *
Nick Pellyccae4122012-01-09 14:12:58 -08005911 * <p>This is used to create intents that only specify a type and not data,
5912 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005913 *
Nick Pellyccae4122012-01-09 14:12:58 -08005914 * <p>This method automatically clears any data that was
5915 * previously set (for example by {@link #setData}).
5916 *
5917 * <p>The MIME type is normalized using
5918 * {@link #normalizeMimeType} before it is set,
5919 * so really this is just a convenience method for
5920 * <pre>
5921 * setType(Intent.normalizeMimeType(type))
5922 * </pre>
5923 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005924 * @param type The MIME type of the data being handled by this intent.
5925 *
5926 * @return Returns the same Intent object, for chaining multiple calls
5927 * into a single statement.
5928 *
Nick Pellyccae4122012-01-09 14:12:58 -08005929 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005930 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005931 * @see #normalizeMimeType
5932 */
5933 public Intent setTypeAndNormalize(String type) {
5934 return setType(normalizeMimeType(type));
5935 }
5936
5937 /**
5938 * (Usually optional) Set the data for the intent along with an explicit
5939 * MIME data type. This method should very rarely be used -- it allows you
5940 * to override the MIME type that would ordinarily be inferred from the
5941 * data with your own type given here.
5942 *
5943 * <p><em>Note: MIME type and Uri scheme matching in the
5944 * Android framework is case-sensitive, unlike the formal RFC definitions.
5945 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005946 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005947 * {@link #setDataAndTypeAndNormalize}
5948 * to ensure that they are converted to lower case.</em>
5949 *
5950 * @param data The Uri of the data this intent is now targeting.
5951 * @param type The MIME type of the data being handled by this intent.
5952 *
5953 * @return Returns the same Intent object, for chaining multiple calls
5954 * into a single statement.
5955 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005956 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08005957 * @see #setData
5958 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005959 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005960 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005961 */
5962 public Intent setDataAndType(Uri data, String type) {
5963 mData = data;
5964 mType = type;
5965 return this;
5966 }
5967
5968 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005969 * (Usually optional) Normalize and set both the data Uri and an explicit
5970 * MIME data type. This method should very rarely be used -- it allows you
5971 * to override the MIME type that would ordinarily be inferred from the
5972 * data with your own type given here.
5973 *
5974 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005975 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08005976 * before they are set, so really this is just a convenience method for
5977 * <pre>
5978 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
5979 * </pre>
5980 *
5981 * @param data The Uri of the data this intent is now targeting.
5982 * @param type The MIME type of the data being handled by this intent.
5983 *
5984 * @return Returns the same Intent object, for chaining multiple calls
5985 * into a single statement.
5986 *
5987 * @see #setType
5988 * @see #setData
5989 * @see #setDataAndType
5990 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005991 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005992 */
5993 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005994 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08005995 }
5996
5997 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005998 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005999 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006000 * activities that provide <em>all</em> of the requested categories will be
6001 * used.
6002 *
6003 * @param category The desired category. This can be either one of the
6004 * predefined Intent categories, or a custom category in your own
6005 * namespace.
6006 *
6007 * @return Returns the same Intent object, for chaining multiple calls
6008 * into a single statement.
6009 *
6010 * @see #hasCategory
6011 * @see #removeCategory
6012 */
6013 public Intent addCategory(String category) {
6014 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006015 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006016 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006017 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006018 return this;
6019 }
6020
6021 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006022 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006023 *
6024 * @param category The category to remove.
6025 *
6026 * @see #addCategory
6027 */
6028 public void removeCategory(String category) {
6029 if (mCategories != null) {
6030 mCategories.remove(category);
6031 if (mCategories.size() == 0) {
6032 mCategories = null;
6033 }
6034 }
6035 }
6036
6037 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006038 * Set a selector for this Intent. This is a modification to the kinds of
6039 * things the Intent will match. If the selector is set, it will be used
6040 * when trying to find entities that can handle the Intent, instead of the
6041 * main contents of the Intent. This allows you build an Intent containing
6042 * a generic protocol while targeting it more specifically.
6043 *
6044 * <p>An example of where this may be used is with things like
6045 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6046 * Intent that will launch the Browser application. However, the correct
6047 * main entry point of an application is actually {@link #ACTION_MAIN}
6048 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6049 * used to specify the actual Activity to launch. If you launch the browser
6050 * with something different, undesired behavior may happen if the user has
6051 * previously or later launches it the normal way, since they do not match.
6052 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6053 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6054 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6055 *
6056 * <p>Setting a selector does not impact the behavior of
6057 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6058 * desired behavior of a selector -- it does not impact the base meaning
6059 * of the Intent, just what kinds of things will be matched against it
6060 * when determining who can handle it.</p>
6061 *
6062 * <p>You can not use both a selector and {@link #setPackage(String)} on
6063 * the same base Intent.</p>
6064 *
6065 * @param selector The desired selector Intent; set to null to not use
6066 * a special selector.
6067 */
6068 public void setSelector(Intent selector) {
6069 if (selector == this) {
6070 throw new IllegalArgumentException(
6071 "Intent being set as a selector of itself");
6072 }
6073 if (selector != null && mPackage != null) {
6074 throw new IllegalArgumentException(
6075 "Can't set selector when package name is already set");
6076 }
6077 mSelector = selector;
6078 }
6079
6080 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006081 * Set a {@link ClipData} associated with this Intent. This replaces any
6082 * previously set ClipData.
6083 *
6084 * <p>The ClipData in an intent is not used for Intent matching or other
6085 * such operations. Semantically it is like extras, used to transmit
6086 * additional data with the Intent. The main feature of using this over
6087 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6088 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6089 * items included in the clip data. This is useful, in particular, if
6090 * you want to transmit an Intent containing multiple <code>content:</code>
6091 * URIs for which the recipient may not have global permission to access the
6092 * content provider.
6093 *
6094 * <p>If the ClipData contains items that are themselves Intents, any
6095 * grant flags in those Intents will be ignored. Only the top-level flags
6096 * of the main Intent are respected, and will be applied to all Uri or
6097 * Intent items in the clip (or sub-items of the clip).
6098 *
6099 * <p>The MIME type, label, and icon in the ClipData object are not
6100 * directly used by Intent. Applications should generally rely on the
6101 * MIME type of the Intent itself, not what it may find in the ClipData.
6102 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006103 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006104 *
6105 * @param clip The new clip to set. May be null to clear the current clip.
6106 */
6107 public void setClipData(ClipData clip) {
6108 mClipData = clip;
6109 }
6110
6111 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006112 * This is NOT a secure mechanism to identify the user who sent the intent.
6113 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6114 * who sent the intent.
6115 * @hide
6116 */
6117 public void setContentUserHint(int contentUserHint) {
6118 mContentUserHint = contentUserHint;
6119 }
6120
6121 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006122 * Add extended data to the intent. The name must include a package
6123 * prefix, for example the app com.android.contacts would use names
6124 * like "com.android.contacts.ShowAll".
6125 *
6126 * @param name The name of the extra data, with package prefix.
6127 * @param value The boolean data value.
6128 *
6129 * @return Returns the same Intent object, for chaining multiple calls
6130 * into a single statement.
6131 *
6132 * @see #putExtras
6133 * @see #removeExtra
6134 * @see #getBooleanExtra(String, boolean)
6135 */
6136 public Intent putExtra(String name, boolean value) {
6137 if (mExtras == null) {
6138 mExtras = new Bundle();
6139 }
6140 mExtras.putBoolean(name, value);
6141 return this;
6142 }
6143
6144 /**
6145 * Add extended data to the intent. The name must include a package
6146 * prefix, for example the app com.android.contacts would use names
6147 * like "com.android.contacts.ShowAll".
6148 *
6149 * @param name The name of the extra data, with package prefix.
6150 * @param value The byte data value.
6151 *
6152 * @return Returns the same Intent object, for chaining multiple calls
6153 * into a single statement.
6154 *
6155 * @see #putExtras
6156 * @see #removeExtra
6157 * @see #getByteExtra(String, byte)
6158 */
6159 public Intent putExtra(String name, byte value) {
6160 if (mExtras == null) {
6161 mExtras = new Bundle();
6162 }
6163 mExtras.putByte(name, value);
6164 return this;
6165 }
6166
6167 /**
6168 * Add extended data to the intent. The name must include a package
6169 * prefix, for example the app com.android.contacts would use names
6170 * like "com.android.contacts.ShowAll".
6171 *
6172 * @param name The name of the extra data, with package prefix.
6173 * @param value The char data value.
6174 *
6175 * @return Returns the same Intent object, for chaining multiple calls
6176 * into a single statement.
6177 *
6178 * @see #putExtras
6179 * @see #removeExtra
6180 * @see #getCharExtra(String, char)
6181 */
6182 public Intent putExtra(String name, char value) {
6183 if (mExtras == null) {
6184 mExtras = new Bundle();
6185 }
6186 mExtras.putChar(name, value);
6187 return this;
6188 }
6189
6190 /**
6191 * Add extended data to the intent. The name must include a package
6192 * prefix, for example the app com.android.contacts would use names
6193 * like "com.android.contacts.ShowAll".
6194 *
6195 * @param name The name of the extra data, with package prefix.
6196 * @param value The short data value.
6197 *
6198 * @return Returns the same Intent object, for chaining multiple calls
6199 * into a single statement.
6200 *
6201 * @see #putExtras
6202 * @see #removeExtra
6203 * @see #getShortExtra(String, short)
6204 */
6205 public Intent putExtra(String name, short value) {
6206 if (mExtras == null) {
6207 mExtras = new Bundle();
6208 }
6209 mExtras.putShort(name, value);
6210 return this;
6211 }
6212
6213 /**
6214 * Add extended data to the intent. The name must include a package
6215 * prefix, for example the app com.android.contacts would use names
6216 * like "com.android.contacts.ShowAll".
6217 *
6218 * @param name The name of the extra data, with package prefix.
6219 * @param value The integer data value.
6220 *
6221 * @return Returns the same Intent object, for chaining multiple calls
6222 * into a single statement.
6223 *
6224 * @see #putExtras
6225 * @see #removeExtra
6226 * @see #getIntExtra(String, int)
6227 */
6228 public Intent putExtra(String name, int value) {
6229 if (mExtras == null) {
6230 mExtras = new Bundle();
6231 }
6232 mExtras.putInt(name, value);
6233 return this;
6234 }
6235
6236 /**
6237 * Add extended data to the intent. The name must include a package
6238 * prefix, for example the app com.android.contacts would use names
6239 * like "com.android.contacts.ShowAll".
6240 *
6241 * @param name The name of the extra data, with package prefix.
6242 * @param value The long data value.
6243 *
6244 * @return Returns the same Intent object, for chaining multiple calls
6245 * into a single statement.
6246 *
6247 * @see #putExtras
6248 * @see #removeExtra
6249 * @see #getLongExtra(String, long)
6250 */
6251 public Intent putExtra(String name, long value) {
6252 if (mExtras == null) {
6253 mExtras = new Bundle();
6254 }
6255 mExtras.putLong(name, value);
6256 return this;
6257 }
6258
6259 /**
6260 * Add extended data to the intent. The name must include a package
6261 * prefix, for example the app com.android.contacts would use names
6262 * like "com.android.contacts.ShowAll".
6263 *
6264 * @param name The name of the extra data, with package prefix.
6265 * @param value The float data value.
6266 *
6267 * @return Returns the same Intent object, for chaining multiple calls
6268 * into a single statement.
6269 *
6270 * @see #putExtras
6271 * @see #removeExtra
6272 * @see #getFloatExtra(String, float)
6273 */
6274 public Intent putExtra(String name, float value) {
6275 if (mExtras == null) {
6276 mExtras = new Bundle();
6277 }
6278 mExtras.putFloat(name, value);
6279 return this;
6280 }
6281
6282 /**
6283 * Add extended data to the intent. The name must include a package
6284 * prefix, for example the app com.android.contacts would use names
6285 * like "com.android.contacts.ShowAll".
6286 *
6287 * @param name The name of the extra data, with package prefix.
6288 * @param value The double data value.
6289 *
6290 * @return Returns the same Intent object, for chaining multiple calls
6291 * into a single statement.
6292 *
6293 * @see #putExtras
6294 * @see #removeExtra
6295 * @see #getDoubleExtra(String, double)
6296 */
6297 public Intent putExtra(String name, double value) {
6298 if (mExtras == null) {
6299 mExtras = new Bundle();
6300 }
6301 mExtras.putDouble(name, value);
6302 return this;
6303 }
6304
6305 /**
6306 * Add extended data to the intent. The name must include a package
6307 * prefix, for example the app com.android.contacts would use names
6308 * like "com.android.contacts.ShowAll".
6309 *
6310 * @param name The name of the extra data, with package prefix.
6311 * @param value The String data value.
6312 *
6313 * @return Returns the same Intent object, for chaining multiple calls
6314 * into a single statement.
6315 *
6316 * @see #putExtras
6317 * @see #removeExtra
6318 * @see #getStringExtra(String)
6319 */
6320 public Intent putExtra(String name, String value) {
6321 if (mExtras == null) {
6322 mExtras = new Bundle();
6323 }
6324 mExtras.putString(name, value);
6325 return this;
6326 }
6327
6328 /**
6329 * Add extended data to the intent. The name must include a package
6330 * prefix, for example the app com.android.contacts would use names
6331 * like "com.android.contacts.ShowAll".
6332 *
6333 * @param name The name of the extra data, with package prefix.
6334 * @param value The CharSequence data value.
6335 *
6336 * @return Returns the same Intent object, for chaining multiple calls
6337 * into a single statement.
6338 *
6339 * @see #putExtras
6340 * @see #removeExtra
6341 * @see #getCharSequenceExtra(String)
6342 */
6343 public Intent putExtra(String name, CharSequence value) {
6344 if (mExtras == null) {
6345 mExtras = new Bundle();
6346 }
6347 mExtras.putCharSequence(name, value);
6348 return this;
6349 }
6350
6351 /**
6352 * Add extended data to the intent. The name must include a package
6353 * prefix, for example the app com.android.contacts would use names
6354 * like "com.android.contacts.ShowAll".
6355 *
6356 * @param name The name of the extra data, with package prefix.
6357 * @param value The Parcelable data value.
6358 *
6359 * @return Returns the same Intent object, for chaining multiple calls
6360 * into a single statement.
6361 *
6362 * @see #putExtras
6363 * @see #removeExtra
6364 * @see #getParcelableExtra(String)
6365 */
6366 public Intent putExtra(String name, Parcelable value) {
6367 if (mExtras == null) {
6368 mExtras = new Bundle();
6369 }
6370 mExtras.putParcelable(name, value);
6371 return this;
6372 }
6373
6374 /**
6375 * Add extended data to the intent. The name must include a package
6376 * prefix, for example the app com.android.contacts would use names
6377 * like "com.android.contacts.ShowAll".
6378 *
6379 * @param name The name of the extra data, with package prefix.
6380 * @param value The Parcelable[] data value.
6381 *
6382 * @return Returns the same Intent object, for chaining multiple calls
6383 * into a single statement.
6384 *
6385 * @see #putExtras
6386 * @see #removeExtra
6387 * @see #getParcelableArrayExtra(String)
6388 */
6389 public Intent putExtra(String name, Parcelable[] value) {
6390 if (mExtras == null) {
6391 mExtras = new Bundle();
6392 }
6393 mExtras.putParcelableArray(name, value);
6394 return this;
6395 }
6396
6397 /**
6398 * Add extended data to the intent. The name must include a package
6399 * prefix, for example the app com.android.contacts would use names
6400 * like "com.android.contacts.ShowAll".
6401 *
6402 * @param name The name of the extra data, with package prefix.
6403 * @param value The ArrayList<Parcelable> data value.
6404 *
6405 * @return Returns the same Intent object, for chaining multiple calls
6406 * into a single statement.
6407 *
6408 * @see #putExtras
6409 * @see #removeExtra
6410 * @see #getParcelableArrayListExtra(String)
6411 */
6412 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6413 if (mExtras == null) {
6414 mExtras = new Bundle();
6415 }
6416 mExtras.putParcelableArrayList(name, value);
6417 return this;
6418 }
6419
6420 /**
6421 * Add extended data to the intent. The name must include a package
6422 * prefix, for example the app com.android.contacts would use names
6423 * like "com.android.contacts.ShowAll".
6424 *
6425 * @param name The name of the extra data, with package prefix.
6426 * @param value The ArrayList<Integer> data value.
6427 *
6428 * @return Returns the same Intent object, for chaining multiple calls
6429 * into a single statement.
6430 *
6431 * @see #putExtras
6432 * @see #removeExtra
6433 * @see #getIntegerArrayListExtra(String)
6434 */
6435 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6436 if (mExtras == null) {
6437 mExtras = new Bundle();
6438 }
6439 mExtras.putIntegerArrayList(name, value);
6440 return this;
6441 }
6442
6443 /**
6444 * Add extended data to the intent. The name must include a package
6445 * prefix, for example the app com.android.contacts would use names
6446 * like "com.android.contacts.ShowAll".
6447 *
6448 * @param name The name of the extra data, with package prefix.
6449 * @param value The ArrayList<String> data value.
6450 *
6451 * @return Returns the same Intent object, for chaining multiple calls
6452 * into a single statement.
6453 *
6454 * @see #putExtras
6455 * @see #removeExtra
6456 * @see #getStringArrayListExtra(String)
6457 */
6458 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6459 if (mExtras == null) {
6460 mExtras = new Bundle();
6461 }
6462 mExtras.putStringArrayList(name, value);
6463 return this;
6464 }
6465
6466 /**
6467 * Add extended data to the intent. The name must include a package
6468 * prefix, for example the app com.android.contacts would use names
6469 * like "com.android.contacts.ShowAll".
6470 *
6471 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006472 * @param value The ArrayList<CharSequence> data value.
6473 *
6474 * @return Returns the same Intent object, for chaining multiple calls
6475 * into a single statement.
6476 *
6477 * @see #putExtras
6478 * @see #removeExtra
6479 * @see #getCharSequenceArrayListExtra(String)
6480 */
6481 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6482 if (mExtras == null) {
6483 mExtras = new Bundle();
6484 }
6485 mExtras.putCharSequenceArrayList(name, value);
6486 return this;
6487 }
6488
6489 /**
6490 * Add extended data to the intent. The name must include a package
6491 * prefix, for example the app com.android.contacts would use names
6492 * like "com.android.contacts.ShowAll".
6493 *
6494 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006495 * @param value The Serializable data value.
6496 *
6497 * @return Returns the same Intent object, for chaining multiple calls
6498 * into a single statement.
6499 *
6500 * @see #putExtras
6501 * @see #removeExtra
6502 * @see #getSerializableExtra(String)
6503 */
6504 public Intent putExtra(String name, Serializable value) {
6505 if (mExtras == null) {
6506 mExtras = new Bundle();
6507 }
6508 mExtras.putSerializable(name, value);
6509 return this;
6510 }
6511
6512 /**
6513 * Add extended data to the intent. The name must include a package
6514 * prefix, for example the app com.android.contacts would use names
6515 * like "com.android.contacts.ShowAll".
6516 *
6517 * @param name The name of the extra data, with package prefix.
6518 * @param value The boolean array data value.
6519 *
6520 * @return Returns the same Intent object, for chaining multiple calls
6521 * into a single statement.
6522 *
6523 * @see #putExtras
6524 * @see #removeExtra
6525 * @see #getBooleanArrayExtra(String)
6526 */
6527 public Intent putExtra(String name, boolean[] value) {
6528 if (mExtras == null) {
6529 mExtras = new Bundle();
6530 }
6531 mExtras.putBooleanArray(name, value);
6532 return this;
6533 }
6534
6535 /**
6536 * Add extended data to the intent. The name must include a package
6537 * prefix, for example the app com.android.contacts would use names
6538 * like "com.android.contacts.ShowAll".
6539 *
6540 * @param name The name of the extra data, with package prefix.
6541 * @param value The byte array data value.
6542 *
6543 * @return Returns the same Intent object, for chaining multiple calls
6544 * into a single statement.
6545 *
6546 * @see #putExtras
6547 * @see #removeExtra
6548 * @see #getByteArrayExtra(String)
6549 */
6550 public Intent putExtra(String name, byte[] value) {
6551 if (mExtras == null) {
6552 mExtras = new Bundle();
6553 }
6554 mExtras.putByteArray(name, value);
6555 return this;
6556 }
6557
6558 /**
6559 * Add extended data to the intent. The name must include a package
6560 * prefix, for example the app com.android.contacts would use names
6561 * like "com.android.contacts.ShowAll".
6562 *
6563 * @param name The name of the extra data, with package prefix.
6564 * @param value The short array data value.
6565 *
6566 * @return Returns the same Intent object, for chaining multiple calls
6567 * into a single statement.
6568 *
6569 * @see #putExtras
6570 * @see #removeExtra
6571 * @see #getShortArrayExtra(String)
6572 */
6573 public Intent putExtra(String name, short[] value) {
6574 if (mExtras == null) {
6575 mExtras = new Bundle();
6576 }
6577 mExtras.putShortArray(name, value);
6578 return this;
6579 }
6580
6581 /**
6582 * Add extended data to the intent. The name must include a package
6583 * prefix, for example the app com.android.contacts would use names
6584 * like "com.android.contacts.ShowAll".
6585 *
6586 * @param name The name of the extra data, with package prefix.
6587 * @param value The char array data value.
6588 *
6589 * @return Returns the same Intent object, for chaining multiple calls
6590 * into a single statement.
6591 *
6592 * @see #putExtras
6593 * @see #removeExtra
6594 * @see #getCharArrayExtra(String)
6595 */
6596 public Intent putExtra(String name, char[] value) {
6597 if (mExtras == null) {
6598 mExtras = new Bundle();
6599 }
6600 mExtras.putCharArray(name, value);
6601 return this;
6602 }
6603
6604 /**
6605 * Add extended data to the intent. The name must include a package
6606 * prefix, for example the app com.android.contacts would use names
6607 * like "com.android.contacts.ShowAll".
6608 *
6609 * @param name The name of the extra data, with package prefix.
6610 * @param value The int array data value.
6611 *
6612 * @return Returns the same Intent object, for chaining multiple calls
6613 * into a single statement.
6614 *
6615 * @see #putExtras
6616 * @see #removeExtra
6617 * @see #getIntArrayExtra(String)
6618 */
6619 public Intent putExtra(String name, int[] value) {
6620 if (mExtras == null) {
6621 mExtras = new Bundle();
6622 }
6623 mExtras.putIntArray(name, value);
6624 return this;
6625 }
6626
6627 /**
6628 * Add extended data to the intent. The name must include a package
6629 * prefix, for example the app com.android.contacts would use names
6630 * like "com.android.contacts.ShowAll".
6631 *
6632 * @param name The name of the extra data, with package prefix.
6633 * @param value The byte array data value.
6634 *
6635 * @return Returns the same Intent object, for chaining multiple calls
6636 * into a single statement.
6637 *
6638 * @see #putExtras
6639 * @see #removeExtra
6640 * @see #getLongArrayExtra(String)
6641 */
6642 public Intent putExtra(String name, long[] value) {
6643 if (mExtras == null) {
6644 mExtras = new Bundle();
6645 }
6646 mExtras.putLongArray(name, value);
6647 return this;
6648 }
6649
6650 /**
6651 * Add extended data to the intent. The name must include a package
6652 * prefix, for example the app com.android.contacts would use names
6653 * like "com.android.contacts.ShowAll".
6654 *
6655 * @param name The name of the extra data, with package prefix.
6656 * @param value The float array data value.
6657 *
6658 * @return Returns the same Intent object, for chaining multiple calls
6659 * into a single statement.
6660 *
6661 * @see #putExtras
6662 * @see #removeExtra
6663 * @see #getFloatArrayExtra(String)
6664 */
6665 public Intent putExtra(String name, float[] value) {
6666 if (mExtras == null) {
6667 mExtras = new Bundle();
6668 }
6669 mExtras.putFloatArray(name, value);
6670 return this;
6671 }
6672
6673 /**
6674 * Add extended data to the intent. The name must include a package
6675 * prefix, for example the app com.android.contacts would use names
6676 * like "com.android.contacts.ShowAll".
6677 *
6678 * @param name The name of the extra data, with package prefix.
6679 * @param value The double array data value.
6680 *
6681 * @return Returns the same Intent object, for chaining multiple calls
6682 * into a single statement.
6683 *
6684 * @see #putExtras
6685 * @see #removeExtra
6686 * @see #getDoubleArrayExtra(String)
6687 */
6688 public Intent putExtra(String name, double[] value) {
6689 if (mExtras == null) {
6690 mExtras = new Bundle();
6691 }
6692 mExtras.putDoubleArray(name, value);
6693 return this;
6694 }
6695
6696 /**
6697 * Add extended data to the intent. The name must include a package
6698 * prefix, for example the app com.android.contacts would use names
6699 * like "com.android.contacts.ShowAll".
6700 *
6701 * @param name The name of the extra data, with package prefix.
6702 * @param value The String array data value.
6703 *
6704 * @return Returns the same Intent object, for chaining multiple calls
6705 * into a single statement.
6706 *
6707 * @see #putExtras
6708 * @see #removeExtra
6709 * @see #getStringArrayExtra(String)
6710 */
6711 public Intent putExtra(String name, String[] value) {
6712 if (mExtras == null) {
6713 mExtras = new Bundle();
6714 }
6715 mExtras.putStringArray(name, value);
6716 return this;
6717 }
6718
6719 /**
6720 * Add extended data to the intent. The name must include a package
6721 * prefix, for example the app com.android.contacts would use names
6722 * like "com.android.contacts.ShowAll".
6723 *
6724 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006725 * @param value The CharSequence array data value.
6726 *
6727 * @return Returns the same Intent object, for chaining multiple calls
6728 * into a single statement.
6729 *
6730 * @see #putExtras
6731 * @see #removeExtra
6732 * @see #getCharSequenceArrayExtra(String)
6733 */
6734 public Intent putExtra(String name, CharSequence[] value) {
6735 if (mExtras == null) {
6736 mExtras = new Bundle();
6737 }
6738 mExtras.putCharSequenceArray(name, value);
6739 return this;
6740 }
6741
6742 /**
6743 * Add extended data to the intent. The name must include a package
6744 * prefix, for example the app com.android.contacts would use names
6745 * like "com.android.contacts.ShowAll".
6746 *
6747 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006748 * @param value The Bundle data value.
6749 *
6750 * @return Returns the same Intent object, for chaining multiple calls
6751 * into a single statement.
6752 *
6753 * @see #putExtras
6754 * @see #removeExtra
6755 * @see #getBundleExtra(String)
6756 */
6757 public Intent putExtra(String name, Bundle value) {
6758 if (mExtras == null) {
6759 mExtras = new Bundle();
6760 }
6761 mExtras.putBundle(name, value);
6762 return this;
6763 }
6764
6765 /**
6766 * Add extended data to the intent. The name must include a package
6767 * prefix, for example the app com.android.contacts would use names
6768 * like "com.android.contacts.ShowAll".
6769 *
6770 * @param name The name of the extra data, with package prefix.
6771 * @param value The IBinder data value.
6772 *
6773 * @return Returns the same Intent object, for chaining multiple calls
6774 * into a single statement.
6775 *
6776 * @see #putExtras
6777 * @see #removeExtra
6778 * @see #getIBinderExtra(String)
6779 *
6780 * @deprecated
6781 * @hide
6782 */
6783 @Deprecated
6784 public Intent putExtra(String name, IBinder value) {
6785 if (mExtras == null) {
6786 mExtras = new Bundle();
6787 }
6788 mExtras.putIBinder(name, value);
6789 return this;
6790 }
6791
6792 /**
6793 * Copy all extras in 'src' in to this intent.
6794 *
6795 * @param src Contains the extras to copy.
6796 *
6797 * @see #putExtra
6798 */
6799 public Intent putExtras(Intent src) {
6800 if (src.mExtras != null) {
6801 if (mExtras == null) {
6802 mExtras = new Bundle(src.mExtras);
6803 } else {
6804 mExtras.putAll(src.mExtras);
6805 }
6806 }
6807 return this;
6808 }
6809
6810 /**
6811 * Add a set of extended data to the intent. The keys must include a package
6812 * prefix, for example the app com.android.contacts would use names
6813 * like "com.android.contacts.ShowAll".
6814 *
6815 * @param extras The Bundle of extras to add to this intent.
6816 *
6817 * @see #putExtra
6818 * @see #removeExtra
6819 */
6820 public Intent putExtras(Bundle extras) {
6821 if (mExtras == null) {
6822 mExtras = new Bundle();
6823 }
6824 mExtras.putAll(extras);
6825 return this;
6826 }
6827
6828 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006829 * Completely replace the extras in the Intent with the extras in the
6830 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006831 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006832 * @param src The exact extras contained in this Intent are copied
6833 * into the target intent, replacing any that were previously there.
6834 */
6835 public Intent replaceExtras(Intent src) {
6836 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6837 return this;
6838 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006839
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006840 /**
6841 * Completely replace the extras in the Intent with the given Bundle of
6842 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006843 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006844 * @param extras The new set of extras in the Intent, or null to erase
6845 * all extras.
6846 */
6847 public Intent replaceExtras(Bundle extras) {
6848 mExtras = extras != null ? new Bundle(extras) : null;
6849 return this;
6850 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006851
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006852 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006853 * Remove extended data from the intent.
6854 *
6855 * @see #putExtra
6856 */
6857 public void removeExtra(String name) {
6858 if (mExtras != null) {
6859 mExtras.remove(name);
6860 if (mExtras.size() == 0) {
6861 mExtras = null;
6862 }
6863 }
6864 }
6865
6866 /**
6867 * Set special flags controlling how this intent is handled. Most values
6868 * here depend on the type of component being executed by the Intent,
6869 * specifically the FLAG_ACTIVITY_* flags are all for use with
6870 * {@link Context#startActivity Context.startActivity()} and the
6871 * FLAG_RECEIVER_* flags are all for use with
6872 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6873 *
Scott Main7aee61f2011-02-08 11:25:01 -08006874 * <p>See the
6875 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6876 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006877 * the behavior of your application.
6878 *
6879 * @param flags The desired flags.
6880 *
6881 * @return Returns the same Intent object, for chaining multiple calls
6882 * into a single statement.
6883 *
6884 * @see #getFlags
6885 * @see #addFlags
6886 *
6887 * @see #FLAG_GRANT_READ_URI_PERMISSION
6888 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006889 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6890 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006891 * @see #FLAG_DEBUG_LOG_RESOLUTION
6892 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006893 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006894 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006895 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006896 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006897 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6898 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006899 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006900 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006901 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006902 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006903 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006904 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006905 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006906 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6907 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006908 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006909 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006910 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006911 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6912 */
6913 public Intent setFlags(int flags) {
6914 mFlags = flags;
6915 return this;
6916 }
6917
6918 /**
6919 * Add additional flags to the intent (or with existing flags
6920 * value).
6921 *
6922 * @param flags The new flags to set.
6923 *
6924 * @return Returns the same Intent object, for chaining multiple calls
6925 * into a single statement.
6926 *
6927 * @see #setFlags
6928 */
6929 public Intent addFlags(int flags) {
6930 mFlags |= flags;
6931 return this;
6932 }
6933
6934 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006935 * (Usually optional) Set an explicit application package name that limits
6936 * the components this Intent will resolve to. If left to the default
6937 * value of null, all components in all applications will considered.
6938 * If non-null, the Intent can only match the components in the given
6939 * application package.
6940 *
6941 * @param packageName The name of the application package to handle the
6942 * intent, or null to allow any application package.
6943 *
6944 * @return Returns the same Intent object, for chaining multiple calls
6945 * into a single statement.
6946 *
6947 * @see #getPackage
6948 * @see #resolveActivity
6949 */
6950 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006951 if (packageName != null && mSelector != null) {
6952 throw new IllegalArgumentException(
6953 "Can't set package name when selector is already set");
6954 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006955 mPackage = packageName;
6956 return this;
6957 }
6958
6959 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006960 * (Usually optional) Explicitly set the component to handle the intent.
6961 * If left with the default value of null, the system will determine the
6962 * appropriate class to use based on the other fields (action, data,
6963 * type, categories) in the Intent. If this class is defined, the
6964 * specified class will always be used regardless of the other fields. You
6965 * should only set this value when you know you absolutely want a specific
6966 * class to be used; otherwise it is better to let the system find the
6967 * appropriate class so that you will respect the installed applications
6968 * and user preferences.
6969 *
6970 * @param component The name of the application component to handle the
6971 * intent, or null to let the system find one for you.
6972 *
6973 * @return Returns the same Intent object, for chaining multiple calls
6974 * into a single statement.
6975 *
6976 * @see #setClass
6977 * @see #setClassName(Context, String)
6978 * @see #setClassName(String, String)
6979 * @see #getComponent
6980 * @see #resolveActivity
6981 */
6982 public Intent setComponent(ComponentName component) {
6983 mComponent = component;
6984 return this;
6985 }
6986
6987 /**
6988 * Convenience for calling {@link #setComponent} with an
6989 * explicit class name.
6990 *
6991 * @param packageContext A Context of the application package implementing
6992 * this class.
6993 * @param className The name of a class inside of the application package
6994 * that will be used as the component for this Intent.
6995 *
6996 * @return Returns the same Intent object, for chaining multiple calls
6997 * into a single statement.
6998 *
6999 * @see #setComponent
7000 * @see #setClass
7001 */
7002 public Intent setClassName(Context packageContext, String className) {
7003 mComponent = new ComponentName(packageContext, className);
7004 return this;
7005 }
7006
7007 /**
7008 * Convenience for calling {@link #setComponent} with an
7009 * explicit application package name and class name.
7010 *
7011 * @param packageName The name of the package implementing the desired
7012 * component.
7013 * @param className The name of a class inside of the application package
7014 * that will be used as the component for this Intent.
7015 *
7016 * @return Returns the same Intent object, for chaining multiple calls
7017 * into a single statement.
7018 *
7019 * @see #setComponent
7020 * @see #setClass
7021 */
7022 public Intent setClassName(String packageName, String className) {
7023 mComponent = new ComponentName(packageName, className);
7024 return this;
7025 }
7026
7027 /**
7028 * Convenience for calling {@link #setComponent(ComponentName)} with the
7029 * name returned by a {@link Class} object.
7030 *
7031 * @param packageContext A Context of the application package implementing
7032 * this class.
7033 * @param cls The class name to set, equivalent to
7034 * <code>setClassName(context, cls.getName())</code>.
7035 *
7036 * @return Returns the same Intent object, for chaining multiple calls
7037 * into a single statement.
7038 *
7039 * @see #setComponent
7040 */
7041 public Intent setClass(Context packageContext, Class<?> cls) {
7042 mComponent = new ComponentName(packageContext, cls);
7043 return this;
7044 }
7045
7046 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007047 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7048 * used as a hint to the receiver for animations and the like. Null means that there
7049 * is no source bounds.
7050 */
7051 public void setSourceBounds(Rect r) {
7052 if (r != null) {
7053 mSourceBounds = new Rect(r);
7054 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007055 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007056 }
7057 }
7058
Tor Norbyed9273d62013-05-30 15:59:53 -07007059 /** @hide */
7060 @IntDef(flag = true,
7061 value = {
7062 FILL_IN_ACTION,
7063 FILL_IN_DATA,
7064 FILL_IN_CATEGORIES,
7065 FILL_IN_COMPONENT,
7066 FILL_IN_PACKAGE,
7067 FILL_IN_SOURCE_BOUNDS,
7068 FILL_IN_SELECTOR,
7069 FILL_IN_CLIP_DATA
7070 })
7071 @Retention(RetentionPolicy.SOURCE)
7072 public @interface FillInFlags {}
7073
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007074 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007075 * Use with {@link #fillIn} to allow the current action value to be
7076 * overwritten, even if it is already set.
7077 */
7078 public static final int FILL_IN_ACTION = 1<<0;
7079
7080 /**
7081 * Use with {@link #fillIn} to allow the current data or type value
7082 * overwritten, even if it is already set.
7083 */
7084 public static final int FILL_IN_DATA = 1<<1;
7085
7086 /**
7087 * Use with {@link #fillIn} to allow the current categories to be
7088 * overwritten, even if they are already set.
7089 */
7090 public static final int FILL_IN_CATEGORIES = 1<<2;
7091
7092 /**
7093 * Use with {@link #fillIn} to allow the current component value to be
7094 * overwritten, even if it is already set.
7095 */
7096 public static final int FILL_IN_COMPONENT = 1<<3;
7097
7098 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007099 * Use with {@link #fillIn} to allow the current package value to be
7100 * overwritten, even if it is already set.
7101 */
7102 public static final int FILL_IN_PACKAGE = 1<<4;
7103
7104 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007105 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007106 * overwritten, even if it is already set.
7107 */
7108 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7109
7110 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007111 * Use with {@link #fillIn} to allow the current selector to be
7112 * overwritten, even if it is already set.
7113 */
7114 public static final int FILL_IN_SELECTOR = 1<<6;
7115
7116 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007117 * Use with {@link #fillIn} to allow the current ClipData to be
7118 * overwritten, even if it is already set.
7119 */
7120 public static final int FILL_IN_CLIP_DATA = 1<<7;
7121
7122 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007123 * Copy the contents of <var>other</var> in to this object, but only
7124 * where fields are not defined by this object. For purposes of a field
7125 * being defined, the following pieces of data in the Intent are
7126 * considered to be separate fields:
7127 *
7128 * <ul>
7129 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007130 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007131 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7132 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007133 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007134 * <li> component, as set by {@link #setComponent(ComponentName)} or
7135 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007136 * <li> source bounds, as set by {@link #setSourceBounds}.
7137 * <li> selector, as set by {@link #setSelector(Intent)}.
7138 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007139 * <li> each top-level name in the associated extras.
7140 * </ul>
7141 *
7142 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007143 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007144 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7145 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7146 * the restriction where the corresponding field will not be replaced if
7147 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007148 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007149 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7150 * is explicitly specified. The selector will only be copied if
7151 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007152 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007153 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7154 * and Intent B with {action="gotit", data-type="some/thing",
7155 * categories="one","two"}.
7156 *
7157 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7158 * containing: {action="gotit", data-type="some/thing",
7159 * categories="bar"}.
7160 *
7161 * @param other Another Intent whose values are to be used to fill in
7162 * the current one.
7163 * @param flags Options to control which fields can be filled in.
7164 *
7165 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007166 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007167 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7168 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7169 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007170 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007171 @FillInFlags
7172 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007173 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007174 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007175 if (other.mAction != null
7176 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007177 mAction = other.mAction;
7178 changes |= FILL_IN_ACTION;
7179 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007180 if ((other.mData != null || other.mType != null)
7181 && ((mData == null && mType == null)
7182 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007183 mData = other.mData;
7184 mType = other.mType;
7185 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007186 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007187 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007188 if (other.mCategories != null
7189 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007190 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007191 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007192 }
7193 changes |= FILL_IN_CATEGORIES;
7194 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007195 if (other.mPackage != null
7196 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007197 // Only do this if mSelector is not set.
7198 if (mSelector == null) {
7199 mPackage = other.mPackage;
7200 changes |= FILL_IN_PACKAGE;
7201 }
7202 }
7203 // Selector is special: it can only be set if explicitly allowed,
7204 // for the same reason as the component name.
7205 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7206 if (mPackage == null) {
7207 mSelector = new Intent(other.mSelector);
7208 mPackage = null;
7209 changes |= FILL_IN_SELECTOR;
7210 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007211 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007212 if (other.mClipData != null
7213 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7214 mClipData = other.mClipData;
7215 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007216 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007217 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007218 // Component is special: it can -only- be set if explicitly allowed,
7219 // since otherwise the sender could force the intent somewhere the
7220 // originator didn't intend.
7221 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007222 mComponent = other.mComponent;
7223 changes |= FILL_IN_COMPONENT;
7224 }
7225 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007226 if (other.mSourceBounds != null
7227 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7228 mSourceBounds = new Rect(other.mSourceBounds);
7229 changes |= FILL_IN_SOURCE_BOUNDS;
7230 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007231 if (mExtras == null) {
7232 if (other.mExtras != null) {
7233 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007234 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007235 }
7236 } else if (other.mExtras != null) {
7237 try {
7238 Bundle newb = new Bundle(other.mExtras);
7239 newb.putAll(mExtras);
7240 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007241 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007242 } catch (RuntimeException e) {
7243 // Modifying the extras can cause us to unparcel the contents
7244 // of the bundle, and if we do this in the system process that
7245 // may fail. We really should handle this (i.e., the Bundle
7246 // impl shouldn't be on top of a plain map), but for now just
7247 // ignore it and keep the original contents. :(
7248 Log.w("Intent", "Failure filling in extras", e);
7249 }
7250 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007251 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7252 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7253 mContentUserHint = other.mContentUserHint;
7254 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007255 return changes;
7256 }
7257
7258 /**
7259 * Wrapper class holding an Intent and implementing comparisons on it for
7260 * the purpose of filtering. The class implements its
7261 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7262 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7263 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7264 * on the wrapped Intent.
7265 */
7266 public static final class FilterComparison {
7267 private final Intent mIntent;
7268 private final int mHashCode;
7269
7270 public FilterComparison(Intent intent) {
7271 mIntent = intent;
7272 mHashCode = intent.filterHashCode();
7273 }
7274
7275 /**
7276 * Return the Intent that this FilterComparison represents.
7277 * @return Returns the Intent held by the FilterComparison. Do
7278 * not modify!
7279 */
7280 public Intent getIntent() {
7281 return mIntent;
7282 }
7283
7284 @Override
7285 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007286 if (obj instanceof FilterComparison) {
7287 Intent other = ((FilterComparison)obj).mIntent;
7288 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007289 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007290 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007291 }
7292
7293 @Override
7294 public int hashCode() {
7295 return mHashCode;
7296 }
7297 }
7298
7299 /**
7300 * Determine if two intents are the same for the purposes of intent
7301 * resolution (filtering). That is, if their action, data, type,
7302 * class, and categories are the same. This does <em>not</em> compare
7303 * any extra data included in the intents.
7304 *
7305 * @param other The other Intent to compare against.
7306 *
7307 * @return Returns true if action, data, type, class, and categories
7308 * are the same.
7309 */
7310 public boolean filterEquals(Intent other) {
7311 if (other == null) {
7312 return false;
7313 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007314 if (!Objects.equals(this.mAction, other.mAction)) return false;
7315 if (!Objects.equals(this.mData, other.mData)) return false;
7316 if (!Objects.equals(this.mType, other.mType)) return false;
7317 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7318 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7319 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007320
7321 return true;
7322 }
7323
7324 /**
7325 * Generate hash code that matches semantics of filterEquals().
7326 *
7327 * @return Returns the hash value of the action, data, type, class, and
7328 * categories.
7329 *
7330 * @see #filterEquals
7331 */
7332 public int filterHashCode() {
7333 int code = 0;
7334 if (mAction != null) {
7335 code += mAction.hashCode();
7336 }
7337 if (mData != null) {
7338 code += mData.hashCode();
7339 }
7340 if (mType != null) {
7341 code += mType.hashCode();
7342 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007343 if (mPackage != null) {
7344 code += mPackage.hashCode();
7345 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007346 if (mComponent != null) {
7347 code += mComponent.hashCode();
7348 }
7349 if (mCategories != null) {
7350 code += mCategories.hashCode();
7351 }
7352 return code;
7353 }
7354
7355 @Override
7356 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007357 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007358
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007359 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007360 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007361 b.append(" }");
7362
7363 return b.toString();
7364 }
7365
7366 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007367 public String toInsecureString() {
7368 StringBuilder b = new StringBuilder(128);
7369
7370 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007371 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007372 b.append(" }");
7373
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007374 return b.toString();
7375 }
Romain Guy4969af72009-06-17 10:53:19 -07007376
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007377 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007378 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007379 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007380
7381 b.append("Intent { ");
7382 toShortString(b, false, true, true, true);
7383 b.append(" }");
7384
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007385 return b.toString();
7386 }
7387
7388 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007389 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7390 StringBuilder b = new StringBuilder(128);
7391 toShortString(b, secure, comp, extras, clip);
7392 return b.toString();
7393 }
7394
7395 /** @hide */
7396 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7397 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007398 boolean first = true;
7399 if (mAction != null) {
7400 b.append("act=").append(mAction);
7401 first = false;
7402 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007403 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007404 if (!first) {
7405 b.append(' ');
7406 }
7407 first = false;
7408 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007409 for (int i=0; i<mCategories.size(); i++) {
7410 if (i > 0) b.append(',');
7411 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007412 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007413 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007414 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007415 if (mData != null) {
7416 if (!first) {
7417 b.append(' ');
7418 }
7419 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007420 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007421 if (secure) {
7422 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007423 } else {
7424 b.append(mData);
7425 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007426 }
7427 if (mType != null) {
7428 if (!first) {
7429 b.append(' ');
7430 }
7431 first = false;
7432 b.append("typ=").append(mType);
7433 }
7434 if (mFlags != 0) {
7435 if (!first) {
7436 b.append(' ');
7437 }
7438 first = false;
7439 b.append("flg=0x").append(Integer.toHexString(mFlags));
7440 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007441 if (mPackage != null) {
7442 if (!first) {
7443 b.append(' ');
7444 }
7445 first = false;
7446 b.append("pkg=").append(mPackage);
7447 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007448 if (comp && mComponent != null) {
7449 if (!first) {
7450 b.append(' ');
7451 }
7452 first = false;
7453 b.append("cmp=").append(mComponent.flattenToShortString());
7454 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007455 if (mSourceBounds != null) {
7456 if (!first) {
7457 b.append(' ');
7458 }
7459 first = false;
7460 b.append("bnds=").append(mSourceBounds.toShortString());
7461 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007462 if (mClipData != null) {
7463 if (!first) {
7464 b.append(' ');
7465 }
7466 first = false;
7467 if (clip) {
7468 b.append("clip={");
7469 mClipData.toShortString(b);
7470 b.append('}');
7471 } else {
7472 b.append("(has clip)");
7473 }
7474 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007475 if (extras && mExtras != null) {
7476 if (!first) {
7477 b.append(' ');
7478 }
7479 first = false;
7480 b.append("(has extras)");
7481 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007482 if (mContentUserHint != UserHandle.USER_CURRENT) {
7483 if (!first) {
7484 b.append(' ');
7485 }
7486 first = false;
7487 b.append("u=").append(mContentUserHint);
7488 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007489 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007490 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007491 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007492 b.append("}");
7493 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007494 }
7495
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007496 /**
7497 * Call {@link #toUri} with 0 flags.
7498 * @deprecated Use {@link #toUri} instead.
7499 */
7500 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007501 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007502 return toUri(0);
7503 }
7504
7505 /**
7506 * Convert this Intent into a String holding a URI representation of it.
7507 * The returned URI string has been properly URI encoded, so it can be
7508 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7509 * Intent's data as the base URI, with an additional fragment describing
7510 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007511 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007512 * <p>You can convert the returned string back to an Intent with
7513 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007514 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007515 * @param flags Additional operating flags. Either 0,
7516 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007517 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007518 * @return Returns a URI encoding URI string describing the entire contents
7519 * of the Intent.
7520 */
7521 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007522 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007523 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7524 if (mPackage == null) {
7525 throw new IllegalArgumentException(
7526 "Intent must include an explicit package name to build an android-app: "
7527 + this);
7528 }
7529 uri.append("android-app://");
7530 uri.append(mPackage);
7531 String scheme = null;
7532 if (mData != null) {
7533 scheme = mData.getScheme();
7534 if (scheme != null) {
7535 uri.append('/');
7536 uri.append(scheme);
7537 String authority = mData.getEncodedAuthority();
7538 if (authority != null) {
7539 uri.append('/');
7540 uri.append(authority);
7541 String path = mData.getEncodedPath();
7542 if (path != null) {
7543 uri.append(path);
7544 }
7545 String queryParams = mData.getEncodedQuery();
7546 if (queryParams != null) {
7547 uri.append('?');
7548 uri.append(queryParams);
7549 }
7550 String fragment = mData.getEncodedFragment();
7551 if (fragment != null) {
7552 uri.append('#');
7553 uri.append(fragment);
7554 }
7555 }
7556 }
7557 }
7558 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7559 mPackage, flags);
7560 return uri.toString();
7561 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007562 String scheme = null;
7563 if (mData != null) {
7564 String data = mData.toString();
7565 if ((flags&URI_INTENT_SCHEME) != 0) {
7566 final int N = data.length();
7567 for (int i=0; i<N; i++) {
7568 char c = data.charAt(i);
7569 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7570 || c == '.' || c == '-') {
7571 continue;
7572 }
7573 if (c == ':' && i > 0) {
7574 // Valid scheme.
7575 scheme = data.substring(0, i);
7576 uri.append("intent:");
7577 data = data.substring(i+1);
7578 break;
7579 }
Tom Taylord4a47292009-12-21 13:59:18 -08007580
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007581 // No scheme.
7582 break;
7583 }
7584 }
7585 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007586
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007587 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7588 uri.append("intent:");
7589 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007590
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007591 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007592
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007593 return uri.toString();
7594 }
7595
7596 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7597 String defPackage, int flags) {
7598 StringBuilder frag = new StringBuilder(128);
7599
7600 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007601 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007602 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007603 // Note that for now we are not going to try to handle the
7604 // data part; not clear how to represent this as a URI, and
7605 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007606 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7607 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007608 }
7609
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007610 if (frag.length() > 0) {
7611 uri.append("#Intent;");
7612 uri.append(frag);
7613 uri.append("end");
7614 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007615 }
7616
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007617 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7618 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007619 if (scheme != null) {
7620 uri.append("scheme=").append(scheme).append(';');
7621 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007622 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007623 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007624 }
7625 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007626 for (int i=0; i<mCategories.size(); i++) {
7627 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007628 }
7629 }
7630 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007631 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007632 }
7633 if (mFlags != 0) {
7634 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7635 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007636 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007637 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7638 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007639 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007640 uri.append("component=").append(Uri.encode(
7641 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007642 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007643 if (mSourceBounds != null) {
7644 uri.append("sourceBounds=")
7645 .append(Uri.encode(mSourceBounds.flattenToString()))
7646 .append(';');
7647 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007648 if (mExtras != null) {
7649 for (String key : mExtras.keySet()) {
7650 final Object value = mExtras.get(key);
7651 char entryType =
7652 value instanceof String ? 'S' :
7653 value instanceof Boolean ? 'B' :
7654 value instanceof Byte ? 'b' :
7655 value instanceof Character ? 'c' :
7656 value instanceof Double ? 'd' :
7657 value instanceof Float ? 'f' :
7658 value instanceof Integer ? 'i' :
7659 value instanceof Long ? 'l' :
7660 value instanceof Short ? 's' :
7661 '\0';
7662
7663 if (entryType != '\0') {
7664 uri.append(entryType);
7665 uri.append('.');
7666 uri.append(Uri.encode(key));
7667 uri.append('=');
7668 uri.append(Uri.encode(value.toString()));
7669 uri.append(';');
7670 }
7671 }
7672 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007673 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007674
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007675 public int describeContents() {
7676 return (mExtras != null) ? mExtras.describeContents() : 0;
7677 }
7678
7679 public void writeToParcel(Parcel out, int flags) {
7680 out.writeString(mAction);
7681 Uri.writeToParcel(out, mData);
7682 out.writeString(mType);
7683 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007684 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007685 ComponentName.writeToParcel(mComponent, out);
7686
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007687 if (mSourceBounds != null) {
7688 out.writeInt(1);
7689 mSourceBounds.writeToParcel(out, flags);
7690 } else {
7691 out.writeInt(0);
7692 }
7693
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007694 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007695 final int N = mCategories.size();
7696 out.writeInt(N);
7697 for (int i=0; i<N; i++) {
7698 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007699 }
7700 } else {
7701 out.writeInt(0);
7702 }
7703
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007704 if (mSelector != null) {
7705 out.writeInt(1);
7706 mSelector.writeToParcel(out, flags);
7707 } else {
7708 out.writeInt(0);
7709 }
7710
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007711 if (mClipData != null) {
7712 out.writeInt(1);
7713 mClipData.writeToParcel(out, flags);
7714 } else {
7715 out.writeInt(0);
7716 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007717 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007718 out.writeBundle(mExtras);
7719 }
7720
7721 public static final Parcelable.Creator<Intent> CREATOR
7722 = new Parcelable.Creator<Intent>() {
7723 public Intent createFromParcel(Parcel in) {
7724 return new Intent(in);
7725 }
7726 public Intent[] newArray(int size) {
7727 return new Intent[size];
7728 }
7729 };
7730
Dianne Hackborneb034652009-09-07 00:49:58 -07007731 /** @hide */
7732 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007733 readFromParcel(in);
7734 }
7735
7736 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007737 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007738 mData = Uri.CREATOR.createFromParcel(in);
7739 mType = in.readString();
7740 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007741 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007742 mComponent = ComponentName.readFromParcel(in);
7743
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007744 if (in.readInt() != 0) {
7745 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7746 }
7747
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007748 int N = in.readInt();
7749 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007750 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007751 int i;
7752 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007753 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007754 }
7755 } else {
7756 mCategories = null;
7757 }
7758
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007759 if (in.readInt() != 0) {
7760 mSelector = new Intent(in);
7761 }
7762
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007763 if (in.readInt() != 0) {
7764 mClipData = new ClipData(in);
7765 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007766 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007767 mExtras = in.readBundle();
7768 }
7769
7770 /**
7771 * Parses the "intent" element (and its children) from XML and instantiates
7772 * an Intent object. The given XML parser should be located at the tag
7773 * where parsing should start (often named "intent"), from which the
7774 * basic action, data, type, and package and class name will be
7775 * retrieved. The function will then parse in to any child elements,
7776 * looking for <category android:name="xxx"> tags to add categories and
7777 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7778 * to the intent.
7779 *
7780 * @param resources The Resources to use when inflating resources.
7781 * @param parser The XML parser pointing at an "intent" tag.
7782 * @param attrs The AttributeSet interface for retrieving extended
7783 * attribute data at the current <var>parser</var> location.
7784 * @return An Intent object matching the XML data.
7785 * @throws XmlPullParserException If there was an XML parsing error.
7786 * @throws IOException If there was an I/O error.
7787 */
7788 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7789 throws XmlPullParserException, IOException {
7790 Intent intent = new Intent();
7791
7792 TypedArray sa = resources.obtainAttributes(attrs,
7793 com.android.internal.R.styleable.Intent);
7794
7795 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7796
7797 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7798 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7799 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7800
7801 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7802 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7803 if (packageName != null && className != null) {
7804 intent.setComponent(new ComponentName(packageName, className));
7805 }
7806
7807 sa.recycle();
7808
7809 int outerDepth = parser.getDepth();
7810 int type;
7811 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7812 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7813 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7814 continue;
7815 }
7816
7817 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007818 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007819 sa = resources.obtainAttributes(attrs,
7820 com.android.internal.R.styleable.IntentCategory);
7821 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7822 sa.recycle();
7823
7824 if (cat != null) {
7825 intent.addCategory(cat);
7826 }
7827 XmlUtils.skipCurrentTag(parser);
7828
Craig Mautner21d24a22014-04-23 11:45:37 -07007829 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007830 if (intent.mExtras == null) {
7831 intent.mExtras = new Bundle();
7832 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007833 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007834 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007835
7836 } else {
7837 XmlUtils.skipCurrentTag(parser);
7838 }
7839 }
7840
7841 return intent;
7842 }
Nick Pellyccae4122012-01-09 14:12:58 -08007843
Craig Mautner21d24a22014-04-23 11:45:37 -07007844 /** @hide */
7845 public void saveToXml(XmlSerializer out) throws IOException {
7846 if (mAction != null) {
7847 out.attribute(null, ATTR_ACTION, mAction);
7848 }
7849 if (mData != null) {
7850 out.attribute(null, ATTR_DATA, mData.toString());
7851 }
7852 if (mType != null) {
7853 out.attribute(null, ATTR_TYPE, mType);
7854 }
7855 if (mComponent != null) {
7856 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7857 }
7858 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7859
7860 if (mCategories != null) {
7861 out.startTag(null, TAG_CATEGORIES);
7862 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7863 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7864 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007865 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007866 }
7867 }
7868
7869 /** @hide */
7870 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7871 XmlPullParserException {
7872 Intent intent = new Intent();
7873 final int outerDepth = in.getDepth();
7874
7875 int attrCount = in.getAttributeCount();
7876 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7877 final String attrName = in.getAttributeName(attrNdx);
7878 final String attrValue = in.getAttributeValue(attrNdx);
7879 if (ATTR_ACTION.equals(attrName)) {
7880 intent.setAction(attrValue);
7881 } else if (ATTR_DATA.equals(attrName)) {
7882 intent.setData(Uri.parse(attrValue));
7883 } else if (ATTR_TYPE.equals(attrName)) {
7884 intent.setType(attrValue);
7885 } else if (ATTR_COMPONENT.equals(attrName)) {
7886 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7887 } else if (ATTR_FLAGS.equals(attrName)) {
7888 intent.setFlags(Integer.valueOf(attrValue, 16));
7889 } else {
7890 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7891 }
7892 }
7893
7894 int event;
7895 String name;
7896 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7897 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7898 if (event == XmlPullParser.START_TAG) {
7899 name = in.getName();
7900 if (TAG_CATEGORIES.equals(name)) {
7901 attrCount = in.getAttributeCount();
7902 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7903 intent.addCategory(in.getAttributeValue(attrNdx));
7904 }
7905 } else {
7906 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7907 XmlUtils.skipCurrentTag(in);
7908 }
7909 }
7910 }
7911
7912 return intent;
7913 }
7914
Nick Pellyccae4122012-01-09 14:12:58 -08007915 /**
7916 * Normalize a MIME data type.
7917 *
7918 * <p>A normalized MIME type has white-space trimmed,
7919 * content-type parameters removed, and is lower-case.
7920 * This aligns the type with Android best practices for
7921 * intent filtering.
7922 *
7923 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7924 * "text/x-vCard" becomes "text/x-vcard".
7925 *
7926 * <p>All MIME types received from outside Android (such as user input,
7927 * or external sources like Bluetooth, NFC, or the Internet) should
7928 * be normalized before they are used to create an Intent.
7929 *
7930 * @param type MIME data type to normalize
7931 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007932 * @see #setType
7933 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007934 */
7935 public static String normalizeMimeType(String type) {
7936 if (type == null) {
7937 return null;
7938 }
7939
Elliott Hughescb64d432013-08-02 10:00:44 -07007940 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007941
7942 final int semicolonIndex = type.indexOf(';');
7943 if (semicolonIndex != -1) {
7944 type = type.substring(0, semicolonIndex);
7945 }
7946 return type;
7947 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007948
7949 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007950 * Prepare this {@link Intent} to leave an app process.
7951 *
7952 * @hide
7953 */
7954 public void prepareToLeaveProcess() {
7955 setAllowFds(false);
7956
7957 if (mSelector != null) {
7958 mSelector.prepareToLeaveProcess();
7959 }
7960 if (mClipData != null) {
7961 mClipData.prepareToLeaveProcess();
7962 }
7963
7964 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
7965 // There are several ACTION_MEDIA_* broadcasts that send file://
7966 // Uris, so only check common actions.
7967 if (ACTION_VIEW.equals(mAction) ||
7968 ACTION_EDIT.equals(mAction) ||
7969 ACTION_ATTACH_DATA.equals(mAction)) {
7970 mData.checkFileUriExposed("Intent.getData()");
7971 }
7972 }
7973 }
7974
7975 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007976 * @hide
7977 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007978 public void prepareToEnterProcess() {
7979 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00007980 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
7981 fixUris(mContentUserHint);
7982 mContentUserHint = UserHandle.USER_CURRENT;
7983 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007984 }
7985 }
7986
7987 /**
7988 * @hide
7989 */
7990 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007991 Uri data = getData();
7992 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007993 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007994 }
7995 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007996 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007997 }
7998 String action = getAction();
7999 if (ACTION_SEND.equals(action)) {
8000 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8001 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008002 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008003 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008004 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008005 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8006 if (streams != null) {
8007 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8008 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008009 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008010 }
8011 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8012 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008013 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8014 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8015 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8016 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8017 if (output != null) {
8018 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8019 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008020 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008021 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008022
8023 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008024 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008025 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8026 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008027 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008028 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008029 * @hide
8030 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008031 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008032 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008033 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008034
8035 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008036 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008037
8038 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008039 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008040 // Inspect contained intents to see if we need to migrate extras. We
8041 // don't promote ClipData to the parent, since ChooserActivity will
8042 // already start the picked item as the caller, and we can't combine
8043 // the flags in a safe way.
8044
8045 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008046 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008047 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8048 if (intent != null) {
8049 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008050 }
8051 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008052 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008053 try {
8054 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8055 if (intents != null) {
8056 for (int i = 0; i < intents.length; i++) {
8057 final Intent intent = (Intent) intents[i];
8058 if (intent != null) {
8059 migrated |= intent.migrateExtraStreamToClipData();
8060 }
8061 }
8062 }
8063 } catch (ClassCastException e) {
8064 }
8065 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008066
8067 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008068 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008069 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8070 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8071 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8072 if (stream != null || text != null || htmlText != null) {
8073 final ClipData clipData = new ClipData(
8074 null, new String[] { getType() },
8075 new ClipData.Item(text, htmlText, null, stream));
8076 setClipData(clipData);
8077 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008078 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008079 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008080 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008081 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008082
8083 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008084 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008085 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8086 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8087 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8088 int num = -1;
8089 if (streams != null) {
8090 num = streams.size();
8091 }
8092 if (texts != null) {
8093 if (num >= 0 && num != texts.size()) {
8094 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008095 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008096 }
8097 num = texts.size();
8098 }
8099 if (htmlTexts != null) {
8100 if (num >= 0 && num != htmlTexts.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 = htmlTexts.size();
8105 }
8106 if (num > 0) {
8107 final ClipData clipData = new ClipData(
8108 null, new String[] { getType() },
8109 makeClipItem(streams, texts, htmlTexts, 0));
8110
8111 for (int i = 1; i < num; i++) {
8112 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8113 }
8114
8115 setClipData(clipData);
8116 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008117 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008118 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008119 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008120 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008121 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8122 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8123 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8124 final Uri output;
8125 try {
8126 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8127 } catch (ClassCastException e) {
8128 return false;
8129 }
8130 if (output != null) {
8131 setClipData(ClipData.newRawUri("", output));
8132 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8133 return true;
8134 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008135 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008136
8137 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008138 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008139
8140 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8141 ArrayList<String> htmlTexts, int which) {
8142 Uri uri = streams != null ? streams.get(which) : null;
8143 CharSequence text = texts != null ? texts.get(which) : null;
8144 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8145 return new ClipData.Item(text, htmlText, null, uri);
8146 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008147
8148 /** @hide */
8149 public boolean isDocument() {
8150 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8151 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008152}