blob: 671c62c169796ee323d699e9f542c5b41a2348b5 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Dianne Hackborn221ea892013-08-04 16:50:16 -070019import android.content.pm.ApplicationInfo;
Adam Powell2ed547e2015-04-29 18:45:04 -070020import android.os.ResultReceiver;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010021import android.provider.MediaStore;
Dianne Hackbornadd005c2013-07-17 18:43:12 -070022import android.util.ArraySet;
Jeff Sharkey846318a2014-04-04 12:12:41 -070023
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import org.xmlpull.v1.XmlPullParser;
25import org.xmlpull.v1.XmlPullParserException;
26
Tor Norbye7b9c9122013-05-30 16:48:33 -070027import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070028import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070029import android.annotation.SdkConstant;
Jose Lima73915cf2014-07-29 17:16:31 -070030import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.annotation.SdkConstant.SdkConstantType;
32import android.content.pm.ActivityInfo;
Jose Lima73915cf2014-07-29 17:16:31 -070033
Nicolas Prevotd85fc722014-04-16 19:52:08 +010034import static android.content.ContentProvider.maybeAddUserId;
Jose Lima73915cf2014-07-29 17:16:31 -070035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070036import android.content.pm.PackageManager;
37import android.content.pm.ResolveInfo;
38import android.content.res.Resources;
39import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080040import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070041import android.net.Uri;
42import android.os.Bundle;
43import android.os.IBinder;
44import android.os.Parcel;
45import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000046import android.os.Process;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070047import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010048import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070049import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070050import android.provider.DocumentsProvider;
51import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070052import android.util.AttributeSet;
53import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080054
55import com.android.internal.util.XmlUtils;
Jose Lima73915cf2014-07-29 17:16:31 -070056
Craig Mautner21d24a22014-04-23 11:45:37 -070057import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058
59import java.io.IOException;
60import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070061import java.lang.annotation.Retention;
62import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070063import java.net.URISyntaxException;
64import java.util.ArrayList;
Dianne Hackborn221ea892013-08-04 16:50:16 -070065import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080066import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070067import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068import java.util.Set;
69
70/**
71 * An intent is an abstract description of an operation to be performed. It
72 * can be used with {@link Context#startActivity(Intent) startActivity} to
73 * launch an {@link android.app.Activity},
74 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
75 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
76 * and {@link android.content.Context#startService} or
77 * {@link android.content.Context#bindService} to communicate with a
78 * background {@link android.app.Service}.
79 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070080 * <p>An Intent provides a facility for performing late runtime binding between the code in
81 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070082 * can be thought of as the glue between activities. It is basically a passive data structure
83 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070084 *
85 * <div class="special reference">
86 * <h3>Developer Guides</h3>
87 * <p>For information about how to create and resolve intents, read the
88 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
89 * developer guide.</p>
90 * </div>
91 *
92 * <a name="IntentStructure"></a>
93 * <h3>Intent Structure</h3>
94 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 *
96 * <ul>
97 * <li> <p><b>action</b> -- The general action to be performed, such as
98 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
99 * etc.</p>
100 * </li>
101 * <li> <p><b>data</b> -- The data to operate on, such as a person record
102 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
103 * </li>
104 * </ul>
105 *
106 *
107 * <p>Some examples of action/data pairs are:</p>
108 *
109 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700110 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700111 * information about the person whose identifier is "1".</p>
112 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * the phone dialer with the person filled in.</p>
115 * </li>
116 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
117 * the phone dialer with the given number filled in. Note how the
118 * VIEW action does what what is considered the most reasonable thing for
119 * a particular URI.</p>
120 * </li>
121 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
122 * the phone dialer with the given number filled in.</p>
123 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700124 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700125 * information about the person whose identifier is "1".</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * a list of people, which the user can browse through. This example is a
129 * typical top-level entry into the Contacts application, showing you the
130 * list of people. Selecting a particular person to view would result in a
131 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
132 * being used to start an activity to display that person.</p>
133 * </li>
134 * </ul>
135 *
136 * <p>In addition to these primary attributes, there are a number of secondary
137 * attributes that you can also include with an intent:</p>
138 *
139 * <ul>
140 * <li> <p><b>category</b> -- Gives additional information about the action
141 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
142 * appear in the Launcher as a top-level application, while
143 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
144 * of alternative actions the user can perform on a piece of data.</p>
145 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
146 * intent data. Normally the type is inferred from the data itself.
147 * By setting this attribute, you disable that evaluation and force
148 * an explicit type.</p>
149 * <li> <p><b>component</b> -- Specifies an explicit name of a component
150 * class to use for the intent. Normally this is determined by looking
151 * at the other information in the intent (the action, data/type, and
152 * categories) and matching that with a component that can handle it.
153 * If this attribute is set then none of the evaluation is performed,
154 * and this component is used exactly as is. By specifying this attribute,
155 * all of the other Intent attributes become optional.</p>
156 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
157 * This can be used to provide extended information to the component.
158 * For example, if we have a action to send an e-mail message, we could
159 * also include extra pieces of data here to supply a subject, body,
160 * etc.</p>
161 * </ul>
162 *
163 * <p>Here are some examples of other operations you can specify as intents
164 * using these additional parameters:</p>
165 *
166 * <ul>
167 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
168 * Launch the home screen.</p>
169 * </li>
170 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
171 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
172 * vnd.android.cursor.item/phone}</i></b>
173 * -- Display the list of people's phone numbers, allowing the user to
174 * browse through them and pick one and return it to the parent activity.</p>
175 * </li>
176 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
177 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
178 * -- Display all pickers for data that can be opened with
179 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
180 * allowing the user to pick one of them and then some data inside of it
181 * and returning the resulting URI to the caller. This can be used,
182 * for example, in an e-mail application to allow the user to pick some
183 * data to include as an attachment.</p>
184 * </li>
185 * </ul>
186 *
187 * <p>There are a variety of standard Intent action and category constants
188 * defined in the Intent class, but applications can also define their own.
189 * These strings use java style scoping, to ensure they are unique -- for
190 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700191 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 *
193 * <p>Put together, the set of actions, data types, categories, and extra data
194 * defines a language for the system allowing for the expression of phrases
195 * such as "call john smith's cell". As applications are added to the system,
196 * they can extend this language by adding new actions, types, and categories, or
197 * they can modify the behavior of existing phrases by supplying their own
198 * activities that handle them.</p>
199 *
200 * <a name="IntentResolution"></a>
201 * <h3>Intent Resolution</h3>
202 *
203 * <p>There are two primary forms of intents you will use.
204 *
205 * <ul>
206 * <li> <p><b>Explicit Intents</b> have specified a component (via
207 * {@link #setComponent} or {@link #setClass}), which provides the exact
208 * class to be run. Often these will not include any other information,
209 * simply being a way for an application to launch various internal
210 * activities it has as the user interacts with the application.
211 *
212 * <li> <p><b>Implicit Intents</b> have not specified a component;
213 * instead, they must include enough information for the system to
214 * determine which of the available components is best to run for that
215 * intent.
216 * </ul>
217 *
218 * <p>When using implicit intents, given such an arbitrary intent we need to
219 * know what to do with it. This is handled by the process of <em>Intent
220 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
221 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
222 * more activities/receivers) that can handle it.</p>
223 *
224 * <p>The intent resolution mechanism basically revolves around matching an
225 * Intent against all of the &lt;intent-filter&gt; descriptions in the
226 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
227 * objects explicitly registered with {@link Context#registerReceiver}.) More
228 * details on this can be found in the documentation on the {@link
229 * IntentFilter} class.</p>
230 *
231 * <p>There are three pieces of information in the Intent that are used for
232 * resolution: the action, type, and category. Using this information, a query
233 * is done on the {@link PackageManager} for a component that can handle the
234 * intent. The appropriate component is determined based on the intent
235 * information supplied in the <code>AndroidManifest.xml</code> file as
236 * follows:</p>
237 *
238 * <ul>
239 * <li> <p>The <b>action</b>, if given, must be listed by the component as
240 * one it handles.</p>
241 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
242 * already supplied in the Intent. Like the action, if a type is
243 * included in the intent (either explicitly or implicitly in its
244 * data), then this must be listed by the component as one it handles.</p>
245 * <li> For data that is not a <code>content:</code> URI and where no explicit
246 * type is included in the Intent, instead the <b>scheme</b> of the
247 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
248 * considered. Again like the action, if we are matching a scheme it
249 * must be listed by the component as one it can handle.
250 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
251 * by the activity as categories it handles. That is, if you include
252 * the categories {@link #CATEGORY_LAUNCHER} and
253 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
254 * with an intent that lists <em>both</em> of those categories.
255 * Activities will very often need to support the
256 * {@link #CATEGORY_DEFAULT} so that they can be found by
257 * {@link Context#startActivity Context.startActivity()}.</p>
258 * </ul>
259 *
260 * <p>For example, consider the Note Pad sample application that
261 * allows user to browse through a list of notes data and view details about
262 * individual items. Text in italics indicate places were you would replace a
263 * name with one specific to your own package.</p>
264 *
265 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
266 * package="<i>com.android.notepad</i>"&gt;
267 * &lt;application android:icon="@drawable/app_notes"
268 * android:label="@string/app_name"&gt;
269 *
270 * &lt;provider class=".NotePadProvider"
271 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
272 *
273 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
274 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700275 * &lt;action android:name="android.intent.action.MAIN" /&gt;
276 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700277 * &lt;/intent-filter&gt;
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.VIEW" /&gt;
280 * &lt;action android:name="android.intent.action.EDIT" /&gt;
281 * &lt;action android:name="android.intent.action.PICK" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700284 * &lt;/intent-filter&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
287 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
288 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700289 * &lt;/intent-filter&gt;
290 * &lt;/activity&gt;
291 *
292 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
293 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700294 * &lt;action android:name="android.intent.action.VIEW" /&gt;
295 * &lt;action android:name="android.intent.action.EDIT" /&gt;
296 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
297 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700298 * &lt;/intent-filter&gt;
299 *
300 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700301 * &lt;action android:name="android.intent.action.INSERT" /&gt;
302 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
303 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700304 * &lt;/intent-filter&gt;
305 *
306 * &lt;/activity&gt;
307 *
308 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
309 * android:theme="@android:style/Theme.Dialog"&gt;
310 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700311 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
312 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
313 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
314 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
315 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700316 * &lt;/intent-filter&gt;
317 * &lt;/activity&gt;
318 *
319 * &lt;/application&gt;
320 * &lt;/manifest&gt;</pre>
321 *
322 * <p>The first activity,
323 * <code>com.android.notepad.NotesList</code>, serves as our main
324 * entry into the app. It can do three things as described by its three intent
325 * templates:
326 * <ol>
327 * <li><pre>
328 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700329 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
330 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700331 * &lt;/intent-filter&gt;</pre>
332 * <p>This provides a top-level entry into the NotePad application: the standard
333 * MAIN action is a main entry point (not requiring any other information in
334 * the Intent), and the LAUNCHER category says that this entry point should be
335 * listed in the application launcher.</p>
336 * <li><pre>
337 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700338 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
339 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
340 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
341 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
342 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700343 * &lt;/intent-filter&gt;</pre>
344 * <p>This declares the things that the activity can do on a directory of
345 * notes. The type being supported is given with the &lt;type&gt; tag, where
346 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
347 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
348 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
349 * The activity allows the user to view or edit the directory of data (via
350 * the VIEW and EDIT actions), or to pick a particular note and return it
351 * to the caller (via the PICK action). Note also the DEFAULT category
352 * supplied here: this is <em>required</em> for the
353 * {@link Context#startActivity Context.startActivity} method to resolve your
354 * activity when its component name is not explicitly specified.</p>
355 * <li><pre>
356 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700357 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
358 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
359 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700360 * &lt;/intent-filter&gt;</pre>
361 * <p>This filter describes the ability return to the caller a note selected by
362 * the user without needing to know where it came from. The data type
363 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
364 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
365 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
366 * The GET_CONTENT action is similar to the PICK action, where the activity
367 * will return to its caller a piece of data selected by the user. Here,
368 * however, the caller specifies the type of data they desire instead of
369 * the type of data the user will be picking from.</p>
370 * </ol>
371 *
372 * <p>Given these capabilities, the following intents will resolve to the
373 * NotesList activity:</p>
374 *
375 * <ul>
376 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
377 * activities that can be used as top-level entry points into an
378 * application.</p>
379 * <li> <p><b>{ action=android.app.action.MAIN,
380 * category=android.app.category.LAUNCHER }</b> is the actual intent
381 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700382 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700383 * data=content://com.google.provider.NotePad/notes }</b>
384 * displays a list of all the notes under
385 * "content://com.google.provider.NotePad/notes", which
386 * the user can browse through and see the details on.</p>
387 * <li> <p><b>{ action=android.app.action.PICK
388 * data=content://com.google.provider.NotePad/notes }</b>
389 * provides a list of the notes under
390 * "content://com.google.provider.NotePad/notes", from which
391 * the user can pick a note whose data URL is returned back to the caller.</p>
392 * <li> <p><b>{ action=android.app.action.GET_CONTENT
393 * type=vnd.android.cursor.item/vnd.google.note }</b>
394 * is similar to the pick action, but allows the caller to specify the
395 * kind of data they want back so that the system can find the appropriate
396 * activity to pick something of that data type.</p>
397 * </ul>
398 *
399 * <p>The second activity,
400 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
401 * note entry and allows them to edit it. It can do two things as described
402 * by its two intent templates:
403 * <ol>
404 * <li><pre>
405 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700406 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
407 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
408 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
409 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700410 * &lt;/intent-filter&gt;</pre>
411 * <p>The first, primary, purpose of this activity is to let the user interact
412 * with a single note, as decribed by the MIME type
413 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
414 * either VIEW a note or allow the user to EDIT it. Again we support the
415 * DEFAULT category to allow the activity to be launched without explicitly
416 * specifying its component.</p>
417 * <li><pre>
418 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700419 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
420 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
421 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700422 * &lt;/intent-filter&gt;</pre>
423 * <p>The secondary use of this activity is to insert a new note entry into
424 * an existing directory of notes. This is used when the user creates a new
425 * note: the INSERT action is executed on the directory of notes, causing
426 * this activity to run and have the user create the new note data which
427 * it then adds to the content provider.</p>
428 * </ol>
429 *
430 * <p>Given these capabilities, the following intents will resolve to the
431 * NoteEditor activity:</p>
432 *
433 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700434 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700435 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
436 * shows the user the content of note <var>{ID}</var>.</p>
437 * <li> <p><b>{ action=android.app.action.EDIT
438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * allows the user to edit the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.INSERT
441 * data=content://com.google.provider.NotePad/notes }</b>
442 * creates a new, empty note in the notes list at
443 * "content://com.google.provider.NotePad/notes"
444 * and allows the user to edit it. If they keep their changes, the URI
445 * of the newly created note is returned to the caller.</p>
446 * </ul>
447 *
448 * <p>The last activity,
449 * <code>com.android.notepad.TitleEditor</code>, allows the user to
450 * edit the title of a note. This could be implemented as a class that the
451 * application directly invokes (by explicitly setting its component in
452 * the Intent), but here we show a way you can publish alternative
453 * operations on existing data:</p>
454 *
455 * <pre>
456 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700457 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
458 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
459 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
461 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700462 * &lt;/intent-filter&gt;</pre>
463 *
464 * <p>In the single intent template here, we
465 * have created our own private action called
466 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
467 * edit the title of a note. It must be invoked on a specific note
468 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
469 * view and edit actions, but here displays and edits the title contained
470 * in the note data.
471 *
472 * <p>In addition to supporting the default category as usual, our title editor
473 * also supports two other standard categories: ALTERNATIVE and
474 * SELECTED_ALTERNATIVE. Implementing
475 * these categories allows others to find the special action it provides
476 * without directly knowing about it, through the
477 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
478 * more often to build dynamic menu items with
479 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
480 * template here was also supply an explicit name for the template
481 * (via <code>android:label="@string/resolve_title"</code>) to better control
482 * what the user sees when presented with this activity as an alternative
483 * action to the data they are viewing.
484 *
485 * <p>Given these capabilities, the following intent will resolve to the
486 * TitleEditor activity:</p>
487 *
488 * <ul>
489 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
490 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
491 * displays and allows the user to edit the title associated
492 * with note <var>{ID}</var>.</p>
493 * </ul>
494 *
495 * <h3>Standard Activity Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for launching
498 * activities (usually through {@link Context#startActivity}. The most
499 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
500 * {@link #ACTION_EDIT}.
501 *
502 * <ul>
503 * <li> {@link #ACTION_MAIN}
504 * <li> {@link #ACTION_VIEW}
505 * <li> {@link #ACTION_ATTACH_DATA}
506 * <li> {@link #ACTION_EDIT}
507 * <li> {@link #ACTION_PICK}
508 * <li> {@link #ACTION_CHOOSER}
509 * <li> {@link #ACTION_GET_CONTENT}
510 * <li> {@link #ACTION_DIAL}
511 * <li> {@link #ACTION_CALL}
512 * <li> {@link #ACTION_SEND}
513 * <li> {@link #ACTION_SENDTO}
514 * <li> {@link #ACTION_ANSWER}
515 * <li> {@link #ACTION_INSERT}
516 * <li> {@link #ACTION_DELETE}
517 * <li> {@link #ACTION_RUN}
518 * <li> {@link #ACTION_SYNC}
519 * <li> {@link #ACTION_PICK_ACTIVITY}
520 * <li> {@link #ACTION_SEARCH}
521 * <li> {@link #ACTION_WEB_SEARCH}
522 * <li> {@link #ACTION_FACTORY_TEST}
523 * </ul>
524 *
525 * <h3>Standard Broadcast Actions</h3>
526 *
527 * <p>These are the current standard actions that Intent defines for receiving
528 * broadcasts (usually through {@link Context#registerReceiver} or a
529 * &lt;receiver&gt; tag in a manifest).
530 *
531 * <ul>
532 * <li> {@link #ACTION_TIME_TICK}
533 * <li> {@link #ACTION_TIME_CHANGED}
534 * <li> {@link #ACTION_TIMEZONE_CHANGED}
535 * <li> {@link #ACTION_BOOT_COMPLETED}
536 * <li> {@link #ACTION_PACKAGE_ADDED}
537 * <li> {@link #ACTION_PACKAGE_CHANGED}
538 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 * <li> {@link #ACTION_PACKAGE_RESTARTED}
540 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700541 * <li> {@link #ACTION_UID_REMOVED}
542 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700543 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700544 * <li> {@link #ACTION_POWER_DISCONNECTED}
545 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * </ul>
547 *
548 * <h3>Standard Categories</h3>
549 *
550 * <p>These are the current standard categories that can be used to further
551 * clarify an Intent via {@link #addCategory}.
552 *
553 * <ul>
554 * <li> {@link #CATEGORY_DEFAULT}
555 * <li> {@link #CATEGORY_BROWSABLE}
556 * <li> {@link #CATEGORY_TAB}
557 * <li> {@link #CATEGORY_ALTERNATIVE}
558 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
559 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800560 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700561 * <li> {@link #CATEGORY_HOME}
562 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400564 * <li> {@link #CATEGORY_CAR_DOCK}
565 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500566 * <li> {@link #CATEGORY_LE_DESK_DOCK}
567 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200568 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700569 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * </ul>
571 *
572 * <h3>Standard Extra Data</h3>
573 *
574 * <p>These are the current standard fields that can be used as extra data via
575 * {@link #putExtra}.
576 *
577 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800578 * <li> {@link #EXTRA_ALARM_COUNT}
579 * <li> {@link #EXTRA_BCC}
580 * <li> {@link #EXTRA_CC}
581 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
582 * <li> {@link #EXTRA_DATA_REMOVED}
583 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500584 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
585 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800586 * <li> {@link #EXTRA_DOCK_STATE_CAR}
587 * <li> {@link #EXTRA_DOCK_STATE_DESK}
588 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
589 * <li> {@link #EXTRA_DONT_KILL_APP}
590 * <li> {@link #EXTRA_EMAIL}
591 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700592 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800593 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700594 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800595 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700596 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
598 * <li> {@link #EXTRA_REPLACING}
599 * <li> {@link #EXTRA_SHORTCUT_ICON}
600 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
601 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700602 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_SHORTCUT_NAME}
604 * <li> {@link #EXTRA_SUBJECT}
605 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_TITLE}
608 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * </ul>
610 *
611 * <h3>Flags</h3>
612 *
613 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800614 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
615 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800617public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700618 private static final String ATTR_ACTION = "action";
619 private static final String TAG_CATEGORIES = "categories";
620 private static final String ATTR_CATEGORY = "category";
621 private static final String TAG_EXTRA = "extra";
622 private static final String ATTR_TYPE = "type";
623 private static final String ATTR_COMPONENT = "component";
624 private static final String ATTR_DATA = "data";
625 private static final String ATTR_FLAGS = "flags";
626
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700627 // ---------------------------------------------------------------------
628 // ---------------------------------------------------------------------
629 // Standard intent activity actions (see action variable).
630
631 /**
632 * Activity Action: Start as a main entry point, does not expect to
633 * receive data.
634 * <p>Input: nothing
635 * <p>Output: nothing
636 */
637 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
638 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700640 /**
641 * Activity Action: Display the data to the user. This is the most common
642 * action performed on data -- it is the generic action you can use on
643 * a piece of data to get the most reasonable thing to occur. For example,
644 * when used on a contacts entry it will view the entry; when used on a
645 * mailto: URI it will bring up a compose window filled with the information
646 * supplied by the URI; when used with a tel: URI it will invoke the
647 * dialer.
648 * <p>Input: {@link #getData} is URI from which to retrieve data.
649 * <p>Output: nothing.
650 */
651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
652 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 /**
655 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
656 * performed on a piece of data.
657 */
658 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 /**
661 * Used to indicate that some piece of data should be attached to some other
662 * place. For example, image data could be attached to a contact. It is up
663 * to the recipient to decide where the data should be attached; the intent
664 * does not specify the ultimate destination.
665 * <p>Input: {@link #getData} is URI of data to be attached.
666 * <p>Output: nothing.
667 */
668 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
669 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800670
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700671 /**
672 * Activity Action: Provide explicit editable access to the given data.
673 * <p>Input: {@link #getData} is URI of data to be edited.
674 * <p>Output: nothing.
675 */
676 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
677 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800678
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700679 /**
680 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
681 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
682 * The extras can contain type specific data to pass through to the editing/creating
683 * activity.
684 * <p>Output: The URI of the item that was picked. This must be a content:
685 * URI so that any receiver can access it.
686 */
687 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
688 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800689
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700690 /**
691 * Activity Action: Pick an item from the data, returning what was selected.
692 * <p>Input: {@link #getData} is URI containing a directory of data
693 * (vnd.android.cursor.dir/*) from which to pick an item.
694 * <p>Output: The URI of the item that was picked.
695 */
696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
697 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800698
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700699 /**
700 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800701 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700702 * <p>Output: An Intent representing the shortcut. The intent must contain three
703 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
704 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800705 * (value: ShortcutIconResource).</p>
706 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700707 * @see #EXTRA_SHORTCUT_INTENT
708 * @see #EXTRA_SHORTCUT_NAME
709 * @see #EXTRA_SHORTCUT_ICON
710 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
711 * @see android.content.Intent.ShortcutIconResource
712 */
713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
715
716 /**
717 * The name of the extra used to define the Intent of a shortcut.
718 *
719 * @see #ACTION_CREATE_SHORTCUT
720 */
721 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
722 /**
723 * The name of the extra used to define the name of a shortcut.
724 *
725 * @see #ACTION_CREATE_SHORTCUT
726 */
727 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
728 /**
729 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
730 *
731 * @see #ACTION_CREATE_SHORTCUT
732 */
733 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
734 /**
735 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
736 *
737 * @see #ACTION_CREATE_SHORTCUT
738 * @see android.content.Intent.ShortcutIconResource
739 */
740 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
741 "android.intent.extra.shortcut.ICON_RESOURCE";
742
743 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800744 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700745 *
746 * @see Intent#ACTION_CREATE_SHORTCUT
747 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800748 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
749 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 */
751 public static class ShortcutIconResource implements Parcelable {
752 /**
753 * The package name of the application containing the icon.
754 */
755 public String packageName;
756
757 /**
758 * The resource name of the icon, including package, name and type.
759 */
760 public String resourceName;
761
762 /**
763 * Creates a new ShortcutIconResource for the specified context and resource
764 * identifier.
765 *
766 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700767 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700769 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700770 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700771 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700772 ShortcutIconResource icon = new ShortcutIconResource();
773 icon.packageName = context.getPackageName();
774 icon.resourceName = context.getResources().getResourceName(resourceId);
775 return icon;
776 }
777
778 /**
779 * Used to read a ShortcutIconResource from a Parcel.
780 */
781 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
782 new Parcelable.Creator<ShortcutIconResource>() {
783
784 public ShortcutIconResource createFromParcel(Parcel source) {
785 ShortcutIconResource icon = new ShortcutIconResource();
786 icon.packageName = source.readString();
787 icon.resourceName = source.readString();
788 return icon;
789 }
790
791 public ShortcutIconResource[] newArray(int size) {
792 return new ShortcutIconResource[size];
793 }
794 };
795
796 /**
797 * No special parcel contents.
798 */
799 public int describeContents() {
800 return 0;
801 }
802
803 public void writeToParcel(Parcel dest, int flags) {
804 dest.writeString(packageName);
805 dest.writeString(resourceName);
806 }
807
808 @Override
809 public String toString() {
810 return resourceName;
811 }
812 }
813
814 /**
815 * Activity Action: Display an activity chooser, allowing the user to pick
816 * what they want to before proceeding. This can be used as an alternative
817 * to the standard activity picker that is displayed by the system when
818 * you try to start an activity with multiple possible matches, with these
819 * differences in behavior:
820 * <ul>
821 * <li>You can specify the title that will appear in the activity chooser.
822 * <li>The user does not have the option to make one of the matching
823 * activities a preferred activity, and all possible activities will
824 * always be shown even if one of them is currently marked as the
825 * preferred activity.
826 * </ul>
827 * <p>
828 * This action should be used when the user will naturally expect to
829 * select an activity in order to proceed. An example if when not to use
830 * it is when the user clicks on a "mailto:" link. They would naturally
831 * expect to go directly to their mail app, so startActivity() should be
832 * called directly: it will
833 * either launch the current preferred app, or put up a dialog allowing the
834 * user to pick an app to use and optionally marking that as preferred.
835 * <p>
836 * In contrast, if the user is selecting a menu item to send a picture
837 * they are viewing to someone else, there are many different things they
838 * may want to do at this point: send it through e-mail, upload it to a
839 * web service, etc. In this case the CHOOSER action should be used, to
840 * always present to the user a list of the things they can do, with a
841 * nice title given by the caller such as "Send this photo with:".
842 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700843 * If you need to grant URI permissions through a chooser, you must specify
844 * the permissions to be granted on the ACTION_CHOOSER Intent
845 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
846 * {@link #setClipData} to specify the URIs to be granted as well as
847 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
848 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
849 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700850 * As a convenience, an Intent of this form can be created with the
851 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700852 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700853 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700854 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
855 * and can optionally have a {@link #EXTRA_TITLE} field containing the
856 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700857 * <p>
858 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700859 */
860 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
861 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
862
863 /**
864 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
865 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700866 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
867 * target intent, also optionally supplying a title. If the target
868 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
869 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
870 * set in the returned chooser intent, with its ClipData set appropriately:
871 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500872 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700873 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700874 * @param target The Intent that the user will be selecting an activity
875 * to perform.
876 * @param title Optional title that will be displayed in the chooser.
877 * @return Return a new Intent object that you can hand to
878 * {@link Context#startActivity(Intent) Context.startActivity()} and
879 * related methods.
880 */
881 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700882 return createChooser(target, title, null);
883 }
884
885 /**
886 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
887 *
888 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
889 * target intent, also optionally supplying a title. If the target
890 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
891 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
892 * set in the returned chooser intent, with its ClipData set appropriately:
893 * either a direct reflection of {@link #getClipData()} if that is non-null,
894 * or a new ClipData built from {@link #getData()}.</p>
895 *
896 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
897 * when the user makes a choice. This can be useful if the calling application wants
898 * to remember the last chosen target and surface it as a more prominent or one-touch
899 * affordance elsewhere in the UI for next time.</p>
900 *
901 * @param target The Intent that the user will be selecting an activity
902 * to perform.
903 * @param title Optional title that will be displayed in the chooser.
904 * @param sender Optional IntentSender to be called when a choice is made.
905 * @return Return a new Intent object that you can hand to
906 * {@link Context#startActivity(Intent) Context.startActivity()} and
907 * related methods.
908 */
909 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700910 Intent intent = new Intent(ACTION_CHOOSER);
911 intent.putExtra(EXTRA_INTENT, target);
912 if (title != null) {
913 intent.putExtra(EXTRA_TITLE, title);
914 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700915
Adam Powell0b3c1122014-10-09 12:50:14 -0700916 if (sender != null) {
917 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
918 }
919
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700920 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700921 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
922 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
923 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700924 if (permFlags != 0) {
925 ClipData targetClipData = target.getClipData();
926 if (targetClipData == null && target.getData() != null) {
927 ClipData.Item item = new ClipData.Item(target.getData());
928 String[] mimeTypes;
929 if (target.getType() != null) {
930 mimeTypes = new String[] { target.getType() };
931 } else {
932 mimeTypes = new String[] { };
933 }
934 targetClipData = new ClipData(null, mimeTypes, item);
935 }
936 if (targetClipData != null) {
937 intent.setClipData(targetClipData);
938 intent.addFlags(permFlags);
939 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700940 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700941
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700942 return intent;
943 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700944
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700945 /**
946 * Activity Action: Allow the user to select a particular kind of data and
947 * return it. This is different than {@link #ACTION_PICK} in that here we
948 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800949 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700950 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900951 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700952 * etc.
953 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900954 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700955 * of data, such as a person contact, you set the MIME type to the kind of
956 * data you want and launch it with {@link Context#startActivity(Intent)}.
957 * The system will then launch the best application to select that kind
958 * of data for you.
959 * <p>
960 * You may also be interested in any of a set of types of content the user
961 * can pick. For example, an e-mail application that wants to allow the
962 * user to add an attachment to an e-mail message can use this action to
963 * bring up a list of all of the types of content the user can attach.
964 * <p>
965 * In this case, you should wrap the GET_CONTENT intent with a chooser
966 * (through {@link #createChooser}), which will give the proper interface
967 * for the user to pick how to send your data and allow you to specify
968 * a prompt indicating what they are doing. You will usually specify a
969 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
970 * broad range of content types the user can select from.
971 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900972 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700973 * only pick from data that can be represented as a stream. This is
974 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
975 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800976 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900977 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800978 * is locally available on the device. For example, if this extra is set
979 * to true then an image picker should not show any pictures that are available
980 * from a remote server but not already on the local device (thus requiring
981 * they be downloaded when opened).
982 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800983 * If the caller can handle multiple returned items (the user performing
984 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
985 * to indicate this.
986 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700987 * Input: {@link #getType} is the desired MIME type to retrieve. Note
988 * that no URI is supplied in the intent, as there are no constraints on
989 * where the returned data originally comes from. You may also include the
990 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800991 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800992 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
993 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700994 * <p>
995 * Output: The URI of the item that was picked. This must be a content:
996 * URI so that any receiver can access it.
997 */
998 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
999 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1000 /**
1001 * Activity Action: Dial a number as specified by the data. This shows a
1002 * UI with the number being dialed, allowing the user to explicitly
1003 * initiate the call.
1004 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1005 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1006 * number.
1007 * <p>Output: nothing.
1008 */
1009 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1010 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1011 /**
1012 * Activity Action: Perform a call to someone specified by the data.
1013 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1014 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1015 * number.
1016 * <p>Output: nothing.
1017 *
1018 * <p>Note: there will be restrictions on which applications can initiate a
1019 * call; most applications should use the {@link #ACTION_DIAL}.
1020 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1021 * numbers. Applications can <strong>dial</strong> emergency numbers using
1022 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001023 *
1024 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#MNC MNC}
1025 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001026 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001027 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001028 */
1029 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1030 public static final String ACTION_CALL = "android.intent.action.CALL";
1031 /**
1032 * Activity Action: Perform a call to an emergency number specified by the
1033 * data.
1034 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1035 * tel: URI of an explicit phone number.
1036 * <p>Output: nothing.
1037 * @hide
1038 */
1039 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1040 /**
1041 * Activity action: Perform a call to any number (emergency or not)
1042 * specified by the data.
1043 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1044 * tel: URI of an explicit phone number.
1045 * <p>Output: nothing.
1046 * @hide
1047 */
1048 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1049 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001050 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1051 * sending this intent is a no-op.
1052 * <p>Input: No data should be specified. get*Extra may have an optional
1053 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1054 * send the activation result.
1055 * <p>Output: nothing.
1056 * @hide
1057 */
1058 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1059 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1060 "android.intent.action.SIM_ACTIVATION_REQUEST";
1061 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001062 * Activity Action: Send a message to someone specified by the data.
1063 * <p>Input: {@link #getData} is URI describing the target.
1064 * <p>Output: nothing.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1068 /**
1069 * Activity Action: Deliver some data to someone else. Who the data is
1070 * being delivered to is not specified; it is up to the receiver of this
1071 * action to ask the user where the data should be sent.
1072 * <p>
1073 * When launching a SEND intent, you should usually wrap it in a chooser
1074 * (through {@link #createChooser}), which will give the proper interface
1075 * for the user to pick how to send your data and allow you to specify
1076 * a prompt indicating what they are doing.
1077 * <p>
1078 * Input: {@link #getType} is the MIME type of the data being sent.
1079 * get*Extra can have either a {@link #EXTRA_TEXT}
1080 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1081 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1082 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1083 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001084 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1085 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1086 * your text with HTML formatting.
1087 * <p>
1088 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1089 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1090 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1091 * content: URIs and other advanced features of {@link ClipData}. If
1092 * using this approach, you still must supply the same data through the
1093 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1094 * for compatibility with old applications. If you don't set a ClipData,
1095 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001096 * <p>
1097 * Optional standard extras, which may be interpreted by some recipients as
1098 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1099 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1100 * <p>
1101 * Output: nothing.
1102 */
1103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1104 public static final String ACTION_SEND = "android.intent.action.SEND";
1105 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001106 * Activity Action: Deliver multiple data to someone else.
1107 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001108 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001109 * <p>
1110 * Input: {@link #getType} is the MIME type of the data being sent.
1111 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001112 * #EXTRA_STREAM} field, containing the data to be sent. If using
1113 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1114 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001115 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001116 * Multiple types are supported, and receivers should handle mixed types
1117 * whenever possible. The right way for the receiver to check them is to
1118 * use the content resolver on each URI. The intent sender should try to
1119 * put the most concrete mime type in the intent type, but it can fall
1120 * back to {@literal <type>/*} or {@literal *}/* as needed.
1121 * <p>
1122 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1123 * be image/jpg, but if you are sending image/jpg and image/png, then the
1124 * intent's type should be image/*.
1125 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001126 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1127 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1128 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1129 * content: URIs and other advanced features of {@link ClipData}. If
1130 * using this approach, you still must supply the same data through the
1131 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1132 * for compatibility with old applications. If you don't set a ClipData,
1133 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1134 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001135 * Optional standard extras, which may be interpreted by some recipients as
1136 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1137 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1138 * <p>
1139 * Output: nothing.
1140 */
1141 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1142 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1143 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001144 * Activity Action: Handle an incoming phone call.
1145 * <p>Input: nothing.
1146 * <p>Output: nothing.
1147 */
1148 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1149 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1150 /**
1151 * Activity Action: Insert an empty item into the given container.
1152 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1153 * in which to place the data.
1154 * <p>Output: URI of the new data that was created.
1155 */
1156 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1157 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1158 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001159 * Activity Action: Create a new item in the given container, initializing it
1160 * from the current contents of the clipboard.
1161 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1162 * in which to place the data.
1163 * <p>Output: URI of the new data that was created.
1164 */
1165 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1166 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1167 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001168 * Activity Action: Delete the given data from its container.
1169 * <p>Input: {@link #getData} is URI of data to be deleted.
1170 * <p>Output: nothing.
1171 */
1172 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1173 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1174 /**
1175 * Activity Action: Run the data, whatever that means.
1176 * <p>Input: ? (Note: this is currently specific to the test harness.)
1177 * <p>Output: nothing.
1178 */
1179 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1180 public static final String ACTION_RUN = "android.intent.action.RUN";
1181 /**
1182 * Activity Action: Perform a data synchronization.
1183 * <p>Input: ?
1184 * <p>Output: ?
1185 */
1186 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1188 /**
1189 * Activity Action: Pick an activity given an intent, returning the class
1190 * selected.
1191 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1192 * used with {@link PackageManager#queryIntentActivities} to determine the
1193 * set of activities from which to pick.
1194 * <p>Output: Class name of the activity that was selected.
1195 */
1196 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1197 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1198 /**
1199 * Activity Action: Perform a search.
1200 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1201 * is the text to search for. If empty, simply
1202 * enter your search results Activity with the search UI activated.
1203 * <p>Output: nothing.
1204 */
1205 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1206 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1207 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001208 * Activity Action: Start the platform-defined tutorial
1209 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1210 * is the text to search for. If empty, simply
1211 * enter your search results Activity with the search UI activated.
1212 * <p>Output: nothing.
1213 */
1214 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1215 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1216 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001217 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001218 * <p>
1219 * Input: {@link android.app.SearchManager#QUERY
1220 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1221 * a url starts with http or https, the site will be opened. If it is plain
1222 * text, Google search will be applied.
1223 * <p>
1224 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001228
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001229 /**
Jim Miller07994402012-05-02 14:22:27 -07001230 * Activity Action: Perform assist action.
1231 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001232 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1233 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001234 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1235 * information.
Jim Miller07994402012-05-02 14:22:27 -07001236 * Output: nothing.
1237 */
1238 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1239 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001240
1241 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001242 * Activity Action: Perform voice assist action.
1243 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001244 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1245 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001246 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001247 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001248 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1252
1253 /**
Adam Skory7140a252013-09-11 12:04:58 +01001254 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1255 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001256 */
1257 public static final String EXTRA_ASSIST_PACKAGE
1258 = "android.intent.extra.ASSIST_PACKAGE";
1259
1260 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001261 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1262 * application package at the time the assist was invoked.
1263 */
1264 public static final String EXTRA_ASSIST_UID
1265 = "android.intent.extra.ASSIST_UID";
1266
1267 /**
Adam Skory7140a252013-09-11 12:04:58 +01001268 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1269 * information supplied by the current foreground app at the time of the assist request.
1270 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001271 */
1272 public static final String EXTRA_ASSIST_CONTEXT
1273 = "android.intent.extra.ASSIST_CONTEXT";
1274
Jim Miller07994402012-05-02 14:22:27 -07001275 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001276 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1277 * keyboard as the primary input device for assistance.
1278 */
1279 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1280 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1281
1282 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001283 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1284 * that was used to invoke the assist.
1285 */
1286 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1287 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1288
1289 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001290 * Activity Action: List all available applications
1291 * <p>Input: Nothing.
1292 * <p>Output: nothing.
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1296 /**
1297 * Activity Action: Show settings for choosing wallpaper
1298 * <p>Input: Nothing.
1299 * <p>Output: Nothing.
1300 */
1301 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1302 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1303
1304 /**
1305 * Activity Action: Show activity for reporting a bug.
1306 * <p>Input: Nothing.
1307 * <p>Output: Nothing.
1308 */
1309 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1310 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1311
1312 /**
1313 * Activity Action: Main entry point for factory tests. Only used when
1314 * the device is booting in factory test node. The implementing package
1315 * must be installed in the system image.
1316 * <p>Input: nothing
1317 * <p>Output: nothing
1318 */
1319 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1320
1321 /**
1322 * Activity Action: The user pressed the "call" button to go to the dialer
1323 * or other appropriate UI for placing a call.
1324 * <p>Input: Nothing.
1325 * <p>Output: Nothing.
1326 */
1327 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1328 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1329
1330 /**
1331 * Activity Action: Start Voice Command.
1332 * <p>Input: Nothing.
1333 * <p>Output: Nothing.
1334 */
1335 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1336 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001337
1338 /**
1339 * Activity Action: Start action associated with long pressing on the
1340 * search key.
1341 * <p>Input: Nothing.
1342 * <p>Output: Nothing.
1343 */
1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001346
Jacek Surazski86b6c532009-05-13 14:38:28 +02001347 /**
1348 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1349 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001350 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001351 * <p>Input: No data is specified. The bug report is passed in using
1352 * an {@link #EXTRA_BUG_REPORT} field.
1353 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001354 *
1355 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001356 */
1357 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1358 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001359
1360 /**
1361 * Activity Action: Show power usage information to the user.
1362 * <p>Input: Nothing.
1363 * <p>Output: Nothing.
1364 */
1365 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001367
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001368 /**
1369 * Activity Action: Setup wizard to launch after a platform update. This
1370 * activity should have a string meta-data field associated with it,
1371 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1372 * the platform for setup. The activity will be launched only if
1373 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1374 * same value.
1375 * <p>Input: Nothing.
1376 * <p>Output: Nothing.
1377 * @hide
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001381
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001382 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001383 * Activity Action: Show settings for managing network data usage of a
1384 * specific application. Applications should define an activity that offers
1385 * options to control data usage.
1386 */
1387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1388 public static final String ACTION_MANAGE_NETWORK_USAGE =
1389 "android.intent.action.MANAGE_NETWORK_USAGE";
1390
1391 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001392 * Activity Action: Launch application installer.
1393 * <p>
1394 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001395 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1396 * you can also use "package:<package-name>" to install an application for the
1397 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001398 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1399 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1400 * <p>
1401 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1402 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001403 * <p>
1404 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1405 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1406 * in order to launch the application installer.
1407 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001408 *
1409 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1410 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1411 * @see #EXTRA_RETURN_RESULT
1412 */
1413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1414 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1415
1416 /**
1417 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1418 * package. Specifies the installer package name; this package will receive the
1419 * {@link #ACTION_APP_ERROR} intent.
1420 */
1421 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1422 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1423
1424 /**
1425 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1426 * package. Specifies that the application being installed should not be
1427 * treated as coming from an unknown source, but as coming from the app
1428 * invoking the Intent. For this to work you must start the installer with
1429 * startActivityForResult().
1430 */
1431 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1432 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1433
1434 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001435 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1436 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001437 * data field originated from.
1438 */
rich cannings706e8ba2012-08-20 13:20:14 -07001439 public static final String EXTRA_ORIGINATING_URI
1440 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001441
1442 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001443 * This extra can be used with any Intent used to launch an activity, supplying information
1444 * about who is launching that activity. This field contains a {@link android.net.Uri}
1445 * object, typically an http: or https: URI of the web site that the referral came from;
1446 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1447 * a native application that it came from.
1448 *
1449 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1450 * instead of directly retrieving the extra. It is also valid for applications to
1451 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1452 * a string, not a Uri; the field here, if supplied, will always take precedence,
1453 * however.</p>
1454 *
1455 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001456 */
1457 public static final String EXTRA_REFERRER
1458 = "android.intent.extra.REFERRER";
1459
1460 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001461 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1462 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1463 * not be created, in particular when Intent extras are supplied through the
1464 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1465 * schemes.
1466 *
1467 * @see #EXTRA_REFERRER
1468 */
1469 public static final String EXTRA_REFERRER_NAME
1470 = "android.intent.extra.REFERRER_NAME";
1471
1472 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001473 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1474 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1475 * @hide
1476 */
1477 public static final String EXTRA_ORIGINATING_UID
1478 = "android.intent.extra.ORIGINATING_UID";
1479
1480 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001481 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1482 * package. Tells the installer UI to skip the confirmation with the user
1483 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001484 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1485 * will no longer show an interstitial message about updating existing
1486 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001487 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001488 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001489 public static final String EXTRA_ALLOW_REPLACE
1490 = "android.intent.extra.ALLOW_REPLACE";
1491
1492 /**
1493 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1494 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1495 * return to the application the result code of the install/uninstall. The returned result
1496 * code will be {@link android.app.Activity#RESULT_OK} on success or
1497 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1498 */
1499 public static final String EXTRA_RETURN_RESULT
1500 = "android.intent.extra.RETURN_RESULT";
1501
1502 /**
1503 * Package manager install result code. @hide because result codes are not
1504 * yet ready to be exposed.
1505 */
1506 public static final String EXTRA_INSTALL_RESULT
1507 = "android.intent.extra.INSTALL_RESULT";
1508
1509 /**
1510 * Activity Action: Launch application uninstaller.
1511 * <p>
1512 * Input: The data must be a package: URI whose scheme specific part is
1513 * the package name of the current installed package to be uninstalled.
1514 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1515 * <p>
1516 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1517 * succeeded.
1518 */
1519 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1520 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1521
1522 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001523 * Specify whether the package should be uninstalled for all users.
1524 * @hide because these should not be part of normal application flow.
1525 */
1526 public static final String EXTRA_UNINSTALL_ALL_USERS
1527 = "android.intent.extra.UNINSTALL_ALL_USERS";
1528
1529 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001530 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1531 * describing the last run version of the platform that was setup.
1532 * @hide
1533 */
1534 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1535
Svet Ganov3695b8a2015-03-24 16:30:25 -07001536 /**
1537 * Activity action: Launch UI to manage the permissions of an app.
1538 * <p>
1539 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1540 * will be managed by the launched UI.
1541 * </p>
1542 * <p>
1543 * Output: Nothing.
1544 * </p>
1545 *
1546 * @see #EXTRA_PACKAGE_NAME
1547 *
1548 * @hide
1549 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1551 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1552 "android.intent.action.MANAGE_APP_PERMISSIONS";
1553
1554 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001555 * Activity action: Launch UI to manage permissions.
1556 * <p>
1557 * Input: Nothing.
1558 * </p>
1559 * <p>
1560 * Output: Nothing.
1561 * </p>
1562 *
1563 * @hide
1564 */
Svet Ganov321f0152015-05-16 22:51:50 -07001565 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1566 public static final String ACTION_MANAGE_PERMISSIONS =
1567 "android.intent.action.MANAGE_PERMISSIONS";
1568
1569 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001570 * Intent extra: An app package name.
1571 * <p>
1572 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001573 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001574 *
1575 * @hide
1576 */
1577 @SystemApi
1578 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1579
1580 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001581 * Broadcast action that requests current permission granted information. It will respond
1582 * to the request by sending a broadcast with action defined by
1583 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001584 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1585 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1586 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001587 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001588 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1589 * number of permissions requested and the number of granted additional permissions
1590 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001591 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001592 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1593 * of localized permission group names that are granted in
1594 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001595 *
1596 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1597 * permissions and the total number of apps requesting runtime permissions will be the first
1598 * and second elements respectively of an int[] in the response as
1599 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1600 *
1601 * @hide
1602 */
1603 public static final String ACTION_GET_PERMISSIONS_COUNT
1604 = "android.intent.action.GET_PERMISSIONS_COUNT";
1605
1606 /**
1607 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1608 * @hide
1609 */
1610 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1611 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1612
1613 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001614 * List of CharSequence of localized permission group labels.
1615 * @hide
1616 */
1617 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1618 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1619
1620 /**
1621 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001622 * @hide
1623 */
1624 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1625 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1626
1627 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001628 * Activity action: Launch UI to manage which apps have a given permission.
1629 * <p>
1630 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1631 * to which will be managed by the launched UI.
1632 * </p>
1633 * <p>
1634 * Output: Nothing.
1635 * </p>
1636 *
1637 * @see #EXTRA_PERMISSION_NAME
1638 *
1639 * @hide
1640 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001641 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1642 public static final String ACTION_MANAGE_PERMISSION_APPS =
1643 "android.intent.action.MANAGE_PERMISSION_APPS";
1644
1645 /**
1646 * Intent extra: The name of a permission.
1647 * <p>
1648 * Type: String
1649 * </p>
1650 *
1651 * @hide
1652 */
1653 @SystemApi
1654 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1655
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001656 // ---------------------------------------------------------------------
1657 // ---------------------------------------------------------------------
1658 // Standard intent broadcast actions (see action variable).
1659
1660 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001661 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1662 * <p>
1663 * For historical reasons, the name of this broadcast action refers to the power
1664 * state of the screen but it is actually sent in response to changes in the
1665 * overall interactive state of the device.
1666 * </p><p>
1667 * This broadcast is sent when the device becomes non-interactive which may have
1668 * nothing to do with the screen turning off. To determine the
1669 * actual state of the screen, use {@link android.view.Display#getState}.
1670 * </p><p>
1671 * See {@link android.os.PowerManager#isInteractive} for details.
1672 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001673 * You <em>cannot</em> receive this through components declared in
1674 * manifests, only by explicitly registering for it with
1675 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1676 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001677 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001678 * <p class="note">This is a protected intent that can only be sent
1679 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001680 */
1681 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1682 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001683
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001684 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001685 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1686 * <p>
1687 * For historical reasons, the name of this broadcast action refers to the power
1688 * state of the screen but it is actually sent in response to changes in the
1689 * overall interactive state of the device.
1690 * </p><p>
1691 * This broadcast is sent when the device becomes interactive which may have
1692 * nothing to do with the screen turning on. To determine the
1693 * actual state of the screen, use {@link android.view.Display#getState}.
1694 * </p><p>
1695 * See {@link android.os.PowerManager#isInteractive} for details.
1696 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001697 * You <em>cannot</em> receive this through components declared in
1698 * manifests, only by explicitly registering for it with
1699 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1700 * Context.registerReceiver()}.
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_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001707
1708 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001709 * Broadcast Action: Sent after the system stops dreaming.
1710 *
1711 * <p class="note">This is a protected intent that can only be sent by the system.
1712 * It is only sent to registered receivers.</p>
1713 */
1714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1715 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1716
1717 /**
1718 * Broadcast Action: Sent after the system starts dreaming.
1719 *
1720 * <p class="note">This is a protected intent that can only be sent by the system.
1721 * It is only sent to registered receivers.</p>
1722 */
1723 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1724 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1725
1726 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001727 * 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 -07001728 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001729 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001730 * <p class="note">This is a protected intent that can only be sent
1731 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001732 */
1733 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001734 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001735
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001736 /**
1737 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001738 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001739 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001740 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1741 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001742 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001743 * <p class="note">This is a protected intent that can only be sent
1744 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001745 */
1746 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1747 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1748 /**
1749 * Broadcast Action: The time was set.
1750 */
1751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1752 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1753 /**
1754 * Broadcast Action: The date has changed.
1755 */
1756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1757 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1758 /**
1759 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1760 * <ul>
1761 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1762 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001763 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001764 * <p class="note">This is a protected intent that can only be sent
1765 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001766 */
1767 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1768 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1769 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001770 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1771 * DNS entries should be tossed.
1772 * @hide
1773 */
1774 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1775 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1776 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001777 * Alarm Changed Action: This is broadcast when the AlarmClock
1778 * application's alarm is set or unset. It is used by the
1779 * AlarmClock application and the StatusBar service.
1780 * @hide
1781 */
1782 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1783 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1784 /**
1785 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1786 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1787 * @hide
1788 */
1789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1790 public static final String ACTION_SYNC_STATE_CHANGED
1791 = "android.intent.action.SYNC_STATE_CHANGED";
1792 /**
1793 * Broadcast Action: This is broadcast once, after the system has finished
1794 * booting. It can be used to perform application-specific initialization,
1795 * such as installing alarms. You must hold the
1796 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1797 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001798 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001799 * <p class="note">This is a protected intent that can only be sent
1800 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001801 */
1802 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1803 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1804 /**
1805 * Broadcast Action: This is broadcast when a user action should request a
1806 * temporary system dialog to dismiss. Some examples of temporary system
1807 * dialogs are the notification window-shade and the recent tasks dialog.
1808 */
1809 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1810 /**
1811 * Broadcast Action: Trigger the download and eventual installation
1812 * of a package.
1813 * <p>Input: {@link #getData} is the URI of the package file to download.
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.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001817 *
1818 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001819 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001820 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1822 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1823 /**
1824 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001825 * device. The data contains the name of the package. Note that the
1826 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001827 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001828 * <ul>
1829 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1830 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1831 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1832 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001833 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001834 * <p class="note">This is a protected intent that can only be sent
1835 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001836 */
1837 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1838 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1839 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001840 * Broadcast Action: A new version of an application package has been
1841 * installed, replacing an existing version that was previously installed.
1842 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001843 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001844 * <ul>
1845 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1846 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001847 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001848 * <p class="note">This is a protected intent that can only be sent
1849 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001850 */
1851 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1852 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1853 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001854 * Broadcast Action: A new version of your application has been installed
1855 * over an existing one. This is only sent to the application that was
1856 * replaced. It does not contain any additional data; to receive it, just
1857 * use an intent filter for this action.
1858 *
1859 * <p class="note">This is a protected intent that can only be sent
1860 * by the system.
1861 */
1862 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1863 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1864 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001865 * Broadcast Action: An existing application package has been removed from
1866 * the device. The data contains the name of the package. The package
1867 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001868 * <ul>
1869 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1870 * to the package.
1871 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1872 * application -- data and code -- is being removed.
1873 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1874 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1875 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001876 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001877 * <p class="note">This is a protected intent that can only be sent
1878 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001879 */
1880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1881 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1882 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001883 * Broadcast Action: An existing application package has been completely
1884 * removed from the device. The data contains the name of the package.
1885 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1886 * {@link #EXTRA_DATA_REMOVED} is true and
1887 * {@link #EXTRA_REPLACING} is false of that broadcast.
1888 *
1889 * <ul>
1890 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1891 * to the package.
1892 * </ul>
1893 *
1894 * <p class="note">This is a protected intent that can only be sent
1895 * by the system.
1896 */
1897 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1898 public static final String ACTION_PACKAGE_FULLY_REMOVED
1899 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1900 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001901 * Broadcast Action: An existing application package has been changed (e.g.
1902 * a component has been enabled or disabled). The data contains the name of
1903 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001904 * <ul>
1905 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001906 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001907 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001908 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1909 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001910 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001911 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001912 * <p class="note">This is a protected intent that can only be sent
1913 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001914 */
1915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1916 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1917 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001918 * @hide
1919 * Broadcast Action: Ask system services if there is any reason to
1920 * restart the given package. The data contains the name of the
1921 * package.
1922 * <ul>
1923 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1924 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1925 * </ul>
1926 *
1927 * <p class="note">This is a protected intent that can only be sent
1928 * by the system.
1929 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08001930 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001931 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1932 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1933 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001934 * Broadcast Action: The user has restarted a package, and all of its
1935 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001936 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001937 * be removed. Note that the restarted package does <em>not</em>
1938 * receive this broadcast.
1939 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001940 * <ul>
1941 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1942 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001943 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001944 * <p class="note">This is a protected intent that can only be sent
1945 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001946 */
1947 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1948 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1949 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001950 * Broadcast Action: The user has cleared the data of a package. This should
1951 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001952 * its persistent data is erased and this broadcast sent.
1953 * Note that the cleared package does <em>not</em>
1954 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001955 * <ul>
1956 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1957 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001958 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001959 * <p class="note">This is a protected intent that can only be sent
1960 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001961 */
1962 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1963 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1964 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001965 * Broadcast Action: A user ID has been removed from the system. The user
1966 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001967 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001968 * <p class="note">This is a protected intent that can only be sent
1969 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001970 */
1971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1972 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001973
1974 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001975 * Broadcast Action: Sent to the installer package of an application
1976 * when that application is first launched (that is the first time it
1977 * is moved out of the stopped state). The data contains the name of the package.
1978 *
1979 * <p class="note">This is a protected intent that can only be sent
1980 * by the system.
1981 */
1982 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1983 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1984
1985 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001986 * Broadcast Action: Sent to the system package verifier when a package
1987 * needs to be verified. The data contains the package URI.
1988 * <p class="note">
1989 * This is a protected intent that can only be sent by the system.
1990 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001991 */
1992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1993 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1994
1995 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001996 * Broadcast Action: Sent to the system package verifier when a package is
1997 * verified. The data contains the package URI.
1998 * <p class="note">
1999 * This is a protected intent that can only be sent by the system.
2000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2003
2004 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002005 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2006 * needs to be verified. The data contains the filter data hosts to be verified against.
2007 * <p class="note">
2008 * This is a protected intent that can only be sent by the system.
2009 * </p>
2010 *
2011 * @hide
2012 */
2013 @SystemApi
2014 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2015 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2016
2017 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002018 * Broadcast Action: Resources for a set of packages (which were
2019 * previously unavailable) are currently
2020 * available since the media on which they exist is available.
2021 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2022 * list of packages whose availability changed.
2023 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2024 * list of uids of packages whose availability changed.
2025 * Note that the
2026 * packages in this list do <em>not</em> receive this broadcast.
2027 * The specified set of packages are now available on the system.
2028 * <p>Includes the following extras:
2029 * <ul>
2030 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2031 * whose resources(were previously unavailable) are currently available.
2032 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2033 * packages whose resources(were previously unavailable)
2034 * are currently available.
2035 * </ul>
2036 *
2037 * <p class="note">This is a protected intent that can only be sent
2038 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002039 */
2040 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002041 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2042 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002043
2044 /**
2045 * Broadcast Action: Resources for a set of packages are currently
2046 * unavailable since the media on which they exist is unavailable.
2047 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2048 * list of packages whose availability changed.
2049 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2050 * list of uids of packages whose availability changed.
2051 * The specified set of packages can no longer be
2052 * launched and are practically unavailable on the system.
2053 * <p>Inclues the following extras:
2054 * <ul>
2055 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2056 * whose resources are no longer available.
2057 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2058 * whose resources are no longer available.
2059 * </ul>
2060 *
2061 * <p class="note">This is a protected intent that can only be sent
2062 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002063 */
2064 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002065 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002066 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002067
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002068 /**
2069 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002070 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002071 * This should <em>only</em> be used to determine when the wallpaper
2072 * has changed to show the new wallpaper to the user. You should certainly
2073 * never, in response to this, change the wallpaper or other attributes of
2074 * it such as the suggested size. That would be crazy, right? You'd cause
2075 * all kinds of loops, especially if other apps are doing similar things,
2076 * right? Of course. So please don't do this.
2077 *
2078 * @deprecated Modern applications should use
2079 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2080 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2081 * shown behind their UI, rather than watching for this broadcast and
2082 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002083 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002084 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002085 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2086 /**
2087 * Broadcast Action: The current device {@link android.content.res.Configuration}
2088 * (orientation, locale, etc) has changed. When such a change happens, the
2089 * UIs (view hierarchy) will need to be rebuilt based on this new
2090 * information; for the most part, applications don't need to worry about
2091 * this, because the system will take care of stopping and restarting the
2092 * application to make sure it sees the new changes. Some system code that
2093 * can not be restarted will need to watch for this action and handle it
2094 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002095 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002096 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002097 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002098 * in manifests, only by explicitly registering for it with
2099 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2100 * Context.registerReceiver()}.
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.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002104 *
2105 * @see android.content.res.Configuration
2106 */
2107 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2108 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2109 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002110 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002111 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002112 * <p class="note">This is a protected intent that can only be sent
2113 * by the system.
2114 */
2115 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2116 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2117 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002118 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2119 * charging state, level, and other information about the battery.
2120 * See {@link android.os.BatteryManager} for documentation on the
2121 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002122 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002123 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002124 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002125 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002126 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002127 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2128 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2129 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2130 * broadcasts that are sent and can be received through manifest
2131 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002132 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002133 * <p class="note">This is a protected intent that can only be sent
2134 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002135 */
2136 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2137 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2138 /**
2139 * Broadcast Action: Indicates low battery condition on the device.
2140 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002141 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002142 * <p class="note">This is a protected intent that can only be sent
2143 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002144 */
2145 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2146 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2147 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002148 * Broadcast Action: Indicates the battery is now okay after being low.
2149 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2150 * gone back up to an okay state.
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.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002154 */
2155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2156 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2157 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002158 * Broadcast Action: External power has been connected to the device.
2159 * This is intended for applications that wish to register specifically to this notification.
2160 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2161 * stay active to receive this notification. This action can be used to implement actions
2162 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002163 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002164 * <p class="note">This is a protected intent that can only be sent
2165 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002166 */
2167 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002168 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002169 /**
2170 * Broadcast Action: External power has been removed from the device.
2171 * This is intended for applications that wish to register specifically to this notification.
2172 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2173 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002174 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002175 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002176 * <p class="note">This is a protected intent that can only be sent
2177 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002178 */
2179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002180 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002181 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002182 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002183 * Broadcast Action: Device is shutting down.
2184 * This is broadcast when the device is being shut down (completely turned
2185 * off, not sleeping). Once the broadcast is complete, the final shutdown
2186 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002187 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002188 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002189 * <p class="note">This is a protected intent that can only be sent
2190 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002191 * <p>May include the following extras:
2192 * <ul>
2193 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2194 * shutdown is only for userspace processes. If not set, assumed to be false.
2195 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002196 */
2197 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002198 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002199 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002200 * Activity Action: Start this activity to request system shutdown.
2201 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2202 * to request confirmation from the user before shutting down.
2203 *
2204 * <p class="note">This is a protected intent that can only be sent
2205 * by the system.
2206 *
2207 * {@hide}
2208 */
2209 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2210 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002211 * Broadcast Action: A sticky broadcast that indicates low memory
2212 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002213 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002214 * <p class="note">This is a protected intent that can only be sent
2215 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002216 */
2217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2218 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2219 /**
2220 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002221 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002222 * <p class="note">This is a protected intent that can only be sent
2223 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002224 */
2225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2227 /**
Jake Hambybb371632010-08-23 18:16:48 -07002228 * Broadcast Action: A sticky broadcast that indicates a memory full
2229 * condition on the device. This is intended for activities that want
2230 * to be able to fill the data partition completely, leaving only
2231 * enough free space to prevent system-wide SQLite failures.
2232 *
2233 * <p class="note">This is a protected intent that can only be sent
2234 * by the system.
2235 *
2236 * {@hide}
2237 */
2238 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2239 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2240 /**
2241 * Broadcast Action: Indicates memory full condition on the device
2242 * no longer exists.
2243 *
2244 * <p class="note">This is a protected intent that can only be sent
2245 * by the system.
2246 *
2247 * {@hide}
2248 */
2249 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2250 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2251 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002252 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2253 * and package management should be started.
2254 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2255 * notification.
2256 */
2257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2258 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2259 /**
2260 * Broadcast Action: The device has entered USB Mass Storage mode.
2261 * This is used mainly for the USB Settings panel.
2262 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2263 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002264 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002265 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002266 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002267 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2268
2269 /**
2270 * Broadcast Action: The device has exited USB Mass Storage mode.
2271 * This is used mainly for the USB Settings panel.
2272 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2273 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002274 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002275 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002276 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002277 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2278
2279 /**
2280 * Broadcast Action: External media has been removed.
2281 * The path to the mount point for the removed media is contained in the Intent.mData field.
2282 */
2283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2284 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2285
2286 /**
2287 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002288 * 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 -07002289 */
2290 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2291 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2292
2293 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002294 * Broadcast Action: External media is present, and being disk-checked
2295 * 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 -08002296 */
2297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2298 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2299
2300 /**
2301 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2302 * 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 -08002303 */
2304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2305 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2306
2307 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002308 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002309 * 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 -07002310 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2311 * media was mounted read only.
2312 */
2313 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2314 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2315
2316 /**
2317 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002318 * 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 -07002319 */
2320 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2321 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2322
2323 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002324 * Broadcast Action: External media is no longer being shared via USB mass storage.
2325 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2326 *
2327 * @hide
2328 */
2329 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2330
2331 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002332 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2333 * The path to the mount point for the removed media is contained in the Intent.mData field.
2334 */
2335 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2336 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2337
2338 /**
2339 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002340 * 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 -07002341 */
2342 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2343 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2344
2345 /**
2346 * Broadcast Action: User has expressed the desire to remove the external storage media.
2347 * Applications should close all files they have open within the mount point when they receive this intent.
2348 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2349 */
2350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2351 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2352
2353 /**
2354 * Broadcast Action: The media scanner has started scanning a directory.
2355 * The path to the directory being scanned is contained in the Intent.mData field.
2356 */
2357 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2358 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2359
2360 /**
2361 * Broadcast Action: The media scanner has finished scanning a directory.
2362 * The path to the scanned directory is contained in the Intent.mData field.
2363 */
2364 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2365 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2366
2367 /**
2368 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2369 * The path to the file is contained in the Intent.mData field.
2370 */
2371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2372 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2373
2374 /**
2375 * Broadcast Action: The "Media Button" was pressed. Includes a single
2376 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2377 * caused the broadcast.
2378 */
2379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2380 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2381
2382 /**
2383 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2384 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2385 * caused the broadcast.
2386 */
2387 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2388 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2389
2390 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2391 // location; they are not general-purpose actions.
2392
2393 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002394 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002395 */
2396 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2397 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2398 "android.intent.action.GTALK_CONNECTED";
2399
2400 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002401 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002402 */
2403 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2404 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2405 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002406
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002407 /**
2408 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002409 */
2410 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2411 public static final String ACTION_INPUT_METHOD_CHANGED =
2412 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002413
2414 /**
2415 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2416 * more radios have been turned off or on. The intent will have the following extra value:</p>
2417 * <ul>
2418 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2419 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2420 * turned off</li>
2421 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002422 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002423 * <p class="note">This is a protected intent that can only be sent
2424 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002425 */
2426 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2427 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2428
2429 /**
2430 * Broadcast Action: Some content providers have parts of their namespace
2431 * where they publish new events or items that the user may be especially
2432 * interested in. For these things, they may broadcast this action when the
2433 * set of interesting items change.
2434 *
2435 * For example, GmailProvider sends this notification when the set of unread
2436 * mail in the inbox changes.
2437 *
2438 * <p>The data of the intent identifies which part of which provider
2439 * changed. When queried through the content resolver, the data URI will
2440 * return the data set in question.
2441 *
2442 * <p>The intent will have the following extra values:
2443 * <ul>
2444 * <li><em>count</em> - The number of items in the data set. This is the
2445 * same as the number of items in the cursor returned by querying the
2446 * data URI. </li>
2447 * </ul>
2448 *
2449 * This intent will be sent at boot (if the count is non-zero) and when the
2450 * data set changes. It is possible for the data set to change without the
2451 * count changing (for example, if a new unread message arrives in the same
2452 * sync operation in which a message is archived). The phone should still
2453 * ring/vibrate/etc as normal in this case.
2454 */
2455 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2456 public static final String ACTION_PROVIDER_CHANGED =
2457 "android.intent.action.PROVIDER_CHANGED";
2458
2459 /**
2460 * Broadcast Action: Wired Headset plugged in or unplugged.
2461 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002462 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2463 * and documentation.
2464 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002465 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002466 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002467 */
2468 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002469 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002470
2471 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002472 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2473 * <ul>
2474 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2475 * </ul>
2476 *
2477 * <p class="note">This is a protected intent that can only be sent
2478 * by the system.
2479 *
2480 * @hide
2481 */
2482 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2483 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2484 = "android.intent.action.ADVANCED_SETTINGS";
2485
2486 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002487 * Broadcast Action: Sent after application restrictions are changed.
2488 *
2489 * <p class="note">This is a protected intent that can only be sent
2490 * by the system.</p>
2491 */
2492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2493 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2494 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2495
2496 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002497 * Broadcast Action: An outgoing call is about to be placed.
2498 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002499 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002500 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002501 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002502 * the phone number originally intended to be dialed.</li>
2503 * </ul>
2504 * <p>Once the broadcast is finished, the resultData is used as the actual
2505 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002506 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002507 * outgoing call in turn: for example, a parental control application
2508 * might verify that the user is authorized to place the call at that
2509 * time, then a number-rewriting application might add an area code if
2510 * one was not specified.</p>
2511 * <p>For consistency, any receiver whose purpose is to prohibit phone
2512 * calls should have a priority of 0, to ensure it will see the final
2513 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002514 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002515 * should have a positive priority.
2516 * Negative priorities are reserved for the system for this broadcast;
2517 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002518 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2519 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002520 * <p>Emergency calls cannot be intercepted using this mechanism, and
2521 * other calls cannot be modified to call emergency numbers using this
2522 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002523 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2524 * call to use their own service instead. Those apps should first prevent
2525 * the call from being placed by setting resultData to <code>null</code>
2526 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002527 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002528 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2529 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002530 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002531 * <p class="note">This is a protected intent that can only be sent
2532 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002533 */
2534 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2535 public static final String ACTION_NEW_OUTGOING_CALL =
2536 "android.intent.action.NEW_OUTGOING_CALL";
2537
2538 /**
2539 * Broadcast Action: Have the device reboot. This is only for use by
2540 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002541 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002542 * <p class="note">This is a protected intent that can only be sent
2543 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2546 public static final String ACTION_REBOOT =
2547 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002548
Wei Huang97ecc9c2009-05-11 17:44:20 -07002549 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002550 * Broadcast Action: A sticky broadcast for changes in the physical
2551 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002552 *
2553 * <p>The intent will have the following extra values:
2554 * <ul>
2555 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002556 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002557 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002558 * <p>This is intended for monitoring the current physical dock state.
2559 * See {@link android.app.UiModeManager} for the normal API dealing with
2560 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002561 */
2562 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2563 public static final String ACTION_DOCK_EVENT =
2564 "android.intent.action.DOCK_EVENT";
2565
2566 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002567 * Broadcast Action: A broadcast when idle maintenance can be started.
2568 * This means that the user is not interacting with the device and is
2569 * not expected to do so soon. Typical use of the idle maintenance is
2570 * to perform somehow expensive tasks that can be postponed at a moment
2571 * when they will not degrade user experience.
2572 * <p>
2573 * <p class="note">In order to keep the device responsive in case of an
2574 * unexpected user interaction, implementations of a maintenance task
2575 * should be interruptible. In such a scenario a broadcast with action
2576 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2577 * should not do the maintenance work in
2578 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2579 * maintenance service by {@link Context#startService(Intent)}. Also
2580 * you should hold a wake lock while your maintenance service is running
2581 * to prevent the device going to sleep.
2582 * </p>
2583 * <p>
2584 * <p class="note">This is a protected intent that can only be sent by
2585 * the system.
2586 * </p>
2587 *
2588 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002589 *
2590 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002591 */
2592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2593 public static final String ACTION_IDLE_MAINTENANCE_START =
2594 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2595
2596 /**
2597 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2598 * This means that the user was not interacting with the device as a result
2599 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2600 * was sent and now the user started interacting with the device. Typical
2601 * use of the idle maintenance is to perform somehow expensive tasks that
2602 * can be postponed at a moment when they will not degrade user experience.
2603 * <p>
2604 * <p class="note">In order to keep the device responsive in case of an
2605 * unexpected user interaction, implementations of a maintenance task
2606 * should be interruptible. Hence, on receiving a broadcast with this
2607 * action, the maintenance task should be interrupted as soon as possible.
2608 * In other words, you should not do the maintenance work in
2609 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2610 * maintenance service that was started on receiving of
2611 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2612 * lock you acquired when your maintenance service started.
2613 * </p>
2614 * <p class="note">This is a protected intent that can only be sent
2615 * by the system.
2616 *
2617 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002618 *
2619 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622 public static final String ACTION_IDLE_MAINTENANCE_END =
2623 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2624
2625 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002626 * Broadcast Action: a remote intent is to be broadcasted.
2627 *
2628 * A remote intent is used for remote RPC between devices. The remote intent
2629 * is serialized and sent from one device to another device. The receiving
2630 * device parses the remote intent and broadcasts it. Note that anyone can
2631 * broadcast a remote intent. However, if the intent receiver of the remote intent
2632 * does not trust intent broadcasts from arbitrary intent senders, it should require
2633 * the sender to hold certain permissions so only trusted sender's broadcast will be
2634 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002635 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002636 */
2637 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002638 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002639
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002640 /**
2641 * Broadcast Action: hook for permforming cleanup after a system update.
2642 *
2643 * The broadcast is sent when the system is booting, before the
2644 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2645 * image. A receiver for this should do its work and then disable itself
2646 * so that it does not get run again at the next boot.
2647 * @hide
2648 */
2649 public static final String ACTION_PRE_BOOT_COMPLETED =
2650 "android.intent.action.PRE_BOOT_COMPLETED";
2651
Amith Yamasani13593602012-03-22 16:16:17 -07002652 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002653 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002654 * on restricted users. The broadcast intent contains an extra
2655 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2656 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2657 * String[] depending on the restriction type.<p/>
2658 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002659 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2660 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2661 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002662 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2663 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002664 * @see RestrictionEntry
2665 */
2666 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2667 "android.intent.action.GET_RESTRICTION_ENTRIES";
2668
2669 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002670 * Sent the first time a user is starting, to allow system apps to
2671 * perform one time initialization. (This will not be seen by third
2672 * party applications because a newly initialized user does not have any
2673 * third party applications installed for it.) This is sent early in
2674 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002675 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2676 * broadcast, since it is part of a visible user interaction; be as quick
2677 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002678 */
2679 public static final String ACTION_USER_INITIALIZE =
2680 "android.intent.action.USER_INITIALIZE";
2681
2682 /**
2683 * Sent when a user switch is happening, causing the process's user to be
2684 * brought to the foreground. This is only sent to receivers registered
2685 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2686 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002687 * foreground. This is sent as a foreground
2688 * broadcast, since it is part of a visible user interaction; be as quick
2689 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002690 */
2691 public static final String ACTION_USER_FOREGROUND =
2692 "android.intent.action.USER_FOREGROUND";
2693
2694 /**
2695 * Sent when a user switch is happening, causing the process's user to be
2696 * sent to the background. This is only sent to receivers registered
2697 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2698 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002699 * background. This is sent as a foreground
2700 * broadcast, since it is part of a visible user interaction; be as quick
2701 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002702 */
2703 public static final String ACTION_USER_BACKGROUND =
2704 "android.intent.action.USER_BACKGROUND";
2705
2706 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002707 * Broadcast sent to the system when a user is added. Carries an extra
2708 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2709 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002710 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002711 * @hide
2712 */
2713 public static final String ACTION_USER_ADDED =
2714 "android.intent.action.USER_ADDED";
2715
2716 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002717 * Broadcast sent by the system when a user is started. Carries an extra
2718 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002719 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002720 * that has been started. This is sent as a foreground
2721 * broadcast, since it is part of a visible user interaction; be as quick
2722 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002723 * @hide
2724 */
2725 public static final String ACTION_USER_STARTED =
2726 "android.intent.action.USER_STARTED";
2727
2728 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002729 * Broadcast sent when a user is in the process of starting. Carries an extra
2730 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2731 * sent to registered receivers, not manifest receivers. It is sent to all
2732 * users (including the one that is being started). You must hold
2733 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2734 * this broadcast. This is sent as a background broadcast, since
2735 * its result is not part of the primary UX flow; to safely keep track of
2736 * started/stopped state of a user you can use this in conjunction with
2737 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2738 * other user state broadcasts since those are foreground broadcasts so can
2739 * execute in a different order.
2740 * @hide
2741 */
2742 public static final String ACTION_USER_STARTING =
2743 "android.intent.action.USER_STARTING";
2744
2745 /**
2746 * Broadcast sent when a user is going to be stopped. Carries an extra
2747 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2748 * sent to registered receivers, not manifest receivers. It is sent to all
2749 * users (including the one that is being stopped). You must hold
2750 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2751 * this broadcast. The user will not stop until all receivers have
2752 * handled the broadcast. This is sent as a background broadcast, since
2753 * its result is not part of the primary UX flow; to safely keep track of
2754 * started/stopped state of a user you can use this in conjunction with
2755 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2756 * other user state broadcasts since those are foreground broadcasts so can
2757 * execute in a different order.
2758 * @hide
2759 */
2760 public static final String ACTION_USER_STOPPING =
2761 "android.intent.action.USER_STOPPING";
2762
2763 /**
2764 * Broadcast sent to the system when a user is stopped. Carries an extra
2765 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2766 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2767 * specific package. This is only sent to registered receivers, not manifest
2768 * receivers. It is sent to all running users <em>except</em> the one that
2769 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002770 * @hide
2771 */
2772 public static final String ACTION_USER_STOPPED =
2773 "android.intent.action.USER_STOPPED";
2774
2775 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002776 * 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 -07002777 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002778 * one that has been removed. The user will not be completely removed until all receivers have
2779 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002780 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002781 * @hide
2782 */
2783 public static final String ACTION_USER_REMOVED =
2784 "android.intent.action.USER_REMOVED";
2785
2786 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002787 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002788 * the userHandle of the user to become the current one. This is only sent to
2789 * registered receivers, not manifest receivers. It is sent to all running users.
2790 * You must hold
2791 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002792 * @hide
2793 */
2794 public static final String ACTION_USER_SWITCHED =
2795 "android.intent.action.USER_SWITCHED";
2796
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002797 /**
2798 * Broadcast sent to the system when a user's information changes. Carries an extra
2799 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002800 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002801 * @hide
2802 */
2803 public static final String ACTION_USER_INFO_CHANGED =
2804 "android.intent.action.USER_INFO_CHANGED";
2805
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002806 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002807 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2808 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002809 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2810 * that need to display merged content across both primary and managed profiles need to
2811 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002812 * not manifest receivers.
2813 */
2814 public static final String ACTION_MANAGED_PROFILE_ADDED =
2815 "android.intent.action.MANAGED_PROFILE_ADDED";
2816
2817 /**
2818 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002819 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2820 * Only applications (for example Launchers) that need to display merged content across both
2821 * primary and managed profiles need to worry about this broadcast. This is only sent to
2822 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002823 */
2824 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2825 "android.intent.action.MANAGED_PROFILE_REMOVED";
2826
2827 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002828 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2829 */
2830 public static final String ACTION_QUICK_CLOCK =
2831 "android.intent.action.QUICK_CLOCK";
2832
Michael Wright0087a142013-02-05 16:29:39 -08002833 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002834 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002835 * @hide
2836 */
2837 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2838 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2839
Justin Kohd378ad72013-04-01 12:18:26 -07002840 /**
2841 * Broadcast Action: A global button was pressed. Includes a single
2842 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2843 * caused the broadcast.
2844 * @hide
2845 */
2846 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2847
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002848 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002849 * Activity Action: Allow the user to select and return one or more existing
2850 * documents. When invoked, the system will display the various
2851 * {@link DocumentsProvider} instances installed on the device, letting the
2852 * user interactively navigate through them. These documents include local
2853 * media, such as photos and video, and documents provided by installed
2854 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002855 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002856 * Each document is represented as a {@code content://} URI backed by a
2857 * {@link DocumentsProvider}, which can be opened as a stream with
2858 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2859 * {@link android.provider.DocumentsContract.Document} metadata.
2860 * <p>
2861 * All selected documents are returned to the calling application with
2862 * persistable read and write permission grants. If you want to maintain
2863 * access to the documents across device reboots, you need to explicitly
2864 * take the persistable permissions using
2865 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2866 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002867 * Callers must indicate the acceptable document MIME types through
2868 * {@link #setType(String)}. For example, to select photos, use
2869 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2870 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2871 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002872 * <p>
2873 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002874 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2875 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002876 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002877 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2878 * returned URIs can be opened with
2879 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002880 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002881 * Output: The URI of the item that was picked, returned in
2882 * {@link #getData()}. This must be a {@code content://} URI so that any
2883 * receiver can access it. If multiple documents were selected, they are
2884 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002885 *
2886 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002887 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002888 * @see #ACTION_CREATE_DOCUMENT
2889 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002890 */
2891 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2892 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2893
2894 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002895 * Activity Action: Allow the user to create a new document. When invoked,
2896 * the system will display the various {@link DocumentsProvider} instances
2897 * installed on the device, letting the user navigate through them. The
2898 * returned document may be a newly created document with no content, or it
2899 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002900 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002901 * Each document is represented as a {@code content://} URI backed by a
2902 * {@link DocumentsProvider}, which can be opened as a stream with
2903 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2904 * {@link android.provider.DocumentsContract.Document} metadata.
2905 * <p>
2906 * Callers must indicate the concrete MIME type of the document being
2907 * created by setting {@link #setType(String)}. This MIME type cannot be
2908 * changed after the document is created.
2909 * <p>
2910 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2911 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002912 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002913 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2914 * returned URIs can be opened with
2915 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002916 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002917 * Output: The URI of the item that was created. This must be a
2918 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002919 *
2920 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002921 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002922 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002923 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002924 */
2925 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2926 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2927
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002928 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002929 * Activity Action: Allow the user to pick a directory subtree. When
2930 * invoked, the system will display the various {@link DocumentsProvider}
2931 * instances installed on the device, letting the user navigate through
2932 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002933 * <p>
2934 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002935 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2936 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2937 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002938 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002939 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002940 *
2941 * @see DocumentsContract
2942 */
2943 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002944 public static final String
2945 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002946
Jeff Sharkey004a4b22014-09-24 11:45:24 -07002947 /** {@hide} */
2948 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
2949
Christopher Tate6597e342015-02-17 12:15:25 -08002950 /**
2951 * Broadcast action: report that a settings element is being restored from backup. The intent
2952 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
2953 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
2954 * is the value of that settings entry prior to the restore operation. All of these values are
2955 * represented as strings.
2956 *
2957 * <p>This broadcast is sent only for settings provider entries known to require special handling
2958 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
2959 * the provider's backup agent implementation.
2960 *
2961 * @see #EXTRA_SETTING_NAME
2962 * @see #EXTRA_SETTING_PREVIOUS_VALUE
2963 * @see #EXTRA_SETTING_NEW_VALUE
2964 * {@hide}
2965 */
2966 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
2967
2968 /** {@hide} */
2969 public static final String EXTRA_SETTING_NAME = "setting_name";
2970 /** {@hide} */
2971 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
2972 /** {@hide} */
2973 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
2974
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002975 /**
2976 * Activity Action: Process a piece of text.
2977 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
2978 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
2979 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
2980 */
2981 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2982 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
2983 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01002984 * The name of the extra used to define the text to be processed, as a
2985 * CharSequence. Note that this may be a styled CharSequence, so you must use
2986 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002987 */
2988 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
2989 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01002990 * The name of the boolean extra used to define if the processed text will be used as read-only.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00002991 */
2992 public static final String EXTRA_PROCESS_TEXT_READONLY =
2993 "android.intent.extra.PROCESS_TEXT_READONLY";
2994
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002995 // ---------------------------------------------------------------------
2996 // ---------------------------------------------------------------------
2997 // Standard intent categories (see addCategory()).
2998
2999 /**
3000 * Set if the activity should be an option for the default action
3001 * (center press) to perform on a piece of data. Setting this will
3002 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003003 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003004 * Intent when initiating an action -- it is for use in intent filters
3005 * specified in packages.
3006 */
3007 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3008 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3009 /**
3010 * Activities that can be safely invoked from a browser must support this
3011 * category. For example, if the user is viewing a web page or an e-mail
3012 * and clicks on a link in the text, the Intent generated execute that
3013 * link will require the BROWSABLE category, so that only activities
3014 * supporting this category will be considered as possible actions. By
3015 * supporting this category, you are promising that there is nothing
3016 * damaging (without user intervention) that can happen by invoking any
3017 * matching Intent.
3018 */
3019 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3020 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3021 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003022 * Categories for activities that can participate in voice interaction.
3023 * An activity that supports this category must be prepared to run with
3024 * no UI shown at all (though in some case it may have a UI shown), and
3025 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3026 */
3027 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3028 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3029 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003030 * Set if the activity should be considered as an alternative action to
3031 * the data the user is currently viewing. See also
3032 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3033 * applies to the selection in a list of items.
3034 *
3035 * <p>Supporting this category means that you would like your activity to be
3036 * displayed in the set of alternative things the user can do, usually as
3037 * part of the current activity's options menu. You will usually want to
3038 * include a specific label in the &lt;intent-filter&gt; of this action
3039 * describing to the user what it does.
3040 *
3041 * <p>The action of IntentFilter with this category is important in that it
3042 * describes the specific action the target will perform. This generally
3043 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3044 * a specific name such as "com.android.camera.action.CROP. Only one
3045 * alternative of any particular action will be shown to the user, so using
3046 * a specific action like this makes sure that your alternative will be
3047 * displayed while also allowing other applications to provide their own
3048 * overrides of that particular action.
3049 */
3050 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3051 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3052 /**
3053 * Set if the activity should be considered as an alternative selection
3054 * action to the data the user has currently selected. This is like
3055 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3056 * of items from which the user can select, giving them alternatives to the
3057 * default action that will be performed on it.
3058 */
3059 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3060 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3061 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003062 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003063 */
3064 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3065 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3066 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003067 * Should be displayed in the top-level launcher.
3068 */
3069 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3070 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3071 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003072 * Indicates an activity optimized for Leanback mode, and that should
3073 * be displayed in the Leanback launcher.
3074 */
3075 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3076 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3077 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003078 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3079 * @hide
3080 */
3081 @SystemApi
3082 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3083 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003084 * Provides information about the package it is in; typically used if
3085 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3086 * a front-door to the user without having to be shown in the all apps list.
3087 */
3088 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3089 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3090 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003091 * This is the home activity, that is the first activity that is displayed
3092 * when the device boots.
3093 */
3094 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3095 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3096 /**
3097 * This activity is a preference panel.
3098 */
3099 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3100 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3101 /**
3102 * This activity is a development preference panel.
3103 */
3104 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3105 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3106 /**
3107 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003108 */
3109 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3110 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3111 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003112 * This activity allows the user to browse and download new applications.
3113 */
3114 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3115 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3116 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003117 * This activity may be exercised by the monkey or other automated test tools.
3118 */
3119 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3120 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3121 /**
3122 * To be used as a test (not part of the normal user experience).
3123 */
3124 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3125 /**
3126 * To be used as a unit test (run through the Test Harness).
3127 */
3128 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3129 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003130 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003131 * experience).
3132 */
3133 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003134
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003135 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003136 * Used to indicate that an intent only wants URIs that can be opened with
3137 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3138 * must support at least the columns defined in {@link OpenableColumns} when
3139 * queried.
3140 *
3141 * @see #ACTION_GET_CONTENT
3142 * @see #ACTION_OPEN_DOCUMENT
3143 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003144 */
3145 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3146 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3147
3148 /**
3149 * To be used as code under test for framework instrumentation tests.
3150 */
3151 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3152 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003153 /**
3154 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003155 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3156 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003157 */
3158 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3159 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3160 /**
3161 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003162 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3163 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003164 */
3165 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3166 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003167 /**
3168 * An activity to run when device is inserted into a analog (low end) dock.
3169 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3170 * information, see {@link android.app.UiModeManager}.
3171 */
3172 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3173 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3174
3175 /**
3176 * An activity to run when device is inserted into a digital (high end) dock.
3177 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3178 * information, see {@link android.app.UiModeManager}.
3179 */
3180 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3181 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003182
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003183 /**
3184 * Used to indicate that the activity can be used in a car environment.
3185 */
3186 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3187 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3188
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003189 // ---------------------------------------------------------------------
3190 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003191 // Application launch intent categories (see addCategory()).
3192
3193 /**
3194 * Used with {@link #ACTION_MAIN} to launch the browser application.
3195 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003196 * <p>NOTE: This should not be used as the primary key of an Intent,
3197 * since it will not result in the app launching with the correct
3198 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003199 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003200 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003201 */
3202 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3203 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3204
3205 /**
3206 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3207 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003208 * <p>NOTE: This should not be used as the primary key of an Intent,
3209 * since it will not result in the app launching with the correct
3210 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003211 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003212 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003213 */
3214 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3215 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3216
3217 /**
3218 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3219 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003220 * <p>NOTE: This should not be used as the primary key of an Intent,
3221 * since it will not result in the app launching with the correct
3222 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003223 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003224 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003225 */
3226 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3227 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3228
3229 /**
3230 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3231 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003232 * <p>NOTE: This should not be used as the primary key of an Intent,
3233 * since it will not result in the app launching with the correct
3234 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003235 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003236 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003237 */
3238 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3239 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3240
3241 /**
3242 * Used with {@link #ACTION_MAIN} to launch the email application.
3243 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003244 * <p>NOTE: This should not be used as the primary key of an Intent,
3245 * since it will not result in the app launching with the correct
3246 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003247 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003248 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003249 */
3250 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3251 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3252
3253 /**
3254 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3255 * The activity should be able to view and manipulate image and video files
3256 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003257 * <p>NOTE: This should not be used as the primary key of an Intent,
3258 * since it will not result in the app launching with the correct
3259 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003260 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003261 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003262 */
3263 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3264 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3265
3266 /**
3267 * Used with {@link #ACTION_MAIN} to launch the maps application.
3268 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003269 * <p>NOTE: This should not be used as the primary key of an Intent,
3270 * since it will not result in the app launching with the correct
3271 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003272 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003273 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003274 */
3275 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3276 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3277
3278 /**
3279 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3280 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003281 * <p>NOTE: This should not be used as the primary key of an Intent,
3282 * since it will not result in the app launching with the correct
3283 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003284 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003285 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003286 */
3287 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3288 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3289
3290 /**
3291 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003292 * The activity should be able to play, browse, or manipulate music files
3293 * stored on the device.
3294 * <p>NOTE: This should not be used as the primary key of an Intent,
3295 * since it will not result in the app launching with the correct
3296 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003297 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003298 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003299 */
3300 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3301 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3302
3303 // ---------------------------------------------------------------------
3304 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003305 // Standard extra data keys.
3306
3307 /**
3308 * The initial data to place in a newly created record. Use with
3309 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3310 * fields as would be given to the underlying ContentProvider.insert()
3311 * call.
3312 */
3313 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3314
3315 /**
3316 * A constant CharSequence that is associated with the Intent, used with
3317 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3318 * this may be a styled CharSequence, so you must use
3319 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3320 * retrieve it.
3321 */
3322 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3323
3324 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003325 * A constant String that is associated with the Intent, used with
3326 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3327 * as HTML formatted text. Note that you <em>must</em> also supply
3328 * {@link #EXTRA_TEXT}.
3329 */
3330 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3331
3332 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003333 * A content: URI holding a stream of data associated with the Intent,
3334 * used with {@link #ACTION_SEND} to supply the data being sent.
3335 */
3336 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3337
3338 /**
3339 * A String[] holding e-mail addresses that should be delivered to.
3340 */
3341 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3342
3343 /**
3344 * A String[] holding e-mail addresses that should be carbon copied.
3345 */
3346 public static final String EXTRA_CC = "android.intent.extra.CC";
3347
3348 /**
3349 * A String[] holding e-mail addresses that should be blind carbon copied.
3350 */
3351 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3352
3353 /**
3354 * A constant string holding the desired subject line of a message.
3355 */
3356 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3357
3358 /**
3359 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003360 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003361 */
3362 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3363
3364 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003365 * An Intent[] describing additional, alternate choices you would like shown with
3366 * {@link #ACTION_CHOOSER}.
3367 *
3368 * <p>An app may be capable of providing several different payload types to complete a
3369 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3370 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3371 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3372 * photo data or a hosted link where the photos can be viewed.</p>
3373 *
3374 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3375 * first/primary/preferred intent in the set. Additional intents specified in
3376 * this extra are ordered; by default intents that appear earlier in the array will be
3377 * preferred over intents that appear later in the array as matches for the same
3378 * target component. To alter this preference, a calling app may also supply
3379 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3380 */
3381 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3382
3383 /**
3384 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3385 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3386 *
3387 * <p>An app preparing an action for another app to complete may wish to allow the user to
3388 * disambiguate between several options for completing the action based on the chosen target
3389 * or otherwise refine the action before it is invoked.
3390 * </p>
3391 *
3392 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3393 * <ul>
3394 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3395 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3396 * chosen target beyond the first</li>
3397 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3398 * should fill in and send once the disambiguation is complete</li>
3399 * </ul>
3400 */
3401 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3402 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3403
3404 /**
3405 * A {@link ResultReceiver} used to return data back to the sender.
3406 *
3407 * <p>Used to complete an app-specific
3408 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3409 *
3410 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3411 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3412 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3413 * when the user selects a target component from the chooser. It is up to the recipient
3414 * to send a result to this ResultReceiver to signal that disambiguation is complete
3415 * and that the chooser should invoke the user's choice.</p>
3416 *
3417 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3418 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3419 * to match and fill in the final Intent or ChooserTarget before starting it.
3420 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3421 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3422 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3423 *
3424 * <p>The result code passed to the ResultReceiver should be
3425 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3426 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3427 * the chooser should finish without starting a target.</p>
3428 */
3429 public static final String EXTRA_RESULT_RECEIVER
3430 = "android.intent.extra.RESULT_RECEIVER";
3431
3432 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003433 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003434 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003435 */
3436 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3437
3438 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003439 * A Parcelable[] of {@link Intent} or
3440 * {@link android.content.pm.LabeledIntent} objects as set with
3441 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3442 * a the front of the list of choices, when shown to the user with a
3443 * {@link #ACTION_CHOOSER}.
3444 */
3445 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3446
3447 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003448 * A Bundle forming a mapping of potential target package names to different extras Bundles
3449 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3450 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3451 * be currently installed on the device.
3452 *
3453 * <p>An application may choose to provide alternate extras for the case where a user
3454 * selects an activity from a predetermined set of target packages. If the activity
3455 * the user selects from the chooser belongs to a package with its package name as
3456 * a key in this bundle, the corresponding extras for that package will be merged with
3457 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3458 * extra has the same key as an extra already present in the intent it will overwrite
3459 * the extra from the intent.</p>
3460 *
3461 * <p><em>Examples:</em>
3462 * <ul>
3463 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3464 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3465 * parameters for that target.</li>
3466 * <li>An application may offer additional metadata for known targets of a given intent
3467 * to pass along information only relevant to that target such as account or content
3468 * identifiers already known to that application.</li>
3469 * </ul></p>
3470 */
3471 public static final String EXTRA_REPLACEMENT_EXTRAS =
3472 "android.intent.extra.REPLACEMENT_EXTRAS";
3473
3474 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003475 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3476 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3477 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3478 * {@link ComponentName} of the chosen component.
3479 *
3480 * <p>In some situations this callback may never come, for example if the user abandons
3481 * the chooser, switches to another task or any number of other reasons. Apps should not
3482 * be written assuming that this callback will always occur.</p>
3483 */
3484 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3485 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3486
3487 /**
3488 * The {@link ComponentName} chosen by the user to complete an action.
3489 *
3490 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3491 */
3492 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3493
3494 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003495 * A {@link android.view.KeyEvent} object containing the event that
3496 * triggered the creation of the Intent it is in.
3497 */
3498 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3499
3500 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003501 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3502 * before shutting down.
3503 *
3504 * {@hide}
3505 */
3506 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3507
3508 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003509 * 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 -07003510 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3511 * of restarting the application.
3512 */
3513 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3514
3515 /**
3516 * A String holding the phone number originally entered in
3517 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3518 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3519 */
3520 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003521
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003522 /**
3523 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3524 * intents to supply the uid the package had been assigned. Also an optional
3525 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3526 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3527 * purpose.
3528 */
3529 public static final String EXTRA_UID = "android.intent.extra.UID";
3530
3531 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003532 * @hide String array of package names.
3533 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003534 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003535 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3536
3537 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003538 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3539 * intents to indicate whether this represents a full uninstall (removing
3540 * both the code and its data) or a partial uninstall (leaving its data,
3541 * implying that this is an update).
3542 */
3543 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003544
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003545 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003546 * @hide
3547 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3548 * intents to indicate that at this point the package has been removed for
3549 * all users on the device.
3550 */
3551 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3552 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3553
3554 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003555 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3556 * intents to indicate that this is a replacement of the package, so this
3557 * broadcast will immediately be followed by an add broadcast for a
3558 * different version of the same package.
3559 */
3560 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003561
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003562 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003563 * Used as an int extra field in {@link android.app.AlarmManager} intents
3564 * to tell the application being invoked how many pending alarms are being
3565 * delievered with the intent. For one-shot alarms this will always be 1.
3566 * For recurring alarms, this might be greater than 1 if the device was
3567 * asleep or powered off at the time an earlier alarm would have been
3568 * delivered.
3569 */
3570 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003571
Jacek Surazski86b6c532009-05-13 14:38:28 +02003572 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003573 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3574 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003575 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3576 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003577 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3578 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3579 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003580 */
3581 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3582
3583 /**
3584 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3585 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003586 */
3587 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3588
3589 /**
3590 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3591 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003592 */
3593 public static final int EXTRA_DOCK_STATE_DESK = 1;
3594
3595 /**
3596 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3597 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003598 */
3599 public static final int EXTRA_DOCK_STATE_CAR = 2;
3600
3601 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003602 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3603 * to represent that the phone is in a analog (low end) dock.
3604 */
3605 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3606
3607 /**
3608 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3609 * to represent that the phone is in a digital (high end) dock.
3610 */
3611 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3612
3613 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003614 * Boolean that can be supplied as meta-data with a dock activity, to
3615 * indicate that the dock should take over the home key when it is active.
3616 */
3617 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003618
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003619 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003620 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3621 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003622 */
3623 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3624
3625 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003626 * Used in the extra field in the remote intent. It's astring token passed with the
3627 * remote intent.
3628 */
3629 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3630 "android.intent.extra.remote_intent_token";
3631
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003632 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003633 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003634 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003635 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003636 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003637 "android.intent.extra.changed_component_name";
3638
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003639 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003640 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003641 * and contains a string array of all of the components that have changed. If
3642 * the state of the overall package has changed, then it will contain an entry
3643 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003644 */
3645 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3646 "android.intent.extra.changed_component_name_list";
3647
3648 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003649 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003650 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3651 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003652 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003653 */
3654 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3655 "android.intent.extra.changed_package_list";
3656
3657 /**
3658 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003659 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3660 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003661 * and contains an integer array of uids of all of the components
3662 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003663 */
3664 public static final String EXTRA_CHANGED_UID_LIST =
3665 "android.intent.extra.changed_uid_list";
3666
3667 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003668 * @hide
3669 * Magic extra system code can use when binding, to give a label for
3670 * who it is that has bound to a service. This is an integer giving
3671 * a framework string resource that can be displayed to the user.
3672 */
3673 public static final String EXTRA_CLIENT_LABEL =
3674 "android.intent.extra.client_label";
3675
3676 /**
3677 * @hide
3678 * Magic extra system code can use when binding, to give a PendingIntent object
3679 * that can be launched for the user to disable the system's use of this
3680 * service.
3681 */
3682 public static final String EXTRA_CLIENT_INTENT =
3683 "android.intent.extra.client_intent";
3684
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003685 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003686 * Extra used to indicate that an intent should only return data that is on
3687 * the local device. This is a boolean extra; the default is false. If true,
3688 * an implementation should only allow the user to select data that is
3689 * already on the device, not requiring it be downloaded from a remote
3690 * service when opened.
3691 *
3692 * @see #ACTION_GET_CONTENT
3693 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003694 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003695 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003696 */
3697 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003698 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003699
Amith Yamasani13593602012-03-22 16:16:17 -07003700 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003701 * Extra used to indicate that an intent can allow the user to select and
3702 * return multiple items. This is a boolean extra; the default is false. If
3703 * true, an implementation is allowed to present the user with a UI where
3704 * they can pick multiple items that are all returned to the caller. When
3705 * this happens, they should be returned as the {@link #getClipData()} part
3706 * of the result Intent.
3707 *
3708 * @see #ACTION_GET_CONTENT
3709 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003710 */
3711 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003712 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003713
3714 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003715 * The integer userHandle carried with broadcast intents related to addition, removal and
3716 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3717 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3718 *
Amith Yamasani13593602012-03-22 16:16:17 -07003719 * @hide
3720 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003721 public static final String EXTRA_USER_HANDLE =
3722 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003723
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003724 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003725 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3726 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3727 */
3728 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003729 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003730
3731 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003732 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003733 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3734 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003735 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003736 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3737
3738 /**
3739 * Extra sent in the intent to the BroadcastReceiver that handles
3740 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3741 * the restrictions as key/value pairs.
3742 */
3743 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3744 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003745
Amith Yamasani86118ba2013-03-28 14:33:16 -07003746 /**
3747 * Extra used in the response from a BroadcastReceiver that handles
3748 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3749 */
3750 public static final String EXTRA_RESTRICTIONS_INTENT =
3751 "android.intent.extra.restrictions_intent";
3752
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003753 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003754 * Extra used to communicate a set of acceptable MIME types. The type of the
3755 * extra is {@code String[]}. Values may be a combination of concrete MIME
3756 * types (such as "image/png") and/or partial MIME types (such as
3757 * "audio/*").
3758 *
3759 * @see #ACTION_GET_CONTENT
3760 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003761 */
3762 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3763
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003764 /**
3765 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3766 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003767 * When this is true, hardware devices can use this information to determine that
3768 * they shouldn't do a complete shutdown of their device since this is not a
3769 * complete shutdown down to the kernel, but only user space restarting.
3770 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003771 */
3772 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3773 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3774
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003775 /**
3776 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3777 * user has set their time format preferences to the 24 hour format.
3778 *
3779 * @hide for internal use only.
3780 */
3781 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3782 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3783
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003784 /** {@hide} */
3785 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3786
Rubin Xue8490f12015-06-25 12:17:48 +01003787 /** {@hide} */
3788 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
3789
Santos Cordon15a13782015-03-31 18:32:31 -07003790 /**
3791 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3792 * activation request.
3793 * TODO: Add information about the structure and response data used with the pending intent.
3794 * @hide
3795 */
3796 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3797 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3798
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003799 // ---------------------------------------------------------------------
3800 // ---------------------------------------------------------------------
3801 // Intent flags (see mFlags variable).
3802
Tor Norbyed9273d62013-05-30 15:59:53 -07003803 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003804 @IntDef(flag = true, value = {
3805 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3806 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003807 @Retention(RetentionPolicy.SOURCE)
3808 public @interface GrantUriMode {}
3809
Jeff Sharkey846318a2014-04-04 12:12:41 -07003810 /** @hide */
3811 @IntDef(flag = true, value = {
3812 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3813 @Retention(RetentionPolicy.SOURCE)
3814 public @interface AccessUriMode {}
3815
3816 /**
3817 * Test if given mode flags specify an access mode, which must be at least
3818 * read and/or write.
3819 *
3820 * @hide
3821 */
3822 public static boolean isAccessUriMode(int modeFlags) {
3823 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3824 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3825 }
3826
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003827 /**
3828 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003829 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003830 * specified in its ClipData. When applying to an Intent's ClipData,
3831 * all URIs as well as recursive traversals through data or other ClipData
3832 * in Intent items will be granted; only the grant flags of the top-level
3833 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003834 */
3835 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3836 /**
3837 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003838 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003839 * specified in its ClipData. When applying to an Intent's ClipData,
3840 * all URIs as well as recursive traversals through data or other ClipData
3841 * in Intent items will be granted; only the grant flags of the top-level
3842 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003843 */
3844 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3845 /**
3846 * Can be set by the caller to indicate that this Intent is coming from
3847 * a background operation, not from direct user interaction.
3848 */
3849 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3850 /**
3851 * A flag you can enable for debugging: when set, log messages will be
3852 * printed during the resolution of this intent to show you what has
3853 * been found to create the final resolved list.
3854 */
3855 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003856 /**
3857 * If set, this intent will not match any components in packages that
3858 * are currently stopped. If this is not set, then the default behavior
3859 * is to include such applications in the result.
3860 */
3861 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3862 /**
3863 * If set, this intent will always match any components in packages that
3864 * are currently stopped. This is the default behavior when
3865 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3866 * flags are set, this one wins (it allows overriding of exclude for
3867 * places where the framework may automatically set the exclude flag).
3868 */
3869 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003870
3871 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003872 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003873 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003874 * persisted across device reboots until explicitly revoked with
3875 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3876 * grant for possible persisting; the receiving application must call
3877 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3878 * actually persist.
3879 *
3880 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3881 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3882 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003883 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003884 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003885 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003886
3887 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003888 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3889 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3890 * applies to any URI that is a prefix match against the original granted
3891 * URI. (Without this flag, the URI must match exactly for access to be
3892 * granted.) Another URI is considered a prefix match only when scheme,
3893 * authority, and all path segments defined by the prefix are an exact
3894 * match.
3895 */
3896 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3897
3898 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003899 * If set, the new activity is not kept in the history stack. As soon as
3900 * the user navigates away from it, the activity is finished. This may also
3901 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3902 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07003903 *
3904 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
3905 * is never invoked when the current activity starts a new activity which
3906 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003907 */
3908 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3909 /**
3910 * If set, the activity will not be launched if it is already running
3911 * at the top of the history stack.
3912 */
3913 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3914 /**
3915 * If set, this activity will become the start of a new task on this
3916 * history stack. A task (from the activity that started it to the
3917 * next task activity) defines an atomic group of activities that the
3918 * user can move to. Tasks can be moved to the foreground and background;
3919 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003920 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003921 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3922 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003923 *
3924 * <p>This flag is generally used by activities that want
3925 * to present a "launcher" style behavior: they give the user a list of
3926 * separate things that can be done, which otherwise run completely
3927 * independently of the activity launching them.
3928 *
3929 * <p>When using this flag, if a task is already running for the activity
3930 * you are now starting, then a new activity will not be started; instead,
3931 * the current task will simply be brought to the front of the screen with
3932 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3933 * to disable this behavior.
3934 *
3935 * <p>This flag can not be used when the caller is requesting a result from
3936 * the activity being launched.
3937 */
3938 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3939 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003940 * This flag is used to create a new task and launch an activity into it.
3941 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3942 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3943 * search through existing tasks for ones matching this Intent. Only if no such
3944 * task is found would a new task be created. When paired with
3945 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3946 * the search for a matching task and unconditionally start a new task.
3947 *
3948 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3949 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003950 * top-level application launcher.</strong> Used in conjunction with
3951 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3952 * behavior of bringing an existing task to the foreground. When set,
3953 * a new task is <em>always</em> started to host the Activity for the
3954 * Intent, regardless of whether there is already an existing task running
3955 * the same thing.
3956 *
3957 * <p><strong>Because the default system does not include graphical task management,
3958 * you should not use this flag unless you provide some way for a user to
3959 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003960 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003961 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3962 * creating new document tasks.
3963 *
3964 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07003965 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003966 *
Scott Main7aee61f2011-02-08 11:25:01 -08003967 * <p>See
3968 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3969 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003970 *
3971 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3972 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003973 */
3974 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3975 /**
3976 * If set, and the activity being launched is already running in the
3977 * current task, then instead of launching a new instance of that activity,
3978 * all of the other activities on top of it will be closed and this Intent
3979 * will be delivered to the (now on top) old activity as a new Intent.
3980 *
3981 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3982 * If D calls startActivity() with an Intent that resolves to the component
3983 * of activity B, then C and D will be finished and B receive the given
3984 * Intent, resulting in the stack now being: A, B.
3985 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003986 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003987 * either receive the new intent you are starting here in its
3988 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003989 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003990 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3991 * the same intent, then it will be finished and re-created; for all other
3992 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3993 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003994 *
3995 * <p>This launch mode can also be used to good effect in conjunction with
3996 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3997 * of a task, it will bring any currently running instance of that task
3998 * to the foreground, and then clear it to its root state. This is
3999 * especially useful, for example, when launching an activity from the
4000 * notification manager.
4001 *
Scott Main7aee61f2011-02-08 11:25:01 -08004002 * <p>See
4003 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4004 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004005 */
4006 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4007 /**
4008 * If set and this intent is being used to launch a new activity from an
4009 * existing one, then the reply target of the existing activity will be
4010 * transfered to the new activity. This way the new activity can call
4011 * {@link android.app.Activity#setResult} and have that result sent back to
4012 * the reply target of the original activity.
4013 */
4014 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4015 /**
4016 * If set and this intent is being used to launch a new activity from an
4017 * existing one, the current activity will not be counted as the top
4018 * activity for deciding whether the new intent should be delivered to
4019 * the top instead of starting a new one. The previous activity will
4020 * be used as the top, with the assumption being that the current activity
4021 * will finish itself immediately.
4022 */
4023 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4024 /**
4025 * If set, the new activity is not kept in the list of recently launched
4026 * activities.
4027 */
4028 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4029 /**
4030 * This flag is not normally set by application code, but set for you by
4031 * the system as described in the
4032 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4033 * launchMode} documentation for the singleTask mode.
4034 */
4035 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4036 /**
4037 * If set, and this activity is either being started in a new task or
4038 * bringing to the top an existing task, then it will be launched as
4039 * the front door of the task. This will result in the application of
4040 * any affinities needed to have that task in the proper state (either
4041 * moving activities to or from it), or simply resetting that task to
4042 * its initial state if needed.
4043 */
4044 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4045 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004046 * This flag is not normally set by application code, but set for you by
4047 * the system if this activity is being launched from history
4048 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004049 */
4050 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004051 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004052 * @deprecated As of API 21 this performs identically to
4053 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004054 */
4055 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004056 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004057 * This flag is used to open a document into a new task rooted at the activity launched
4058 * by this Intent. Through the use of this flag, or its equivalent attribute,
4059 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004060 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004061 *
Craig Mautner026596b2014-05-21 15:35:44 -07004062 * <p>The use of the activity attribute form of this,
4063 * {@link android.R.attr#documentLaunchMode}, is
4064 * preferred over the Intent flag described here. The attribute form allows the
4065 * Activity to specify multiple document behavior for all launchers of the Activity
4066 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004067 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004068 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4069 * it is kept after the activity is finished is different than the use of
4070 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4071 * this flag is being used to create a new recents entry, then by default that entry
4072 * will be removed once the activity is finished. You can modify this behavior with
4073 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4074 *
Craig Mautner026596b2014-05-21 15:35:44 -07004075 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4076 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4077 * equivalent of the Activity manifest specifying {@link
4078 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4079 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4080 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004081 *
Craig Mautner026596b2014-05-21 15:35:44 -07004082 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004083 *
Craig Mautner026596b2014-05-21 15:35:44 -07004084 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004085 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4086 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004087 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004088 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004089 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004090 * callback from occurring on the current frontmost activity before it is
4091 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004092 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004093 * <p>Typically, an activity can rely on that callback to indicate that an
4094 * explicit user action has caused their activity to be moved out of the
4095 * foreground. The callback marks an appropriate point in the activity's
4096 * lifecycle for it to dismiss any notifications that it intends to display
4097 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004098 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004099 * <p>If an activity is ever started via any non-user-driven events such as
4100 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4101 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004102 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004103 */
4104 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004105 /**
4106 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4107 * this flag will cause the launched activity to be brought to the front of its
4108 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004109 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004110 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4111 * If D calls startActivity() with an Intent that resolves to the component
4112 * of activity B, then B will be brought to the front of the history stack,
4113 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004114 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004115 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004116 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004117 */
4118 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004119 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004120 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4121 * this flag will prevent the system from applying an activity transition
4122 * animation to go to the next activity state. This doesn't mean an
4123 * animation will never run -- if another activity change happens that doesn't
4124 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004125 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004126 * when you are going to do a series of activity operations but the
4127 * animation seen by the user shouldn't be driven by the first activity
4128 * change but rather a later one.
4129 */
4130 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4131 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004132 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4133 * this flag will cause any existing task that would be associated with the
4134 * activity to be cleared before the activity is started. That is, the activity
4135 * becomes the new root of an otherwise empty task, and any old activities
4136 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4137 */
4138 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4139 /**
4140 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4141 * this flag will cause a newly launching task to be placed on top of the current
4142 * home activity task (if there is one). That is, pressing back from the task
4143 * will always return the user to home even if that was not the last activity they
4144 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4145 */
4146 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4147 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004148 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4149 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004150 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004151 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004152 * this flag. When set and the task's activity is finished, the recents
4153 * entry will remain in the interface for the user to re-launch it, like a
4154 * recents entry for a top-level application.
4155 * <p>
4156 * The receiving activity can override this request with
4157 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4158 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004159 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004160 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004161 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004162
4163 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004164 * If set, when sending a broadcast only registered receivers will be
4165 * called -- no BroadcastReceiver components will be launched.
4166 */
4167 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004168 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004169 * If set, when sending a broadcast the new broadcast will replace
4170 * any existing pending broadcast that matches it. Matching is defined
4171 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4172 * true for the intents of the two broadcasts. When a match is found,
4173 * the new broadcast (and receivers associated with it) will replace the
4174 * existing one in the pending broadcast list, remaining at the same
4175 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004176 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004177 * <p>This flag is most typically used with sticky broadcasts, which
4178 * only care about delivering the most recent values of the broadcast
4179 * to their receivers.
4180 */
4181 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4182 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004183 * If set, when sending a broadcast the recipient is allowed to run at
4184 * foreground priority, with a shorter timeout interval. During normal
4185 * broadcasts the receivers are not automatically hoisted out of the
4186 * background priority class.
4187 */
4188 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4189 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004190 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4191 * They can still propagate results through to later receivers, but they can not prevent
4192 * later receivers from seeing the broadcast.
4193 */
4194 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4195 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004196 * If set, when sending a broadcast <i>before boot has completed</i> only
4197 * registered receivers will be called -- no BroadcastReceiver components
4198 * will be launched. Sticky intent state will be recorded properly even
4199 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4200 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004201 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004202 * <p>This flag is only for use by system sevices as a convenience to
4203 * avoid having to implement a more complex mechanism around detection
4204 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004205 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004206 * @hide
4207 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004208 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004209 /**
4210 * Set when this broadcast is for a boot upgrade, a special mode that
4211 * allows the broadcast to be sent before the system is ready and launches
4212 * the app process with no providers running in it.
4213 * @hide
4214 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004215 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004216
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004217 /**
4218 * @hide Flags that can't be changed with PendingIntent.
4219 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004220 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4221 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4222 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004223
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004224 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004225 // ---------------------------------------------------------------------
4226 // toUri() and parseUri() options.
4227
4228 /**
4229 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4230 * always has the "intent:" scheme. This syntax can be used when you want
4231 * to later disambiguate between URIs that are intended to describe an
4232 * Intent vs. all others that should be treated as raw URIs. When used
4233 * with {@link #parseUri}, any other scheme will result in a generic
4234 * VIEW action for that raw URI.
4235 */
4236 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004237
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004238 /**
4239 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4240 * always has the "android-app:" scheme. This is a variation of
4241 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4242 * http/https URI being delivered to a specific package name. The format
4243 * is:
4244 *
4245 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004246 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004247 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004248 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4249 * you must also include a scheme; including a path also requires both a host and a scheme.
4250 * The final #Intent; fragment can be used without a scheme, host, or path.
4251 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004252 * used with intents that have a {@link #setSelector}, since the base intent
4253 * will always have an explicit package name.</p>
4254 *
4255 * <p>Some examples of how this scheme maps to Intent objects:</p>
4256 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4257 * <colgroup align="left" />
4258 * <colgroup align="left" />
4259 * <thead>
4260 * <tr><th>URI</th> <th>Intent</th></tr>
4261 * </thead>
4262 *
4263 * <tbody>
4264 * <tr><td><code>android-app://com.example.app</code></td>
4265 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4266 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4267 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4268 * </table></td>
4269 * </tr>
4270 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4271 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4272 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4273 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4274 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4275 * </table></td>
4276 * </tr>
4277 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4278 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4279 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4280 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4281 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4282 * </table></td>
4283 * </tr>
4284 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4285 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4286 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4287 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4288 * </table></td>
4289 * </tr>
4290 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4291 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4292 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4293 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4294 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4295 * </table></td>
4296 * </tr>
4297 * <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>
4298 * <td><table border="" style="margin:0" >
4299 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4300 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4301 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4302 * </table></td>
4303 * </tr>
4304 * </tbody>
4305 * </table>
4306 */
4307 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4308
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004309 /**
4310 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4311 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4312 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4313 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4314 * generated Intent can not cause unexpected data access to happen.
4315 *
4316 * <p>If you do not trust the source of the URI being parsed, you should still do further
4317 * processing to protect yourself from it. In particular, when using it to start an
4318 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4319 * that can handle it.</p>
4320 */
4321 public static final int URI_ALLOW_UNSAFE = 1<<2;
4322
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004323 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004324
4325 private String mAction;
4326 private Uri mData;
4327 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004328 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004329 private ComponentName mComponent;
4330 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004331 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004332 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004333 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004334 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004335 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004336 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004337
4338 // ---------------------------------------------------------------------
4339
4340 /**
4341 * Create an empty intent.
4342 */
4343 public Intent() {
4344 }
4345
4346 /**
4347 * Copy constructor.
4348 */
4349 public Intent(Intent o) {
4350 this.mAction = o.mAction;
4351 this.mData = o.mData;
4352 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004353 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004354 this.mComponent = o.mComponent;
4355 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004356 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004357 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004358 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004359 }
4360 if (o.mExtras != null) {
4361 this.mExtras = new Bundle(o.mExtras);
4362 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004363 if (o.mSourceBounds != null) {
4364 this.mSourceBounds = new Rect(o.mSourceBounds);
4365 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004366 if (o.mSelector != null) {
4367 this.mSelector = new Intent(o.mSelector);
4368 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004369 if (o.mClipData != null) {
4370 this.mClipData = new ClipData(o.mClipData);
4371 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004372 }
4373
4374 @Override
4375 public Object clone() {
4376 return new Intent(this);
4377 }
4378
4379 private Intent(Intent o, boolean all) {
4380 this.mAction = o.mAction;
4381 this.mData = o.mData;
4382 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004383 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004384 this.mComponent = o.mComponent;
4385 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004386 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004387 }
4388 }
4389
4390 /**
4391 * Make a clone of only the parts of the Intent that are relevant for
4392 * filter matching: the action, data, type, component, and categories.
4393 */
4394 public Intent cloneFilter() {
4395 return new Intent(this, false);
4396 }
4397
4398 /**
4399 * Create an intent with a given action. All other fields (data, type,
4400 * class) are null. Note that the action <em>must</em> be in a
4401 * namespace because Intents are used globally in the system -- for
4402 * example the system VIEW action is android.intent.action.VIEW; an
4403 * application's custom action would be something like
4404 * com.google.app.myapp.CUSTOM_ACTION.
4405 *
4406 * @param action The Intent action, such as ACTION_VIEW.
4407 */
4408 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004409 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004410 }
4411
4412 /**
4413 * Create an intent with a given action and for a given data url. Note
4414 * that the action <em>must</em> be in a namespace because Intents are
4415 * used globally in the system -- for example the system VIEW action is
4416 * android.intent.action.VIEW; an application's custom action would be
4417 * something like com.google.app.myapp.CUSTOM_ACTION.
4418 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004419 * <p><em>Note: scheme and host name matching in the Android framework is
4420 * case-sensitive, unlike the formal RFC. As a result,
4421 * you should always ensure that you write your Uri with these elements
4422 * using lower case letters, and normalize any Uris you receive from
4423 * outside of Android to ensure the scheme and host is lower case.</em></p>
4424 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004425 * @param action The Intent action, such as ACTION_VIEW.
4426 * @param uri The Intent data URI.
4427 */
4428 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004429 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004430 mData = uri;
4431 }
4432
4433 /**
4434 * Create an intent for a specific component. All other fields (action, data,
4435 * type, class) are null, though they can be modified later with explicit
4436 * calls. This provides a convenient way to create an intent that is
4437 * intended to execute a hard-coded class name, rather than relying on the
4438 * system to find an appropriate class for you; see {@link #setComponent}
4439 * for more information on the repercussions of this.
4440 *
4441 * @param packageContext A Context of the application package implementing
4442 * this class.
4443 * @param cls The component class that is to be used for the intent.
4444 *
4445 * @see #setClass
4446 * @see #setComponent
4447 * @see #Intent(String, android.net.Uri , Context, Class)
4448 */
4449 public Intent(Context packageContext, Class<?> cls) {
4450 mComponent = new ComponentName(packageContext, cls);
4451 }
4452
4453 /**
4454 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004455 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004456 * construct the Intent and then calling {@link #setClass} to set its
4457 * class.
4458 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004459 * <p><em>Note: scheme and host name matching in the Android framework is
4460 * case-sensitive, unlike the formal RFC. As a result,
4461 * you should always ensure that you write your Uri with these elements
4462 * using lower case letters, and normalize any Uris you receive from
4463 * outside of Android to ensure the scheme and host is lower case.</em></p>
4464 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004465 * @param action The Intent action, such as ACTION_VIEW.
4466 * @param uri The Intent data URI.
4467 * @param packageContext A Context of the application package implementing
4468 * this class.
4469 * @param cls The component class that is to be used for the intent.
4470 *
4471 * @see #Intent(String, android.net.Uri)
4472 * @see #Intent(Context, Class)
4473 * @see #setClass
4474 * @see #setComponent
4475 */
4476 public Intent(String action, Uri uri,
4477 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004478 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004479 mData = uri;
4480 mComponent = new ComponentName(packageContext, cls);
4481 }
4482
4483 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004484 * Create an intent to launch the main (root) activity of a task. This
4485 * is the Intent that is started when the application's is launched from
4486 * Home. For anything else that wants to launch an application in the
4487 * same way, it is important that they use an Intent structured the same
4488 * way, and can use this function to ensure this is the case.
4489 *
4490 * <p>The returned Intent has the given Activity component as its explicit
4491 * component, {@link #ACTION_MAIN} as its action, and includes the
4492 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4493 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4494 * to do that through {@link #addFlags(int)} on the returned Intent.
4495 *
4496 * @param mainActivity The main activity component that this Intent will
4497 * launch.
4498 * @return Returns a newly created Intent that can be used to launch the
4499 * activity as a main application entry.
4500 *
4501 * @see #setClass
4502 * @see #setComponent
4503 */
4504 public static Intent makeMainActivity(ComponentName mainActivity) {
4505 Intent intent = new Intent(ACTION_MAIN);
4506 intent.setComponent(mainActivity);
4507 intent.addCategory(CATEGORY_LAUNCHER);
4508 return intent;
4509 }
4510
4511 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004512 * Make an Intent for the main activity of an application, without
4513 * specifying a specific activity to run but giving a selector to find
4514 * the activity. This results in a final Intent that is structured
4515 * the same as when the application is launched from
4516 * Home. For anything else that wants to launch an application in the
4517 * same way, it is important that they use an Intent structured the same
4518 * way, and can use this function to ensure this is the case.
4519 *
4520 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4521 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4522 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4523 * to do that through {@link #addFlags(int)} on the returned Intent.
4524 *
4525 * @param selectorAction The action name of the Intent's selector.
4526 * @param selectorCategory The name of a category to add to the Intent's
4527 * selector.
4528 * @return Returns a newly created Intent that can be used to launch the
4529 * activity as a main application entry.
4530 *
4531 * @see #setSelector(Intent)
4532 */
4533 public static Intent makeMainSelectorActivity(String selectorAction,
4534 String selectorCategory) {
4535 Intent intent = new Intent(ACTION_MAIN);
4536 intent.addCategory(CATEGORY_LAUNCHER);
4537 Intent selector = new Intent();
4538 selector.setAction(selectorAction);
4539 selector.addCategory(selectorCategory);
4540 intent.setSelector(selector);
4541 return intent;
4542 }
4543
4544 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004545 * Make an Intent that can be used to re-launch an application's task
4546 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4547 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4548 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4549 *
4550 * @param mainActivity The activity component that is the root of the
4551 * task; this is the activity that has been published in the application's
4552 * manifest as the main launcher icon.
4553 *
4554 * @return Returns a newly created Intent that can be used to relaunch the
4555 * activity's task in its root state.
4556 */
4557 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4558 Intent intent = makeMainActivity(mainActivity);
4559 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4560 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4561 return intent;
4562 }
4563
4564 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004565 * Call {@link #parseUri} with 0 flags.
4566 * @deprecated Use {@link #parseUri} instead.
4567 */
4568 @Deprecated
4569 public static Intent getIntent(String uri) throws URISyntaxException {
4570 return parseUri(uri, 0);
4571 }
Tom Taylord4a47292009-12-21 13:59:18 -08004572
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004573 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004574 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004575 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004576 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004577 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004578 *
4579 * <p>The URI given here must not be relative -- that is, it must include
4580 * the scheme and full path.
4581 *
4582 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004583 * @param flags Additional processing flags. Either 0,
4584 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004585 *
4586 * @return Intent The newly created Intent object.
4587 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004588 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4589 * it bad (as parsed by the Uri class) or the Intent data within the
4590 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004591 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004592 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004593 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004594 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004595 int i = 0;
4596 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004597 final boolean androidApp = uri.startsWith("android-app:");
4598
4599 // Validate intent scheme if requested.
4600 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4601 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004602 Intent intent = new Intent(ACTION_VIEW);
4603 try {
4604 intent.setData(Uri.parse(uri));
4605 } catch (IllegalArgumentException e) {
4606 throw new URISyntaxException(uri, e.getMessage());
4607 }
4608 return intent;
4609 }
4610 }
Tom Taylord4a47292009-12-21 13:59:18 -08004611
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004612 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004613 // simple case
4614 if (i == -1) {
4615 if (!androidApp) {
4616 return new Intent(ACTION_VIEW, Uri.parse(uri));
4617 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004618
4619 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004620 } else if (!uri.startsWith("#Intent;", i)) {
4621 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004622 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004623 } else {
4624 i = -1;
4625 }
4626 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004627
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004628 // new format
4629 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004630 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004631 boolean explicitAction = false;
4632 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004633
4634 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004635 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004636 String data;
4637 if (i >= 0) {
4638 data = uri.substring(0, i);
4639 i += 8; // length of "#Intent;"
4640 } else {
4641 data = uri;
4642 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004643
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004644 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004645 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004646 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004647 if (eq < 0) eq = i-1;
4648 int semi = uri.indexOf(';', i);
4649 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004650
4651 // action
4652 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004653 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004654 if (!inSelector) {
4655 explicitAction = true;
4656 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004657 }
4658
4659 // categories
4660 else if (uri.startsWith("category=", i)) {
4661 intent.addCategory(value);
4662 }
4663
4664 // type
4665 else if (uri.startsWith("type=", i)) {
4666 intent.mType = value;
4667 }
4668
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004669 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004670 else if (uri.startsWith("launchFlags=", i)) {
4671 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004672 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4673 intent.mFlags &= ~IMMUTABLE_FLAGS;
4674 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004675 }
4676
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004677 // package
4678 else if (uri.startsWith("package=", i)) {
4679 intent.mPackage = value;
4680 }
4681
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004682 // component
4683 else if (uri.startsWith("component=", i)) {
4684 intent.mComponent = ComponentName.unflattenFromString(value);
4685 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004686
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004687 // scheme
4688 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004689 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004690 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004691 } else {
4692 scheme = value;
4693 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004694 }
4695
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004696 // source bounds
4697 else if (uri.startsWith("sourceBounds=", i)) {
4698 intent.mSourceBounds = Rect.unflattenFromString(value);
4699 }
4700
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004701 // selector
4702 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4703 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004704 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004705 }
4706
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004707 // extra
4708 else {
4709 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004710 // create Bundle if it doesn't already exist
4711 if (intent.mExtras == null) intent.mExtras = new Bundle();
4712 Bundle b = intent.mExtras;
4713 // add EXTRA
4714 if (uri.startsWith("S.", i)) b.putString(key, value);
4715 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4716 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4717 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4718 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4719 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4720 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4721 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4722 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4723 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4724 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004725
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004726 // move to the next item
4727 i = semi + 1;
4728 }
4729
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004730 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004731 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004732 if (baseIntent.mPackage == null) {
4733 baseIntent.setSelector(intent);
4734 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004735 intent = baseIntent;
4736 }
4737
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004738 if (data != null) {
4739 if (data.startsWith("intent:")) {
4740 data = data.substring(7);
4741 if (scheme != null) {
4742 data = scheme + ':' + data;
4743 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004744 } else if (data.startsWith("android-app:")) {
4745 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4746 // Correctly formed android-app, first part is package name.
4747 int end = data.indexOf('/', 14);
4748 if (end < 0) {
4749 // All we have is a package name.
4750 intent.mPackage = data.substring(14);
4751 if (!explicitAction) {
4752 intent.setAction(ACTION_MAIN);
4753 }
4754 data = "";
4755 } else {
4756 // Target the Intent at the given package name always.
4757 String authority = null;
4758 intent.mPackage = data.substring(14, end);
4759 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004760 if ((end+1) < data.length()) {
4761 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4762 // Found a scheme, remember it.
4763 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004764 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004765 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4766 // Found a authority, remember it.
4767 authority = data.substring(end+1, newEnd);
4768 end = newEnd;
4769 }
4770 } else {
4771 // All we have is a scheme.
4772 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004773 }
4774 }
4775 if (scheme == null) {
4776 // If there was no scheme, then this just targets the package.
4777 if (!explicitAction) {
4778 intent.setAction(ACTION_MAIN);
4779 }
4780 data = "";
4781 } else if (authority == null) {
4782 data = scheme + ":";
4783 } else {
4784 data = scheme + "://" + authority + data.substring(end);
4785 }
4786 }
4787 } else {
4788 data = "";
4789 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004790 }
Tom Taylord4a47292009-12-21 13:59:18 -08004791
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004792 if (data.length() > 0) {
4793 try {
4794 intent.mData = Uri.parse(data);
4795 } catch (IllegalArgumentException e) {
4796 throw new URISyntaxException(uri, e.getMessage());
4797 }
4798 }
4799 }
Tom Taylord4a47292009-12-21 13:59:18 -08004800
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004801 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004802
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004803 } catch (IndexOutOfBoundsException e) {
4804 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4805 }
4806 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004807
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004808 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004809 return getIntentOld(uri, 0);
4810 }
4811
4812 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004813 Intent intent;
4814
4815 int i = uri.lastIndexOf('#');
4816 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004817 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004818 final int intentFragmentStart = i;
4819 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004820
4821 i++;
4822
4823 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004824 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004825 i += 7;
4826 int j = uri.indexOf(')', i);
4827 action = uri.substring(i, j);
4828 i = j + 1;
4829 }
4830
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004831 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004832
4833 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004834 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004835 i += 11;
4836 int j = uri.indexOf(')', i);
4837 while (i < j) {
4838 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004839 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004840 if (i < sep) {
4841 intent.addCategory(uri.substring(i, sep));
4842 }
4843 i = sep + 1;
4844 }
4845 i = j + 1;
4846 }
4847
4848 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004849 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004850 i += 5;
4851 int j = uri.indexOf(')', i);
4852 intent.mType = uri.substring(i, j);
4853 i = j + 1;
4854 }
4855
4856 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004857 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004858 i += 12;
4859 int j = uri.indexOf(')', i);
4860 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004861 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4862 intent.mFlags &= ~IMMUTABLE_FLAGS;
4863 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004864 i = j + 1;
4865 }
4866
4867 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004868 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004869 i += 10;
4870 int j = uri.indexOf(')', i);
4871 int sep = uri.indexOf('!', i);
4872 if (sep >= 0 && sep < j) {
4873 String pkg = uri.substring(i, sep);
4874 String cls = uri.substring(sep + 1, j);
4875 intent.mComponent = new ComponentName(pkg, cls);
4876 }
4877 i = j + 1;
4878 }
4879
4880 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004881 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004882 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004883
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004884 final int closeParen = uri.indexOf(')', i);
4885 if (closeParen == -1) throw new URISyntaxException(uri,
4886 "EXTRA missing trailing ')'", i);
4887
4888 while (i < closeParen) {
4889 // fetch the key value
4890 int j = uri.indexOf('=', i);
4891 if (j <= i + 1 || i >= closeParen) {
4892 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4893 }
4894 char type = uri.charAt(i);
4895 i++;
4896 String key = uri.substring(i, j);
4897 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004898
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004899 // get type-value
4900 j = uri.indexOf('!', i);
4901 if (j == -1 || j >= closeParen) j = closeParen;
4902 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4903 String value = uri.substring(i, j);
4904 i = j;
4905
4906 // create Bundle if it doesn't already exist
4907 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004908
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004909 // add item to bundle
4910 try {
4911 switch (type) {
4912 case 'S':
4913 intent.mExtras.putString(key, Uri.decode(value));
4914 break;
4915 case 'B':
4916 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4917 break;
4918 case 'b':
4919 intent.mExtras.putByte(key, Byte.parseByte(value));
4920 break;
4921 case 'c':
4922 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4923 break;
4924 case 'd':
4925 intent.mExtras.putDouble(key, Double.parseDouble(value));
4926 break;
4927 case 'f':
4928 intent.mExtras.putFloat(key, Float.parseFloat(value));
4929 break;
4930 case 'i':
4931 intent.mExtras.putInt(key, Integer.parseInt(value));
4932 break;
4933 case 'l':
4934 intent.mExtras.putLong(key, Long.parseLong(value));
4935 break;
4936 case 's':
4937 intent.mExtras.putShort(key, Short.parseShort(value));
4938 break;
4939 default:
4940 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4941 }
4942 } catch (NumberFormatException e) {
4943 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4944 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004945
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004946 char ch = uri.charAt(i);
4947 if (ch == ')') break;
4948 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4949 i++;
4950 }
4951 }
4952
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004953 if (isIntentFragment) {
4954 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4955 } else {
4956 intent.mData = Uri.parse(uri);
4957 }
Tom Taylord4a47292009-12-21 13:59:18 -08004958
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004959 if (intent.mAction == null) {
4960 // By default, if no action is specified, then use VIEW.
4961 intent.mAction = ACTION_VIEW;
4962 }
4963
4964 } else {
4965 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4966 }
4967
4968 return intent;
4969 }
4970
4971 /**
4972 * Retrieve the general action to be performed, such as
4973 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4974 * the information in the intent should be interpreted -- most importantly,
4975 * what to do with the data returned by {@link #getData}.
4976 *
4977 * @return The action of this intent or null if none is specified.
4978 *
4979 * @see #setAction
4980 */
4981 public String getAction() {
4982 return mAction;
4983 }
4984
4985 /**
4986 * Retrieve data this intent is operating on. This URI specifies the name
4987 * of the data; often it uses the content: scheme, specifying data in a
4988 * content provider. Other schemes may be handled by specific activities,
4989 * such as http: by the web browser.
4990 *
4991 * @return The URI of the data this intent is targeting or null.
4992 *
4993 * @see #getScheme
4994 * @see #setData
4995 */
4996 public Uri getData() {
4997 return mData;
4998 }
4999
5000 /**
5001 * The same as {@link #getData()}, but returns the URI as an encoded
5002 * String.
5003 */
5004 public String getDataString() {
5005 return mData != null ? mData.toString() : null;
5006 }
5007
5008 /**
5009 * Return the scheme portion of the intent's data. If the data is null or
5010 * does not include a scheme, null is returned. Otherwise, the scheme
5011 * prefix without the final ':' is returned, i.e. "http".
5012 *
5013 * <p>This is the same as calling getData().getScheme() (and checking for
5014 * null data).
5015 *
5016 * @return The scheme of this intent.
5017 *
5018 * @see #getData
5019 */
5020 public String getScheme() {
5021 return mData != null ? mData.getScheme() : null;
5022 }
5023
5024 /**
5025 * Retrieve any explicit MIME type included in the intent. This is usually
5026 * null, as the type is determined by the intent data.
5027 *
5028 * @return If a type was manually set, it is returned; else null is
5029 * returned.
5030 *
5031 * @see #resolveType(ContentResolver)
5032 * @see #setType
5033 */
5034 public String getType() {
5035 return mType;
5036 }
5037
5038 /**
5039 * Return the MIME data type of this intent. If the type field is
5040 * explicitly set, that is simply returned. Otherwise, if the data is set,
5041 * the type of that data is returned. If neither fields are set, a null is
5042 * returned.
5043 *
5044 * @return The MIME type of this intent.
5045 *
5046 * @see #getType
5047 * @see #resolveType(ContentResolver)
5048 */
5049 public String resolveType(Context context) {
5050 return resolveType(context.getContentResolver());
5051 }
5052
5053 /**
5054 * Return the MIME data type of this intent. If the type field is
5055 * explicitly set, that is simply returned. Otherwise, if the data is set,
5056 * the type of that data is returned. If neither fields are set, a null is
5057 * returned.
5058 *
5059 * @param resolver A ContentResolver that can be used to determine the MIME
5060 * type of the intent's data.
5061 *
5062 * @return The MIME type of this intent.
5063 *
5064 * @see #getType
5065 * @see #resolveType(Context)
5066 */
5067 public String resolveType(ContentResolver resolver) {
5068 if (mType != null) {
5069 return mType;
5070 }
5071 if (mData != null) {
5072 if ("content".equals(mData.getScheme())) {
5073 return resolver.getType(mData);
5074 }
5075 }
5076 return null;
5077 }
5078
5079 /**
5080 * Return the MIME data type of this intent, only if it will be needed for
5081 * intent resolution. This is not generally useful for application code;
5082 * it is used by the frameworks for communicating with back-end system
5083 * services.
5084 *
5085 * @param resolver A ContentResolver that can be used to determine the MIME
5086 * type of the intent's data.
5087 *
5088 * @return The MIME type of this intent, or null if it is unknown or not
5089 * needed.
5090 */
5091 public String resolveTypeIfNeeded(ContentResolver resolver) {
5092 if (mComponent != null) {
5093 return mType;
5094 }
5095 return resolveType(resolver);
5096 }
5097
5098 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005099 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005100 *
5101 * @param category The category to check.
5102 *
5103 * @return boolean True if the intent contains the category, else false.
5104 *
5105 * @see #getCategories
5106 * @see #addCategory
5107 */
5108 public boolean hasCategory(String category) {
5109 return mCategories != null && mCategories.contains(category);
5110 }
5111
5112 /**
5113 * Return the set of all categories in the intent. If there are no categories,
5114 * returns NULL.
5115 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005116 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005117 *
5118 * @see #hasCategory
5119 * @see #addCategory
5120 */
5121 public Set<String> getCategories() {
5122 return mCategories;
5123 }
5124
5125 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005126 * Return the specific selector associated with this Intent. If there is
5127 * none, returns null. See {@link #setSelector} for more information.
5128 *
5129 * @see #setSelector
5130 */
5131 public Intent getSelector() {
5132 return mSelector;
5133 }
5134
5135 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005136 * Return the {@link ClipData} associated with this Intent. If there is
5137 * none, returns null. See {@link #setClipData} for more information.
5138 *
John Spurlock125d1332013-11-25 11:58:37 -05005139 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005140 */
5141 public ClipData getClipData() {
5142 return mClipData;
5143 }
5144
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005145 /** @hide */
5146 public int getContentUserHint() {
5147 return mContentUserHint;
5148 }
5149
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005150 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005151 * Sets the ClassLoader that will be used when unmarshalling
5152 * any Parcelable values from the extras of this Intent.
5153 *
5154 * @param loader a ClassLoader, or null to use the default loader
5155 * at the time of unmarshalling.
5156 */
5157 public void setExtrasClassLoader(ClassLoader loader) {
5158 if (mExtras != null) {
5159 mExtras.setClassLoader(loader);
5160 }
5161 }
5162
5163 /**
5164 * Returns true if an extra value is associated with the given name.
5165 * @param name the extra's name
5166 * @return true if the given extra is present.
5167 */
5168 public boolean hasExtra(String name) {
5169 return mExtras != null && mExtras.containsKey(name);
5170 }
5171
5172 /**
5173 * Returns true if the Intent's extras contain a parcelled file descriptor.
5174 * @return true if the Intent contains a parcelled file descriptor.
5175 */
5176 public boolean hasFileDescriptors() {
5177 return mExtras != null && mExtras.hasFileDescriptors();
5178 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005179
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005180 /** @hide */
5181 public void setAllowFds(boolean allowFds) {
5182 if (mExtras != null) {
5183 mExtras.setAllowFds(allowFds);
5184 }
5185 }
5186
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005187 /**
5188 * Retrieve extended data from the intent.
5189 *
5190 * @param name The name of the desired item.
5191 *
5192 * @return the value of an item that previously added with putExtra()
5193 * or null if none was found.
5194 *
5195 * @deprecated
5196 * @hide
5197 */
5198 @Deprecated
5199 public Object getExtra(String name) {
5200 return getExtra(name, null);
5201 }
5202
5203 /**
5204 * Retrieve extended data from the intent.
5205 *
5206 * @param name The name of the desired item.
5207 * @param defaultValue the value to be returned if no value of the desired
5208 * type is stored with the given name.
5209 *
5210 * @return the value of an item that previously added with putExtra()
5211 * or the default value if none was found.
5212 *
5213 * @see #putExtra(String, boolean)
5214 */
5215 public boolean getBooleanExtra(String name, boolean defaultValue) {
5216 return mExtras == null ? defaultValue :
5217 mExtras.getBoolean(name, defaultValue);
5218 }
5219
5220 /**
5221 * Retrieve extended data from the intent.
5222 *
5223 * @param name The name of the desired item.
5224 * @param defaultValue the value to be returned if no value of the desired
5225 * type is stored with the given name.
5226 *
5227 * @return the value of an item that previously added with putExtra()
5228 * or the default value if none was found.
5229 *
5230 * @see #putExtra(String, byte)
5231 */
5232 public byte getByteExtra(String name, byte defaultValue) {
5233 return mExtras == null ? defaultValue :
5234 mExtras.getByte(name, defaultValue);
5235 }
5236
5237 /**
5238 * Retrieve extended data from the intent.
5239 *
5240 * @param name The name of the desired item.
5241 * @param defaultValue the value to be returned if no value of the desired
5242 * type is stored with the given name.
5243 *
5244 * @return the value of an item that previously added with putExtra()
5245 * or the default value if none was found.
5246 *
5247 * @see #putExtra(String, short)
5248 */
5249 public short getShortExtra(String name, short defaultValue) {
5250 return mExtras == null ? defaultValue :
5251 mExtras.getShort(name, defaultValue);
5252 }
5253
5254 /**
5255 * Retrieve extended data from the intent.
5256 *
5257 * @param name The name of the desired item.
5258 * @param defaultValue the value to be returned if no value of the desired
5259 * type is stored with the given name.
5260 *
5261 * @return the value of an item that previously added with putExtra()
5262 * or the default value if none was found.
5263 *
5264 * @see #putExtra(String, char)
5265 */
5266 public char getCharExtra(String name, char defaultValue) {
5267 return mExtras == null ? defaultValue :
5268 mExtras.getChar(name, defaultValue);
5269 }
5270
5271 /**
5272 * Retrieve extended data from the intent.
5273 *
5274 * @param name The name of the desired item.
5275 * @param defaultValue the value to be returned if no value of the desired
5276 * type is stored with the given name.
5277 *
5278 * @return the value of an item that previously added with putExtra()
5279 * or the default value if none was found.
5280 *
5281 * @see #putExtra(String, int)
5282 */
5283 public int getIntExtra(String name, int defaultValue) {
5284 return mExtras == null ? defaultValue :
5285 mExtras.getInt(name, defaultValue);
5286 }
5287
5288 /**
5289 * Retrieve extended data from the intent.
5290 *
5291 * @param name The name of the desired item.
5292 * @param defaultValue the value to be returned if no value of the desired
5293 * type is stored with the given name.
5294 *
5295 * @return the value of an item that previously added with putExtra()
5296 * or the default value if none was found.
5297 *
5298 * @see #putExtra(String, long)
5299 */
5300 public long getLongExtra(String name, long defaultValue) {
5301 return mExtras == null ? defaultValue :
5302 mExtras.getLong(name, defaultValue);
5303 }
5304
5305 /**
5306 * Retrieve extended data from the intent.
5307 *
5308 * @param name The name of the desired item.
5309 * @param defaultValue the value to be returned if no value of the desired
5310 * type is stored with the given name.
5311 *
5312 * @return the value of an item that previously added with putExtra(),
5313 * or the default value if no such item is present
5314 *
5315 * @see #putExtra(String, float)
5316 */
5317 public float getFloatExtra(String name, float defaultValue) {
5318 return mExtras == null ? defaultValue :
5319 mExtras.getFloat(name, defaultValue);
5320 }
5321
5322 /**
5323 * Retrieve extended data from the intent.
5324 *
5325 * @param name The name of the desired item.
5326 * @param defaultValue the value to be returned if no value of the desired
5327 * type is stored with the given name.
5328 *
5329 * @return the value of an item that previously added with putExtra()
5330 * or the default value if none was found.
5331 *
5332 * @see #putExtra(String, double)
5333 */
5334 public double getDoubleExtra(String name, double defaultValue) {
5335 return mExtras == null ? defaultValue :
5336 mExtras.getDouble(name, defaultValue);
5337 }
5338
5339 /**
5340 * Retrieve extended data from the intent.
5341 *
5342 * @param name The name of the desired item.
5343 *
5344 * @return the value of an item that previously added with putExtra()
5345 * or null if no String value was found.
5346 *
5347 * @see #putExtra(String, String)
5348 */
5349 public String getStringExtra(String name) {
5350 return mExtras == null ? null : mExtras.getString(name);
5351 }
5352
5353 /**
5354 * Retrieve extended data from the intent.
5355 *
5356 * @param name The name of the desired item.
5357 *
5358 * @return the value of an item that previously added with putExtra()
5359 * or null if no CharSequence value was found.
5360 *
5361 * @see #putExtra(String, CharSequence)
5362 */
5363 public CharSequence getCharSequenceExtra(String name) {
5364 return mExtras == null ? null : mExtras.getCharSequence(name);
5365 }
5366
5367 /**
5368 * Retrieve extended data from the intent.
5369 *
5370 * @param name The name of the desired item.
5371 *
5372 * @return the value of an item that previously added with putExtra()
5373 * or null if no Parcelable value was found.
5374 *
5375 * @see #putExtra(String, Parcelable)
5376 */
5377 public <T extends Parcelable> T getParcelableExtra(String name) {
5378 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5379 }
5380
5381 /**
5382 * Retrieve extended data from the intent.
5383 *
5384 * @param name The name of the desired item.
5385 *
5386 * @return the value of an item that previously added with putExtra()
5387 * or null if no Parcelable[] value was found.
5388 *
5389 * @see #putExtra(String, Parcelable[])
5390 */
5391 public Parcelable[] getParcelableArrayExtra(String name) {
5392 return mExtras == null ? null : mExtras.getParcelableArray(name);
5393 }
5394
5395 /**
5396 * Retrieve extended data from the intent.
5397 *
5398 * @param name The name of the desired item.
5399 *
5400 * @return the value of an item that previously added with putExtra()
5401 * or null if no ArrayList<Parcelable> value was found.
5402 *
5403 * @see #putParcelableArrayListExtra(String, ArrayList)
5404 */
5405 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5406 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5407 }
5408
5409 /**
5410 * Retrieve extended data from the intent.
5411 *
5412 * @param name The name of the desired item.
5413 *
5414 * @return the value of an item that previously added with putExtra()
5415 * or null if no Serializable value was found.
5416 *
5417 * @see #putExtra(String, Serializable)
5418 */
5419 public Serializable getSerializableExtra(String name) {
5420 return mExtras == null ? null : mExtras.getSerializable(name);
5421 }
5422
5423 /**
5424 * Retrieve extended data from the intent.
5425 *
5426 * @param name The name of the desired item.
5427 *
5428 * @return the value of an item that previously added with putExtra()
5429 * or null if no ArrayList<Integer> value was found.
5430 *
5431 * @see #putIntegerArrayListExtra(String, ArrayList)
5432 */
5433 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
5434 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
5435 }
5436
5437 /**
5438 * Retrieve extended data from the intent.
5439 *
5440 * @param name The name of the desired item.
5441 *
5442 * @return the value of an item that previously added with putExtra()
5443 * or null if no ArrayList<String> value was found.
5444 *
5445 * @see #putStringArrayListExtra(String, ArrayList)
5446 */
5447 public ArrayList<String> getStringArrayListExtra(String name) {
5448 return mExtras == null ? null : mExtras.getStringArrayList(name);
5449 }
5450
5451 /**
5452 * Retrieve extended data from the intent.
5453 *
5454 * @param name The name of the desired item.
5455 *
5456 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005457 * or null if no ArrayList<CharSequence> value was found.
5458 *
5459 * @see #putCharSequenceArrayListExtra(String, ArrayList)
5460 */
5461 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
5462 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
5463 }
5464
5465 /**
5466 * Retrieve extended data from the intent.
5467 *
5468 * @param name The name of the desired item.
5469 *
5470 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005471 * or null if no boolean array value was found.
5472 *
5473 * @see #putExtra(String, boolean[])
5474 */
5475 public boolean[] getBooleanArrayExtra(String name) {
5476 return mExtras == null ? null : mExtras.getBooleanArray(name);
5477 }
5478
5479 /**
5480 * Retrieve extended data from the intent.
5481 *
5482 * @param name The name of the desired item.
5483 *
5484 * @return the value of an item that previously added with putExtra()
5485 * or null if no byte array value was found.
5486 *
5487 * @see #putExtra(String, byte[])
5488 */
5489 public byte[] getByteArrayExtra(String name) {
5490 return mExtras == null ? null : mExtras.getByteArray(name);
5491 }
5492
5493 /**
5494 * Retrieve extended data from the intent.
5495 *
5496 * @param name The name of the desired item.
5497 *
5498 * @return the value of an item that previously added with putExtra()
5499 * or null if no short array value was found.
5500 *
5501 * @see #putExtra(String, short[])
5502 */
5503 public short[] getShortArrayExtra(String name) {
5504 return mExtras == null ? null : mExtras.getShortArray(name);
5505 }
5506
5507 /**
5508 * Retrieve extended data from the intent.
5509 *
5510 * @param name The name of the desired item.
5511 *
5512 * @return the value of an item that previously added with putExtra()
5513 * or null if no char array value was found.
5514 *
5515 * @see #putExtra(String, char[])
5516 */
5517 public char[] getCharArrayExtra(String name) {
5518 return mExtras == null ? null : mExtras.getCharArray(name);
5519 }
5520
5521 /**
5522 * Retrieve extended data from the intent.
5523 *
5524 * @param name The name of the desired item.
5525 *
5526 * @return the value of an item that previously added with putExtra()
5527 * or null if no int array value was found.
5528 *
5529 * @see #putExtra(String, int[])
5530 */
5531 public int[] getIntArrayExtra(String name) {
5532 return mExtras == null ? null : mExtras.getIntArray(name);
5533 }
5534
5535 /**
5536 * Retrieve extended data from the intent.
5537 *
5538 * @param name The name of the desired item.
5539 *
5540 * @return the value of an item that previously added with putExtra()
5541 * or null if no long array value was found.
5542 *
5543 * @see #putExtra(String, long[])
5544 */
5545 public long[] getLongArrayExtra(String name) {
5546 return mExtras == null ? null : mExtras.getLongArray(name);
5547 }
5548
5549 /**
5550 * Retrieve extended data from the intent.
5551 *
5552 * @param name The name of the desired item.
5553 *
5554 * @return the value of an item that previously added with putExtra()
5555 * or null if no float array value was found.
5556 *
5557 * @see #putExtra(String, float[])
5558 */
5559 public float[] getFloatArrayExtra(String name) {
5560 return mExtras == null ? null : mExtras.getFloatArray(name);
5561 }
5562
5563 /**
5564 * Retrieve extended data from the intent.
5565 *
5566 * @param name The name of the desired item.
5567 *
5568 * @return the value of an item that previously added with putExtra()
5569 * or null if no double array value was found.
5570 *
5571 * @see #putExtra(String, double[])
5572 */
5573 public double[] getDoubleArrayExtra(String name) {
5574 return mExtras == null ? null : mExtras.getDoubleArray(name);
5575 }
5576
5577 /**
5578 * Retrieve extended data from the intent.
5579 *
5580 * @param name The name of the desired item.
5581 *
5582 * @return the value of an item that previously added with putExtra()
5583 * or null if no String array value was found.
5584 *
5585 * @see #putExtra(String, String[])
5586 */
5587 public String[] getStringArrayExtra(String name) {
5588 return mExtras == null ? null : mExtras.getStringArray(name);
5589 }
5590
5591 /**
5592 * Retrieve extended data from the intent.
5593 *
5594 * @param name The name of the desired item.
5595 *
5596 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005597 * or null if no CharSequence array value was found.
5598 *
5599 * @see #putExtra(String, CharSequence[])
5600 */
5601 public CharSequence[] getCharSequenceArrayExtra(String name) {
5602 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5603 }
5604
5605 /**
5606 * Retrieve extended data from the intent.
5607 *
5608 * @param name The name of the desired item.
5609 *
5610 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005611 * or null if no Bundle value was found.
5612 *
5613 * @see #putExtra(String, Bundle)
5614 */
5615 public Bundle getBundleExtra(String name) {
5616 return mExtras == null ? null : mExtras.getBundle(name);
5617 }
5618
5619 /**
5620 * Retrieve extended data from the intent.
5621 *
5622 * @param name The name of the desired item.
5623 *
5624 * @return the value of an item that previously added with putExtra()
5625 * or null if no IBinder value was found.
5626 *
5627 * @see #putExtra(String, IBinder)
5628 *
5629 * @deprecated
5630 * @hide
5631 */
5632 @Deprecated
5633 public IBinder getIBinderExtra(String name) {
5634 return mExtras == null ? null : mExtras.getIBinder(name);
5635 }
5636
5637 /**
5638 * Retrieve extended data from the intent.
5639 *
5640 * @param name The name of the desired item.
5641 * @param defaultValue The default value to return in case no item is
5642 * associated with the key 'name'
5643 *
5644 * @return the value of an item that previously added with putExtra()
5645 * or defaultValue if none was found.
5646 *
5647 * @see #putExtra
5648 *
5649 * @deprecated
5650 * @hide
5651 */
5652 @Deprecated
5653 public Object getExtra(String name, Object defaultValue) {
5654 Object result = defaultValue;
5655 if (mExtras != null) {
5656 Object result2 = mExtras.get(name);
5657 if (result2 != null) {
5658 result = result2;
5659 }
5660 }
5661
5662 return result;
5663 }
5664
5665 /**
5666 * Retrieves a map of extended data from the intent.
5667 *
5668 * @return the map of all extras previously added with putExtra(),
5669 * or null if none have been added.
5670 */
5671 public Bundle getExtras() {
5672 return (mExtras != null)
5673 ? new Bundle(mExtras)
5674 : null;
5675 }
5676
5677 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07005678 * Filter extras to only basic types.
5679 * @hide
5680 */
5681 public void removeUnsafeExtras() {
5682 if (mExtras != null) {
5683 mExtras.filterValues();
5684 }
5685 }
5686
5687 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005688 * Retrieve any special flags associated with this intent. You will
5689 * normally just set them with {@link #setFlags} and let the system
5690 * take the appropriate action with them.
5691 *
5692 * @return int The currently set flags.
5693 *
5694 * @see #setFlags
5695 */
5696 public int getFlags() {
5697 return mFlags;
5698 }
5699
Dianne Hackborne7f97212011-02-24 14:40:20 -08005700 /** @hide */
5701 public boolean isExcludingStopped() {
5702 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5703 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5704 }
5705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005706 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005707 * Retrieve the application package name this Intent is limited to. When
5708 * resolving an Intent, if non-null this limits the resolution to only
5709 * components in the given application package.
5710 *
5711 * @return The name of the application package for the Intent.
5712 *
5713 * @see #resolveActivity
5714 * @see #setPackage
5715 */
5716 public String getPackage() {
5717 return mPackage;
5718 }
5719
5720 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005721 * Retrieve the concrete component associated with the intent. When receiving
5722 * an intent, this is the component that was found to best handle it (that is,
5723 * yourself) and will always be non-null; in all other cases it will be
5724 * null unless explicitly set.
5725 *
5726 * @return The name of the application component to handle the intent.
5727 *
5728 * @see #resolveActivity
5729 * @see #setComponent
5730 */
5731 public ComponentName getComponent() {
5732 return mComponent;
5733 }
5734
5735 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005736 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5737 * used as a hint to the receiver for animations and the like. Null means that there
5738 * is no source bounds.
5739 */
5740 public Rect getSourceBounds() {
5741 return mSourceBounds;
5742 }
5743
5744 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005745 * Return the Activity component that should be used to handle this intent.
5746 * The appropriate component is determined based on the information in the
5747 * intent, evaluated as follows:
5748 *
5749 * <p>If {@link #getComponent} returns an explicit class, that is returned
5750 * without any further consideration.
5751 *
5752 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5753 * category to be considered.
5754 *
5755 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5756 * action.
5757 *
5758 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5759 * this type.
5760 *
5761 * <p>If {@link #addCategory} has added any categories, the activity must
5762 * handle ALL of the categories specified.
5763 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005764 * <p>If {@link #getPackage} is non-NULL, only activity components in
5765 * that application package will be considered.
5766 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005767 * <p>If there are no activities that satisfy all of these conditions, a
5768 * null string is returned.
5769 *
5770 * <p>If multiple activities are found to satisfy the intent, the one with
5771 * the highest priority will be used. If there are multiple activities
5772 * with the same priority, the system will either pick the best activity
5773 * based on user preference, or resolve to a system class that will allow
5774 * the user to pick an activity and forward from there.
5775 *
5776 * <p>This method is implemented simply by calling
5777 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5778 * true.</p>
5779 * <p> This API is called for you as part of starting an activity from an
5780 * intent. You do not normally need to call it yourself.</p>
5781 *
5782 * @param pm The package manager with which to resolve the Intent.
5783 *
5784 * @return Name of the component implementing an activity that can
5785 * display the intent.
5786 *
5787 * @see #setComponent
5788 * @see #getComponent
5789 * @see #resolveActivityInfo
5790 */
5791 public ComponentName resolveActivity(PackageManager pm) {
5792 if (mComponent != null) {
5793 return mComponent;
5794 }
5795
5796 ResolveInfo info = pm.resolveActivity(
5797 this, PackageManager.MATCH_DEFAULT_ONLY);
5798 if (info != null) {
5799 return new ComponentName(
5800 info.activityInfo.applicationInfo.packageName,
5801 info.activityInfo.name);
5802 }
5803
5804 return null;
5805 }
5806
5807 /**
5808 * Resolve the Intent into an {@link ActivityInfo}
5809 * describing the activity that should execute the intent. Resolution
5810 * follows the same rules as described for {@link #resolveActivity}, but
5811 * you get back the completely information about the resolved activity
5812 * instead of just its class name.
5813 *
5814 * @param pm The package manager with which to resolve the Intent.
5815 * @param flags Addition information to retrieve as per
5816 * {@link PackageManager#getActivityInfo(ComponentName, int)
5817 * PackageManager.getActivityInfo()}.
5818 *
5819 * @return PackageManager.ActivityInfo
5820 *
5821 * @see #resolveActivity
5822 */
5823 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5824 ActivityInfo ai = null;
5825 if (mComponent != null) {
5826 try {
5827 ai = pm.getActivityInfo(mComponent, flags);
5828 } catch (PackageManager.NameNotFoundException e) {
5829 // ignore
5830 }
5831 } else {
5832 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005833 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005834 if (info != null) {
5835 ai = info.activityInfo;
5836 }
5837 }
5838
5839 return ai;
5840 }
5841
5842 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005843 * Special function for use by the system to resolve service
5844 * intents to system apps. Throws an exception if there are
5845 * multiple potential matches to the Intent. Returns null if
5846 * there are no matches.
5847 * @hide
5848 */
5849 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5850 if (mComponent != null) {
5851 return mComponent;
5852 }
5853
5854 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5855 if (results == null) {
5856 return null;
5857 }
5858 ComponentName comp = null;
5859 for (int i=0; i<results.size(); i++) {
5860 ResolveInfo ri = results.get(i);
5861 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5862 continue;
5863 }
5864 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5865 ri.serviceInfo.name);
5866 if (comp != null) {
5867 throw new IllegalStateException("Multiple system services handle " + this
5868 + ": " + comp + ", " + foundComp);
5869 }
5870 comp = foundComp;
5871 }
5872 return comp;
5873 }
5874
5875 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005876 * Set the general action to be performed.
5877 *
5878 * @param action An action name, such as ACTION_VIEW. Application-specific
5879 * actions should be prefixed with the vendor's package name.
5880 *
5881 * @return Returns the same Intent object, for chaining multiple calls
5882 * into a single statement.
5883 *
5884 * @see #getAction
5885 */
5886 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005887 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005888 return this;
5889 }
5890
5891 /**
5892 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005893 * clears any type that was previously set by {@link #setType} or
5894 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005895 *
Nick Pellyccae4122012-01-09 14:12:58 -08005896 * <p><em>Note: scheme matching in the Android framework is
5897 * case-sensitive, unlike the formal RFC. As a result,
5898 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005899 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005900 * {@link #setDataAndNormalize}
5901 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005902 *
Nick Pellyccae4122012-01-09 14:12:58 -08005903 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005904 *
5905 * @return Returns the same Intent object, for chaining multiple calls
5906 * into a single statement.
5907 *
5908 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005909 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005910 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005911 */
5912 public Intent setData(Uri data) {
5913 mData = data;
5914 mType = null;
5915 return this;
5916 }
5917
5918 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005919 * Normalize and set the data this intent is operating on.
5920 *
5921 * <p>This method automatically clears any type that was
5922 * previously set (for example, by {@link #setType}).
5923 *
5924 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005925 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005926 * so really this is just a convenience method for
5927 * <pre>
5928 * setData(data.normalize())
5929 * </pre>
5930 *
5931 * @param data The Uri of the data this intent is now targeting.
5932 *
5933 * @return Returns the same Intent object, for chaining multiple calls
5934 * into a single statement.
5935 *
5936 * @see #getData
5937 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005938 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005939 */
5940 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005941 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005942 }
5943
5944 /**
5945 * Set an explicit MIME data type.
5946 *
5947 * <p>This is used to create intents that only specify a type and not data,
5948 * for example to indicate the type of data to return.
5949 *
5950 * <p>This method automatically clears any data that was
5951 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005952 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005953 * <p><em>Note: MIME type matching in the Android framework is
5954 * case-sensitive, unlike formal RFC MIME types. As a result,
5955 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005956 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5957 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005958 *
5959 * @param type The MIME type of the data being handled by this intent.
5960 *
5961 * @return Returns the same Intent object, for chaining multiple calls
5962 * into a single statement.
5963 *
5964 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005965 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005966 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005967 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005968 */
5969 public Intent setType(String type) {
5970 mData = null;
5971 mType = type;
5972 return this;
5973 }
5974
5975 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005976 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005977 *
Nick Pellyccae4122012-01-09 14:12:58 -08005978 * <p>This is used to create intents that only specify a type and not data,
5979 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005980 *
Nick Pellyccae4122012-01-09 14:12:58 -08005981 * <p>This method automatically clears any data that was
5982 * previously set (for example by {@link #setData}).
5983 *
5984 * <p>The MIME type is normalized using
5985 * {@link #normalizeMimeType} before it is set,
5986 * so really this is just a convenience method for
5987 * <pre>
5988 * setType(Intent.normalizeMimeType(type))
5989 * </pre>
5990 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005991 * @param type The MIME type of the data being handled by this intent.
5992 *
5993 * @return Returns the same Intent object, for chaining multiple calls
5994 * into a single statement.
5995 *
Nick Pellyccae4122012-01-09 14:12:58 -08005996 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005997 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005998 * @see #normalizeMimeType
5999 */
6000 public Intent setTypeAndNormalize(String type) {
6001 return setType(normalizeMimeType(type));
6002 }
6003
6004 /**
6005 * (Usually optional) Set the data for the intent along with an explicit
6006 * MIME data type. This method should very rarely be used -- it allows you
6007 * to override the MIME type that would ordinarily be inferred from the
6008 * data with your own type given here.
6009 *
6010 * <p><em>Note: MIME type and Uri scheme matching in the
6011 * Android framework is case-sensitive, unlike the formal RFC definitions.
6012 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006013 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006014 * {@link #setDataAndTypeAndNormalize}
6015 * to ensure that they are converted to lower case.</em>
6016 *
6017 * @param data The Uri of the data this intent is now targeting.
6018 * @param type The MIME type of the data being handled by this intent.
6019 *
6020 * @return Returns the same Intent object, for chaining multiple calls
6021 * into a single statement.
6022 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006023 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006024 * @see #setData
6025 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006026 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006027 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006028 */
6029 public Intent setDataAndType(Uri data, String type) {
6030 mData = data;
6031 mType = type;
6032 return this;
6033 }
6034
6035 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006036 * (Usually optional) Normalize and set both the data Uri and an explicit
6037 * MIME data type. This method should very rarely be used -- it allows you
6038 * to override the MIME type that would ordinarily be inferred from the
6039 * data with your own type given here.
6040 *
6041 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006042 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006043 * before they are set, so really this is just a convenience method for
6044 * <pre>
6045 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6046 * </pre>
6047 *
6048 * @param data The Uri of the data this intent is now targeting.
6049 * @param type The MIME type of the data being handled by this intent.
6050 *
6051 * @return Returns the same Intent object, for chaining multiple calls
6052 * into a single statement.
6053 *
6054 * @see #setType
6055 * @see #setData
6056 * @see #setDataAndType
6057 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006058 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006059 */
6060 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006061 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006062 }
6063
6064 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006065 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006066 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006067 * activities that provide <em>all</em> of the requested categories will be
6068 * used.
6069 *
6070 * @param category The desired category. This can be either one of the
6071 * predefined Intent categories, or a custom category in your own
6072 * namespace.
6073 *
6074 * @return Returns the same Intent object, for chaining multiple calls
6075 * into a single statement.
6076 *
6077 * @see #hasCategory
6078 * @see #removeCategory
6079 */
6080 public Intent addCategory(String category) {
6081 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006082 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006083 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006084 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006085 return this;
6086 }
6087
6088 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006089 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006090 *
6091 * @param category The category to remove.
6092 *
6093 * @see #addCategory
6094 */
6095 public void removeCategory(String category) {
6096 if (mCategories != null) {
6097 mCategories.remove(category);
6098 if (mCategories.size() == 0) {
6099 mCategories = null;
6100 }
6101 }
6102 }
6103
6104 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006105 * Set a selector for this Intent. This is a modification to the kinds of
6106 * things the Intent will match. If the selector is set, it will be used
6107 * when trying to find entities that can handle the Intent, instead of the
6108 * main contents of the Intent. This allows you build an Intent containing
6109 * a generic protocol while targeting it more specifically.
6110 *
6111 * <p>An example of where this may be used is with things like
6112 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6113 * Intent that will launch the Browser application. However, the correct
6114 * main entry point of an application is actually {@link #ACTION_MAIN}
6115 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6116 * used to specify the actual Activity to launch. If you launch the browser
6117 * with something different, undesired behavior may happen if the user has
6118 * previously or later launches it the normal way, since they do not match.
6119 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6120 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6121 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6122 *
6123 * <p>Setting a selector does not impact the behavior of
6124 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6125 * desired behavior of a selector -- it does not impact the base meaning
6126 * of the Intent, just what kinds of things will be matched against it
6127 * when determining who can handle it.</p>
6128 *
6129 * <p>You can not use both a selector and {@link #setPackage(String)} on
6130 * the same base Intent.</p>
6131 *
6132 * @param selector The desired selector Intent; set to null to not use
6133 * a special selector.
6134 */
6135 public void setSelector(Intent selector) {
6136 if (selector == this) {
6137 throw new IllegalArgumentException(
6138 "Intent being set as a selector of itself");
6139 }
6140 if (selector != null && mPackage != null) {
6141 throw new IllegalArgumentException(
6142 "Can't set selector when package name is already set");
6143 }
6144 mSelector = selector;
6145 }
6146
6147 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006148 * Set a {@link ClipData} associated with this Intent. This replaces any
6149 * previously set ClipData.
6150 *
6151 * <p>The ClipData in an intent is not used for Intent matching or other
6152 * such operations. Semantically it is like extras, used to transmit
6153 * additional data with the Intent. The main feature of using this over
6154 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6155 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6156 * items included in the clip data. This is useful, in particular, if
6157 * you want to transmit an Intent containing multiple <code>content:</code>
6158 * URIs for which the recipient may not have global permission to access the
6159 * content provider.
6160 *
6161 * <p>If the ClipData contains items that are themselves Intents, any
6162 * grant flags in those Intents will be ignored. Only the top-level flags
6163 * of the main Intent are respected, and will be applied to all Uri or
6164 * Intent items in the clip (or sub-items of the clip).
6165 *
6166 * <p>The MIME type, label, and icon in the ClipData object are not
6167 * directly used by Intent. Applications should generally rely on the
6168 * MIME type of the Intent itself, not what it may find in the ClipData.
6169 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006170 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006171 *
6172 * @param clip The new clip to set. May be null to clear the current clip.
6173 */
6174 public void setClipData(ClipData clip) {
6175 mClipData = clip;
6176 }
6177
6178 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006179 * This is NOT a secure mechanism to identify the user who sent the intent.
6180 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6181 * who sent the intent.
6182 * @hide
6183 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01006184 public void prepareToLeaveUser(int userId) {
6185 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
6186 // We want mContentUserHint to refer to the original user, so don't do anything.
6187 if (mContentUserHint == UserHandle.USER_CURRENT) {
6188 mContentUserHint = userId;
6189 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006190 }
6191
6192 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006193 * Add extended data to the intent. The name must include a package
6194 * prefix, for example the app com.android.contacts would use names
6195 * like "com.android.contacts.ShowAll".
6196 *
6197 * @param name The name of the extra data, with package prefix.
6198 * @param value The boolean data value.
6199 *
6200 * @return Returns the same Intent object, for chaining multiple calls
6201 * into a single statement.
6202 *
6203 * @see #putExtras
6204 * @see #removeExtra
6205 * @see #getBooleanExtra(String, boolean)
6206 */
6207 public Intent putExtra(String name, boolean value) {
6208 if (mExtras == null) {
6209 mExtras = new Bundle();
6210 }
6211 mExtras.putBoolean(name, value);
6212 return this;
6213 }
6214
6215 /**
6216 * Add extended data to the intent. The name must include a package
6217 * prefix, for example the app com.android.contacts would use names
6218 * like "com.android.contacts.ShowAll".
6219 *
6220 * @param name The name of the extra data, with package prefix.
6221 * @param value The byte data value.
6222 *
6223 * @return Returns the same Intent object, for chaining multiple calls
6224 * into a single statement.
6225 *
6226 * @see #putExtras
6227 * @see #removeExtra
6228 * @see #getByteExtra(String, byte)
6229 */
6230 public Intent putExtra(String name, byte value) {
6231 if (mExtras == null) {
6232 mExtras = new Bundle();
6233 }
6234 mExtras.putByte(name, value);
6235 return this;
6236 }
6237
6238 /**
6239 * Add extended data to the intent. The name must include a package
6240 * prefix, for example the app com.android.contacts would use names
6241 * like "com.android.contacts.ShowAll".
6242 *
6243 * @param name The name of the extra data, with package prefix.
6244 * @param value The char data value.
6245 *
6246 * @return Returns the same Intent object, for chaining multiple calls
6247 * into a single statement.
6248 *
6249 * @see #putExtras
6250 * @see #removeExtra
6251 * @see #getCharExtra(String, char)
6252 */
6253 public Intent putExtra(String name, char value) {
6254 if (mExtras == null) {
6255 mExtras = new Bundle();
6256 }
6257 mExtras.putChar(name, value);
6258 return this;
6259 }
6260
6261 /**
6262 * Add extended data to the intent. The name must include a package
6263 * prefix, for example the app com.android.contacts would use names
6264 * like "com.android.contacts.ShowAll".
6265 *
6266 * @param name The name of the extra data, with package prefix.
6267 * @param value The short data value.
6268 *
6269 * @return Returns the same Intent object, for chaining multiple calls
6270 * into a single statement.
6271 *
6272 * @see #putExtras
6273 * @see #removeExtra
6274 * @see #getShortExtra(String, short)
6275 */
6276 public Intent putExtra(String name, short value) {
6277 if (mExtras == null) {
6278 mExtras = new Bundle();
6279 }
6280 mExtras.putShort(name, value);
6281 return this;
6282 }
6283
6284 /**
6285 * Add extended data to the intent. The name must include a package
6286 * prefix, for example the app com.android.contacts would use names
6287 * like "com.android.contacts.ShowAll".
6288 *
6289 * @param name The name of the extra data, with package prefix.
6290 * @param value The integer data value.
6291 *
6292 * @return Returns the same Intent object, for chaining multiple calls
6293 * into a single statement.
6294 *
6295 * @see #putExtras
6296 * @see #removeExtra
6297 * @see #getIntExtra(String, int)
6298 */
6299 public Intent putExtra(String name, int value) {
6300 if (mExtras == null) {
6301 mExtras = new Bundle();
6302 }
6303 mExtras.putInt(name, value);
6304 return this;
6305 }
6306
6307 /**
6308 * Add extended data to the intent. The name must include a package
6309 * prefix, for example the app com.android.contacts would use names
6310 * like "com.android.contacts.ShowAll".
6311 *
6312 * @param name The name of the extra data, with package prefix.
6313 * @param value The long data value.
6314 *
6315 * @return Returns the same Intent object, for chaining multiple calls
6316 * into a single statement.
6317 *
6318 * @see #putExtras
6319 * @see #removeExtra
6320 * @see #getLongExtra(String, long)
6321 */
6322 public Intent putExtra(String name, long value) {
6323 if (mExtras == null) {
6324 mExtras = new Bundle();
6325 }
6326 mExtras.putLong(name, value);
6327 return this;
6328 }
6329
6330 /**
6331 * Add extended data to the intent. The name must include a package
6332 * prefix, for example the app com.android.contacts would use names
6333 * like "com.android.contacts.ShowAll".
6334 *
6335 * @param name The name of the extra data, with package prefix.
6336 * @param value The float data value.
6337 *
6338 * @return Returns the same Intent object, for chaining multiple calls
6339 * into a single statement.
6340 *
6341 * @see #putExtras
6342 * @see #removeExtra
6343 * @see #getFloatExtra(String, float)
6344 */
6345 public Intent putExtra(String name, float value) {
6346 if (mExtras == null) {
6347 mExtras = new Bundle();
6348 }
6349 mExtras.putFloat(name, value);
6350 return this;
6351 }
6352
6353 /**
6354 * Add extended data to the intent. The name must include a package
6355 * prefix, for example the app com.android.contacts would use names
6356 * like "com.android.contacts.ShowAll".
6357 *
6358 * @param name The name of the extra data, with package prefix.
6359 * @param value The double data value.
6360 *
6361 * @return Returns the same Intent object, for chaining multiple calls
6362 * into a single statement.
6363 *
6364 * @see #putExtras
6365 * @see #removeExtra
6366 * @see #getDoubleExtra(String, double)
6367 */
6368 public Intent putExtra(String name, double value) {
6369 if (mExtras == null) {
6370 mExtras = new Bundle();
6371 }
6372 mExtras.putDouble(name, value);
6373 return this;
6374 }
6375
6376 /**
6377 * Add extended data to the intent. The name must include a package
6378 * prefix, for example the app com.android.contacts would use names
6379 * like "com.android.contacts.ShowAll".
6380 *
6381 * @param name The name of the extra data, with package prefix.
6382 * @param value The String data value.
6383 *
6384 * @return Returns the same Intent object, for chaining multiple calls
6385 * into a single statement.
6386 *
6387 * @see #putExtras
6388 * @see #removeExtra
6389 * @see #getStringExtra(String)
6390 */
6391 public Intent putExtra(String name, String value) {
6392 if (mExtras == null) {
6393 mExtras = new Bundle();
6394 }
6395 mExtras.putString(name, value);
6396 return this;
6397 }
6398
6399 /**
6400 * Add extended data to the intent. The name must include a package
6401 * prefix, for example the app com.android.contacts would use names
6402 * like "com.android.contacts.ShowAll".
6403 *
6404 * @param name The name of the extra data, with package prefix.
6405 * @param value The CharSequence data value.
6406 *
6407 * @return Returns the same Intent object, for chaining multiple calls
6408 * into a single statement.
6409 *
6410 * @see #putExtras
6411 * @see #removeExtra
6412 * @see #getCharSequenceExtra(String)
6413 */
6414 public Intent putExtra(String name, CharSequence value) {
6415 if (mExtras == null) {
6416 mExtras = new Bundle();
6417 }
6418 mExtras.putCharSequence(name, value);
6419 return this;
6420 }
6421
6422 /**
6423 * Add extended data to the intent. The name must include a package
6424 * prefix, for example the app com.android.contacts would use names
6425 * like "com.android.contacts.ShowAll".
6426 *
6427 * @param name The name of the extra data, with package prefix.
6428 * @param value The Parcelable data value.
6429 *
6430 * @return Returns the same Intent object, for chaining multiple calls
6431 * into a single statement.
6432 *
6433 * @see #putExtras
6434 * @see #removeExtra
6435 * @see #getParcelableExtra(String)
6436 */
6437 public Intent putExtra(String name, Parcelable value) {
6438 if (mExtras == null) {
6439 mExtras = new Bundle();
6440 }
6441 mExtras.putParcelable(name, value);
6442 return this;
6443 }
6444
6445 /**
6446 * Add extended data to the intent. The name must include a package
6447 * prefix, for example the app com.android.contacts would use names
6448 * like "com.android.contacts.ShowAll".
6449 *
6450 * @param name The name of the extra data, with package prefix.
6451 * @param value The Parcelable[] data value.
6452 *
6453 * @return Returns the same Intent object, for chaining multiple calls
6454 * into a single statement.
6455 *
6456 * @see #putExtras
6457 * @see #removeExtra
6458 * @see #getParcelableArrayExtra(String)
6459 */
6460 public Intent putExtra(String name, Parcelable[] value) {
6461 if (mExtras == null) {
6462 mExtras = new Bundle();
6463 }
6464 mExtras.putParcelableArray(name, value);
6465 return this;
6466 }
6467
6468 /**
6469 * Add extended data to the intent. The name must include a package
6470 * prefix, for example the app com.android.contacts would use names
6471 * like "com.android.contacts.ShowAll".
6472 *
6473 * @param name The name of the extra data, with package prefix.
6474 * @param value The ArrayList<Parcelable> data value.
6475 *
6476 * @return Returns the same Intent object, for chaining multiple calls
6477 * into a single statement.
6478 *
6479 * @see #putExtras
6480 * @see #removeExtra
6481 * @see #getParcelableArrayListExtra(String)
6482 */
6483 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
6484 if (mExtras == null) {
6485 mExtras = new Bundle();
6486 }
6487 mExtras.putParcelableArrayList(name, value);
6488 return this;
6489 }
6490
6491 /**
6492 * Add extended data to the intent. The name must include a package
6493 * prefix, for example the app com.android.contacts would use names
6494 * like "com.android.contacts.ShowAll".
6495 *
6496 * @param name The name of the extra data, with package prefix.
6497 * @param value The ArrayList<Integer> data value.
6498 *
6499 * @return Returns the same Intent object, for chaining multiple calls
6500 * into a single statement.
6501 *
6502 * @see #putExtras
6503 * @see #removeExtra
6504 * @see #getIntegerArrayListExtra(String)
6505 */
6506 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6507 if (mExtras == null) {
6508 mExtras = new Bundle();
6509 }
6510 mExtras.putIntegerArrayList(name, value);
6511 return this;
6512 }
6513
6514 /**
6515 * Add extended data to the intent. The name must include a package
6516 * prefix, for example the app com.android.contacts would use names
6517 * like "com.android.contacts.ShowAll".
6518 *
6519 * @param name The name of the extra data, with package prefix.
6520 * @param value The ArrayList<String> data value.
6521 *
6522 * @return Returns the same Intent object, for chaining multiple calls
6523 * into a single statement.
6524 *
6525 * @see #putExtras
6526 * @see #removeExtra
6527 * @see #getStringArrayListExtra(String)
6528 */
6529 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6530 if (mExtras == null) {
6531 mExtras = new Bundle();
6532 }
6533 mExtras.putStringArrayList(name, value);
6534 return this;
6535 }
6536
6537 /**
6538 * Add extended data to the intent. The name must include a package
6539 * prefix, for example the app com.android.contacts would use names
6540 * like "com.android.contacts.ShowAll".
6541 *
6542 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006543 * @param value The ArrayList<CharSequence> data value.
6544 *
6545 * @return Returns the same Intent object, for chaining multiple calls
6546 * into a single statement.
6547 *
6548 * @see #putExtras
6549 * @see #removeExtra
6550 * @see #getCharSequenceArrayListExtra(String)
6551 */
6552 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6553 if (mExtras == null) {
6554 mExtras = new Bundle();
6555 }
6556 mExtras.putCharSequenceArrayList(name, value);
6557 return this;
6558 }
6559
6560 /**
6561 * Add extended data to the intent. The name must include a package
6562 * prefix, for example the app com.android.contacts would use names
6563 * like "com.android.contacts.ShowAll".
6564 *
6565 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006566 * @param value The Serializable data value.
6567 *
6568 * @return Returns the same Intent object, for chaining multiple calls
6569 * into a single statement.
6570 *
6571 * @see #putExtras
6572 * @see #removeExtra
6573 * @see #getSerializableExtra(String)
6574 */
6575 public Intent putExtra(String name, Serializable value) {
6576 if (mExtras == null) {
6577 mExtras = new Bundle();
6578 }
6579 mExtras.putSerializable(name, value);
6580 return this;
6581 }
6582
6583 /**
6584 * Add extended data to the intent. The name must include a package
6585 * prefix, for example the app com.android.contacts would use names
6586 * like "com.android.contacts.ShowAll".
6587 *
6588 * @param name The name of the extra data, with package prefix.
6589 * @param value The boolean array data value.
6590 *
6591 * @return Returns the same Intent object, for chaining multiple calls
6592 * into a single statement.
6593 *
6594 * @see #putExtras
6595 * @see #removeExtra
6596 * @see #getBooleanArrayExtra(String)
6597 */
6598 public Intent putExtra(String name, boolean[] value) {
6599 if (mExtras == null) {
6600 mExtras = new Bundle();
6601 }
6602 mExtras.putBooleanArray(name, value);
6603 return this;
6604 }
6605
6606 /**
6607 * Add extended data to the intent. The name must include a package
6608 * prefix, for example the app com.android.contacts would use names
6609 * like "com.android.contacts.ShowAll".
6610 *
6611 * @param name The name of the extra data, with package prefix.
6612 * @param value The byte array data value.
6613 *
6614 * @return Returns the same Intent object, for chaining multiple calls
6615 * into a single statement.
6616 *
6617 * @see #putExtras
6618 * @see #removeExtra
6619 * @see #getByteArrayExtra(String)
6620 */
6621 public Intent putExtra(String name, byte[] value) {
6622 if (mExtras == null) {
6623 mExtras = new Bundle();
6624 }
6625 mExtras.putByteArray(name, value);
6626 return this;
6627 }
6628
6629 /**
6630 * Add extended data to the intent. The name must include a package
6631 * prefix, for example the app com.android.contacts would use names
6632 * like "com.android.contacts.ShowAll".
6633 *
6634 * @param name The name of the extra data, with package prefix.
6635 * @param value The short array data value.
6636 *
6637 * @return Returns the same Intent object, for chaining multiple calls
6638 * into a single statement.
6639 *
6640 * @see #putExtras
6641 * @see #removeExtra
6642 * @see #getShortArrayExtra(String)
6643 */
6644 public Intent putExtra(String name, short[] value) {
6645 if (mExtras == null) {
6646 mExtras = new Bundle();
6647 }
6648 mExtras.putShortArray(name, value);
6649 return this;
6650 }
6651
6652 /**
6653 * Add extended data to the intent. The name must include a package
6654 * prefix, for example the app com.android.contacts would use names
6655 * like "com.android.contacts.ShowAll".
6656 *
6657 * @param name The name of the extra data, with package prefix.
6658 * @param value The char array data value.
6659 *
6660 * @return Returns the same Intent object, for chaining multiple calls
6661 * into a single statement.
6662 *
6663 * @see #putExtras
6664 * @see #removeExtra
6665 * @see #getCharArrayExtra(String)
6666 */
6667 public Intent putExtra(String name, char[] value) {
6668 if (mExtras == null) {
6669 mExtras = new Bundle();
6670 }
6671 mExtras.putCharArray(name, value);
6672 return this;
6673 }
6674
6675 /**
6676 * Add extended data to the intent. The name must include a package
6677 * prefix, for example the app com.android.contacts would use names
6678 * like "com.android.contacts.ShowAll".
6679 *
6680 * @param name The name of the extra data, with package prefix.
6681 * @param value The int array data value.
6682 *
6683 * @return Returns the same Intent object, for chaining multiple calls
6684 * into a single statement.
6685 *
6686 * @see #putExtras
6687 * @see #removeExtra
6688 * @see #getIntArrayExtra(String)
6689 */
6690 public Intent putExtra(String name, int[] value) {
6691 if (mExtras == null) {
6692 mExtras = new Bundle();
6693 }
6694 mExtras.putIntArray(name, value);
6695 return this;
6696 }
6697
6698 /**
6699 * Add extended data to the intent. The name must include a package
6700 * prefix, for example the app com.android.contacts would use names
6701 * like "com.android.contacts.ShowAll".
6702 *
6703 * @param name The name of the extra data, with package prefix.
6704 * @param value The byte array data value.
6705 *
6706 * @return Returns the same Intent object, for chaining multiple calls
6707 * into a single statement.
6708 *
6709 * @see #putExtras
6710 * @see #removeExtra
6711 * @see #getLongArrayExtra(String)
6712 */
6713 public Intent putExtra(String name, long[] value) {
6714 if (mExtras == null) {
6715 mExtras = new Bundle();
6716 }
6717 mExtras.putLongArray(name, value);
6718 return this;
6719 }
6720
6721 /**
6722 * Add extended data to the intent. The name must include a package
6723 * prefix, for example the app com.android.contacts would use names
6724 * like "com.android.contacts.ShowAll".
6725 *
6726 * @param name The name of the extra data, with package prefix.
6727 * @param value The float array data value.
6728 *
6729 * @return Returns the same Intent object, for chaining multiple calls
6730 * into a single statement.
6731 *
6732 * @see #putExtras
6733 * @see #removeExtra
6734 * @see #getFloatArrayExtra(String)
6735 */
6736 public Intent putExtra(String name, float[] value) {
6737 if (mExtras == null) {
6738 mExtras = new Bundle();
6739 }
6740 mExtras.putFloatArray(name, value);
6741 return this;
6742 }
6743
6744 /**
6745 * Add extended data to the intent. The name must include a package
6746 * prefix, for example the app com.android.contacts would use names
6747 * like "com.android.contacts.ShowAll".
6748 *
6749 * @param name The name of the extra data, with package prefix.
6750 * @param value The double array data value.
6751 *
6752 * @return Returns the same Intent object, for chaining multiple calls
6753 * into a single statement.
6754 *
6755 * @see #putExtras
6756 * @see #removeExtra
6757 * @see #getDoubleArrayExtra(String)
6758 */
6759 public Intent putExtra(String name, double[] value) {
6760 if (mExtras == null) {
6761 mExtras = new Bundle();
6762 }
6763 mExtras.putDoubleArray(name, value);
6764 return this;
6765 }
6766
6767 /**
6768 * Add extended data to the intent. The name must include a package
6769 * prefix, for example the app com.android.contacts would use names
6770 * like "com.android.contacts.ShowAll".
6771 *
6772 * @param name The name of the extra data, with package prefix.
6773 * @param value The String array data value.
6774 *
6775 * @return Returns the same Intent object, for chaining multiple calls
6776 * into a single statement.
6777 *
6778 * @see #putExtras
6779 * @see #removeExtra
6780 * @see #getStringArrayExtra(String)
6781 */
6782 public Intent putExtra(String name, String[] value) {
6783 if (mExtras == null) {
6784 mExtras = new Bundle();
6785 }
6786 mExtras.putStringArray(name, value);
6787 return this;
6788 }
6789
6790 /**
6791 * Add extended data to the intent. The name must include a package
6792 * prefix, for example the app com.android.contacts would use names
6793 * like "com.android.contacts.ShowAll".
6794 *
6795 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006796 * @param value The CharSequence array data value.
6797 *
6798 * @return Returns the same Intent object, for chaining multiple calls
6799 * into a single statement.
6800 *
6801 * @see #putExtras
6802 * @see #removeExtra
6803 * @see #getCharSequenceArrayExtra(String)
6804 */
6805 public Intent putExtra(String name, CharSequence[] value) {
6806 if (mExtras == null) {
6807 mExtras = new Bundle();
6808 }
6809 mExtras.putCharSequenceArray(name, value);
6810 return this;
6811 }
6812
6813 /**
6814 * Add extended data to the intent. The name must include a package
6815 * prefix, for example the app com.android.contacts would use names
6816 * like "com.android.contacts.ShowAll".
6817 *
6818 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006819 * @param value The Bundle data value.
6820 *
6821 * @return Returns the same Intent object, for chaining multiple calls
6822 * into a single statement.
6823 *
6824 * @see #putExtras
6825 * @see #removeExtra
6826 * @see #getBundleExtra(String)
6827 */
6828 public Intent putExtra(String name, Bundle value) {
6829 if (mExtras == null) {
6830 mExtras = new Bundle();
6831 }
6832 mExtras.putBundle(name, value);
6833 return this;
6834 }
6835
6836 /**
6837 * Add extended data to the intent. The name must include a package
6838 * prefix, for example the app com.android.contacts would use names
6839 * like "com.android.contacts.ShowAll".
6840 *
6841 * @param name The name of the extra data, with package prefix.
6842 * @param value The IBinder data value.
6843 *
6844 * @return Returns the same Intent object, for chaining multiple calls
6845 * into a single statement.
6846 *
6847 * @see #putExtras
6848 * @see #removeExtra
6849 * @see #getIBinderExtra(String)
6850 *
6851 * @deprecated
6852 * @hide
6853 */
6854 @Deprecated
6855 public Intent putExtra(String name, IBinder value) {
6856 if (mExtras == null) {
6857 mExtras = new Bundle();
6858 }
6859 mExtras.putIBinder(name, value);
6860 return this;
6861 }
6862
6863 /**
6864 * Copy all extras in 'src' in to this intent.
6865 *
6866 * @param src Contains the extras to copy.
6867 *
6868 * @see #putExtra
6869 */
6870 public Intent putExtras(Intent src) {
6871 if (src.mExtras != null) {
6872 if (mExtras == null) {
6873 mExtras = new Bundle(src.mExtras);
6874 } else {
6875 mExtras.putAll(src.mExtras);
6876 }
6877 }
6878 return this;
6879 }
6880
6881 /**
6882 * Add a set of extended data to the intent. The keys must include a package
6883 * prefix, for example the app com.android.contacts would use names
6884 * like "com.android.contacts.ShowAll".
6885 *
6886 * @param extras The Bundle of extras to add to this intent.
6887 *
6888 * @see #putExtra
6889 * @see #removeExtra
6890 */
6891 public Intent putExtras(Bundle extras) {
6892 if (mExtras == null) {
6893 mExtras = new Bundle();
6894 }
6895 mExtras.putAll(extras);
6896 return this;
6897 }
6898
6899 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006900 * Completely replace the extras in the Intent with the extras in the
6901 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006902 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006903 * @param src The exact extras contained in this Intent are copied
6904 * into the target intent, replacing any that were previously there.
6905 */
6906 public Intent replaceExtras(Intent src) {
6907 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6908 return this;
6909 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006910
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006911 /**
6912 * Completely replace the extras in the Intent with the given Bundle of
6913 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006914 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006915 * @param extras The new set of extras in the Intent, or null to erase
6916 * all extras.
6917 */
6918 public Intent replaceExtras(Bundle extras) {
6919 mExtras = extras != null ? new Bundle(extras) : null;
6920 return this;
6921 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006922
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006923 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006924 * Remove extended data from the intent.
6925 *
6926 * @see #putExtra
6927 */
6928 public void removeExtra(String name) {
6929 if (mExtras != null) {
6930 mExtras.remove(name);
6931 if (mExtras.size() == 0) {
6932 mExtras = null;
6933 }
6934 }
6935 }
6936
6937 /**
6938 * Set special flags controlling how this intent is handled. Most values
6939 * here depend on the type of component being executed by the Intent,
6940 * specifically the FLAG_ACTIVITY_* flags are all for use with
6941 * {@link Context#startActivity Context.startActivity()} and the
6942 * FLAG_RECEIVER_* flags are all for use with
6943 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6944 *
Scott Main7aee61f2011-02-08 11:25:01 -08006945 * <p>See the
6946 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6947 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006948 * the behavior of your application.
6949 *
6950 * @param flags The desired flags.
6951 *
6952 * @return Returns the same Intent object, for chaining multiple calls
6953 * into a single statement.
6954 *
6955 * @see #getFlags
6956 * @see #addFlags
6957 *
6958 * @see #FLAG_GRANT_READ_URI_PERMISSION
6959 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006960 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6961 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006962 * @see #FLAG_DEBUG_LOG_RESOLUTION
6963 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006964 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006965 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006966 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006967 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006968 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6969 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006970 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006971 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006972 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006973 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006974 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006975 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006976 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006977 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6978 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006979 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006980 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006981 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006982 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6983 */
6984 public Intent setFlags(int flags) {
6985 mFlags = flags;
6986 return this;
6987 }
6988
6989 /**
6990 * Add additional flags to the intent (or with existing flags
6991 * value).
6992 *
6993 * @param flags The new flags to set.
6994 *
6995 * @return Returns the same Intent object, for chaining multiple calls
6996 * into a single statement.
6997 *
6998 * @see #setFlags
6999 */
7000 public Intent addFlags(int flags) {
7001 mFlags |= flags;
7002 return this;
7003 }
7004
7005 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007006 * (Usually optional) Set an explicit application package name that limits
7007 * the components this Intent will resolve to. If left to the default
7008 * value of null, all components in all applications will considered.
7009 * If non-null, the Intent can only match the components in the given
7010 * application package.
7011 *
7012 * @param packageName The name of the application package to handle the
7013 * intent, or null to allow any application package.
7014 *
7015 * @return Returns the same Intent object, for chaining multiple calls
7016 * into a single statement.
7017 *
7018 * @see #getPackage
7019 * @see #resolveActivity
7020 */
7021 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007022 if (packageName != null && mSelector != null) {
7023 throw new IllegalArgumentException(
7024 "Can't set package name when selector is already set");
7025 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007026 mPackage = packageName;
7027 return this;
7028 }
7029
7030 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007031 * (Usually optional) Explicitly set the component to handle the intent.
7032 * If left with the default value of null, the system will determine the
7033 * appropriate class to use based on the other fields (action, data,
7034 * type, categories) in the Intent. If this class is defined, the
7035 * specified class will always be used regardless of the other fields. You
7036 * should only set this value when you know you absolutely want a specific
7037 * class to be used; otherwise it is better to let the system find the
7038 * appropriate class so that you will respect the installed applications
7039 * and user preferences.
7040 *
7041 * @param component The name of the application component to handle the
7042 * intent, or null to let the system find one for you.
7043 *
7044 * @return Returns the same Intent object, for chaining multiple calls
7045 * into a single statement.
7046 *
7047 * @see #setClass
7048 * @see #setClassName(Context, String)
7049 * @see #setClassName(String, String)
7050 * @see #getComponent
7051 * @see #resolveActivity
7052 */
7053 public Intent setComponent(ComponentName component) {
7054 mComponent = component;
7055 return this;
7056 }
7057
7058 /**
7059 * Convenience for calling {@link #setComponent} with an
7060 * explicit class name.
7061 *
7062 * @param packageContext A Context of the application package implementing
7063 * this class.
7064 * @param className The name of a class inside of the application package
7065 * that will be used as the component for this Intent.
7066 *
7067 * @return Returns the same Intent object, for chaining multiple calls
7068 * into a single statement.
7069 *
7070 * @see #setComponent
7071 * @see #setClass
7072 */
7073 public Intent setClassName(Context packageContext, String className) {
7074 mComponent = new ComponentName(packageContext, className);
7075 return this;
7076 }
7077
7078 /**
7079 * Convenience for calling {@link #setComponent} with an
7080 * explicit application package name and class name.
7081 *
7082 * @param packageName The name of the package implementing the desired
7083 * component.
7084 * @param className The name of a class inside of the application package
7085 * that will be used as the component for this Intent.
7086 *
7087 * @return Returns the same Intent object, for chaining multiple calls
7088 * into a single statement.
7089 *
7090 * @see #setComponent
7091 * @see #setClass
7092 */
7093 public Intent setClassName(String packageName, String className) {
7094 mComponent = new ComponentName(packageName, className);
7095 return this;
7096 }
7097
7098 /**
7099 * Convenience for calling {@link #setComponent(ComponentName)} with the
7100 * name returned by a {@link Class} object.
7101 *
7102 * @param packageContext A Context of the application package implementing
7103 * this class.
7104 * @param cls The class name to set, equivalent to
7105 * <code>setClassName(context, cls.getName())</code>.
7106 *
7107 * @return Returns the same Intent object, for chaining multiple calls
7108 * into a single statement.
7109 *
7110 * @see #setComponent
7111 */
7112 public Intent setClass(Context packageContext, Class<?> cls) {
7113 mComponent = new ComponentName(packageContext, cls);
7114 return this;
7115 }
7116
7117 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007118 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7119 * used as a hint to the receiver for animations and the like. Null means that there
7120 * is no source bounds.
7121 */
7122 public void setSourceBounds(Rect r) {
7123 if (r != null) {
7124 mSourceBounds = new Rect(r);
7125 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007126 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007127 }
7128 }
7129
Tor Norbyed9273d62013-05-30 15:59:53 -07007130 /** @hide */
7131 @IntDef(flag = true,
7132 value = {
7133 FILL_IN_ACTION,
7134 FILL_IN_DATA,
7135 FILL_IN_CATEGORIES,
7136 FILL_IN_COMPONENT,
7137 FILL_IN_PACKAGE,
7138 FILL_IN_SOURCE_BOUNDS,
7139 FILL_IN_SELECTOR,
7140 FILL_IN_CLIP_DATA
7141 })
7142 @Retention(RetentionPolicy.SOURCE)
7143 public @interface FillInFlags {}
7144
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007145 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007146 * Use with {@link #fillIn} to allow the current action value to be
7147 * overwritten, even if it is already set.
7148 */
7149 public static final int FILL_IN_ACTION = 1<<0;
7150
7151 /**
7152 * Use with {@link #fillIn} to allow the current data or type value
7153 * overwritten, even if it is already set.
7154 */
7155 public static final int FILL_IN_DATA = 1<<1;
7156
7157 /**
7158 * Use with {@link #fillIn} to allow the current categories to be
7159 * overwritten, even if they are already set.
7160 */
7161 public static final int FILL_IN_CATEGORIES = 1<<2;
7162
7163 /**
7164 * Use with {@link #fillIn} to allow the current component value to be
7165 * overwritten, even if it is already set.
7166 */
7167 public static final int FILL_IN_COMPONENT = 1<<3;
7168
7169 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007170 * Use with {@link #fillIn} to allow the current package value to be
7171 * overwritten, even if it is already set.
7172 */
7173 public static final int FILL_IN_PACKAGE = 1<<4;
7174
7175 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007176 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007177 * overwritten, even if it is already set.
7178 */
7179 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7180
7181 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007182 * Use with {@link #fillIn} to allow the current selector to be
7183 * overwritten, even if it is already set.
7184 */
7185 public static final int FILL_IN_SELECTOR = 1<<6;
7186
7187 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007188 * Use with {@link #fillIn} to allow the current ClipData to be
7189 * overwritten, even if it is already set.
7190 */
7191 public static final int FILL_IN_CLIP_DATA = 1<<7;
7192
7193 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007194 * Copy the contents of <var>other</var> in to this object, but only
7195 * where fields are not defined by this object. For purposes of a field
7196 * being defined, the following pieces of data in the Intent are
7197 * considered to be separate fields:
7198 *
7199 * <ul>
7200 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007201 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007202 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7203 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007204 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007205 * <li> component, as set by {@link #setComponent(ComponentName)} or
7206 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007207 * <li> source bounds, as set by {@link #setSourceBounds}.
7208 * <li> selector, as set by {@link #setSelector(Intent)}.
7209 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007210 * <li> each top-level name in the associated extras.
7211 * </ul>
7212 *
7213 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007214 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007215 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7216 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7217 * the restriction where the corresponding field will not be replaced if
7218 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007219 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007220 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7221 * is explicitly specified. The selector will only be copied if
7222 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007223 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007224 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7225 * and Intent B with {action="gotit", data-type="some/thing",
7226 * categories="one","two"}.
7227 *
7228 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7229 * containing: {action="gotit", data-type="some/thing",
7230 * categories="bar"}.
7231 *
7232 * @param other Another Intent whose values are to be used to fill in
7233 * the current one.
7234 * @param flags Options to control which fields can be filled in.
7235 *
7236 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007237 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007238 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7239 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7240 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007241 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007242 @FillInFlags
7243 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007244 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007245 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007246 if (other.mAction != null
7247 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007248 mAction = other.mAction;
7249 changes |= FILL_IN_ACTION;
7250 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007251 if ((other.mData != null || other.mType != null)
7252 && ((mData == null && mType == null)
7253 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007254 mData = other.mData;
7255 mType = other.mType;
7256 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007257 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007258 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007259 if (other.mCategories != null
7260 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007261 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007262 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007263 }
7264 changes |= FILL_IN_CATEGORIES;
7265 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007266 if (other.mPackage != null
7267 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007268 // Only do this if mSelector is not set.
7269 if (mSelector == null) {
7270 mPackage = other.mPackage;
7271 changes |= FILL_IN_PACKAGE;
7272 }
7273 }
7274 // Selector is special: it can only be set if explicitly allowed,
7275 // for the same reason as the component name.
7276 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7277 if (mPackage == null) {
7278 mSelector = new Intent(other.mSelector);
7279 mPackage = null;
7280 changes |= FILL_IN_SELECTOR;
7281 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007282 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007283 if (other.mClipData != null
7284 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7285 mClipData = other.mClipData;
7286 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007287 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007288 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007289 // Component is special: it can -only- be set if explicitly allowed,
7290 // since otherwise the sender could force the intent somewhere the
7291 // originator didn't intend.
7292 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007293 mComponent = other.mComponent;
7294 changes |= FILL_IN_COMPONENT;
7295 }
7296 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007297 if (other.mSourceBounds != null
7298 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7299 mSourceBounds = new Rect(other.mSourceBounds);
7300 changes |= FILL_IN_SOURCE_BOUNDS;
7301 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007302 if (mExtras == null) {
7303 if (other.mExtras != null) {
7304 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007305 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007306 }
7307 } else if (other.mExtras != null) {
7308 try {
7309 Bundle newb = new Bundle(other.mExtras);
7310 newb.putAll(mExtras);
7311 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007312 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007313 } catch (RuntimeException e) {
7314 // Modifying the extras can cause us to unparcel the contents
7315 // of the bundle, and if we do this in the system process that
7316 // may fail. We really should handle this (i.e., the Bundle
7317 // impl shouldn't be on top of a plain map), but for now just
7318 // ignore it and keep the original contents. :(
7319 Log.w("Intent", "Failure filling in extras", e);
7320 }
7321 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007322 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7323 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7324 mContentUserHint = other.mContentUserHint;
7325 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007326 return changes;
7327 }
7328
7329 /**
7330 * Wrapper class holding an Intent and implementing comparisons on it for
7331 * the purpose of filtering. The class implements its
7332 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7333 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7334 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7335 * on the wrapped Intent.
7336 */
7337 public static final class FilterComparison {
7338 private final Intent mIntent;
7339 private final int mHashCode;
7340
7341 public FilterComparison(Intent intent) {
7342 mIntent = intent;
7343 mHashCode = intent.filterHashCode();
7344 }
7345
7346 /**
7347 * Return the Intent that this FilterComparison represents.
7348 * @return Returns the Intent held by the FilterComparison. Do
7349 * not modify!
7350 */
7351 public Intent getIntent() {
7352 return mIntent;
7353 }
7354
7355 @Override
7356 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007357 if (obj instanceof FilterComparison) {
7358 Intent other = ((FilterComparison)obj).mIntent;
7359 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007360 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007361 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007362 }
7363
7364 @Override
7365 public int hashCode() {
7366 return mHashCode;
7367 }
7368 }
7369
7370 /**
7371 * Determine if two intents are the same for the purposes of intent
7372 * resolution (filtering). That is, if their action, data, type,
7373 * class, and categories are the same. This does <em>not</em> compare
7374 * any extra data included in the intents.
7375 *
7376 * @param other The other Intent to compare against.
7377 *
7378 * @return Returns true if action, data, type, class, and categories
7379 * are the same.
7380 */
7381 public boolean filterEquals(Intent other) {
7382 if (other == null) {
7383 return false;
7384 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007385 if (!Objects.equals(this.mAction, other.mAction)) return false;
7386 if (!Objects.equals(this.mData, other.mData)) return false;
7387 if (!Objects.equals(this.mType, other.mType)) return false;
7388 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7389 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7390 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007391
7392 return true;
7393 }
7394
7395 /**
7396 * Generate hash code that matches semantics of filterEquals().
7397 *
7398 * @return Returns the hash value of the action, data, type, class, and
7399 * categories.
7400 *
7401 * @see #filterEquals
7402 */
7403 public int filterHashCode() {
7404 int code = 0;
7405 if (mAction != null) {
7406 code += mAction.hashCode();
7407 }
7408 if (mData != null) {
7409 code += mData.hashCode();
7410 }
7411 if (mType != null) {
7412 code += mType.hashCode();
7413 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007414 if (mPackage != null) {
7415 code += mPackage.hashCode();
7416 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007417 if (mComponent != null) {
7418 code += mComponent.hashCode();
7419 }
7420 if (mCategories != null) {
7421 code += mCategories.hashCode();
7422 }
7423 return code;
7424 }
7425
7426 @Override
7427 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007428 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007429
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007430 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007431 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007432 b.append(" }");
7433
7434 return b.toString();
7435 }
7436
7437 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007438 public String toInsecureString() {
7439 StringBuilder b = new StringBuilder(128);
7440
7441 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007442 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007443 b.append(" }");
7444
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007445 return b.toString();
7446 }
Romain Guy4969af72009-06-17 10:53:19 -07007447
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007448 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007449 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007450 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007451
7452 b.append("Intent { ");
7453 toShortString(b, false, true, true, true);
7454 b.append(" }");
7455
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007456 return b.toString();
7457 }
7458
7459 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007460 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
7461 StringBuilder b = new StringBuilder(128);
7462 toShortString(b, secure, comp, extras, clip);
7463 return b.toString();
7464 }
7465
7466 /** @hide */
7467 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
7468 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007469 boolean first = true;
7470 if (mAction != null) {
7471 b.append("act=").append(mAction);
7472 first = false;
7473 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007474 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007475 if (!first) {
7476 b.append(' ');
7477 }
7478 first = false;
7479 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007480 for (int i=0; i<mCategories.size(); i++) {
7481 if (i > 0) b.append(',');
7482 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007483 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007484 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007485 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007486 if (mData != null) {
7487 if (!first) {
7488 b.append(' ');
7489 }
7490 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07007491 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007492 if (secure) {
7493 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007494 } else {
7495 b.append(mData);
7496 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007497 }
7498 if (mType != null) {
7499 if (!first) {
7500 b.append(' ');
7501 }
7502 first = false;
7503 b.append("typ=").append(mType);
7504 }
7505 if (mFlags != 0) {
7506 if (!first) {
7507 b.append(' ');
7508 }
7509 first = false;
7510 b.append("flg=0x").append(Integer.toHexString(mFlags));
7511 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007512 if (mPackage != null) {
7513 if (!first) {
7514 b.append(' ');
7515 }
7516 first = false;
7517 b.append("pkg=").append(mPackage);
7518 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007519 if (comp && mComponent != null) {
7520 if (!first) {
7521 b.append(' ');
7522 }
7523 first = false;
7524 b.append("cmp=").append(mComponent.flattenToShortString());
7525 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007526 if (mSourceBounds != null) {
7527 if (!first) {
7528 b.append(' ');
7529 }
7530 first = false;
7531 b.append("bnds=").append(mSourceBounds.toShortString());
7532 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007533 if (mClipData != null) {
7534 if (!first) {
7535 b.append(' ');
7536 }
7537 first = false;
7538 if (clip) {
7539 b.append("clip={");
7540 mClipData.toShortString(b);
7541 b.append('}');
7542 } else {
7543 b.append("(has clip)");
7544 }
7545 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007546 if (extras && mExtras != null) {
7547 if (!first) {
7548 b.append(' ');
7549 }
7550 first = false;
7551 b.append("(has extras)");
7552 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007553 if (mContentUserHint != UserHandle.USER_CURRENT) {
7554 if (!first) {
7555 b.append(' ');
7556 }
7557 first = false;
7558 b.append("u=").append(mContentUserHint);
7559 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007560 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007561 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007562 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007563 b.append("}");
7564 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007565 }
7566
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007567 /**
7568 * Call {@link #toUri} with 0 flags.
7569 * @deprecated Use {@link #toUri} instead.
7570 */
7571 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007572 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007573 return toUri(0);
7574 }
7575
7576 /**
7577 * Convert this Intent into a String holding a URI representation of it.
7578 * The returned URI string has been properly URI encoded, so it can be
7579 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7580 * Intent's data as the base URI, with an additional fragment describing
7581 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007582 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007583 * <p>You can convert the returned string back to an Intent with
7584 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007585 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007586 * @param flags Additional operating flags. Either 0,
7587 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007588 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007589 * @return Returns a URI encoding URI string describing the entire contents
7590 * of the Intent.
7591 */
7592 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007593 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007594 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
7595 if (mPackage == null) {
7596 throw new IllegalArgumentException(
7597 "Intent must include an explicit package name to build an android-app: "
7598 + this);
7599 }
7600 uri.append("android-app://");
7601 uri.append(mPackage);
7602 String scheme = null;
7603 if (mData != null) {
7604 scheme = mData.getScheme();
7605 if (scheme != null) {
7606 uri.append('/');
7607 uri.append(scheme);
7608 String authority = mData.getEncodedAuthority();
7609 if (authority != null) {
7610 uri.append('/');
7611 uri.append(authority);
7612 String path = mData.getEncodedPath();
7613 if (path != null) {
7614 uri.append(path);
7615 }
7616 String queryParams = mData.getEncodedQuery();
7617 if (queryParams != null) {
7618 uri.append('?');
7619 uri.append(queryParams);
7620 }
7621 String fragment = mData.getEncodedFragment();
7622 if (fragment != null) {
7623 uri.append('#');
7624 uri.append(fragment);
7625 }
7626 }
7627 }
7628 }
7629 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
7630 mPackage, flags);
7631 return uri.toString();
7632 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007633 String scheme = null;
7634 if (mData != null) {
7635 String data = mData.toString();
7636 if ((flags&URI_INTENT_SCHEME) != 0) {
7637 final int N = data.length();
7638 for (int i=0; i<N; i++) {
7639 char c = data.charAt(i);
7640 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7641 || c == '.' || c == '-') {
7642 continue;
7643 }
7644 if (c == ':' && i > 0) {
7645 // Valid scheme.
7646 scheme = data.substring(0, i);
7647 uri.append("intent:");
7648 data = data.substring(i+1);
7649 break;
7650 }
Tom Taylord4a47292009-12-21 13:59:18 -08007651
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007652 // No scheme.
7653 break;
7654 }
7655 }
7656 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007657
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007658 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7659 uri.append("intent:");
7660 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007661
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007662 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007663
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007664 return uri.toString();
7665 }
7666
7667 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
7668 String defPackage, int flags) {
7669 StringBuilder frag = new StringBuilder(128);
7670
7671 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007672 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08007673 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007674 // Note that for now we are not going to try to handle the
7675 // data part; not clear how to represent this as a URI, and
7676 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007677 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
7678 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007679 }
7680
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007681 if (frag.length() > 0) {
7682 uri.append("#Intent;");
7683 uri.append(frag);
7684 uri.append("end");
7685 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007686 }
7687
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007688 private void toUriInner(StringBuilder uri, String scheme, String defAction,
7689 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007690 if (scheme != null) {
7691 uri.append("scheme=").append(scheme).append(';');
7692 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007693 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007694 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007695 }
7696 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007697 for (int i=0; i<mCategories.size(); i++) {
7698 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007699 }
7700 }
7701 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007702 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007703 }
7704 if (mFlags != 0) {
7705 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7706 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08007707 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007708 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7709 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007710 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007711 uri.append("component=").append(Uri.encode(
7712 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007713 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007714 if (mSourceBounds != null) {
7715 uri.append("sourceBounds=")
7716 .append(Uri.encode(mSourceBounds.flattenToString()))
7717 .append(';');
7718 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007719 if (mExtras != null) {
7720 for (String key : mExtras.keySet()) {
7721 final Object value = mExtras.get(key);
7722 char entryType =
7723 value instanceof String ? 'S' :
7724 value instanceof Boolean ? 'B' :
7725 value instanceof Byte ? 'b' :
7726 value instanceof Character ? 'c' :
7727 value instanceof Double ? 'd' :
7728 value instanceof Float ? 'f' :
7729 value instanceof Integer ? 'i' :
7730 value instanceof Long ? 'l' :
7731 value instanceof Short ? 's' :
7732 '\0';
7733
7734 if (entryType != '\0') {
7735 uri.append(entryType);
7736 uri.append('.');
7737 uri.append(Uri.encode(key));
7738 uri.append('=');
7739 uri.append(Uri.encode(value.toString()));
7740 uri.append(';');
7741 }
7742 }
7743 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007744 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007745
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007746 public int describeContents() {
7747 return (mExtras != null) ? mExtras.describeContents() : 0;
7748 }
7749
7750 public void writeToParcel(Parcel out, int flags) {
7751 out.writeString(mAction);
7752 Uri.writeToParcel(out, mData);
7753 out.writeString(mType);
7754 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007755 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007756 ComponentName.writeToParcel(mComponent, out);
7757
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007758 if (mSourceBounds != null) {
7759 out.writeInt(1);
7760 mSourceBounds.writeToParcel(out, flags);
7761 } else {
7762 out.writeInt(0);
7763 }
7764
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007765 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007766 final int N = mCategories.size();
7767 out.writeInt(N);
7768 for (int i=0; i<N; i++) {
7769 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007770 }
7771 } else {
7772 out.writeInt(0);
7773 }
7774
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007775 if (mSelector != null) {
7776 out.writeInt(1);
7777 mSelector.writeToParcel(out, flags);
7778 } else {
7779 out.writeInt(0);
7780 }
7781
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007782 if (mClipData != null) {
7783 out.writeInt(1);
7784 mClipData.writeToParcel(out, flags);
7785 } else {
7786 out.writeInt(0);
7787 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007788 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007789 out.writeBundle(mExtras);
7790 }
7791
7792 public static final Parcelable.Creator<Intent> CREATOR
7793 = new Parcelable.Creator<Intent>() {
7794 public Intent createFromParcel(Parcel in) {
7795 return new Intent(in);
7796 }
7797 public Intent[] newArray(int size) {
7798 return new Intent[size];
7799 }
7800 };
7801
Dianne Hackborneb034652009-09-07 00:49:58 -07007802 /** @hide */
7803 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007804 readFromParcel(in);
7805 }
7806
7807 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007808 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007809 mData = Uri.CREATOR.createFromParcel(in);
7810 mType = in.readString();
7811 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007812 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007813 mComponent = ComponentName.readFromParcel(in);
7814
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007815 if (in.readInt() != 0) {
7816 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7817 }
7818
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007819 int N = in.readInt();
7820 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007821 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007822 int i;
7823 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007824 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007825 }
7826 } else {
7827 mCategories = null;
7828 }
7829
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007830 if (in.readInt() != 0) {
7831 mSelector = new Intent(in);
7832 }
7833
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007834 if (in.readInt() != 0) {
7835 mClipData = new ClipData(in);
7836 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007837 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 mExtras = in.readBundle();
7839 }
7840
7841 /**
7842 * Parses the "intent" element (and its children) from XML and instantiates
7843 * an Intent object. The given XML parser should be located at the tag
7844 * where parsing should start (often named "intent"), from which the
7845 * basic action, data, type, and package and class name will be
7846 * retrieved. The function will then parse in to any child elements,
7847 * looking for <category android:name="xxx"> tags to add categories and
7848 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7849 * to the intent.
7850 *
7851 * @param resources The Resources to use when inflating resources.
7852 * @param parser The XML parser pointing at an "intent" tag.
7853 * @param attrs The AttributeSet interface for retrieving extended
7854 * attribute data at the current <var>parser</var> location.
7855 * @return An Intent object matching the XML data.
7856 * @throws XmlPullParserException If there was an XML parsing error.
7857 * @throws IOException If there was an I/O error.
7858 */
7859 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7860 throws XmlPullParserException, IOException {
7861 Intent intent = new Intent();
7862
7863 TypedArray sa = resources.obtainAttributes(attrs,
7864 com.android.internal.R.styleable.Intent);
7865
7866 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7867
7868 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7869 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7870 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7871
7872 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7873 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7874 if (packageName != null && className != null) {
7875 intent.setComponent(new ComponentName(packageName, className));
7876 }
7877
7878 sa.recycle();
7879
7880 int outerDepth = parser.getDepth();
7881 int type;
7882 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7883 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7884 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7885 continue;
7886 }
7887
7888 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007889 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007890 sa = resources.obtainAttributes(attrs,
7891 com.android.internal.R.styleable.IntentCategory);
7892 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7893 sa.recycle();
7894
7895 if (cat != null) {
7896 intent.addCategory(cat);
7897 }
7898 XmlUtils.skipCurrentTag(parser);
7899
Craig Mautner21d24a22014-04-23 11:45:37 -07007900 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007901 if (intent.mExtras == null) {
7902 intent.mExtras = new Bundle();
7903 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007904 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007905 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007906
7907 } else {
7908 XmlUtils.skipCurrentTag(parser);
7909 }
7910 }
7911
7912 return intent;
7913 }
Nick Pellyccae4122012-01-09 14:12:58 -08007914
Craig Mautner21d24a22014-04-23 11:45:37 -07007915 /** @hide */
7916 public void saveToXml(XmlSerializer out) throws IOException {
7917 if (mAction != null) {
7918 out.attribute(null, ATTR_ACTION, mAction);
7919 }
7920 if (mData != null) {
7921 out.attribute(null, ATTR_DATA, mData.toString());
7922 }
7923 if (mType != null) {
7924 out.attribute(null, ATTR_TYPE, mType);
7925 }
7926 if (mComponent != null) {
7927 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7928 }
7929 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7930
7931 if (mCategories != null) {
7932 out.startTag(null, TAG_CATEGORIES);
7933 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7934 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7935 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007936 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007937 }
7938 }
7939
7940 /** @hide */
7941 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7942 XmlPullParserException {
7943 Intent intent = new Intent();
7944 final int outerDepth = in.getDepth();
7945
7946 int attrCount = in.getAttributeCount();
7947 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7948 final String attrName = in.getAttributeName(attrNdx);
7949 final String attrValue = in.getAttributeValue(attrNdx);
7950 if (ATTR_ACTION.equals(attrName)) {
7951 intent.setAction(attrValue);
7952 } else if (ATTR_DATA.equals(attrName)) {
7953 intent.setData(Uri.parse(attrValue));
7954 } else if (ATTR_TYPE.equals(attrName)) {
7955 intent.setType(attrValue);
7956 } else if (ATTR_COMPONENT.equals(attrName)) {
7957 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7958 } else if (ATTR_FLAGS.equals(attrName)) {
7959 intent.setFlags(Integer.valueOf(attrValue, 16));
7960 } else {
7961 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7962 }
7963 }
7964
7965 int event;
7966 String name;
7967 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7968 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7969 if (event == XmlPullParser.START_TAG) {
7970 name = in.getName();
7971 if (TAG_CATEGORIES.equals(name)) {
7972 attrCount = in.getAttributeCount();
7973 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7974 intent.addCategory(in.getAttributeValue(attrNdx));
7975 }
7976 } else {
7977 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7978 XmlUtils.skipCurrentTag(in);
7979 }
7980 }
7981 }
7982
7983 return intent;
7984 }
7985
Nick Pellyccae4122012-01-09 14:12:58 -08007986 /**
7987 * Normalize a MIME data type.
7988 *
7989 * <p>A normalized MIME type has white-space trimmed,
7990 * content-type parameters removed, and is lower-case.
7991 * This aligns the type with Android best practices for
7992 * intent filtering.
7993 *
7994 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7995 * "text/x-vCard" becomes "text/x-vcard".
7996 *
7997 * <p>All MIME types received from outside Android (such as user input,
7998 * or external sources like Bluetooth, NFC, or the Internet) should
7999 * be normalized before they are used to create an Intent.
8000 *
8001 * @param type MIME data type to normalize
8002 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008003 * @see #setType
8004 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008005 */
8006 public static String normalizeMimeType(String type) {
8007 if (type == null) {
8008 return null;
8009 }
8010
Elliott Hughescb64d432013-08-02 10:00:44 -07008011 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008012
8013 final int semicolonIndex = type.indexOf(';');
8014 if (semicolonIndex != -1) {
8015 type = type.substring(0, semicolonIndex);
8016 }
8017 return type;
8018 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008019
8020 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008021 * Prepare this {@link Intent} to leave an app process.
8022 *
8023 * @hide
8024 */
8025 public void prepareToLeaveProcess() {
8026 setAllowFds(false);
8027
8028 if (mSelector != null) {
8029 mSelector.prepareToLeaveProcess();
8030 }
8031 if (mClipData != null) {
8032 mClipData.prepareToLeaveProcess();
8033 }
8034
8035 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8036 // There are several ACTION_MEDIA_* broadcasts that send file://
8037 // Uris, so only check common actions.
8038 if (ACTION_VIEW.equals(mAction) ||
8039 ACTION_EDIT.equals(mAction) ||
8040 ACTION_ATTACH_DATA.equals(mAction)) {
8041 mData.checkFileUriExposed("Intent.getData()");
8042 }
8043 }
8044 }
8045
8046 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008047 * @hide
8048 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008049 public void prepareToEnterProcess() {
8050 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008051 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8052 fixUris(mContentUserHint);
8053 mContentUserHint = UserHandle.USER_CURRENT;
8054 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008055 }
8056 }
8057
8058 /**
8059 * @hide
8060 */
8061 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008062 Uri data = getData();
8063 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008064 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008065 }
8066 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008067 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008068 }
8069 String action = getAction();
8070 if (ACTION_SEND.equals(action)) {
8071 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8072 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008073 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008074 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008075 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008076 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8077 if (streams != null) {
8078 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8079 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008080 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008081 }
8082 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8083 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008084 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8085 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8086 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8087 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8088 if (output != null) {
8089 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8090 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008091 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008092 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008093
8094 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008095 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008096 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8097 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008098 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008099 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008100 * @hide
8101 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008102 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008103 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008104 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008105
8106 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008107 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008108
8109 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008110 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008111 // Inspect contained intents to see if we need to migrate extras. We
8112 // don't promote ClipData to the parent, since ChooserActivity will
8113 // already start the picked item as the caller, and we can't combine
8114 // the flags in a safe way.
8115
8116 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008117 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008118 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8119 if (intent != null) {
8120 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008121 }
8122 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008123 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008124 try {
8125 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8126 if (intents != null) {
8127 for (int i = 0; i < intents.length; i++) {
8128 final Intent intent = (Intent) intents[i];
8129 if (intent != null) {
8130 migrated |= intent.migrateExtraStreamToClipData();
8131 }
8132 }
8133 }
8134 } catch (ClassCastException e) {
8135 }
8136 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008137
8138 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008139 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008140 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8141 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8142 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8143 if (stream != null || text != null || htmlText != null) {
8144 final ClipData clipData = new ClipData(
8145 null, new String[] { getType() },
8146 new ClipData.Item(text, htmlText, null, stream));
8147 setClipData(clipData);
8148 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008149 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008150 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008151 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008152 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008153
8154 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008155 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008156 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8157 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8158 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8159 int num = -1;
8160 if (streams != null) {
8161 num = streams.size();
8162 }
8163 if (texts != null) {
8164 if (num >= 0 && num != texts.size()) {
8165 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008166 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008167 }
8168 num = texts.size();
8169 }
8170 if (htmlTexts != null) {
8171 if (num >= 0 && num != htmlTexts.size()) {
8172 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008173 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008174 }
8175 num = htmlTexts.size();
8176 }
8177 if (num > 0) {
8178 final ClipData clipData = new ClipData(
8179 null, new String[] { getType() },
8180 makeClipItem(streams, texts, htmlTexts, 0));
8181
8182 for (int i = 1; i < num; i++) {
8183 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8184 }
8185
8186 setClipData(clipData);
8187 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008188 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008189 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008190 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008191 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008192 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8193 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8194 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8195 final Uri output;
8196 try {
8197 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8198 } catch (ClassCastException e) {
8199 return false;
8200 }
8201 if (output != null) {
8202 setClipData(ClipData.newRawUri("", output));
8203 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8204 return true;
8205 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008206 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008207
8208 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008209 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008210
8211 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8212 ArrayList<String> htmlTexts, int which) {
8213 Uri uri = streams != null ? streams.get(which) : null;
8214 CharSequence text = texts != null ? texts.get(which) : null;
8215 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8216 return new ClipData.Item(text, htmlText, null, uri);
8217 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008218
8219 /** @hide */
8220 public boolean isDocument() {
8221 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8222 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008223}